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:
lgao4 2008-01-31 06:10:38 +00:00
parent 07220da0c0
commit 00d00b6dfd
1 changed files with 27 additions and 13 deletions

View File

@ -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) {
Status = FvbWriteBlock (
Instance, Instance,
LastLba, LastLba,
(OffsetLastLba + 1), (OffsetLastLba + 1),
&ScratchLbaSizeData, &ScratchLbaSizeData,
Global->FvbScratchSpace[Virtual], Global->FvbScratchSpace[Virtual] + OffsetLastLba + 1,
Global, Global,
Virtual Virtual
); );
}
return Status;
} }
EFI_STATUS EFI_STATUS