diff options
author | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-19 09:30:43 +0000 |
---|---|---|
committer | niruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-19 09:30:43 +0000 |
commit | f68af18ee904368090566509d06d096bd89aaa73 (patch) | |
tree | d3214840ff2f924b5b9c69da5d57db3b1b0caa20 /MdeModulePkg/Universal | |
parent | 8598a1ed33f1fea5dac9d32a3ad6d28f62649cdc (diff) | |
download | edk2-platforms-f68af18ee904368090566509d06d096bd89aaa73.tar.xz |
Support Variable driver (EmuRuntimeDxe) to support the default variable data stored in HOB.
Signed-off-by: niruiyu
Reviewed-by: lgao4
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12553 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
4 files changed, 59 insertions, 9 deletions
diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c index df42eda670..3e4c5dab0f 100644 --- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c +++ b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c @@ -186,7 +186,7 @@ GetNextPotentialVariablePtr ( //
// Be careful about pad size for alignment
//
- VarHeader = (VARIABLE_HEADER *) (GetVariableDataPtr (Variable) + Variable->DataSize + GET_PAD_SIZE (Variable->DataSize));
+ VarHeader = (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) GetVariableDataPtr (Variable) + Variable->DataSize + GET_PAD_SIZE (Variable->DataSize));
return VarHeader;
}
@@ -999,12 +999,12 @@ UpdateVariable ( NextVariable = (VARIABLE_HEADER *) (UINT8 *) (mVariableModuleGlobal->NonVolatileLastVariableOffset
+ (UINTN) Global->NonVolatileVariableBase);
- mVariableModuleGlobal->NonVolatileLastVariableOffset += VarSize;
+ mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN (VarSize);
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
- mVariableModuleGlobal->HwErrVariableTotalSize += VarSize;
+ mVariableModuleGlobal->HwErrVariableTotalSize += HEADER_ALIGN (VarSize);
} else {
- mVariableModuleGlobal->CommonVariableTotalSize += VarSize;
+ mVariableModuleGlobal->CommonVariableTotalSize += HEADER_ALIGN (VarSize);
}
} else {
if ((UINT32) (VarSize + mVariableModuleGlobal->VolatileLastVariableOffset) >
@@ -1016,7 +1016,7 @@ UpdateVariable ( NextVariable = (VARIABLE_HEADER *) (UINT8 *) (mVariableModuleGlobal->VolatileLastVariableOffset
+ (UINTN) Global->VolatileVariableBase);
- mVariableModuleGlobal->VolatileLastVariableOffset += VarSize;
+ mVariableModuleGlobal->VolatileLastVariableOffset += HEADER_ALIGN (VarSize);
}
NextVariable->StartId = VARIABLE_DATA;
@@ -1609,10 +1609,15 @@ InitializeVariableStore ( IN BOOLEAN VolatileStore
)
{
+ EFI_STATUS Status;
VARIABLE_STORE_HEADER *VariableStore;
BOOLEAN FullyInitializeStore;
EFI_PHYSICAL_ADDRESS *VariableBase;
UINTN *LastVariableOffset;
+ VARIABLE_STORE_HEADER *VariableStoreHeader;
+ VARIABLE_HEADER *Variable;
+ VOID *VariableData;
+ EFI_HOB_GUID_TYPE *GuidHob;
FullyInitializeStore = TRUE;
@@ -1681,6 +1686,44 @@ InitializeVariableStore ( VariableStore->Reserved = 0;
VariableStore->Reserved1 = 0;
+ if (!VolatileStore) {
+ //
+ // Get HOB variable store.
+ //
+ GuidHob = GetFirstGuidHob (&gEfiVariableGuid);
+ if (GuidHob != NULL) {
+ VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);
+ if (CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) &&
+ (VariableStoreHeader->Format == VARIABLE_STORE_FORMATTED) &&
+ (VariableStoreHeader->State == VARIABLE_STORE_HEALTHY)
+ ) {
+ DEBUG ((EFI_D_INFO, "HOB Variable Store appears to be valid.\n"));
+ //
+ // Flush the HOB variable to Emulation Variable storage.
+ //
+ for ( Variable = (VARIABLE_HEADER *) (VariableStoreHeader + 1)
+ ; (Variable < GetEndPointer (VariableStoreHeader) && (Variable != NULL))
+ ; Variable = GetNextVariablePtr (Variable)
+ ) {
+ ASSERT (Variable->State == VAR_ADDED);
+ ASSERT ((Variable->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0);
+ VariableData = GetVariableDataPtr (Variable);
+ Status = EmuSetVariable (
+ GET_VARIABLE_NAME_PTR (Variable),
+ &Variable->VendorGuid,
+ Variable->Attributes,
+ Variable->DataSize,
+ VariableData,
+ &mVariableModuleGlobal->VariableGlobal[Physical],
+ &mVariableModuleGlobal->VolatileLastVariableOffset,
+ &mVariableModuleGlobal->NonVolatileLastVariableOffset
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+ }
+ }
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf index 5dfb3c091d..19ceb3d47d 100644 --- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf @@ -2,7 +2,7 @@ # Emulation Variable for EFI_RUNTIME_SERVICES.
#
# This module provides three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -48,6 +48,7 @@ DebugLib
MemoryAllocationLib
BaseMemoryLib
+ HobLib
[Protocols]
diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h index b4b2fbb35b..81a45681a2 100644 --- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h +++ b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h @@ -3,7 +3,7 @@ The internal header file includes the common header files, defines
internal structure and functions used by EmuVariable module.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
#include <Guid/VariableFormat.h>
#include <Guid/GlobalVariable.h>
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 21432c6e8a..14d5d9c128 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -970,7 +970,7 @@ GetLangFromSupportedLangCodes ( CompareLength = ISO_639_2_ENTRY_SIZE;
mVariableModuleGlobal->Lang[CompareLength] = '\0';
return CopyMem (mVariableModuleGlobal->Lang, SupportedLang + Index * CompareLength, CompareLength);
-
+
} else {
while (TRUE) {
//
@@ -2421,7 +2421,12 @@ VariableCommonInitialize ( //
GuidHob = GetFirstGuidHob (&gEfiVariableGuid);
if (GuidHob != NULL) {
- mVariableModuleGlobal->VariableGlobal.HobVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) GET_GUID_HOB_DATA (GuidHob);
+ VariableStoreHeader = GET_GUID_HOB_DATA (GuidHob);
+ if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {
+ mVariableModuleGlobal->VariableGlobal.HobVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) VariableStoreHeader;
+ } else {
+ DEBUG ((EFI_D_ERROR, "HOB Variable Store header is corrupted!\n"));
+ }
}
//
|