8/13/2024

Configuration Table in EFI System Table (gST)

 Introduction

UEFI defines Configuration table in EFI system table. The structure with EfiPy style is as below

class EFI_CONFIGURATION_TABLE (Structure): _fields_ = [ ("VendorGuid", EFI_GUID), ("VendorTable", PVOID) ]




class EFI_SYSTEM_TABLE (Structure):

_fields_ = [ ("Hdr", EFI_TABLE_HEADER), ("FirmwareVendor", PCHAR16), ("FirmwareRevision", UINT32), ("ConsoleInHandle", EFI_HANDLE), ("ConIn", POINTER(EFI_SIMPLE_TEXT_INPUT_PROTOCOL)), ("ConsoleOutHandle", EFI_HANDLE), ("ConOut", POINTER(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL)), ("StandardErrorHandle", EFI_HANDLE), ("StdErr", POINTER(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL)), ("RuntimeServices", POINTER(EFI_RUNTIME_SERVICES)), ("BootServices", POINTER(EFI_BOOT_SERVICES)), ("NumberOfTableEntries", UINTN), ("ConfigurationTable", POINTER(EFI_CONFIGURATION_TABLE)) ]








EfiPy2 added related library named EfiPy2.Lib.gStConfiguration.

This module makes user enumerate system configuration friendly.

Usage

from EfiPy2.Lib.gStConfiguration import RetrieveConfiguration, \

                                        FindConfiguration

Functions

RetrieveConfiguration ()

This function returns iterable list object. Each object in list is (EFI_GUID, VendorTable) pair tuple. That is this function convert ConfigurationTable to this format.

[(GUID, Address), (GUID, Address), (GUID, Address), ...]

FindConfiguration (Guid, CfgType = None)

This function finds configuration table according its parameter GUID.

This return object depend on the second parameter CfgType which is subvlass of ctypes._CData.
This function returns address if CfgType is None or it returns CfgType's instance.

Example

gStConfigurationSample.py, it does some things.

This get EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER's instance by gEfiAcpiTableGuid.

Table = FindConfiguration (gEfiAcpiTableGuid, EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER) print (f''' Looking Configuration table from gEfiAcpiTableGuid with class parameter EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER Guid, {gEfiAcpiTableGuid}, Table type.... {type (Table).__name__} Signature: {Table.Signature.to_bytes (8, 'little')} OemId : {bytes (Table.OemId[:])}''')






This statement will return None because it gives empty GUID to FindConfiguration()

DummyGuid = EfiPy.EFI_GUID() Table = FindConfiguration (DummyGuid) print (f''' Looking dummy guid {DummyGuid} Table shoud be None, Table: {Table}''')





Finaly, this get all configuration's GUID and its physical address in tuple form.

Cfg = RetrieveConfiguration () for Guid, Table in Cfg: print (f' Guid {Guid}, Table 0x{Table:08X}')



Result



No comments:

Post a Comment