mirror of https://github.com/acidanthera/audk.git
Fix bug in CustomErashFlashRange function.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4643 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
07220da0c0
commit
00d00b6dfd
|
@ -646,11 +646,15 @@ Returns:
|
||||||
EFI_LBA Index;
|
EFI_LBA Index;
|
||||||
UINTN LbaSize;
|
UINTN LbaSize;
|
||||||
UINTN ScratchLbaSizeData;
|
UINTN ScratchLbaSizeData;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// First LBA
|
// First LBA
|
||||||
//
|
//
|
||||||
FvbGetLbaAddress (Instance, StartLba, NULL, &LbaSize, NULL, Global, Virtual);
|
Status = FvbGetLbaAddress (Instance, StartLba, NULL, &LbaSize, NULL, Global, Virtual);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Use the scratch space as the intermediate buffer to transfer data
|
// Use the scratch space as the intermediate buffer to transfer data
|
||||||
|
@ -668,7 +672,10 @@ Returns:
|
||||||
// write the data back to the first block
|
// write the data back to the first block
|
||||||
//
|
//
|
||||||
if (ScratchLbaSizeData > 0) {
|
if (ScratchLbaSizeData > 0) {
|
||||||
FvbWriteBlock (Instance, StartLba, 0, &ScratchLbaSizeData, Global->FvbScratchSpace[Virtual], Global, Virtual);
|
Status = FvbWriteBlock (Instance, StartLba, 0, &ScratchLbaSizeData, Global->FvbScratchSpace[Virtual], Global, Virtual);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Middle LBAs
|
// Middle LBAs
|
||||||
|
@ -682,22 +689,29 @@ Returns:
|
||||||
// Last LBAs, the same as first LBAs
|
// Last LBAs, the same as first LBAs
|
||||||
//
|
//
|
||||||
if (LastLba > StartLba) {
|
if (LastLba > StartLba) {
|
||||||
FvbGetLbaAddress (Instance, LastLba, NULL, &LbaSize, NULL, Global, Virtual);
|
Status = FvbGetLbaAddress (Instance, LastLba, NULL, &LbaSize, NULL, Global, Virtual);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
FvbReadBlock (Instance, LastLba, 0, &LbaSize, Global->FvbScratchSpace[Virtual], Global, Virtual);
|
FvbReadBlock (Instance, LastLba, 0, &LbaSize, Global->FvbScratchSpace[Virtual], Global, Virtual);
|
||||||
FvbEraseBlock (Instance, LastLba, Global, Virtual);
|
FvbEraseBlock (Instance, LastLba, Global, Virtual);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScratchLbaSizeData = LbaSize - (OffsetStartLba + 1);
|
ScratchLbaSizeData = LbaSize - (OffsetLastLba + 1);
|
||||||
|
|
||||||
return FvbWriteBlock (
|
if (ScratchLbaSizeData > 0) {
|
||||||
Instance,
|
Status = FvbWriteBlock (
|
||||||
LastLba,
|
Instance,
|
||||||
(OffsetLastLba + 1),
|
LastLba,
|
||||||
&ScratchLbaSizeData,
|
(OffsetLastLba + 1),
|
||||||
Global->FvbScratchSpace[Virtual],
|
&ScratchLbaSizeData,
|
||||||
Global,
|
Global->FvbScratchSpace[Virtual] + OffsetLastLba + 1,
|
||||||
Virtual
|
Global,
|
||||||
);
|
Virtual
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
|
Loading…
Reference in New Issue