Sample code
https://svn.code.sf.net/u/efipy/svn/Trunk/CPUID
Description
It is the demo of how to uses x86 instruction CPUID in CorePy/EfiPy.
In CPUID.py, it has python class named "CpuId".
Here is the mapping between EfiPy and C language
#
# typedef struct {
# UINT32 EAX;
# UINT32 EBX;
# UINT32 ECX;
# UINT32 EDX;
# } CpuIdStructure
#
class CpuIdStructure (EfiPy.Structure):
_pack_ = 1
_fields_ = [
('EAX', EfiPy.UINT32),
('EBX', EfiPy.UINT32),
('ECX', EfiPy.UINT32),
('EDX', EfiPy.UINT32)
]
#
# typedef union {
# CpuIdStructure CpuInfo;
# } CpuIdUnion
#
class CpuIdUnion (EfiPy.Union):
_pack_ = 1
_fields_ = [
('CpuInfo', CpuIdStructure)
]
#
# UINT32 GetId (UINT32 eax, UINT32 ecx, CpuIdUnion *CpuInfoAddr);
#
def GetId (self, eax, ecx, CpuInfoAddr):
In CpuIds.py, it is the smallest CPUID sample.
No comments:
Post a Comment