]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
MdeModulePkg/Variable: Consume Variable Flash Info
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VariableDxe.c
index 03fec3048dc46c60ff1d03a96bdf33223d24a88f..d5c409c914d151442b03edcb0f6141a5552b4f08 100644 (file)
@@ -423,6 +423,8 @@ FtwNotificationEvent (
   EFI_PHYSICAL_ADDRESS                VariableStoreBase;\r
   UINT64                              VariableStoreLength;\r
   UINTN                               FtwMaxBlockSize;\r
+  UINT32                              NvStorageVariableSize;\r
+  UINT64                              NvStorageVariableSize64;\r
 \r
   //\r
   // Ensure FTW protocol is installed.\r
@@ -432,14 +434,20 @@ FtwNotificationEvent (
     return;\r
   }\r
 \r
+  Status = GetVariableFlashNvStorageInfo (&NvStorageVariableBase, &NvStorageVariableSize64);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = SafeUint64ToUint32 (NvStorageVariableSize64, &NvStorageVariableSize);\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
+  VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;\r
+\r
   Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);\r
   if (!EFI_ERROR (Status)) {\r
-    ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);\r
+    ASSERT (NvStorageVariableSize <= FtwMaxBlockSize);\r
   }\r
 \r
-  NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;\r
-  VariableStoreBase     = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;\r
-\r
   //\r
   // Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.\r
   //\r