]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
MdeModulePkg/Variable: Consume Variable Flash Info
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VariableNonVolatile.c
index 5e9d40b67ac29f364c9927bda2efbecf38c4a728..9e2d8fe0fe0cc1ccd2608775c6bbadaf1abf484d 100644 (file)
@@ -142,6 +142,7 @@ InitRealNonVolatileVariableStore (
   EFI_PHYSICAL_ADDRESS                  NvStorageBase;\r
   UINT8                                 *NvStorageData;\r
   UINT32                                NvStorageSize;\r
+  UINT64                                NvStorageSize64;\r
   FAULT_TOLERANT_WRITE_LAST_WRITE_DATA  *FtwLastWriteData;\r
   UINT32                                BackUpOffset;\r
   UINT32                                BackUpSize;\r
@@ -153,19 +154,24 @@ InitRealNonVolatileVariableStore (
 \r
   mVariableModuleGlobal->FvbInstance = NULL;\r
 \r
+  Status = GetVariableFlashNvStorageInfo (&NvStorageBase, &NvStorageSize64);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = SafeUint64ToUint32 (NvStorageSize64, &NvStorageSize);\r
+  // This driver currently assumes the size will be UINT32 so assert the value is safe for now.\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  ASSERT (NvStorageBase != 0);\r
+\r
   //\r
   // Allocate runtime memory used for a memory copy of the FLASH region.\r
   // Keep the memory and the FLASH in sync as updates occur.\r
   //\r
-  NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);\r
   NvStorageData = AllocateRuntimeZeroPool (NvStorageSize);\r
   if (NvStorageData == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  NvStorageBase = NV_STORAGE_VARIABLE_BASE;\r
-  ASSERT (NvStorageBase != 0);\r
-\r
   //\r
   // Copy NV storage data to the memory buffer.\r
   //\r