]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain / DxeMain.c
index 0a34711b22a4ab411aa4d08fa5e3f5c04ff87fc0..91e94a78d20598195c50dfc85a268d7fedd5cff5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DXE Core Main Entry Point\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, 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
@@ -247,6 +248,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,14 +291,6 @@ DxeMain (
   Status = CoreInitializeImageServices (HobStart);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  //\r
-  // 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
-  PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
-\r
   //\r
   // Initialize the Global Coherency Domain Services\r
   //\r
@@ -310,6 +304,21 @@ DxeMain (
   PERF_END   (NULL,"PEI", NULL, 0) ;\r
   PERF_START (NULL,"DXE", NULL, 0) ;\r
 \r
+  //\r
+  // 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.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
   // Install the DXE Services Table into the EFI System Tables's Configuration Table\r
   //\r
@@ -389,6 +398,7 @@ DxeMain (
 \r
   CoreInitializePropertiesTable ();\r
   CoreInitializeMemoryAttributesTable ();\r
+  CoreInitializeMemoryProtection ();\r
 \r
   //\r
   // Get persisted vector hand-off info from GUIDeed HOB again due to HobStart may be updated,\r
@@ -515,6 +525,8 @@ DxeMain (
   //\r
   ASSERT (FALSE);\r
   CpuDeadLoop ();\r
+\r
+  UNREACHABLE ();\r
 }\r
 \r
 \r
@@ -745,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
@@ -768,6 +782,8 @@ CoreExitBootServices (
   //\r
   gCpu->DisableInterrupt (gCpu);\r
 \r
+  MemoryProtectionExitBootServicesCallback();\r
+\r
   //\r
   // Clear the non-runtime values of the EFI System Table\r
   //\r