Boot
Service的定义在./MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
首先,程序的入口是_ModuleEntryPoint,其中会调用
ProcessLibraryConstructorList,而该函数会调用UefiBootServicesTableLibConstructor等给gST等指针进行赋值
ProcessLibraryConstructorList是自动生成的。在autogen.c中定义
在MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c
EFI_SYSTEM_TABLE
*gST
= NULL;
EFI_STATUS
EFIAPI
UefiBootServicesTableLibConstructor
(
IN
EFI_HANDLE
ImageHandle,
IN
EFI_SYSTEM_TABLE *SystemTable
)
{
//
// Cache
the Image Handle
//
gImageHandle = ImageHandle;
ASSERT
(gImageHandle != NULL);
//
// Cache
pointer to the EFI System Table
//
gST =
SystemTable;//这里进行的设定过程
ASSERT
(gST != NULL);
//
// Cache
pointer to the EFI Boot Services Table
//
gBS =
SystemTable->BootServices;
ASSERT
(gBS != NULL);
return
EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
_ModuleEntryPoint (
IN
EFI_HANDLE
ImageHandle,
IN
EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS
Status;
if
(_gUefiDriverRevision != 0) {
//
// Make sure that the EFI/UEFI spec revision of the platform is
>= EFI/UEFI spec revision of the application.
//
if (SystemTable->Hdr.Revision <
_gUefiDriverRevision) {
return EFI_INCOMPATIBLE_VERSION;
}
}
//
// Call
constructor for all libraries.
//
ProcessLibraryConstructorList(ImageHandle, SystemTable);
//
// Call
the module's entry point
//
Status =
ProcessModuleEntryPointList (ImageHandle, SystemTable);
//
// Process
destructor for all libraries.
//
ProcessLibraryDestructorList (ImageHandle, SystemTable);
//
// Return
the return status code from the driver entry point
//
return
Status;
}
ProcessLibraryConstructorList是自动生成的。在autogen.c中定义
VOID
EFIAPI
ProcessLibraryConstructorList (
IN
EFI_HANDLE
ImageHandle,
IN
EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS
Status;
Status =
UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
Status =
UefiRuntimeServicesTableLibConstructor (ImageHandle,
SystemTable);
ASSERT_EFI_ERROR (Status);
Status =
PrintLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
Status =
UefiLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
Status =
HobLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
Status =
DxeDebugPrintErrorLevelLibConstructor (ImageHandle,
SystemTable);
ASSERT_EFI_ERROR (Status);
}
加载中,请稍候......