Exemple #1
0
R_HI_init = ExprId('R_HI_init', 32)


cpr0_str = ["CPR0_%d"%x for x in xrange(0x100)]
cpr0_str[0] = "INDEX"
cpr0_str[16] = "ENTRYLO0"
cpr0_str[24] = "ENTRYLO1"
cpr0_str[40] = "PAGEMASK"
cpr0_str[72] = "COUNT"
cpr0_str[80] = "ENTRYHI"
cpr0_str[104] = "CAUSE"
cpr0_str[112] = "EPC"
cpr0_str[128] = "CONFIG"
cpr0_str[152] = "WATCHHI"

regs_cpr0_expr, regs_cpr0_init, regs_cpr0_info = gen_regs(cpr0_str, globals())

gpregs_expr, gpregs_init, gpregs = gen_regs(regs32_str, globals())
regs_flt_expr, regs_flt_init, fltregs = gen_regs(regs_flt_str, globals(), sz=64)
regs_fcc_expr, regs_fcc_init, fccregs = gen_regs(regs_fcc_str, globals())


all_regs_ids = [PC, PC_FETCH, R_LO, R_HI] + gpregs_expr + regs_flt_expr + \
    regs_fcc_expr + regs_cpr0_expr
all_regs_ids_byname = dict([(x.name, x) for x in all_regs_ids])
all_regs_ids_init = [PC_init, PC_FETCH_init, R_LO_init, R_HI_init] + \
    gpregs_init + regs_flt_init + regs_fcc_init + regs_cpr0_init
all_regs_ids_no_alias = all_regs_ids[:]

regs_init = {}
for i, r in enumerate(all_regs_ids):
Exemple #2
0
#-*- coding:utf-8 -*-

from miasm2.expression.expression import *
from miasm2.core.cpu import gen_reg, gen_regs

exception_flags = ExprId('exception_flags', 32)


gpregs32_str = ["W%d" % i for i in xrange(0x1f)] + ["WSP"]
gpregs32_expr, gpregs32_init, gpregs32_info = gen_regs(
    gpregs32_str, globals(), 32)

gpregs64_str = ["X%d" % i for i in xrange(0x1E)] + ["LR", "SP"]
gpregs64_expr, gpregs64_init, gpregs64_info = gen_regs(
    gpregs64_str, globals(), 64)


gpregsz32_str = ["W%d" % i for i in xrange(0x1f)] + ["WZR"]
gpregsz32_expr, gpregsz32_init, gpregsz32_info = gen_regs(
    gpregsz32_str, globals(), 32)

gpregsz64_str = ["X%d" % i for i in xrange(0x1e)] + ["LR", "XZR"]
gpregsz64_expr, gpregsz64_init, gpregsz64_info = gen_regs(
    gpregsz64_str, globals(), 64)

cr_str = ["c%d" % i for i in xrange(0xf)]
cr_expr, cr_init, cr_info = gen_regs(cr_str, globals(), 32)


simd08_str = ["B%d" % i for i in xrange(0x20)]
simd08_expr, simd08_init, simd08_info = gen_regs(simd08_str, globals(), 8)
Exemple #3
0
exception_flags = ExprId("exception_flags", 32)
exception_flags_init = ExprId("exception_flags_init", 32)

is_repeat_end = ExprId("is_repeat_end", 32)
is_repeat_end_init = ExprId("is_repeat_end_init", 32)
last_addr = ExprId("last_addr", 32)
last_addr_init = ExprId("last_addr_init", 32)
take_jmp = ExprId("take_jmp", 32)
take_jmp_init = ExprId("take_jmp_init", 32)
in_erepeat = ExprId("in_erepeat", 32)
in_erepeat_init = ExprId("take_jmp_init", 32)

# General-purpose registers (R0 to R15) names
gpr_names = ["R%d" % r for r in xrange(13)]  # register names
gpr_names += ["TP", "GP", "SP"]  # according to the manual GP does not exist
gpr_exprs, gpr_inits, gpr_infos = gen_regs(gpr_names,
                                           globals())  # sz=32 bits (default)

# Notes:
#     - gpr_exprs: register ExprIds on 32 bits.  The size is important for
#       symbolic execution.
#     - gpr_inits: register initial values.
#     - gpr_infos: object that binds names & ExprIds

# Define aliases to general-purpose registers
TP = gpr_exprs[13]  # Tiny data area Pointer
GP = gpr_exprs[14]  # Global Pointer
SP = gpr_exprs[15]  # Stack Pointer

