EFI_SYSTEM_TABLE 中定义了 EFI_CONFIGURATION_TABLE *ConfigurationTable;
这个结构体定义如下:
typedef struct{ EFI_GUID VendorGuid; VOID *VendorTable; } EFI_CONFIGURATION_TABLE;
整体看起来就是这样:
根据上面的原理可以编写程序枚举系统中的 ConfigurationTable,代码如下:
#include <Uefi.h> #include <Library/UefiLib.h> #include <Library/ShellCEntryLib.h> extern EFI_BOOT_SERVICES *gBS; extern EFI_SYSTEM_TABLE *gST; extern EFI_RUNTIME_SERVICES *gRT; EFI_STATUS PrintGuid ( IN EFI_GUID *Guid ) /*++ Routine Description: This function prints a GUID to STDOUT. Arguments: Guid Pointer to a GUID to print. Returns: EFI_SUCCESS The GUID was printed. EFI_INVALID_PARAMETER The input was NULL. --*/ { if (Guid == NULL) { Print(L"Parameter error!\n"); return EFI_INVALID_PARAMETER; } Print ( L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", (unsigned) Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], Guid->Data4[1], Guid->Data4[2], Guid->Data4[3], Guid->Data4[4], Guid->Data4[5], Guid->Data4[6], Guid->Data4[7] ); return EFI_SUCCESS; } int EFIAPI main ( IN int Argc, IN CHAR16 **Argv ) { UINTN i; EFI_STATUS Status; EFI_CONFIGURATION_TABLE *C=NULL; Print(L"[%d] Tables were found!\n",gST->NumberOfTableEntries); C=gST->ConfigurationTable; for (i=0;i<gST->NumberOfTableEntries-1;i++) { Status=PrintGuid(&C->VendorGuid); C++; } return EFI_SUCCESS; }
然后我们尝试在模拟环境中运行,结果如下:
我们再看看找到的这些GUID是什么意思:
#define TIANO_CUSTOM_DECOMPRESS_GUID \ { 0xA31280AD, 0x481E, 0x41B6, { 0x95, 0xE8, 0x12, 0x7F, 0x4C, 0x98, 0x47, 0x79 } } #define EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID \ { 0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } } #define DXE_SERVICES_TABLE_GUID \ { \ 0x5ad34ba, 0x6f02, 0x4214, {0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } \ } #define HOB_LIST_GUID \ { \ 0x7739f24c, 0x93d7, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ } #define EFI_MEMORY_TYPE_INFORMATION_GUID \ { 0x4c19049f,0x4137,0x4dd3, { 0x9c,0x10,0x8b,0x97,0xa8,0x3f,0xfd,0xfa } } #define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \ { \ 0x49152e77, 0x1ada, 0x4764, {0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } \ } #define SMBIOS_TABLE_GUID \ { \ 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ }
能看懂的只有SMBIOS.......我们再用实体机测试,结果如下:
比上面的多了5个GUID,分别是:
#define LZMA_CUSTOM_DECOMPRESS_GUID \ { 0xEE4E5898, 0x3914, 0x4259, { 0x9D, 0x6E, 0xDC, 0x7B, 0xD7, 0x94, 0x03, 0xCF } } #define EFI_TSC_FREQUENCY_GUID \ { \ 0xdba6a7e3, 0xbb57, 0x4be7, { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \ } #define ACPI_TABLE_GUID \ { \ 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ } #define EFI_ACPI_TABLE_GUID \ { \ 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \ } gEfiOfflineCrashDumpTblGuid = { 0x3804CF02, 0x8538, 0x11E2, { 0x88, 0x47, 0x8D, 0xF1, 0x60, 0x88, 0x70, 0x9B } }
本文完整代码下载:
下一次会介绍 Shell 下如何获取ACPI Table。
Dear sir,
感謝你分享source code,讓我可以先找到 "EFI_SYSTEM_RESOURCE_TABLE_GUID" 的address然後再去讀 然後可以 讀出ESRT Table 的register. Thanks!
EFI_SYSTEM_RESOURCE_TABLE_GUID: B122A263-3661-4F68-9929-78F8B0D62180
Best Regards,
Tim