Saturday, August 15, 2015

EFI_GUID in EfiPy

Description

In EfiPy, it uses self-defined ctypes structure, similar to EDK II structure, rather then python uuid library.
This is for easy to transfer EFI program from C code to Python.

for example, in EFI C program, it uses

EFI_GUID guid_sample = \
  { \
      0x8D59D32B, 0xC655, 0x4AE9, \
     {0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43} \
  };

In EfiPy, it can be codded as

>>> from EfiPy import *
>>> TestGuid1 = EFI_GUID  \
     (0x8D59D32B, 0xC655, 0x4AE9, \
     (0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43))
>>> TestGuid2 = EFI_GUID  \
     (0x8D59D32B, 0xC655, 0x4AE9, \
     (0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x44))

EFI_GUID in EfiPy also provide object comparison and string output function

>>> print "TestGuid1 == TestGuid2 :", TestGuid1 == TestGuid2
TestGuid1 == TestGuid2 : False

Above result is false because these two GUID have different byte in their capability.

>>> print "%s" % TestGuid1
8D59D32B-C655-4AE9-9B15-F25904992A43

Screenshot of efi_guid.py



No comments:

Post a Comment