]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
MdeModulePkg/Core: Decorate phase-transition functions with NORETURN.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain / DxeMain.c
index 9b03509e6b9691f5c554bbf3482ca900eab0d4ee..8380fd78bed81bfd2b586f0536855290a9214e69 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DXE Core Main Entry Point\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -207,6 +207,7 @@ EFI_SYSTEM_TABLE      *gDxeCoreST = NULL;
 EFI_RUNTIME_SERVICES  *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;\r
 EFI_HANDLE            gDxeCoreImageHandle = NULL;\r
 \r
+BOOLEAN               gMemoryMapTerminated = FALSE;\r
 \r
 //\r
 // EFI Decompress Protocol\r
@@ -234,6 +235,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE    gLoa
 \r
 **/\r
 VOID\r
+NORETURN\r
 EFIAPI\r
 DxeMain (\r
   IN  VOID *HobStart\r
@@ -247,6 +249,7 @@ DxeMain (
   EFI_HOB_GUID_TYPE             *GuidHob;\r
   EFI_VECTOR_HANDOFF_INFO       *VectorInfoList;\r
   EFI_VECTOR_HANDOFF_INFO       *VectorInfo;\r
+  VOID                          *EntryPoint;\r
 \r
   //\r
   // Setup the default exception handlers\r
@@ -289,6 +292,12 @@ DxeMain (
   Status = CoreInitializeImageServices (HobStart);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Initialize the Global Coherency Domain Services\r
+  //\r
+  Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   //\r
   // Call constructor for all libraries\r
   //\r
@@ -300,16 +309,17 @@ DxeMain (
   // Report DXE Core image information to the PE/COFF Extra Action Library\r
   //\r
   ZeroMem (&ImageContext, sizeof (ImageContext));\r
-  ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreLoadedImage->ImageBase;\r
-  ImageContext.PdbPointer   = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);\r
+  ImageContext.ImageAddress   = (EFI_PHYSICAL_ADDRESS)(UINTN)gDxeCoreLoadedImage->ImageBase;\r
+  ImageContext.PdbPointer     = PeCoffLoaderGetPdbPointer ((VOID*)(UINTN)ImageContext.ImageAddress);\r
+  ImageContext.SizeOfHeaders  = PeCoffGetSizeOfHeaders ((VOID*)(UINTN)ImageContext.ImageAddress);\r
+  Status = PeCoffLoaderGetEntryPoint ((VOID*)(UINTN)ImageContext.ImageAddress, &EntryPoint);\r
+  if (Status == EFI_SUCCESS) {\r
+    ImageContext.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;\r
+  }\r
+  ImageContext.Handle         = (VOID *)(UINTN)gDxeCoreLoadedImage->ImageBase;\r
+  ImageContext.ImageRead      = PeCoffLoaderImageReadFromMemory;\r
   PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
 \r
-  //\r
-  // Initialize the Global Coherency Domain Services\r
-  //\r
-  Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
   //\r
   // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
   //\r
@@ -374,7 +384,7 @@ DxeMain (
       if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2) {\r
         DEBUG ((DEBUG_INFO | DEBUG_LOAD, "FV2 Hob           0x%0lx - 0x%0lx\n", Hob.FirmwareVolume2->BaseAddress, Hob.FirmwareVolume2->BaseAddress + Hob.FirmwareVolume2->Length - 1));\r
       } else if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) {\r
-        DEBUG ((DEBUG_INFO | DEBUG_LOAD, "FV Hob            0x%0lx - 0x%0lx\n", Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->BaseAddress + Hob.FirmwareVolume2->Length - 1));\r
+        DEBUG ((DEBUG_INFO | DEBUG_LOAD, "FV Hob            0x%0lx - 0x%0lx\n", Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->BaseAddress + Hob.FirmwareVolume->Length - 1));\r
       }\r
     }\r
   DEBUG_CODE_END ();\r
@@ -387,6 +397,9 @@ DxeMain (
 \r
   MemoryProfileInstallProtocol ();\r
 \r
+  CoreInitializePropertiesTable ();\r
+  CoreInitializeMemoryAttributesTable ();\r
+\r
   //\r
   // Get persisted vector hand-off info from GUIDeed HOB again due to HobStart may be updated,\r
   // and install configuration table\r
@@ -512,6 +525,8 @@ DxeMain (
   //\r
   ASSERT (FALSE);\r
   CpuDeadLoop ();\r
+\r
+  UNREACHABLE ();\r
 }\r
 \r
 \r
@@ -742,6 +757,8 @@ CoreExitBootServices (
     return Status;\r
   }\r
 \r
+  gMemoryMapTerminated = TRUE;\r
+\r
   //\r
   // Notify other drivers that we are exiting boot services.\r
   //\r