]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c
1) Initialize gBS, gST, gImageHandle in UefiBootServicesTableLib.c to NULL
[mirror_edk2.git] / EdkModulePkg / Core / Dxe / DxeMain / DxeMain.c
index 427e6b8ca50a005811afc880826d6e80707e1f57..1e31a8899e753e33737722b7bb73f49a805af4e7 100644 (file)
@@ -211,16 +211,16 @@ EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;
 // DXE Core Global Variables for the EFI System Table, Boot Services Table,\r
 // DXE Services Table, and Runtime Services Table\r
 //\r
 // DXE Core Global Variables for the EFI System Table, Boot Services Table,\r
 // DXE Services Table, and Runtime Services Table\r
 //\r
-EFI_BOOT_SERVICES     *gBS = &mBootServices;\r
-EFI_DXE_SERVICES      *gDS = &mDxeServices;\r
-EFI_SYSTEM_TABLE      *gST = NULL;\r
+EFI_BOOT_SERVICES     *gDxeCoreBS = &mBootServices;\r
+EFI_DXE_SERVICES      *gDxeCoreDS = &mDxeServices;\r
+EFI_SYSTEM_TABLE      *gDxeCoreST = NULL;\r
 \r
 //\r
 \r
 //\r
-// For debug initialize gRT to template. gRT must be allocated from RT memory\r
-//  but gRT is used for ASSERT () and DEBUG () type macros so lets give it\r
+// For debug initialize gDxeCoreRT to template. gDxeCoreRT must be allocated from RT memory\r
+//  but gDxeCoreRT is used for ASSERT () and DEBUG () type macros so lets give it\r
 //  a value that will not cause debug infrastructure to crash early on.\r
 //\r
 //  a value that will not cause debug infrastructure to crash early on.\r
 //\r
-EFI_RUNTIME_SERVICES  *gRT = &mEfiRuntimeServicesTableTemplate;\r
+EFI_RUNTIME_SERVICES  *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;\r
 EFI_HANDLE            gDxeCoreImageHandle = NULL;\r
 \r
 VOID  *mHobStart;\r
 EFI_HANDLE            gDxeCoreImageHandle = NULL;\r
 \r
 VOID  *mHobStart;\r
@@ -288,13 +288,13 @@ Returns:
   // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData\r
   // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table\r
   //\r
   // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData\r
   // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table\r
   //\r
-  gST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r
-  ASSERT (gST != NULL);\r
+  gDxeCoreST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);\r
+  ASSERT (gDxeCoreST != NULL);\r
 \r
 \r
-  gRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r
-  ASSERT (gRT != NULL);\r
+  gDxeCoreRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);\r
+  ASSERT (gDxeCoreRT != NULL);\r
 \r
 \r
-  gST->RuntimeServices = gRT;\r
+  gDxeCoreST->RuntimeServices = gDxeCoreRT;\r
 \r
   //\r
   // Start the Image Services.\r
 \r
   //\r
   // Start the Image Services.\r
@@ -305,7 +305,7 @@ Returns:
   //\r
   // Call constructor for all libraries\r
   //\r
   //\r
   // Call constructor for all libraries\r
   //\r
-  ProcessLibraryConstructorList (gDxeCoreImageHandle, gST);\r
+  ProcessLibraryConstructorList (gDxeCoreImageHandle, gDxeCoreST);\r
   PERF_END   (0,PEI_TOK, NULL, 0) ;\r
   PERF_START (0,DXE_TOK, NULL, 0) ;\r
 \r
   PERF_END   (0,PEI_TOK, NULL, 0) ;\r
   PERF_START (0,DXE_TOK, NULL, 0) ;\r
 \r
@@ -318,7 +318,7 @@ Returns:
   //\r
   // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
   //\r
   //\r
   // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
   //\r
-  Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDS);\r
+  Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDxeCoreDS);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
@@ -400,16 +400,16 @@ Returns:
   //\r
   // Produce Firmware Volume Protocols, one for each FV in the HOB list.\r
   //\r
   //\r
   // Produce Firmware Volume Protocols, one for each FV in the HOB list.\r
   //\r
-  Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gST);\r
+  Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = FwVolDriverInit (gDxeCoreImageHandle, gST);\r
+  Status = FwVolDriverInit (gDxeCoreImageHandle, gDxeCoreST);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Produce the Section Extraction Protocol\r
   //\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Produce the Section Extraction Protocol\r
   //\r
-  Status = InitializeSectionExtraction (gDxeCoreImageHandle, gST);\r
+  Status = InitializeSectionExtraction (gDxeCoreImageHandle, gDxeCoreST);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
@@ -742,11 +742,11 @@ Returns:
   Hdr->CRC32 = 0;\r
 \r
   //\r
   Hdr->CRC32 = 0;\r
 \r
   //\r
-  // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r
+  // If gDxeCoreBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then\r
   //  Crc will come back as zero if we set it to zero here\r
   //\r
   Crc = 0;\r
   //  Crc will come back as zero if we set it to zero here\r
   //\r
   Crc = 0;\r
-  gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r
+  gDxeCoreBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);\r
   Hdr->CRC32 = Crc;\r
 }\r
 \r
   Hdr->CRC32 = Crc;\r
 }\r
 \r
@@ -812,24 +812,24 @@ Returns:
   //\r
   // Clear the non-runtime values of the EFI System Table\r
   //\r
   //\r
   // Clear the non-runtime values of the EFI System Table\r
   //\r
-  gST->BootServices        = NULL;\r
-  gST->ConIn               = NULL;\r
-  gST->ConsoleInHandle     = NULL;\r
-  gST->ConOut              = NULL;\r
-  gST->ConsoleOutHandle    = NULL;\r
-  gST->StdErr              = NULL;\r
-  gST->StandardErrorHandle = NULL;\r
+  gDxeCoreST->BootServices        = NULL;\r
+  gDxeCoreST->ConIn               = NULL;\r
+  gDxeCoreST->ConsoleInHandle     = NULL;\r
+  gDxeCoreST->ConOut              = NULL;\r
+  gDxeCoreST->ConsoleOutHandle    = NULL;\r
+  gDxeCoreST->StdErr              = NULL;\r
+  gDxeCoreST->StandardErrorHandle = NULL;\r
 \r
   //\r
   // Recompute the 32-bit CRC of the EFI System Table\r
   //\r
 \r
   //\r
   // Recompute the 32-bit CRC of the EFI System Table\r
   //\r
-  CalculateEfiHdrCrc (&gST->Hdr);\r
+  CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
 \r
   //\r
   // Zero out the Boot Service Table\r
   //\r
 \r
   //\r
   // Zero out the Boot Service Table\r
   //\r
-  SetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0);\r
-  gBS = NULL;\r
+  SetMem (gDxeCoreBS, sizeof (EFI_BOOT_SERVICES), 0);\r
+  gDxeCoreBS = NULL;\r
 \r
   //\r
   // Update the AtRuntime field in Runtiem AP.\r
 \r
   //\r
   // Update the AtRuntime field in Runtiem AP.\r