Background
At the beginning of porting ctypes to EFI environment, there are some validation programs. This is one of them to be used to test CFUNCTYPE if it works or not.
Test point
This script is mainly to declare a c types structure which is used for EFI protocol including member function pointer (EFIPY2_CFUNCTYPE1) and unsigned integer.
This statement is CFUNCTYPE check point.
Status = EfiPy2SampleProtocol.P1Func1 (20, None)
Procedure - python callback function by ctypes
1. Declaire python function (EfiPy2cFunc1 or EfiPy2cFunc2) for callback from ctypes.Structure object.
def EfiPy2cFunc1 (Val1, Val2):
print (" EfiPy2cFunc1 Val1:", Val1)
return 0
2. Create EFIPY2_CFUNCTYPE1 from ctypes.CFUNCTYPE with the same with EfiPy2cFunc1 input/output interface.
EFIPY2_CFUNCTYPE1 = ctypes.CFUNCTYPE (
ctypes.c_uint64, # Return value.
ctypes.c_uint64, # first parameter.
ctypes.POINTER(ctypes.c_uint32) # second parameter.
)
3. And assign an object P1 which is EFIPY2_CFUNCTYPE1 object has callback EfiPy2cFunc1.
P1 = EFIPY2_CFUNCTYPE1 (EfiPy2cFunc1)
No comments:
Post a Comment