参考WWW.LAB-Z.COM大神的操作来寻找一下System Table.
以OVMF 代码为例, 在 \MdeModulePkg\Core\Dxe\DxeMain\DxeMain.c 中可以查到。为了验证,我修改代码,在整个 Table 的最后面加上一个标记。
MemoryProfileInit (HobStart);
//
// Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
// Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
//
//Alix_debug_start
//gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);
gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE) + 4, &mEfiSystemTableTemplate);
p=(UINT8 *)gDxeCoreST;
*(p+sizeof (EFI_SYSTEM_TABLE))='A';
*(p+sizeof (EFI_SYSTEM_TABLE)+1)='L';
*(p+sizeof (EFI_SYSTEM_TABLE)+2)='I';
*(p+sizeof (EFI_SYSTEM_TABLE)+3)='X';
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "AlixMark\n"));
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "0x%x\n", p));
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "0x%x\n", p+sizeof (EFI_SYSTEM_TABLE)));
//Ailx_debug_End
ASSERT (gDxeCoreST != NULL);
gDxeCoreRT = AllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);
ASSERT (gDxeCoreRT != NULL);
编译BIOS 然后在 QEMU 上运行,先是查看串口输出
可以看到给出来的 System Table的内存地址是 0x7BEE018。我们启动到 Shell 使用 mem 命令可以看到内存的信息,其中包括当前的 SystemTable 的地址
*mem最后会输出efi系统表,参考shell下命令相关文章。
附上大神的连接
http://www.lab-z.com/stu22/