Remove the FV header assumption in variable driver.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dong Guo <guo.dong@intel.com>
Reviewed-by: Gao Liming <liming.gao@intel.com>
Reviewed-by: Zeng Star <star.zeng@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16564 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Dong Guo 2014-12-31 01:46:50 +00:00 committed by gdong1
parent 4243567133
commit 1fcbeaeacd
1 changed files with 14 additions and 7 deletions

View File

@ -3370,10 +3370,10 @@ GetFvbInfoByAddress (
UINTN Index;
EFI_PHYSICAL_ADDRESS FvbBaseAddress;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
EFI_FVB_ATTRIBUTES_2 Attributes;
Fvb = NULL;
UINTN BlockSize;
UINTN NumberOfBlocks;
HandleBuffer = NULL;
//
@ -3400,9 +3400,9 @@ GetFvbInfoByAddress (
//
Status = Fvb->GetAttributes (Fvb, &Attributes);
if (EFI_ERROR (Status) || ((Attributes & EFI_FVB2_WRITE_STATUS) == 0)) {
continue;
continue;
}
//
// Compare the address and select the right one.
//
@ -3411,8 +3411,15 @@ GetFvbInfoByAddress (
continue;
}
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvbBaseAddress);
if ((Address >= FvbBaseAddress) && (Address < (FvbBaseAddress + FwVolHeader->FvLength))) {
//
// Assume one FVB has one type of BlockSize.
//
Status = Fvb->GetBlockSize (Fvb, 0, &BlockSize, &NumberOfBlocks);
if (EFI_ERROR (Status)) {
continue;
}
if ((Address >= FvbBaseAddress) && (Address < (FvbBaseAddress + BlockSize * NumberOfBlocks))) {
if (FvbHandle != NULL) {
*FvbHandle = HandleBuffer[Index];
}