Description
EfiPy uses python ctypes, which has been ported to UEFI Python package, can be downloaded from EfiPy2 download site.EfiPy2 is almost mapped to EDKII MdePkg/Include.
#
# import EfiPy2 package
#
import EfiPy2
or
#
# import EfiPy2 package
#
import EfiPy2 as EfiPy
With above python code, import EfiPy2 or import EfiPy2 as EfiPy and running it in UEFI shell environment, it has following features.
1. Basic data type inherited from ctypes (UINTN, UINT32, ...)
2. EFI_SYSTEM_TABLE, EFI_BOOT_SERVICES and EFI_RUNTIME_SERVICES data structure
3. gRT, gST and gBS objects
4. gImageHandle
5. EFI basic data structure
Most usage is import EfiPy2 as EfiPy in these demos and these scripts can be edit and run immediately in UEFI working environment.
There are many macro #define in EDKII source code, it is transferred to constant value/function in EfiPy2.
Some Examples of EfiPy2 base
source code - Table and Services#
# UEFI basic tables gST, gRT, gBS
#
gRT = EFI_RUNTIME_SERVICES.from_address (_EfiPy2.EfiPygRtAddr)
gST = EFI_SYSTEM_TABLE.from_address (_EfiPy2.EfiPygStAddr)
gBS = EFI_BOOT_SERVICES.from_address (_EfiPy2.EfiPygBsAddr)
#
# EDK basic image handle
#
gImageHandle = EFI_HANDLE.from_address( _EfiPy2.gImageHandle)
# pImageHandle = EFI_HANDLE.from_address( _EfiPy2.pImageHandle)
UINT64 = c_uint64
INT64 = c_int64
UINT32 = c_uint32
source code - EfiPy2 constant value/function
#
# ENCODE_ERROR function
#
def ENCODE_ERROR (StatusCode):
return StatusCode | MAX_BIT # MAX_BIT is exported from _EfiPy
#
# Return value
#
RETURN_INVALID_PARAMETER = ENCODE_ERROR (2)
No comments:
Post a Comment