]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/MemDetect.c
OvmfPkg: PlatformPei: Platform specific ACPI power management setup
[mirror_edk2.git] / OvmfPkg / PlatformPei / MemDetect.c
index c1350b931f3a445bc2e9800928aa80e58e109009..bd7bb0227d8c338173780a41bc8ce3db163cfa1d 100644 (file)
@@ -56,7 +56,7 @@ GetSystemMemorySizeBelow4gb (
   Cmos0x34 = (UINT8) CmosRead8 (0x34);\r
   Cmos0x35 = (UINT8) CmosRead8 (0x35);\r
 \r
-  return (((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);\r
+  return (UINT32) (((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);\r
 }\r
 \r
 \r
@@ -205,6 +205,15 @@ InitializeRamRegions (
       EfiACPIMemoryNVS\r
       );\r
 \r
+    //\r
+    // SEC stores its table of GUIDed section handlers here.\r
+    //\r
+    BuildMemoryAllocationHob (\r
+      PcdGet64 (PcdGuidedExtractHandlerTableAddress),\r
+      PcdGet32 (PcdGuidedExtractHandlerTableSize),\r
+      EfiACPIMemoryNVS\r
+      );\r
+\r
 #ifdef MDE_CPU_X64\r
     //\r
     // Reserve the initial page tables built by the reset vector code.\r
@@ -218,13 +227,19 @@ InitializeRamRegions (
       EfiACPIMemoryNVS\r
       );\r
 #endif\r
+  }\r
 \r
+  if (mBootMode != BOOT_ON_S3_RESUME) {\r
     //\r
     // Reserve the lock box storage area\r
     //\r
     // Since this memory range will be used on S3 resume, it must be\r
     // reserved as ACPI NVS.\r
     //\r
+    // If S3 is unsupported, then various drivers might still write to the\r
+    // LockBox area. We ought to prevent DXE from serving allocation requests\r
+    // such that they would overlap the LockBox storage.\r
+    //\r
     ZeroMem (\r
       (VOID*)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),\r
       (UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize)\r
@@ -232,7 +247,7 @@ InitializeRamRegions (
     BuildMemoryAllocationHob (\r
       (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),\r
       (UINT64)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize),\r
-      EfiACPIMemoryNVS\r
+      mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData\r
       );\r
   }\r
 }\r