8/09/2015

Variable Operation

Description

Unicode string in Python is codded as u"string". (This is python2 style)

In Unicode HOWTO in Python document, it has the description about how python3 deal strings...
"Python’s string type uses the Unicode Standard for representing characters, which lets Python programs work with all these different possible characters."

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 as EfiPy2

VariableName  = "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 Github sample folder.

No comments:

Post a Comment