Sunday, August 9, 2015

Variable Operation

Description

Unicode string in Python is codded as u"string".
EfiPy provides GUID declare, which is similar to EDKII GUID declaration.
NULL (in C language) is codded as None in Python (also in ctypes/EfiPy).
Address of object in python ctypes, it is noted as byref() function
C compatible string in Python ctypes is used by create_string_buffer.

Sample code - simplest EDK II get variable by EfiPy

import EfiPy

VariableName  = u"EfiPyDemo"
VariableGuid  = EfiPy.EFI_GUID( 0x8BE4DF61, 0x93CA, 0x11d2, \
                  (0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8D))
DataSize      = EfiPy.UINTN (0x00)
DataBuffer    = (EfiPy.CHAR8 * 5) ()
Attributes    = EfiPy.UINT32 ()
Status = EfiPy.gRT.GetVariable(
                     VariableName,
                     EfiPy.byref (VariableGuid),
                     EfiPy.byref (Attributes),
                     EfiPy.byref (DataSize),
                     EfiPy.byref (DataBuffer)
                     )

Screenshot
















Sample code is at Sourceforge sample folder.

No comments:

Post a Comment