Monday, July 24, 2017

EfiPy_r0.1.4(24622) release

Release Note
This is personal project (author: https://www.facebook.com/wu.max.39).
EfiPy_r0.1.4(24622) is released today for sync for UDK 2017 rev 24622.

What is the next of EfiPy:

1. Easy memory operation in UEFI shell with Python. (Status: in progress)
Example:
1.1. MSR operation:
print "msr[0x1B][8]:    0x%016X" % msr[0x1B][8]
print "msr[0xFE]:       0x%016X" % msr[0xFE]
print "msr[0xFE][7:0]:  0x%016X" % msr[0xFE][7:0]
print "msr[0xFE][0x08]: 0x%016X" % msr[0xFE][0x08]
print "msr[0xFE][0x0A]: 0x%016X" % msr[0xFE][0x0A]

1.2 Memory operation:
print " Mem8[0x3FF39018]: 0x%02X"  % Mem8[0x3FF39018]
print "Mem16[0x3FF39018]: 0x%04X"  % Mem16[0x3FF39018]
print "Mem32[0x3FF39018]: 0x%08X"  % Mem32[0x3FF39018]
print "Mem64[0x3FF39018]: 0x%016X" % Mem64[0x3FF39018]

1.3 IO port
print "Io8[0x71][0:7] & 0x86:   0x%02X" % (Io8[0x71][0:7] & 0x86)
print "Io8[0x71] & 0x86:        0x%02X" % (Io8[0x71]      & 0x86)
print "Io8[0x71][0:7] | 0x86:   0x%02X" % (Io8[0x71][0:7] | 0x86)
print "Io8[0x71][7:0] | 0x86:   0x%02X" % (Io8[0x71][7:0] | 0x86)

1.4 CPUID
print "CPUID(0x01).Regs.EAX.Uint32: 0x%08X" % CPUID(0x01).Regs.EAX.Uint32
print "CPUID(0x01).EAX (Hex): 0x%08X" %       CPUID(0x01).EAX
print "CPUID(0x01).EAX (Bin): %s" %           bin(CPUID(0x01).EAX)
print "===> EAX.SteppingId: [Bits 3:0] Stepping ID"
print "CPUID(0x01).EAX[3:0]: 0x%08X" %        CPUID(0x01).EAX[3:0]
print "CPUID(0x01).EAX.SteppingId: 0x%03X" % CPUID(0x01).EAX.SteppingId

1.5 others...

2. Py2Efi (Status: in progress)
What is Py2Efi?
Capsule program running in EFI shell which packs python libraries into single .efi file.
This capsuled .efi file is a standalone EFI program which makes itself run in another platform without any other python programs.

4 comments:

  1. Hi Max,

    I found your project will fail on EDK2 Nt32 enviroment. below is my fix.

    diff --git a/EfiPyPkg/Disk/EFI/Samples/ConnectScan.py b/EfiPyPkg/Disk/EFI/Samples/ConnectScan.py
    index 1c4674c..9dd58e3 100644
    --- a/EfiPyPkg/Disk/EFI/Samples/ConnectScan.py
    +++ b/EfiPyPkg/Disk/EFI/Samples/ConnectScan.py
    @@ -34,7 +34,7 @@ from EfiPy.MdePkg.Protocol.DevicePathUtilities import gEfiDevicePathUtilitiesPro
    #
    from EfiPy.MdePkg.Protocol.PciRootBridgeIo import gEfiPciRootBridgeIoProtocolGuid
    from EfiPy.MdePkg.Protocol.PciIo import gEfiPciIoProtocolGuid, EFI_PCI_IO_PROTOCOL, EfiPciIoWidthUint8
    -import EfiPy.MdePkg.IndustryStandard.pci as pci
    +import EfiPy.MdePkg.IndustryStandard.Pci as pci

    #
    # ConnectScan class for finding binding driver
    diff --git a/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/IndustryStandard/PciExpress21.py b/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/IndustryStandard/PciExpress21.py
    index 2c1e9c4..e751e35 100644
    --- a/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/IndustryStandard/PciExpress21.py
    +++ b/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/IndustryStandard/PciExpress21.py
    @@ -17,7 +17,7 @@
    #

    from EfiPy.MdePkg.IndustryStandard import *
    -from EfiPy.MdePkg.IndustryStandard.pci import EFI_PCI_CAPABILITY_HDR
    +from EfiPy.MdePkg.IndustryStandard.Pci import EFI_PCI_CAPABILITY_HDR

    class PCI_REG_PCIE_CAPABILITY_Bits (EFIPY_INDUSTRY_STRUCTURE):
    _fields_ = [
    diff --git a/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/ProcessorBind.py b/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/ProcessorBind.py
    index 4362db4..6a9adcd 100644
    --- a/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/ProcessorBind.py
    +++ b/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/ProcessorBind.py
    @@ -33,5 +33,14 @@ UINT8 = c_uint8
    CHAR8 = c_char
    PCHAR8 = c_char_p
    INT8 = c_int8
    -UINTN = c_uint64
    -INTN = c_int64
    +if sizeof (c_void_p) == 4:
    + UINTN = c_uint32
    +else:
    + UINTN = c_uint64
    +
    +if sizeof (c_void_p) == 4:
    + INTN = c_int32
    +else:
    + INTN = c_int64
    +
    +
    diff --git a/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/UefiBaseType.py b/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/UefiBaseType.py
    index d1f1c28..b62c64c 100644
    --- a/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/UefiBaseType.py
    +++ b/EfiPyPkg/Disk/EFI/StdLib/lib/python.27/EfiPy/MdePkg/Uefi/UefiBaseType.py
    @@ -19,7 +19,8 @@ from EfiPy.MdePkg.Base import *
    from EfiPy.MdePkg.Uefi.ProcessorBind import *

    PVOID = c_void_p
    -ENUM = UINT64
    +ENUM = UINTN
    +

    EFI_GUID = GUID

    ReplyDelete
  2. Hi Bin.lain,

    Thanks for your feedback.
    As current EfiPy status, it is at its early stage and developed on X64 ABI.
    you did fix error if EfiPy is ported for IA32 ABI.

    EfiPy exists EFIPY_MDE_CPU_TYPE constants in Python _EfiPy module (EfiPyMain.c) for ABI identification in the future.
    For multiple ABIs support, EfiPy will import ABI dependence module by EFIPY_MDE_CPU_TYPE. The module will include UINTN, INTN, ENUM, at least.

    ReplyDelete
    Replies
    1. Hi Bin.lain,

      As your comment. It has release(EfiPy_r0.1.8(24622)) including other ISAs.
      Note, EfiPy does not yet support the other ISAs.

      Thanks
      Max

      Delete