Clean up FaultTolerantWriteDxe to remove the duplicated definition.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7471 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2009-02-06 09:03:12 +00:00
parent 2374b9734b
commit 276a49b699
7 changed files with 92 additions and 103 deletions

View File

@ -224,8 +224,6 @@ typedef struct {
@param Data Pointer to old core data that is used to initialize the
core's data areas.
@retval EFI_NOT_FOUND Never reach
**/
VOID
EFIAPI

View File

@ -1,7 +1,6 @@
/** @file
This is a simple fault tolerant write driver.
And it only supports write BufferSize <= SpareAreaLength.
This boot service protocol only provides fault tolerant write capability for
block devices. The protocol has internal non-volatile intermediate storage
@ -21,14 +20,27 @@
2) SPARE_COMPLETED is that the data from write buffer is writed into the spare block as the backup.
3) WRITE_COMPLETED is that the data is copied from the spare block to the target block.
This driver operates the data as the whole size of spare block. It also assumes that
working block is an area which contains working space in its last block and has the same size as spare block.
This driver operates the data as the whole size of spare block.
It first read the SpareAreaLength data from the target block into the spare memory buffer.
Then copy the write buffer data into the spare memory buffer.
Then write the spare memory buffer into the spare block.
Final copy the data from the spare block to the target block.
Copyright (c) 2006 - 2008, Intel Corporation
To make this drive work well, the following conditions must be satisfied:
1. The write NumBytes data must be fit within Spare area.
Offset + NumBytes <= SpareAreaLength
2. The whole flash range has the same block size.
3. Working block is an area which contains working space in its last block and has the same size as spare block.
4. Working Block area must be in the single one Firmware Volume Block range which FVB protocol is produced on.
5. Spare area must be in the single one Firmware Volume Block range which FVB protocol is produced on.
6. Any write data area (SpareAreaLength Area) which the data will be written into must be
in the single one Firmware Volume Block range which FVB protocol is produced on.
7. If write data area (such as Variable range) is enlarged, the spare area range must be enlarged.
The spare area must be enough large to store the write data before write them into the target range.
If one of them is not satisfied, FtwLiteWrite may fail.
Usually, Spare area only takes one block. That's SpareAreaLength = BlockSize, NumberOfSpareBlock = 1.
Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
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
@ -89,7 +101,6 @@ FtwLiteWrite (
UINTN Index;
UINT8 *Ptr;
EFI_DEV_PATH_PTR DevPtr;
//
// Refresh work space and get last record
//
@ -121,6 +132,7 @@ FtwLiteWrite (
// Check if the input data can fit within the target block
//
if ((Offset +*NumBytes) > FtwLiteDevice->SpareAreaLength) {
*NumBytes = FtwLiteDevice->SpareAreaLength - Offset;
return EFI_BAD_BUFFER_SIZE;
}
//
@ -152,7 +164,7 @@ FtwLiteWrite (
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Allocate record - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: Allocate record - %r\n", Status));
return EFI_ABORTED;
}
@ -168,7 +180,7 @@ FtwLiteWrite (
Status = Fvb->GetPhysicalAddress (Fvb, &FvbPhysicalAddress);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Get FVB physical address - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: Get FVB physical address - %r\n", Status));
return EFI_ABORTED;
}
@ -223,7 +235,7 @@ FtwLiteWrite (
//
Ptr = MyBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
MyLength = FtwLiteDevice->SizeOfSpareBlock;
MyLength = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwFvBlock->Read (
FtwLiteDevice->FtwFvBlock,
FtwLiteDevice->FtwWorkBlockLba + Index,
@ -242,14 +254,14 @@ FtwLiteWrite (
// Update Offset by adding the offset from the start LBA of working block to
// the target LBA. The target block can not span working block!
//
Offset = (((UINTN) (Lba - FtwLiteDevice->FtwWorkBlockLba)) * FtwLiteDevice->SizeOfSpareBlock + Offset);
Offset = (((UINTN) (Lba - FtwLiteDevice->FtwWorkBlockLba)) * FtwLiteDevice->BlockSize + Offset);
ASSERT ((Offset +*NumBytes) <= FtwLiteDevice->SpareAreaLength);
} else {
Ptr = MyBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
MyLength = FtwLiteDevice->SizeOfSpareBlock;
MyLength = FtwLiteDevice->BlockSize;
Status = Fvb->Read (Fvb, Lba + Index, 0, &MyLength, Ptr);
if (EFI_ERROR (Status)) {
FreePool (MyBuffer);
@ -278,7 +290,7 @@ FtwLiteWrite (
Ptr = SpareBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
MyLength = FtwLiteDevice->SizeOfSpareBlock;
MyLength = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Read (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -301,7 +313,7 @@ FtwLiteWrite (
Status = FtwEraseSpareBlock (FtwLiteDevice);
Ptr = MyBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
MyLength = FtwLiteDevice->SizeOfSpareBlock;
MyLength = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Write (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -358,7 +370,7 @@ FtwLiteWrite (
Status = FtwEraseSpareBlock (FtwLiteDevice);
Ptr = SpareBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
MyLength = FtwLiteDevice->SizeOfSpareBlock;
MyLength = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Write (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -379,7 +391,7 @@ FtwLiteWrite (
FreePool (SpareBuffer);
DEBUG (
(EFI_D_FTW_LITE,
(EFI_D_ERROR,
"FtwLite: Write() success, (Lba:Offset)=(%lx:0x%x), NumBytes: 0x%x\n",
Lba,
Offset,
@ -504,7 +516,7 @@ FtwRestart (
DevPathPtr.MemMap = (MEMMAP_DEVICE_PATH *) &Record->DevPath;
if (!((DevPathPtr.MemMap->Header.Type == HARDWARE_DEVICE_PATH) && (DevPathPtr.MemMap->Header.SubType == HW_MEMMAP_DP))
) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: FVB Device Path is not memory mapped\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: FVB Device Path is not memory mapped\n"));
return EFI_ABORTED;
}
@ -517,7 +529,7 @@ FtwRestart (
// guaranteed to be completed with fault tolerant manner.
//
Status = FtwWriteRecord (FtwLiteDevice, Fvb);
DEBUG ((EFI_D_FTW_INFO, "FtwLite: Restart() - %r\n", Status));
DEBUG ((EFI_D_INFO, "FtwLite: Restart() - %r\n", Status));
Record++;
FtwLiteDevice->FtwLastRecord = Record;
@ -577,7 +589,7 @@ FtwAbort (
//
Status = FtwEraseSpareBlock (FtwLiteDevice);
DEBUG ((EFI_D_FTW_INFO, "FtwLite: Abort() success \n"));
DEBUG ((EFI_D_INFO, "FtwLite: Abort() success \n"));
return EFI_SUCCESS;
}
@ -606,22 +618,16 @@ InitializeFtwLite (
EFI_PHYSICAL_ADDRESS BaseAddress;
EFI_FTW_LITE_DEVICE *FtwLiteDevice;
EFI_FTW_LITE_RECORD *Record;
UINTN Length;
EFI_STATUS Status;
UINTN Offset;
UINTN Length;
EFI_FV_BLOCK_MAP_ENTRY *FvbMapEntry;
UINT32 LbaIndex;
//
// Allocate Private data of this driver, including the FtwWorkSpace[FTW_WORK_SPACE_SIZE].
//
Length = FTW_WORK_SPACE_SIZE;
if (Length < PcdGet32 (PcdFlashNvStorageFtwWorkingSize)) {
Length = PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
}
FtwLiteDevice = NULL;
FtwLiteDevice = AllocatePool (sizeof (EFI_FTW_LITE_DEVICE) + Length);
FtwLiteDevice = AllocatePool (sizeof (EFI_FTW_LITE_DEVICE) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize));
ASSERT (FtwLiteDevice != NULL);
ZeroMem (FtwLiteDevice, sizeof (EFI_FTW_LITE_DEVICE));
@ -631,15 +637,7 @@ InitializeFtwLite (
// Initialize other parameters, and set WorkSpace as FTW_ERASED_BYTE.
//
FtwLiteDevice->FtwWorkSpace = (UINT8 *) (FtwLiteDevice + 1);
FtwLiteDevice->FtwWorkSpaceSize = FTW_WORK_SPACE_SIZE;
FtwLiteDevice->FtwWorkSpaceBase = FTW_WORK_SPACE_BASE;
SetMem (
FtwLiteDevice->FtwWorkSpace,
FtwLiteDevice->FtwWorkSpaceSize,
FTW_ERASED_BYTE
);
FtwLiteDevice->FtwWorkSpaceHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) FtwLiteDevice->FtwWorkSpace;
FtwLiteDevice->FtwLastRecord = NULL;
FtwLiteDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS) PcdGet32 (PcdFlashNvStorageFtwWorkingBase);
@ -684,7 +682,7 @@ InitializeFtwLite (
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) BaseAddress);
if ((FtwLiteDevice->WorkSpaceAddress >= BaseAddress) &&
(FtwLiteDevice->WorkSpaceAddress < (BaseAddress + FwVolHeader->FvLength))
((FtwLiteDevice->WorkSpaceAddress + FtwLiteDevice->WorkSpaceLength) <= (BaseAddress + FwVolHeader->FvLength))
) {
FtwLiteDevice->FtwFvBlock = Fvb;
//
@ -726,7 +724,7 @@ InitializeFtwLite (
}
if ((FtwLiteDevice->SpareAreaAddress >= BaseAddress) &&
(FtwLiteDevice->SpareAreaAddress < (BaseAddress + FwVolHeader->FvLength))
((FtwLiteDevice->SpareAreaAddress + FtwLiteDevice->SpareAreaLength) <= (BaseAddress + FwVolHeader->FvLength))
) {
FtwLiteDevice->FtwBackupFvb = Fvb;
//
@ -742,13 +740,14 @@ InitializeFtwLite (
if ((FtwLiteDevice->SpareAreaAddress >= (BaseAddress + FvbMapEntry->Length * (LbaIndex - 1)))
&& (FtwLiteDevice->SpareAreaAddress < (BaseAddress + FvbMapEntry->Length * LbaIndex))) {
//
// Get the NumberOfSpareBlock and SizeOfSpareBlock
// Get the NumberOfSpareBlock and BlockSize
//
FtwLiteDevice->FtwSpareLba = LbaIndex - 1;
FtwLiteDevice->SizeOfSpareBlock = FvbMapEntry->Length;
FtwLiteDevice->NumberOfSpareBlock = FtwLiteDevice->SpareAreaLength / FtwLiteDevice->SizeOfSpareBlock;
FtwLiteDevice->BlockSize = FvbMapEntry->Length;
FtwLiteDevice->NumberOfSpareBlock = FtwLiteDevice->SpareAreaLength / FtwLiteDevice->BlockSize;
//
// Check the range of spare area to make sure that it's in FV range
// To do delete
//
ASSERT ((FtwLiteDevice->FtwSpareLba + FtwLiteDevice->NumberOfSpareBlock) <= FvbMapEntry->NumBlocks);
break;
@ -768,6 +767,7 @@ InitializeFtwLite (
}
}
}
//
// Calculate the start LBA of working block. Working block is an area which
// contains working space in its last block and has the same size as spare
@ -776,7 +776,9 @@ InitializeFtwLite (
//
FtwLiteDevice->FtwWorkBlockLba = FtwLiteDevice->FtwWorkSpaceLba - FtwLiteDevice->NumberOfSpareBlock + 1;
if ((INT64) (FtwLiteDevice->FtwWorkBlockLba) < 0) {
FtwLiteDevice->FtwWorkBlockLba = 0;
DEBUG ((EFI_D_ERROR, "FtwLite: The spare block range is too large than the working block range!\n"));
FreePool (FtwLiteDevice);
return EFI_ABORTED;
}
if ((FtwLiteDevice->FtwFvBlock == NULL) ||
@ -788,6 +790,7 @@ InitializeFtwLite (
FreePool (FtwLiteDevice);
return EFI_ABORTED;
}
//
// Refresh workspace data from working block
//
@ -798,7 +801,7 @@ InitializeFtwLite (
// If the working block workspace is not valid, try the spare block
//
if (!IsValidWorkSpace (FtwLiteDevice->FtwWorkSpaceHeader)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Workspace invalid, read from backup\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: Workspace invalid, read from backup\n"));
//
// Read from spare block
//
@ -817,7 +820,7 @@ InitializeFtwLite (
//
if (IsValidWorkSpace (FtwLiteDevice->FtwWorkSpaceHeader)) {
Status = FlushSpareBlockToWorkingBlock (FtwLiteDevice);
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Restart working block in Init() - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: Restart working block in Init() - %r\n", Status));
ASSERT_EFI_ERROR (Status);
FtwAbort (FtwLiteDevice);
@ -830,7 +833,7 @@ InitializeFtwLite (
return EFI_ABORTED;
}
} else {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Both are invalid, init workspace\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: Both are invalid, init workspace\n"));
//
// If both are invalid, then initialize work space.
//
@ -875,7 +878,7 @@ InitializeFtwLite (
if ((FtwLiteDevice->FtwLastRecord->WriteAllocated == FTW_VALID_STATE) &&
(FtwLiteDevice->FtwLastRecord->SpareCompleted != FTW_VALID_STATE)
) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Init.. record not SpareCompleted, abort()\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: Init.. record not SpareCompleted, abort()\n"));
FtwAbort (FtwLiteDevice);
}
//
@ -886,7 +889,7 @@ InitializeFtwLite (
) {
Status = FtwRestart (FtwLiteDevice);
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Restart last write - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: Restart last write - %r\n", Status));
if (EFI_ERROR (Status)) {
return Status;
}
@ -906,10 +909,10 @@ InitializeFtwLite (
FtwLiteDevice->FtwWorkSpace + Offset,
FtwLiteDevice->FtwWorkSpaceSize - Offset
)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Workspace is dirty, call reclaim...\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: Workspace is dirty, call reclaim...\n"));
Status = FtwReclaimWorkSpace (FtwLiteDevice, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Workspace reclaim - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: Workspace reclaim - %r\n", Status));
FreePool (FtwLiteDevice);
return EFI_ABORTED;
}

View File

@ -34,9 +34,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <WorkingBlockHeader.h>
#define EFI_D_FTW_LITE EFI_D_ERROR
#define EFI_D_FTW_INFO EFI_D_INFO
//
// Flash erase polarity is 1
//
@ -68,20 +65,6 @@ typedef struct {
#define FTW_LITE_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'T', 'W', 'L')
//
// MACRO for FTW WORK SPACE Base & Size
//
#ifdef EFI_FTW_WORKING_OFFSET
#define FTW_WORK_SPACE_BASE EFI_FTW_WORKING_OFFSET
#else
#define FTW_WORK_SPACE_BASE 0x00E000
#endif
#ifdef EFI_FTW_WORKING_LENGTH
#define FTW_WORK_SPACE_SIZE EFI_FTW_WORKING_LENGTH
#else
#define FTW_WORK_SPACE_SIZE 0x002000
#endif
//
// MACRO for FTW header and record
//
@ -94,22 +77,22 @@ typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
EFI_FTW_LITE_PROTOCOL FtwLiteInstance;
EFI_PHYSICAL_ADDRESS WorkSpaceAddress;
UINTN WorkSpaceLength;
EFI_PHYSICAL_ADDRESS SpareAreaAddress;
UINTN SpareAreaLength;
UINTN NumberOfSpareBlock; // Number of the blocks in spare block
UINTN SizeOfSpareBlock; // Block size in bytes of the blocks in spare block
EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FtwWorkSpaceHeader;
EFI_FTW_LITE_RECORD *FtwLastRecord;
EFI_PHYSICAL_ADDRESS WorkSpaceAddress; // Base address of working space range in flash.
UINTN WorkSpaceLength; // Size of working space range in flash.
EFI_PHYSICAL_ADDRESS SpareAreaAddress; // Base address of spare range in flash.
UINTN SpareAreaLength; // Size of spare range in flash.
UINTN NumberOfSpareBlock; // Number of the blocks in spare block.
UINTN BlockSize; // Block size in bytes of the blocks in flash
EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FtwWorkSpaceHeader;// Pointer to Working Space Header in memory buffer
EFI_FTW_LITE_RECORD *FtwLastRecord; // Pointer to last record in memory buffer
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwFvBlock; // FVB of working block
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwBackupFvb; // FVB of spare block
EFI_LBA FtwSpareLba;
EFI_LBA FtwWorkBlockLba; // Start LBA of working block
EFI_LBA FtwSpareLba; // Start LBA of spare block
EFI_LBA FtwWorkBlockLba; // Start LBA of working block that contains working space in its last block.
EFI_LBA FtwWorkSpaceLba; // Start LBA of working space
UINTN FtwWorkSpaceBase; // Offset from LBA start addr
UINTN FtwWorkSpaceSize;
UINT8 *FtwWorkSpace;
UINTN FtwWorkSpaceBase; // Offset into the FtwWorkSpaceLba block.
UINTN FtwWorkSpaceSize; // Size of working space range that stores write record.
UINT8 *FtwWorkSpace; // Point to Work Space in memory buffer
//
// Following a buffer of FtwWorkSpace[FTW_WORK_SPACE_SIZE],
// Allocated with EFI_FTW_LITE_DEVICE.

View File

@ -1,11 +1,8 @@
#/** @file
# This driver provides lite fault tolerant capability for write operation on flash devices.
# Its implementation depends on the full functionality FVB protocol that support read, write/erase flash access.
# It only supports write BufferSize <= PcdFlashNvStorageFtwSpareSize.
# That's the input write buffer data must fit within the spare range.
# This driver doesn't differentiate the update for boot block and other block.
#
# Copyright (c) 2006 - 2008, Intel Corporation
# Copyright (c) 2006 - 2009, Intel Corporation
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -63,4 +60,5 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
[Depex]
gEfiFirmwareVolumeBlockProtocolGuid AND gEfiAlternateFvBlockGuid
gEfiFirmwareVolumeBlockProtocolGuid AND gEfiAlternateFvBlockGuid ## gEfiAlternateFvBlockGuid specifies FVB protocol with read, write/erase flash access.

View File

@ -295,7 +295,7 @@ FlushSpareBlockToTargetBlock (
//
Ptr = Buffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Count = FtwLiteDevice->SizeOfSpareBlock;
Count = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Read (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -323,10 +323,10 @@ FlushSpareBlockToTargetBlock (
//
Ptr = Buffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Count = FtwLiteDevice->SizeOfSpareBlock;
Count = FtwLiteDevice->BlockSize;
Status = FvBlock->Write (FvBlock, Lba + Index, 0, &Count, Ptr);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: FVB Write block - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: FVB Write block - %r\n", Status));
FreePool (Buffer);
return Status;
}
@ -381,7 +381,11 @@ FlushSpareBlockToWorkingBlock (
return EFI_OUT_OF_RESOURCES;
}
//
// To guarantee that the WorkingBlockValid is set on spare block
// To guarantee that the WorkingBlockValid is set on spare block
//
// Offset = OFFSET_OF(EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER,
// WorkingBlockValid);
// To skip Signature and Crc: sizeof(EFI_GUID)+sizeof(UINT32).
//
WorkSpaceLbaOffset = FtwLiteDevice->FtwWorkSpaceLba - FtwLiteDevice->FtwWorkBlockLba;
FtwUpdateFvState (
@ -395,7 +399,7 @@ FlushSpareBlockToWorkingBlock (
//
Ptr = Buffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Count = FtwLiteDevice->SizeOfSpareBlock;
Count = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Read (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -413,7 +417,7 @@ FlushSpareBlockToWorkingBlock (
//
// Clear the CRC and STATE, copy data from spare to working block.
//
WorkingBlockHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) (Buffer + (UINTN) WorkSpaceLbaOffset * FtwLiteDevice->SizeOfSpareBlock + FtwLiteDevice->FtwWorkSpaceBase);
WorkingBlockHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) (Buffer + (UINTN) WorkSpaceLbaOffset * FtwLiteDevice->BlockSize + FtwLiteDevice->FtwWorkSpaceBase);
InitWorkSpaceHeader (WorkingBlockHeader);
WorkingBlockHeader->WorkingBlockValid = FTW_ERASE_POLARITY;
WorkingBlockHeader->WorkingBlockInvalid = FTW_ERASE_POLARITY;
@ -457,7 +461,7 @@ FlushSpareBlockToWorkingBlock (
//
Ptr = Buffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Count = FtwLiteDevice->SizeOfSpareBlock;
Count = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwFvBlock->Write (
FtwLiteDevice->FtwFvBlock,
FtwLiteDevice->FtwWorkBlockLba + Index,
@ -466,7 +470,7 @@ FlushSpareBlockToWorkingBlock (
Ptr
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: FVB Write block - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: FVB Write block - %r\n", Status));
FreePool (Buffer);
return Status;
}

View File

@ -36,12 +36,14 @@ IsValidWorkSpace (
ASSERT (WorkingHeader != NULL);
if (WorkingHeader->WorkingBlockValid != FTW_VALID_STATE) {
DEBUG ((EFI_D_ERROR, "FtwLite: Work block header valid bit check error\n"));
return FALSE;
}
//
// Check signature with gEfiSystemNvDataFvGuid
//
if (!CompareGuid (&gEfiSystemNvDataFvGuid, &WorkingHeader->Signature)) {
DEBUG ((EFI_D_ERROR, "FtwLite: Work block header signature check error\n"));
return FALSE;
}
//
@ -75,7 +77,7 @@ IsValidWorkSpace (
ASSERT_EFI_ERROR (Status);
if (WorkingBlockHeader.Crc != WorkingHeader->Crc) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Work block header CRC check error\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: Work block header CRC check error\n"));
return FALSE;
}
@ -290,7 +292,7 @@ WorkSpaceRefresh (
//
Status = FtwReclaimWorkSpace (FtwLiteDevice, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: Reclaim workspace - %r\n", Status));
DEBUG ((EFI_D_ERROR, "FtwLite: Reclaim workspace - %r\n", Status));
return EFI_ABORTED;
}
}
@ -327,7 +329,7 @@ FtwReclaimWorkSpace (
EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *WorkingBlockHeader;
EFI_FTW_LITE_RECORD *Record;
DEBUG ((EFI_D_FTW_LITE, "FtwLite: start to reclaim work space\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: start to reclaim work space\n"));
//
// Read all original data from working block to a memory buffer
@ -340,7 +342,7 @@ FtwReclaimWorkSpace (
Ptr = TempBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Length = FtwLiteDevice->SizeOfSpareBlock;
Length = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwFvBlock->Read (
FtwLiteDevice->FtwFvBlock,
FtwLiteDevice->FtwWorkBlockLba + Index,
@ -360,7 +362,7 @@ FtwReclaimWorkSpace (
//
Ptr = TempBuffer +
((UINTN) (FtwLiteDevice->FtwWorkSpaceLba - FtwLiteDevice->FtwWorkBlockLba)) *
FtwLiteDevice->SizeOfSpareBlock + FtwLiteDevice->FtwWorkSpaceBase;
FtwLiteDevice->BlockSize + FtwLiteDevice->FtwWorkSpaceBase;
//
// Clear the content of buffer that will save the new work space data
@ -421,7 +423,7 @@ FtwReclaimWorkSpace (
Ptr = SpareBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Length = FtwLiteDevice->SizeOfSpareBlock;
Length = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Read (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -443,7 +445,7 @@ FtwReclaimWorkSpace (
Status = FtwEraseSpareBlock (FtwLiteDevice);
Ptr = TempBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Length = FtwLiteDevice->SizeOfSpareBlock;
Length = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Write (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -478,7 +480,7 @@ FtwReclaimWorkSpace (
Status = FtwEraseSpareBlock (FtwLiteDevice);
Ptr = SpareBuffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Length = FtwLiteDevice->SizeOfSpareBlock;
Length = FtwLiteDevice->BlockSize;
Status = FtwLiteDevice->FtwBackupFvb->Write (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
@ -496,7 +498,7 @@ FtwReclaimWorkSpace (
FreePool (SpareBuffer);
DEBUG ((EFI_D_FTW_LITE, "FtwLite: reclaim work space success\n"));
DEBUG ((EFI_D_ERROR, "FtwLite: reclaim work space success\n"));
return EFI_SUCCESS;
}

View File

@ -104,9 +104,10 @@ GetDriver (
PROTOCOL instance.
@param ControllerHandle The device handle of the controller to check if a driver override
exists.
@param DriverImageHandle On input, a pointer to the previous driver image handle returned
by GetDriverPath(). On output, a pointer to the next driver
device path.
@param DriverImagePath On input, a pointer to the previous driver device path returned by
GetDriverPath(). On output, a pointer to the next driver
device path. Passing in a pointer to NULL, will return the first
driver device path for ControllerHandle.
@retval EFI_UNSUPPORTED
**/