加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

UEFI gST,gBS,gRT的定义

(2012-01-16 12:38:43)
标签:

杂谈

it

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);

 

}

 

 

0

阅读 收藏 喜欢 打印举报/Report
前一篇:UEFI 笔记1
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有