]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
MdeModulePkg DxeCore/PiSmmCore: Add UEFI memory and SMRAM profile support.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain / DxeMain.c
index ed5a3c9e177a66d744c1fac4728b49bd5a70b0c3..1ac5cc17212d590479723f9216e85e3f69852fe3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DXE Core Main Entry Point\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, 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
@@ -242,11 +242,21 @@ DxeMain (
   EFI_PHYSICAL_ADDRESS          MemoryBaseAddress;\r
   UINT64                        MemoryLength;\r
   PE_COFF_LOADER_IMAGE_CONTEXT  ImageContext;\r
+  UINTN                         Index;\r
+  EFI_HOB_GUID_TYPE             *GuidHob;\r
+  EFI_VECTOR_HANDOFF_INFO       *VectorInfoList;\r
+  EFI_VECTOR_HANDOFF_INFO       *VectorInfo;\r
 \r
   //\r
   // Setup the default exception handlers\r
   //\r
-  SetupCpuExceptionHandlers ();\r
+  VectorInfoList = NULL;\r
+  GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);\r
+  if (GuidHob != NULL) {\r
+    VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *) (GET_GUID_HOB_DATA(GuidHob));\r
+  }\r
+  Status = InitializeCpuExceptionHandlers (VectorInfoList);\r
+  ASSERT_EFI_ERROR (Status);\r
   \r
   //\r
   // Initialize Debug Agent to support source level debug in DXE phase\r
@@ -258,6 +268,8 @@ DxeMain (
   //\r
   CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength);\r
 \r
+  MemoryProfileInit (HobStart);\r
+\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
@@ -286,8 +298,9 @@ DxeMain (
   //\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.PdbPointer   = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);\r
   PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
 \r
   //\r
@@ -371,6 +384,26 @@ DxeMain (
   Status = CoreInitializeEventServices ();\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  MemoryProfileInstallProtocol ();\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
+  //\r
+  GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);\r
+  if (GuidHob != NULL) {\r
+    VectorInfoList = (EFI_VECTOR_HANDOFF_INFO *) (GET_GUID_HOB_DATA(GuidHob));\r
+    VectorInfo = VectorInfoList;\r
+    Index = 1;\r
+    while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) {\r
+      VectorInfo ++;\r
+      Index ++;\r
+    }\r
+    VectorInfo = AllocateCopyPool (sizeof (EFI_VECTOR_HANDOFF_INFO) * Index, (VOID *) VectorInfoList);\r
+    ASSERT (VectorInfo != NULL);\r
+    Status = CoreInstallConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID *) VectorInfo);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
 \r
   //\r
   // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs\r
@@ -713,6 +746,14 @@ CoreExitBootServices (
   //\r
   CoreNotifySignalList (&gEfiEventExitBootServicesGuid);\r
 \r
+  //\r
+  // Report that ExitBootServices() has been called\r
+  //\r
+  REPORT_STATUS_CODE (\r
+    EFI_PROGRESS_CODE,\r
+    (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)\r
+    );\r
+\r
   //\r
   // Disable interrupt of Debug timer.\r
   //\r
@@ -723,14 +764,6 @@ CoreExitBootServices (
   //\r
   gCpu->DisableInterrupt (gCpu);\r
 \r
-  //\r
-  // Report that ExitBootServices() has been called\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)\r
-    );\r
-\r
   //\r
   // Clear the non-runtime values of the EFI System Table\r
   //\r
@@ -828,7 +861,7 @@ DxeMainUefiDecompressGetInfo (
   implementation. It is the caller's responsibility to allocate and free the\r
   Destination and Scratch buffers.\r
   If the compressed source data specified by Source and SourceSize is\r
-  sucessfully decompressed into Destination, then EFI_SUCCESS is returned. If\r
+  successfully decompressed into Destination, then EFI_SUCCESS is returned. If\r
   the compressed source data specified by Source and SourceSize is not in a\r
   valid compressed data format, then EFI_INVALID_PARAMETER is returned.\r
 \r