def PciIo16(Bus, Dev, Func): try: return PciIo16Cache[(Bus, Dev, Func)] except: pass if PciMmioBase != 0: PciIoCellExt["CellBase"] = lambda Reg: PciMmioBase + (Bus << 20) + ( Dev << 15) + (Func << 12) + Reg PciIo16CellClass = _Mem16 else: PciIoCellExt["CellBase"] = lambda Reg: pci.PCI_CONFIG_ACCESS_CF8( (Reg, Func, Dev, Bus, 0, 1)).Uint32 PciIo16CellClass = _PciIo16Cell _PciIo16Obj = _MemArray("PciIo16(%02X:%02X:%02X)" % (Bus, Dev, Func), 16, CellClass=PciIo16CellClass, CellExt=PciIoCellExt) PciIo16Cache[(Bus, Dev, Func)] = _PciIo16Obj return _PciIo16Obj
def PciIo32(Bus, Dev, Func): try: return PciIo32Cache[(Bus, Dev, Func)] except: pass if PciMmioBase != 0: PciIoCellExt["CellBase"] = lambda Reg: PciMmioBase + (Bus << 20) + ( Dev << 15) + (Func << 12) + Reg PciIo32CellClass = _Mem32 else: PciIoCellExt["CellBase"] = lambda Reg: pci.PCI_CONFIG_ACCESS_CF8( (Reg, Func, Dev, Bus, 0, 1)).Uint32 PciIo32CellClass = _PciIo32Cell _PciIo32Obj = _MemArray("PciIo32(%02X:%02X:%02X)" % (Bus, Dev, Func), 32, CellClass=PciIo32CellClass, CellExt=PciIoCellExt, DictKey=PciHeaderS) PciIo32Cache[(Bus, Dev, Func)] = _PciIo32Obj return _PciIo32Obj
mList = list (xrange (0, 0x1000)) mTuple = tuple (xrange (0, 0x1000)) class tOp (_MemCell): def MemSet (self, index, value): mList[index] = value def MemGet (self, index): return mList[index] # # Object zone # tMem8 = _MemArray("tMem8", 8, CellClass = tOp) tMem16 = _MemArray("tMem16", 16, CellClass = tOp) tMem32 = _MemArray("tMem32", 32, CellClass = tOp) tMem64 = _MemArray("tMem64", 64, CellClass = tOp) # # Entry for verify BitOp # if __name__ == "__main__": b = tMem64[0x02] print "tMem64[0x02]", b b = tMem32[0x02] print "tMem32[0x02]", b b = tMem16[0x02] print "tMem16[0x02]", b
# "CellUnion": EFIPY_MSR_COMMON_Reg, "CellDefault": EFIPY_MSR_COMMON_Reg, "CellArray": {}, "CellType": 'Uint64', "CellBits": 'Bits' } print "Looking for platform IA32_DEBUG_INTERFACE status..." CpuId01 = CPUID(0x01) if CpuId01.ECX.SDBG != 1: print "This platform does not support IA32_DEBUG_INTERFACE...exit." exit(0) print "This platform supports IA32_DEBUG_INTERFACE" print "SDBG value: %X" % CpuId01.ECX[11] msr = _MemArray("msr", 64, CellClass=rMsr, CellExt=CellExt) print "Enable (R/W): %x" % msr[0xC80][0] print "Lock (R/W): %x" % msr[0xC80][30] print "Debug Occurred (R/O): %x" % msr[0xC80][31] print print "Try to enable IA32_DEBUG_INTERFACE::Enable bit..." msr[0xC80][0] = 1 print "dump IA32_DEBUG_INTERFACE again..." print "This bit shouldn't be changed on shell..." print "msr[0xC80]", msr[0xC80] print "Enable (R/W): %x" % msr[0xC80][0] print "Lock (R/W): %x" % msr[0xC80][30] print "Debug Occurred (R/O): %x" % msr[0xC80][31]