mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
8598a1ed33
commit
f68af18ee9
|
@ -186,7 +186,7 @@ GetNextPotentialVariablePtr (
|
||||||
//
|
//
|
||||||
// Be careful about pad size for alignment
|
// 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;
|
return VarHeader;
|
||||||
}
|
}
|
||||||
|
@ -999,12 +999,12 @@ UpdateVariable (
|
||||||
|
|
||||||
NextVariable = (VARIABLE_HEADER *) (UINT8 *) (mVariableModuleGlobal->NonVolatileLastVariableOffset
|
NextVariable = (VARIABLE_HEADER *) (UINT8 *) (mVariableModuleGlobal->NonVolatileLastVariableOffset
|
||||||
+ (UINTN) Global->NonVolatileVariableBase);
|
+ (UINTN) Global->NonVolatileVariableBase);
|
||||||
mVariableModuleGlobal->NonVolatileLastVariableOffset += VarSize;
|
mVariableModuleGlobal->NonVolatileLastVariableOffset += HEADER_ALIGN (VarSize);
|
||||||
|
|
||||||
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
|
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {
|
||||||
mVariableModuleGlobal->HwErrVariableTotalSize += VarSize;
|
mVariableModuleGlobal->HwErrVariableTotalSize += HEADER_ALIGN (VarSize);
|
||||||
} else {
|
} else {
|
||||||
mVariableModuleGlobal->CommonVariableTotalSize += VarSize;
|
mVariableModuleGlobal->CommonVariableTotalSize += HEADER_ALIGN (VarSize);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((UINT32) (VarSize + mVariableModuleGlobal->VolatileLastVariableOffset) >
|
if ((UINT32) (VarSize + mVariableModuleGlobal->VolatileLastVariableOffset) >
|
||||||
|
@ -1016,7 +1016,7 @@ UpdateVariable (
|
||||||
|
|
||||||
NextVariable = (VARIABLE_HEADER *) (UINT8 *) (mVariableModuleGlobal->VolatileLastVariableOffset
|
NextVariable = (VARIABLE_HEADER *) (UINT8 *) (mVariableModuleGlobal->VolatileLastVariableOffset
|
||||||
+ (UINTN) Global->VolatileVariableBase);
|
+ (UINTN) Global->VolatileVariableBase);
|
||||||
mVariableModuleGlobal->VolatileLastVariableOffset += VarSize;
|
mVariableModuleGlobal->VolatileLastVariableOffset += HEADER_ALIGN (VarSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
NextVariable->StartId = VARIABLE_DATA;
|
NextVariable->StartId = VARIABLE_DATA;
|
||||||
|
@ -1609,10 +1609,15 @@ InitializeVariableStore (
|
||||||
IN BOOLEAN VolatileStore
|
IN BOOLEAN VolatileStore
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
VARIABLE_STORE_HEADER *VariableStore;
|
VARIABLE_STORE_HEADER *VariableStore;
|
||||||
BOOLEAN FullyInitializeStore;
|
BOOLEAN FullyInitializeStore;
|
||||||
EFI_PHYSICAL_ADDRESS *VariableBase;
|
EFI_PHYSICAL_ADDRESS *VariableBase;
|
||||||
UINTN *LastVariableOffset;
|
UINTN *LastVariableOffset;
|
||||||
|
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
||||||
|
VARIABLE_HEADER *Variable;
|
||||||
|
VOID *VariableData;
|
||||||
|
EFI_HOB_GUID_TYPE *GuidHob;
|
||||||
|
|
||||||
FullyInitializeStore = TRUE;
|
FullyInitializeStore = TRUE;
|
||||||
|
|
||||||
|
@ -1681,6 +1686,44 @@ InitializeVariableStore (
|
||||||
VariableStore->Reserved = 0;
|
VariableStore->Reserved = 0;
|
||||||
VariableStore->Reserved1 = 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;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Emulation Variable for EFI_RUNTIME_SERVICES.
|
# Emulation Variable for EFI_RUNTIME_SERVICES.
|
||||||
#
|
#
|
||||||
# This module provides three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName
|
# 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
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
@ -48,6 +48,7 @@
|
||||||
DebugLib
|
DebugLib
|
||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
|
HobLib
|
||||||
|
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
The internal header file includes the common header files, defines
|
The internal header file includes the common header files, defines
|
||||||
internal structure and functions used by EmuVariable module.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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/UefiLib.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/PcdLib.h>
|
#include <Library/PcdLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
#include <Guid/VariableFormat.h>
|
#include <Guid/VariableFormat.h>
|
||||||
#include <Guid/GlobalVariable.h>
|
#include <Guid/GlobalVariable.h>
|
||||||
|
|
||||||
|
|
|
@ -970,7 +970,7 @@ GetLangFromSupportedLangCodes (
|
||||||
CompareLength = ISO_639_2_ENTRY_SIZE;
|
CompareLength = ISO_639_2_ENTRY_SIZE;
|
||||||
mVariableModuleGlobal->Lang[CompareLength] = '\0';
|
mVariableModuleGlobal->Lang[CompareLength] = '\0';
|
||||||
return CopyMem (mVariableModuleGlobal->Lang, SupportedLang + Index * CompareLength, CompareLength);
|
return CopyMem (mVariableModuleGlobal->Lang, SupportedLang + Index * CompareLength, CompareLength);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
//
|
//
|
||||||
|
@ -2421,7 +2421,12 @@ VariableCommonInitialize (
|
||||||
//
|
//
|
||||||
GuidHob = GetFirstGuidHob (&gEfiVariableGuid);
|
GuidHob = GetFirstGuidHob (&gEfiVariableGuid);
|
||||||
if (GuidHob != NULL) {
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue