]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c
MdeModulePkg/DxeCore: Install UEFI mem attrib table at EndOfDxe.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Misc / MemoryAttributesTable.c
index 3706b232472a9b60f8820177214b65837f7486ab..60557faa1ca1d2f9fc378a22df40f95339542509 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI MemoryAttributesTable support\r
 \r
-Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2016 - 2018, 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
@@ -62,7 +62,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-CoreGetMemoryMapPropertiesTable (\r
+CoreGetMemoryMapWithSeparatedImageSection (\r
   IN OUT UINTN                  *MemoryMapSize,\r
   IN OUT EFI_MEMORY_DESCRIPTOR  *MemoryMap,\r
   OUT UINTN                     *MapKey,\r
@@ -104,7 +104,7 @@ InstallMemoryAttributesTable (
 \r
   if ((mPropertiesTable.MemoryProtectionAttribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) == 0) {\r
     DEBUG ((EFI_D_VERBOSE, "MemoryProtectionAttribute NON_EXECUTABLE_PE_DATA is not set, "));\r
-    DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT >> 10));\r
+    DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10));\r
     return ;\r
   }\r
 \r
@@ -120,7 +120,7 @@ InstallMemoryAttributesTable (
 \r
   MemoryMapSize = 0;\r
   MemoryMap = NULL;\r
-  Status = CoreGetMemoryMapPropertiesTable (\r
+  Status = CoreGetMemoryMapWithSeparatedImageSection (\r
              &MemoryMapSize,\r
              MemoryMap,\r
              &MapKey,\r
@@ -133,7 +133,7 @@ InstallMemoryAttributesTable (
     MemoryMap = AllocatePool (MemoryMapSize);\r
     ASSERT (MemoryMap != NULL);\r
 \r
-    Status = CoreGetMemoryMapPropertiesTable (\r
+    Status = CoreGetMemoryMapWithSeparatedImageSection (\r
                &MemoryMapSize,\r
                MemoryMap,\r
                &MapKey,\r
@@ -201,7 +201,7 @@ InstallMemoryAttributesTable (
   if (mMemoryAttributesTable != NULL) {\r
     FreePool (mMemoryAttributesTable);\r
   }\r
-  mMemoryAttributesTable = MemoryAttributesTable; \r
+  mMemoryAttributesTable = MemoryAttributesTable;\r
 }\r
 \r
 /**\r
@@ -237,7 +237,24 @@ InstallMemoryAttributesTableOnReadyToBoot (
   )\r
 {\r
   InstallMemoryAttributesTable ();\r
-  mMemoryAttributesTableReadyToBoot = TRUE; \r
+  mMemoryAttributesTableReadyToBoot = TRUE;\r
+}\r
+\r
+/**\r
+  Install initial MemoryAttributesTable on EndOfDxe.\r
+  Then SMM can consume this information.\r
+\r
+  @param[in] Event      The Event this notify function registered to.\r
+  @param[in] Context    Pointer to the context data registered to the Event.\r
+**/\r
+VOID\r
+EFIAPI\r
+InstallMemoryAttributesTableOnEndOfDxe (\r
+  IN EFI_EVENT          Event,\r
+  IN VOID               *Context\r
+  )\r
+{\r
+  InstallMemoryAttributesTable ();\r
 }\r
 \r
 /**\r
@@ -251,18 +268,35 @@ CoreInitializeMemoryAttributesTable (
 {\r
   EFI_STATUS  Status;\r
   EFI_EVENT   ReadyToBootEvent;\r
+  EFI_EVENT   EndOfDxeEvent;\r
 \r
   //\r
   // Construct the table at ReadyToBoot.\r
   //\r
   Status = CoreCreateEventInternal (\r
              EVT_NOTIFY_SIGNAL,\r
-             TPL_CALLBACK - 1,\r
+             TPL_CALLBACK,\r
              InstallMemoryAttributesTableOnReadyToBoot,\r
              NULL,\r
              &gEfiEventReadyToBootGuid,\r
              &ReadyToBootEvent\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Construct the initial table at EndOfDxe,\r
+  // then SMM can consume this information.\r
+  // Use TPL_NOTIFY here, as such SMM code (TPL_CALLBACK)\r
+  // can run after it.\r
+  //\r
+  Status = CoreCreateEventInternal (\r
+             EVT_NOTIFY_SIGNAL,\r
+             TPL_NOTIFY,\r
+             InstallMemoryAttributesTableOnEndOfDxe,\r
+             NULL,\r
+             &gEfiEndOfDxeEventGroupGuid,\r
+             &EndOfDxeEvent\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
   return ;\r
 }\r