summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2022-04-05 21:34:51 -0400
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-05-19 06:11:20 +0000
commit4dbebc2d102e83dbafab568a2f7471791001b42c (patch)
treee83d059aa657c085e46d6d5746548f8e98e0778b /MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
parent60b519456cf01beb269bf864a37fa2acdc53f003 (diff)
downloadedk2-4dbebc2d102e83dbafab568a2f7471791001b42c.tar.gz
edk2-4dbebc2d102e83dbafab568a2f7471791001b42c.tar.bz2
edk2-4dbebc2d102e83dbafab568a2f7471791001b42c.zip
MdeModulePkg/Variable: Consume Variable Flash Info
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479 Updates VariableRuntimeDxe, VariableSmm, and VariableStandaloneMm to acquire variable flash information from the Variable Flash Information library. Note: This introduces a dependency on VariableFlashInfoLib in these modules. Therefore, a platform building the variable modules must specify an instance of VariableFlashInfoLib in their platform build. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c')
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
index 5e9d40b67a..9e2d8fe0fe 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
@@ -142,6 +142,7 @@ InitRealNonVolatileVariableStore (
EFI_PHYSICAL_ADDRESS NvStorageBase;
UINT8 *NvStorageData;
UINT32 NvStorageSize;
+ UINT64 NvStorageSize64;
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *FtwLastWriteData;
UINT32 BackUpOffset;
UINT32 BackUpSize;
@@ -153,19 +154,24 @@ InitRealNonVolatileVariableStore (
mVariableModuleGlobal->FvbInstance = NULL;
+ Status = GetVariableFlashNvStorageInfo (&NvStorageBase, &NvStorageSize64);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = SafeUint64ToUint32 (NvStorageSize64, &NvStorageSize);
+ // This driver currently assumes the size will be UINT32 so assert the value is safe for now.
+ ASSERT_EFI_ERROR (Status);
+
+ ASSERT (NvStorageBase != 0);
+
//
// Allocate runtime memory used for a memory copy of the FLASH region.
// Keep the memory and the FLASH in sync as updates occur.
//
- NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
NvStorageData = AllocateRuntimeZeroPool (NvStorageSize);
if (NvStorageData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- NvStorageBase = NV_STORAGE_VARIABLE_BASE;
- ASSERT (NvStorageBase != 0);
-
//
// Copy NV storage data to the memory buffer.
//