def test_op_direct(self): "Operator using directmap" class hexop(addrxlat.Operator): def __init__(self, prefix='', *args, **kwargs): super(hexop, self).__init__(*args, **kwargs) self.prefix = prefix def callback(self, addr): return '{}{:x}'.format(self.prefix, addr.addr) myop = hexop(ctx=self.ctx, sys=self.sys, caps=addrxlat.CAPS(addrxlat.KPHYSADDR), prefix='0x') result = myop(addrxlat.FullAddress(addrxlat.KVADDR, 0xabc)) self.assertEqual(result, '0x1abc')
def __init__(self, *args, **kwargs): super(mycontext, self).__init__(*args, **kwargs) self.read_caps = addrxlat.CAPS(addrxlat.MACHPHYSADDR)
def setUp(self): def read32(addr): # Page table level 2 @ 0 if addr.addr == 0x10000: return 0x101 # Page table level 1 @ 0x65 if addr.addr == 0x10100 + 0x65 * 4: return 0x1c0 # Page table level 1 @ 0x41 if addr.addr == 0x10100 + 0x41 * 4: return 0x1a9 # Memory array at 0x40 if addr.addr == 0x11000 + 0x40 * 4: return 0xaa self.ctx = addrxlat.Context() self.ctx.read_caps = addrxlat.CAPS(addrxlat.MACHPHYSADDR) self.ctx.cb_read32 = read32 self.sys = addrxlat.System() map = addrxlat.Map() self.sys.set_map(addrxlat.SYS_MAP_HW, map) meth = addrxlat.PageTableMethod(addrxlat.MACHPHYSADDR) meth.root = addrxlat.FullAddress(addrxlat.MACHPHYSADDR, 0x10000) meth.pte_format = addrxlat.PTE_PFN32 meth.fields = (8, 8, 8) self.sys.set_meth(addrxlat.SYS_METH_PGT, meth) map.set(0, addrxlat.Range(0xffff, addrxlat.SYS_METH_PGT)) map = addrxlat.Map() self.sys.set_map(addrxlat.SYS_MAP_KV_PHYS, map) meth = addrxlat.LinearMethod(addrxlat.KPHYSADDR, 0x1000) self.sys.set_meth(addrxlat.SYS_METH_DIRECT, meth) map.set(0, addrxlat.Range(0x1fff, addrxlat.SYS_METH_DIRECT)) meth = addrxlat.LookupMethod(addrxlat.KPHYSADDR) meth.endoff = 0xff meth.tbl = ((0x2000, 0xfa00), (0x3000, 0xfb00), (0x3100, 0xff00)) self.sys.set_meth(addrxlat.SYS_METH_CUSTOM, meth) map.set(0x2000, addrxlat.Range(0x1fff, addrxlat.SYS_METH_CUSTOM)) meth = addrxlat.MemoryArrayMethod(addrxlat.KPHYSADDR) meth.base = addrxlat.FullAddress(addrxlat.KVADDR, 0) meth.shift = 8 meth.elemsz = 4 meth.valsz = 4 self.sys.set_meth(addrxlat.SYS_METH_CUSTOM + 1, meth) map.set(0x4000, addrxlat.Range(0x1fff, addrxlat.SYS_METH_CUSTOM + 1)) map.set(0x6000, addrxlat.Range(0x9fff, addrxlat.SYS_METH_PGT)) map = addrxlat.Map() self.sys.set_map(addrxlat.SYS_MAP_KPHYS_DIRECT, map) meth = addrxlat.LinearMethod(addrxlat.KVADDR, -0x1000) self.sys.set_meth(addrxlat.SYS_METH_RDIRECT, meth) map.set(0x1000, addrxlat.Range(0x1fff, addrxlat.SYS_METH_RDIRECT)) map = addrxlat.Map() self.sys.set_map(addrxlat.SYS_MAP_MACHPHYS_KPHYS, map) meth = addrxlat.LinearMethod(addrxlat.KPHYSADDR, -0x10000) self.sys.set_meth(addrxlat.SYS_METH_MACHPHYS_KPHYS, meth) map.set(0x10000, addrxlat.Range(0xffff, addrxlat.SYS_METH_MACHPHYS_KPHYS)) map = addrxlat.Map() self.sys.set_map(addrxlat.SYS_MAP_KPHYS_MACHPHYS, map) meth = addrxlat.LinearMethod(addrxlat.MACHPHYSADDR, 0x10000) self.sys.set_meth(addrxlat.SYS_METH_KPHYS_MACHPHYS, meth) map.set(0, addrxlat.Range(0xffff, addrxlat.SYS_METH_KPHYS_MACHPHYS))
def test_op_caps(self): op = addrxlat.Operator(self.ctx, caps=addrxlat.CAPS(addrxlat.KVADDR)) self.assertIs(op.ctx, self.ctx) self.assertIs(op.sys, None) self.assertEqual(op.caps, addrxlat.CAPS(addrxlat.KVADDR))
def __init__(self, *args: int, **kwargs: int) -> None: super().__init__(*args, **kwargs) self.read_caps = addrxlat.CAPS(addrxlat.KVADDR)
def __init__(self, *args, **kwargs): super(TranslationContext, self).__init__(*args, **kwargs) self.read_caps = addrxlat.CAPS(addrxlat.KVADDR) self.uint32_ptr = gdb.lookup_type('uint32_t').pointer() self.uint64_ptr = gdb.lookup_type('uint64_t').pointer()