]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Add support for UEFI2.5 and PI1.4 PersistentMemory feature
authorLiming Gao <liming.gao@intel.com>
Wed, 29 Apr 2015 01:37:05 +0000 (01:37 +0000)
committerlgao4 <lgao4@Edk2>
Wed, 29 Apr 2015 01:37:05 +0000 (01:37 +0000)
Update DxeCore to collect PersistentMemory resource and report them
in EFI memory map.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17242 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
MdeModulePkg/Core/Dxe/Gcd/Gcd.c
MdeModulePkg/Core/Dxe/Mem/Page.c
MdeModulePkg/Core/Dxe/Mem/Pool.c
MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c

index 084b069fb8a70c4c57900213d2ed98d09e3e0dab..96bb9add8b50230f3dc16b81dca7ee3e283013e3 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
   \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2015, 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
@@ -54,6 +54,7 @@ CHAR16 *mMemoryTypeString[] = {
   L"EfiMemoryMappedIO",\r
   L"EfiMemoryMappedIOPortSpace",\r
   L"EfiPalCode",\r
+  L"EfiPersistentMemory",\r
   L"EfiOSReserved",\r
 };\r
 \r
index 6703c84517467a6632f10ebf7c3bb3852aa97e32..bce01a01a3cdd7ef7ec16a0e07933c48c7a5aaf6 100644 (file)
@@ -3,7 +3,7 @@
   The GCD services are used to manage the memory and I/O regions that\r
   are accessible to the CPU that is executing the DXE core.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, 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
@@ -27,7 +27,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
                                        EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \\r
                                        EFI_RESOURCE_ATTRIBUTE_16_BIT_IO           | \\r
                                        EFI_RESOURCE_ATTRIBUTE_32_BIT_IO           | \\r
-                                       EFI_RESOURCE_ATTRIBUTE_64_BIT_IO           )\r
+                                       EFI_RESOURCE_ATTRIBUTE_64_BIT_IO           | \\r
+                                       EFI_RESOURCE_ATTRIBUTE_PERSISTENT          )\r
 \r
 #define TESTED_MEMORY_ATTRIBUTES      (EFI_RESOURCE_ATTRIBUTE_PRESENT     | \\r
                                        EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \\r
@@ -92,6 +93,7 @@ GCD_ATTRIBUTE_CONVERSION_ENTRY mAttributeConversionTable[] = {
   { EFI_RESOURCE_ATTRIBUTE_PRESENT,                 EFI_MEMORY_PRESENT,     FALSE },\r
   { EFI_RESOURCE_ATTRIBUTE_INITIALIZED,             EFI_MEMORY_INITIALIZED, FALSE },\r
   { EFI_RESOURCE_ATTRIBUTE_TESTED,                  EFI_MEMORY_TESTED,      FALSE },\r
+  { EFI_RESOURCE_ATTRIBUTE_PERSISTABLE,             EFI_MEMORY_NV,          TRUE  },\r
   { 0,                                              0,                      FALSE }\r
 };\r
 \r
@@ -103,6 +105,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *mGcdMemoryTypeNames[] = {
   "Reserved ",  // EfiGcdMemoryTypeReserved\r
   "SystemMem",  // EfiGcdMemoryTypeSystemMemory\r
   "MMIO     ",  // EfiGcdMemoryTypeMemoryMappedIo\r
+  "PersistentMem",// EfiGcdMemoryTypePersistentMemory\r
   "Unknown  "   // EfiGcdMemoryTypeMaximum\r
 };\r
 \r
@@ -231,6 +234,8 @@ CoreValidateResourceDescriptorHobAttributes (
           ((Attributes & EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTABLE) != 0));\r
   ASSERT (((Attributes & EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED) == 0) ||\r
           ((Attributes & EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTABLE) != 0));\r
