def features(): ''' features() -> [str, str, ...] returns sequence of available features ''' info = [CPUID (1).EAX, CPUID (1).EBX, CPUID (1).ECX, CPUID (1).EDX] return [key for key, reg, bit in _feat_table if info[reg] & (1 << bit)]
def brand_string(): a = CPUID (EXTENDED_OFFSET).EAX assert a >= (EXTENDED_OFFSET | 0x4), "brand string is not supported by this CPU" # s = ''.join([_struct.pack("IIII", *cpuid(EXTENDED_OFFSET | k)) for k in 0x2, 0x3, 0x4]) a = CPUID (EXTENDED_OFFSET | 0x02) s = ''.join(_struct.pack("IIII", a.EAX, a.EBX, a.ECX, a.EDX)) a = CPUID (EXTENDED_OFFSET | 0x03) s = s + ''.join(_struct.pack("IIII", a.EAX, a.EBX, a.ECX, a.EDX)) a = CPUID (EXTENDED_OFFSET | 0x04) s = s + ''.join(_struct.pack("IIII", a.EAX, a.EBX, a.ECX, a.EDX)) return s[:s.index('\0')]
def model(): a = CPUID (1).EAX # model_number = (a >> 4) & 0xf # extended_model = (a >> 16) & 0xf # return (extended_model << 4) + model_number return Mem32[a[4:7], a[16:19]]
def brand_id(): a = CPUID (1).EBX return a.BrandIndex
def processor_type(): a = CPUID (1).EAX return (a >> 12) & 0x3
def family(): a = CPUID (1).EAX family_code = (a >> 8) & 0xf extended_family = (a >> 20) & 0xff return extended_family + family_code
def stepping_id(): return CPUID (1).EAX.SteppingId
def vendor(): return _struct.pack("III", CPUID (0).EBX, CPUID (0).EDX, CPUID (0).ECX)
# it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2 of the License. # # CpuidSample.py is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EfiPy. If not, see <http://www.gnu.org/licenses/>. # from LoLeOp.CpuId import CPUID print "=" * 25 CpuId00 = CPUID (0, 0) print "CpuId00", CpuId00 print "=" * 25 print "CpuId00.EAX: %X" % CpuId00.EAX print "CpuId00.EAX[0:1]: %X" % CpuId00.EAX[0:1] print "CpuId00.EAX.MaximumLeaf: %X" % CpuId00.EAX.MaximumLeaf print "=" * 25 print "CpuId00.EAX:", CpuId00.EAX print "CpuId00.EBX:", CpuId00.EBX print "CpuId00.ECX:", CpuId00.ECX print "CpuId00.EDX:", CpuId00.EDX print "=" * 25 print CpuId00 print "=" * 25 print "variant information returned by CPUID(index)" # print "CPUID(0x01).Regs.EAX.Uint32: 0x%08X" % CPUID(0x01).Regs.EAX.Uint32
from EfiPy import Structure, Union, UINT32 # from LoLeOp.rUnionOp import COMMON_REG_32BITS from LoLeOp.CpuId import CPUID, CpuIdIndex, COMMON_REG_32BITS class CPUID_SIGNATURE_EAX_Bits(Structure): _fields_ = [ ("MaximumLeaf", UINT32, 32), ] class CPUID_SIGNATURE_EAX(Union): _fields_ = [("Bits", CPUID_SIGNATURE_EAX_Bits), ("Uint32", UINT32)] class EFIPY_CPUID_TIME_STAMP_COUNTER_Regs(Structure): _fields_ = [('EAX', CPUID_SIGNATURE_EAX), ('EBX', COMMON_REG_32BITS), ('ECX', COMMON_REG_32BITS), ('EDX', COMMON_REG_32BITS)] CpuIdIndex[(0x15, 0x00)] = EFIPY_CPUID_TIME_STAMP_COUNTER_Regs print "=" * 25 CpuId0x15 = CPUID(0x15, 0) print "CpuId0x15.EAX:", CpuId0x15.EAX print "CpuId0x15.EBX:", CpuId0x15.EBX print "CpuId0x15.ECX:", CpuId0x15.ECX print "CpuId0x15.EDX:", CpuId0x15.EDX print "CpuId0x15.EAX.MaximumLeaf: 0x%08X" % CpuId0x15.EAX.MaximumLeaf print "CpuId0x15.EAX[:]: 0x%08X" % CpuId0x15.EAX[:]
from LoLeOp.CpuId import CPUID from LoLeOp.Msr import rMsr, EFIPY_MSR_COMMON_Reg from LoLeOp.BitOp import _MemArray CellExt = { # "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..."