Use Hob to get the variable base address in NV storage, but this need to be changed as use PCD when build tool is ready

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3111 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2
2007-07-06 09:07:47 +00:00
parent 361064ffae
commit 911cad134a
5 changed files with 31 additions and 6 deletions

View File

@@ -43,6 +43,8 @@
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/HobLib.h>
#include <Common/FlashMap.h>
#include <Guid/FlashMapHob.h>
#endif

View File

@@ -1299,13 +1299,15 @@ Returns:
EFI_PHYSICAL_ADDRESS FvVolHdr;
UINT64 TempVariableStoreHeader;
UINT64 TempVariableStoreLen;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
EFI_FLASH_SUBAREA_ENTRY VariableStoreEntry;
UINT64 BaseAddress;
UINT64 Length;
UINTN Index;
UINT8 Data;
EFI_PEI_HOB_POINTERS FvHob;
EFI_FLASH_MAP_ENTRY_DATA *FlashMapEntry;
mVariableModuleGlobal = AllocateRuntimePool (sizeof (ESAL_VARIABLE_GLOBAL));
if (mVariableModuleGlobal == NULL) {
@@ -1341,11 +1343,29 @@ Returns:
//
// Get non volatile varaible store
//
// BUGBUG: Here should use dynamic PCD to get NvStorageVariableBase when build tools is ready.
TempVariableStoreHeader = 0;
TempVariableStoreLen = 0;
FvHob.Raw = GetHobList ();
while ((FvHob.Raw = GetNextGuidHob (&gEfiFlashMapHobGuid, FvHob.Raw)) != NULL) {
TempVariableStoreHeader = (UINT64) PcdGet32 (PcdFlashNvStorageVariableBase);
FlashMapEntry = (EFI_FLASH_MAP_ENTRY_DATA *) GET_GUID_HOB_DATA (FvHob.Guid);
//
// Get the FTW work space Flash Map SUB area
//
if ((FlashMapEntry->AreaType == EFI_FLASH_AREA_EFI_VARIABLES) && (FlashMapEntry->NumEntries == 1)) {
TempVariableStoreHeader = FlashMapEntry->Entries[0].Base;
TempVariableStoreLen = FlashMapEntry->Entries[0].Length;
}
FvHob.Raw = GET_NEXT_HOB (FvHob);
}
ASSERT ((TempVariableStoreHeader != 0) && (TempVariableStoreLen != 0));
//TempVariableStoreHeader = (UINT64) PcdGet32 (PcdFlashNvStorageVariableBase);
VariableStoreEntry.Base = TempVariableStoreHeader + \
(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);
VariableStoreEntry.Length = (UINT64) PcdGet32 (PcdFlashNvStorageVariableSize) - \
VariableStoreEntry.Length = TempVariableStoreLen - \
(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);
//
// Mark the variable storage region of the FLASH as RUNTIME

View File

@@ -82,7 +82,10 @@
DxeServicesTableLib
UefiDriverEntryPoint
PcdLib
HobLib
[Guids]
gEfiFlashMapHobGuid
################################################################################
#