# Control/special registers name
csr_names = [
    "PC", "LP", "SAR", "S3", "RPB", "RPE", "RPC", "HI", "LO", "S9", "S10",
Exemple #4
0
R_LO_init = ExprId('R_LO_init', 32)
R_HI_init = ExprId('R_HI_init', 32)

cpr0_str = ["CPR0_%d" % x for x in xrange(0x100)]
cpr0_str[0] = "INDEX"
cpr0_str[16] = "ENTRYLO0"
cpr0_str[24] = "ENTRYLO1"
cpr0_str[40] = "PAGEMASK"
cpr0_str[72] = "COUNT"
cpr0_str[80] = "ENTRYHI"
cpr0_str[104] = "CAUSE"
cpr0_str[128] = "CONFIG"
cpr0_str[152] = "WATCHHI"

regs_cpr0_expr, regs_cpr0_init, regs_cpr0_info = gen_regs(cpr0_str, globals())

gpregs_expr, gpregs_init, gpregs = gen_regs(regs32_str, globals())
regs_flt_expr, regs_flt_init, fltregs = gen_regs(regs_flt_str,
                                                 globals(),
                                                 sz=64)
regs_fcc_expr, regs_fcc_init, fccregs = gen_regs(regs_fcc_str, globals())


all_regs_ids = [PC, PC_FETCH, R_LO, R_HI] + gpregs_expr + regs_flt_expr + \
    regs_fcc_expr
all_regs_ids_byname = dict([(x.name, x) for x in all_regs_ids])
all_regs_ids_init = [PC_init, PC_FETCH_init, R_LO_init, R_HI_init] + \
    gpregs_init + regs_flt_init + regs_fcc_init
all_regs_ids_no_alias = all_regs_ids[:]
Exemple #5
0
from miasm2.core.cpu import gen_reg, gen_regs

exception_flags = ExprId('exception_flags', 32)
spr_access = ExprId('spr_access', 32)

reserve = ExprId('reserve', 1)
reserve_address = ExprId('reserve_address', 32)

SPR_ACCESS_IS_WRITE = 0x80000000
SPR_ACCESS_SPR_MASK = 0x000003FF
SPR_ACCESS_SPR_OFF  = 0
SPR_ACCESS_GPR_MASK = 0x0001F000
SPR_ACCESS_GPR_OFF  = 12

gpregs_str = ["R%d" % i for i in xrange(32)]
gpregs_expr, gpregs_init, gpregs = gen_regs(gpregs_str, globals(), 32)

crfregs_str = ["CR%d" % i for i in xrange(8)]
crfregs_expr, crfregs_init, crfregs = gen_regs(crfregs_str, globals(), 4)

crfbitregs_str = ["CR%d_%s" % (i, flag) for i in xrange(8)
                  for flag in ['LT', 'GT', 'EQ', 'SO'] ]
crfbitregs_expr, crfbitregs_init, crfbitregs = gen_regs(crfbitregs_str,
                                                        globals(), 1)

xerbitregs_str = ["XER_%s" % field for field in ['SO', 'OV', 'CA'] ]
xerbitregs_expr, xerbitregs_init, xerbitregs = gen_regs(xerbitregs_str,
                                                        globals(), 1)

xerbcreg_str = ["XER_BC"]
xerbcreg_expr, xerbcreg_init, xerbcreg = gen_regs(xerbcreg_str,
Exemple #6
0
from miasm2.core.cpu import gen_reg, gen_regs

exception_flags = ExprId('exception_flags', 32)
spr_access = ExprId('spr_access', 32)

reserve = ExprId('reserve', 1)
reserve_address = ExprId('reserve_address', 32)

SPR_ACCESS_IS_WRITE = 0x80000000
SPR_ACCESS_SPR_MASK = 0x000003FF
SPR_ACCESS_SPR_OFF = 0
SPR_ACCESS_GPR_MASK = 0x0001F000
SPR_ACCESS_GPR_OFF = 12

gpregs_str = ["R%d" % i for i in xrange(32)]
gpregs_expr, gpregs_init, gpregs = gen_regs(gpregs_str, globals(), 32)

crfregs_str = ["CR%d" % i for i in xrange(8)]
crfregs_expr, crfregs_init, crfregs = gen_regs(crfregs_str, globals(), 4)

crfbitregs_str = [
    "CR%d_%s" % (i, flag) for i in xrange(8)
    for flag in ['LT', 'GT', 'EQ', 'SO']
]
crfbitregs_expr, crfbitregs_init, crfbitregs = gen_regs(
    crfbitregs_str, globals(), 1)

xerbitregs_str = ["XER_%s" % field for field in ['SO', 'OV', 'CA']]
xerbitregs_expr, xerbitregs_init, xerbitregs = gen_regs(
    xerbitregs_str, globals(), 1)
Exemple #7
0
exception_flags_init = ExprId("exception_flags_init", 32)

is_repeat_end = ExprId("is_repeat_end", 32)
is_repeat_end_init = ExprId("is_repeat_end_init", 32)
last_addr = ExprId("last_addr", 32)
last_addr_init = ExprId("last_addr_init", 32)
take_jmp = ExprId("take_jmp", 32)
take_jmp_init = ExprId("take_jmp_init", 32)
in_erepeat = ExprId("in_erepeat", 32)
in_erepeat_init = ExprId("take_jmp_init", 32)


# General-purpose registers (R0 to R15) names
gpr_names = ["R%d" % r for r in xrange(13)]  # register names
gpr_names += ["TP", "GP", "SP"]  # according to the manual GP does not exist
gpr_exprs, gpr_inits, gpr_infos = gen_regs(gpr_names, globals())  # sz=32 bits (default)

# Notes:
#     - gpr_exprs: register ExprIds on 32 bits.  The size is important for
#       symbolic execution.
#     - gpr_inits: register initial values.
#     - gpr_infos: object that binds names & ExprIds

# Define aliases to general-purpose registers
TP = gpr_exprs[13]  # Tiny data area Pointer
GP = gpr_exprs[14]  # Global Pointer
SP = gpr_exprs[15]  # Stack Pointer


# Control/special registers name
csr_names = ["PC", "LP", "SAR", "S3", "RPB", "RPE", "RPC", "HI", "LO",