]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
MdeModulePkg DxeCore/PiSmmCore: Add UEFI memory and SMRAM profile support.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.c
index c1b3563d013d277be9e7dd36446171ef7947818b..d16baedec9c319caa980a3f1fcdbf0f397121d00 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SMM Core Main Entry Point\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -78,9 +78,13 @@ SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {
   { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid,          NULL, TRUE  },\r
   { SmmReadyToLockHandler,    &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE }, \r
   { SmmLegacyBootHandler,     &gEfiEventLegacyBootGuid,           NULL, FALSE },\r
+  { SmmEndOfDxeHandler,       &gEfiEndOfDxeEventGroupGuid,        NULL, FALSE },\r
   { NULL,                     NULL,                               NULL, FALSE }\r
 };\r
 \r
+UINTN                           mFullSmramRangeCount;\r
+EFI_SMRAM_DESCRIPTOR            *mFullSmramRanges;\r
+\r
 /**\r
   Place holder function until all the SMM System Table Service are available.\r
 \r
@@ -225,9 +229,51 @@ SmmReadyToLockHandler (
   gST = NULL;\r
   gBS = NULL;\r
 \r
+  SmramProfileReadyToLock ();\r
+\r
   return Status;\r
 }\r
 \r
+/**\r
+  Software SMI handler that is called when the EndOfDxe event is signalled.\r
+  This function installs the SMM EndOfDxe Protocol so SMM Drivers are informed that\r
+  platform code will invoke 3rd part code.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmEndOfDxeHandler (\r
+  IN     EFI_HANDLE  DispatchHandle,\r
+  IN     CONST VOID  *Context,        OPTIONAL\r
+  IN OUT VOID        *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN       *CommBufferSize  OPTIONAL\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  EFI_HANDLE  SmmHandle;\r
+\r
+  DEBUG ((EFI_D_INFO, "SmmEndOfDxeHandler\n"));\r
+  //\r
+  // Install SMM EndOfDxe protocol\r
+  //\r
+  SmmHandle = NULL;\r
+  Status = SmmInstallProtocolInterface (\r
+             &SmmHandle,\r
+             &gEfiSmmEndOfDxeProtocolGuid,\r
+             EFI_NATIVE_INTERFACE,\r
+             NULL\r
+             );\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   The main entry point to SMM Foundation.\r
 \r
@@ -360,6 +406,16 @@ SmmMain (
   //\r
   SmmInitializeMemoryServices (gSmmCorePrivate->SmramRangeCount, gSmmCorePrivate->SmramRanges);\r
 \r
+  SmramProfileInit ();\r
+\r
+  //\r
+  // Copy FullSmramRanges to SMRAM\r
+  //\r
+  mFullSmramRangeCount = gSmmCorePrivate->FullSmramRangeCount;\r
+  mFullSmramRanges = AllocatePool (mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));\r
+  ASSERT (mFullSmramRanges != NULL);\r
+  CopyMem (mFullSmramRanges, gSmmCorePrivate->FullSmramRanges, mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));\r
+\r
   //\r
   // Register all SMI Handlers required by the SMM Core\r
   //\r
@@ -371,6 +427,8 @@ SmmMain (
                );\r
     ASSERT_EFI_ERROR (Status);\r
   }\r
-  \r
+\r
+  RegisterSmramProfileHandler ();\r
+\r
   return EFI_SUCCESS;\r
 }\r