+  ASSERT (((Attributes & EFI_RESOURCE_ATTRIBUTE_PERSISTENT) == 0) ||\r
+          ((Attributes & EFI_RESOURCE_ATTRIBUTE_PERSISTABLE) != 0));\r
 }\r
 \r
 /**\r
@@ -2357,6 +2362,9 @@ CoreInitializeGcdServices (
         if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == PRESENT_MEMORY_ATTRIBUTES) {\r
           GcdMemoryType = EfiGcdMemoryTypeReserved;\r
         }\r
+        if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_PERSISTENT) == EFI_RESOURCE_ATTRIBUTE_PERSISTENT) {\r
+          GcdMemoryType = EfiGcdMemoryTypePersistentMemory;\r
+        }\r
         break;\r
       case EFI_RESOURCE_MEMORY_MAPPED_IO:\r
       case EFI_RESOURCE_FIRMWARE_DEVICE:\r
index 84ebbca141c22810be6ed7b1d891b75c9c1f8431..830b19700aae8750f90da71b1f51da68db224b30 100644 (file)
@@ -67,6 +67,7 @@ EFI_MEMORY_TYPE_STATISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = {
   { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE },  // EfiMemoryMappedIO\r
   { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE },  // EfiMemoryMappedIOPortSpace\r
   { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE,  TRUE  },  // EfiPalCode\r
+  { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE },  // EfiPersistentMemory\r
   { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }   // EfiMaxMemoryType\r
 };\r
 \r
@@ -88,6 +89,7 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
   { EfiMemoryMappedIO,          0 },\r
   { EfiMemoryMappedIOPortSpace, 0 },\r
   { EfiPalCode,                 0 },\r
+  { EfiPersistentMemory,        0 },\r
   { EfiMaxMemoryType,           0 }\r
 };\r
 //\r
@@ -1198,7 +1200,7 @@ CoreInternalAllocatePages (
   }\r
 \r
   if ((MemoryType >= EfiMaxMemoryType && MemoryType <= 0x7fffffff) ||\r
-       MemoryType == EfiConventionalMemory) {\r
+       (MemoryType == EfiConventionalMemory) || (MemoryType == EfiPersistentMemory)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1528,7 +1530,7 @@ CoreGetMemoryMap (
   EFI_STATUS                        Status;\r
   UINTN                             Size;\r
   UINTN                             BufferSize;\r
-  UINTN                             NumberOfRuntimeEntries;\r
+  UINTN                             NumberOfRuntimePersistentEntries;\r
   LIST_ENTRY                        *Link;\r
   MEMORY_MAP                        *Entry;\r
   EFI_GCD_MAP_ENTRY                 *GcdMapEntry;\r
@@ -1546,16 +1548,21 @@ CoreGetMemoryMap (
 \r
   //\r
   // Count the number of Reserved and MMIO entries that are marked for runtime use\r
+  // And, count the number of Persistent entries.\r
   //\r
-  NumberOfRuntimeEntries = 0;\r
+  NumberOfRuntimePersistentEntries = 0;\r
   for (Link = mGcdMemorySpaceMap.ForwardLink; Link != &mGcdMemorySpaceMap; Link = Link->ForwardLink) {\r
     GcdMapEntry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);\r
     if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||\r
         (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo)) {\r
       if ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {\r
-        NumberOfRuntimeEntries++;\r
+        NumberOfRuntimePersistentEntries ++;\r
       }\r
     }\r
+    \r
+    if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypePersistentMemory) {\r
+      NumberOfRuntimePersistentEntries ++;\r
+    }\r
   }\r
 \r
   Size = sizeof (EFI_MEMORY_DESCRIPTOR);\r
@@ -1580,7 +1587,7 @@ CoreGetMemoryMap (
   //\r
   // Compute the buffer size needed to fit the entire map\r
   //\r
-  BufferSize = Size * NumberOfRuntimeEntries;\r
+  BufferSize = Size * NumberOfRuntimePersistentEntries;\r
   for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {\r
     BufferSize += Size;\r
   }\r
@@ -1673,6 +1680,23 @@ CoreGetMemoryMap (
         MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);\r
       }\r
     }\r
+    \r
+    if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypePersistentMemory) {\r
+      // \r
+      // Create EFI_MEMORY_DESCRIPTOR for every Persistent GCD entries\r
+      //\r
+      MemoryMap->PhysicalStart = GcdMapEntry->BaseAddress;\r
+      MemoryMap->VirtualStart  = 0;\r
+      MemoryMap->NumberOfPages = RShiftU64 ((GcdMapEntry->EndAddress - GcdMapEntry->BaseAddress + 1), EFI_PAGE_SHIFT);\r
+      MemoryMap->Attribute     = GcdMapEntry->Attributes | EFI_MEMORY_NV;\r
+      MemoryMap->Type          = EfiPersistentMemory;\r
+      \r
+      //\r
+      // Check to see if the new Memory Map Descriptor can be merged with an \r
+      // existing descriptor if they are adjacent and have the same attributes\r
+      //\r
+      MemoryMap = MergeMemoryMapDescriptor (MemoryMapStart, MemoryMap, Size);\r
+    }\r
   }\r
 \r
   //\r
index e43bac834eea03e17b00c8fb7544b7a45acfc371..ac717fb65f7a3a50da948bb01e67a356a4c6bf53 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Memory pool management functions.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, 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
@@ -197,6 +197,7 @@ LookupPoolHead (
                                  pool\r
 \r
   @retval EFI_INVALID_PARAMETER  PoolType not valid or Buffer is NULL. \r
+                                 PoolType was EfiPersistentMemory.\r
   @retval EFI_OUT_OF_RESOURCES   Size exceeds max pool size or allocation failed.\r
   @retval EFI_SUCCESS            Pool successfully allocated.\r
 \r
@@ -215,7 +216,7 @@ CoreInternalAllocatePool (
   // If it's not a valid type, fail it\r
   //\r
   if ((PoolType >= EfiMaxMemoryType && PoolType <= 0x7fffffff) ||\r
-       PoolType == EfiConventionalMemory) {\r
+       (PoolType == EfiConventionalMemory) || (PoolType == EfiPersistentMemory)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
index a78442901bafa80d036c58ce4a9fb0f3bc49dbbd..38f806e2356b53b663414bb153220c4108833ea3 100644 (file)
@@ -1793,6 +1793,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mMemoryTypeString[] = {
   L"EfiMemoryMappedIO",\r
   L"EfiMemoryMappedIOPortSpace",\r
   L"EfiPalCode",\r
+  L"EfiPersistentMemory",\r
   L"EfiOSReserved",\r
 };\r
 \r