Code clean for Ftw driver, remove the obsolete logic for boot block. Correct some comments in Pei Pcd driver.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7108 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2008-12-24 01:24:17 +00:00
parent 2da292f637
commit 5944a83bac
11 changed files with 72 additions and 667 deletions

View File

@ -3,7 +3,7 @@
This is a simple fault tolerant write driver.
And it only supports write BufferSize <= SpareAreaLength.
This boot service only protocol provides fault tolerant write capability for
This boot service protocol only provides fault tolerant write capability for
block devices. The protocol has internal non-volatile intermediate storage
of the data and private information. It should be able to recover
automatically from a critical fault, such as power failure.
@ -11,6 +11,22 @@
The implementation uses an FTW Lite (Fault Tolerant Write) Work Space.
This work space is a memory copy of the work space on the Working Block,
the size of the work space is the FTW_WORK_SPACE_SIZE bytes.
The work space stores each write record as EFI_FTW_LITE_RECORD structure.
The spare block stores the write buffer before write to the target block.
The write record has three states to specify the different phase of write operation.
1) WRITE_ALLOCATED is that the record is allocated in write space.
The write record structure records the information of write operation.
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.
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
All rights reserved. This program and the accompanying materials
@ -29,11 +45,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Starts a target block update. This function will record data about write
in fault tolerant storage and will complete the write in a recoverable
manner, ensuring at all times that either the original contents or
the modified contents are available. We should check the target
range to prevent the user from writing Spare block and Working
space directly.
the modified contents are available.
@param This Calling context
@param This The pointer to this protocol instance.
@param FvbHandle The handle of FVB protocol that provides services for
reading, writing, and erasing the target block.
@param Lba The logical block address of the target block.
@ -41,13 +55,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@param NumBytes The number of bytes to write to the target block.
@param Buffer The data to write.
@retval EFI_SUCCESS The function completed successfully
@retval EFI_BAD_BUFFER_SIZE The write would span a target block, which is not
a valid action.
@retval EFI_ACCESS_DENIED No writes have been allocated.
@retval EFI_NOT_FOUND Cannot find FVB by handle.
@retval EFI_OUT_OF_RESOURCES Cannot allocate memory.
@retval EFI_ABORTED The function could not complete successfully.
@retval EFI_SUCCESS The function completed successfully
@retval EFI_ABORTED The function could not complete successfully.
@retval EFI_BAD_BUFFER_SIZE The input data can't fit within the spare block.
Offset + *NumBytes > SpareAreaLength.
@retval EFI_ACCESS_DENIED No writes have been allocated.
@retval EFI_OUT_OF_RESOURCES Cannot allocate enough memory resource.
@retval EFI_NOT_FOUND Cannot find FVB protocol by handle.
**/
EFI_STATUS
@ -112,7 +126,7 @@ FtwLiteWrite (
//
// Check if there is enough free space for allocate a record
//
if ((MyOffset + WRITE_TOTAL_SIZE) > FtwLiteDevice->FtwWorkSpaceSize) {
if ((MyOffset + FTW_LITE_RECORD_SIZE) > FtwLiteDevice->FtwWorkSpaceSize) {
Status = FtwReclaimWorkSpace (FtwLiteDevice, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "FtwLite: Reclaim work space - %r", Status));
@ -309,7 +323,7 @@ FtwLiteWrite (
FreePool (MyBuffer);
//
// Set the SpareCompleteD in the FTW record,
// Set the SpareComplete in the FTW record,
//
MyOffset = (UINT8 *) Record - FtwLiteDevice->FtwWorkSpace;
Status = FtwUpdateFvState (
@ -428,11 +442,6 @@ FtwWriteRecord (
ASSERT_EFI_ERROR (Status);
Status = FlushSpareBlockToWorkingBlock (FtwLiteDevice);
} else if (IsBootBlock (FtwLiteDevice, Fvb, Record->Lba)) {
//
// Update boot block
//
Status = FlushSpareBlockToBootBlock (FtwLiteDevice);
} else {
//
// Update blocks other than working block or boot block
@ -607,8 +616,13 @@ InitializeFtwLite (
//
// 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) + FTW_WORK_SPACE_SIZE);
FtwLiteDevice = AllocatePool (sizeof (EFI_FTW_LITE_DEVICE) + Length);
if (FtwLiteDevice != NULL) {
Status = EFI_SUCCESS;
} else {
@ -625,6 +639,7 @@ InitializeFtwLite (
//
FtwLiteDevice->FtwWorkSpace = (UINT8 *) (FtwLiteDevice + 1);
FtwLiteDevice->FtwWorkSpaceSize = FTW_WORK_SPACE_SIZE;
FtwLiteDevice->FtwWorkSpaceBase = FTW_WORK_SPACE_BASE;
SetMem (
FtwLiteDevice->FtwWorkSpace,
FtwLiteDevice->FtwWorkSpaceSize,
@ -676,7 +691,7 @@ InitializeFtwLite (
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) BaseAddress);
if ((FtwLiteDevice->WorkSpaceAddress >= BaseAddress) &&
(FtwLiteDevice->WorkSpaceAddress <= (BaseAddress + FwVolHeader->FvLength))
(FtwLiteDevice->WorkSpaceAddress < (BaseAddress + FwVolHeader->FvLength))
) {
FtwLiteDevice->FtwFvBlock = Fvb;
//
@ -689,7 +704,8 @@ InitializeFtwLite (
FvbMapEntry = &FwVolHeader->BlockMap[0];
while (!((FvbMapEntry->NumBlocks == 0) && (FvbMapEntry->Length == 0))) {
for (LbaIndex = 1; LbaIndex <= FvbMapEntry->NumBlocks; LbaIndex += 1) {
if (FtwLiteDevice->WorkSpaceAddress < (BaseAddress + FvbMapEntry->Length * LbaIndex)) {
if ((FtwLiteDevice->WorkSpaceAddress >= (BaseAddress + FvbMapEntry->Length * (LbaIndex - 1)))
&& (FtwLiteDevice->WorkSpaceAddress < (BaseAddress + FvbMapEntry->Length * LbaIndex))) {
FtwLiteDevice->FtwWorkSpaceLba = LbaIndex - 1;
//
// Get the Work space size and Base(Offset)
@ -702,6 +718,12 @@ InitializeFtwLite (
//
// end for
//
if (LbaIndex <= FvbMapEntry->NumBlocks) {
//
// Work space range is found.
//
break;
}
FvbMapEntry++;
}
//
@ -724,7 +746,8 @@ InitializeFtwLite (
FvbMapEntry = &FwVolHeader->BlockMap[0];
while (!((FvbMapEntry->NumBlocks == 0) && (FvbMapEntry->Length == 0))) {
for (LbaIndex = 1; LbaIndex <= FvbMapEntry->NumBlocks; LbaIndex += 1) {
if (FtwLiteDevice->SpareAreaAddress < (BaseAddress + FvbMapEntry->Length * LbaIndex)) {
if ((FtwLiteDevice->SpareAreaAddress >= (BaseAddress + FvbMapEntry->Length * (LbaIndex - 1)))
&& (FtwLiteDevice->SpareAreaAddress < (BaseAddress + FvbMapEntry->Length * LbaIndex))) {
//
// Get the NumberOfSpareBlock and SizeOfSpareBlock
//
@ -738,7 +761,12 @@ InitializeFtwLite (
break;
}
}
if (LbaIndex <= FvbMapEntry->NumBlocks) {
//
// Spare FV range is found.
//
break;
}
FvbMapEntry++;
}
//
@ -873,7 +901,7 @@ InitializeFtwLite (
Record = FtwLiteDevice->FtwLastRecord;
Offset = (UINT8 *) Record - FtwLiteDevice->FtwWorkSpace;
if (FtwLiteDevice->FtwWorkSpace[Offset] != FTW_ERASED_BYTE) {
Offset += WRITE_TOTAL_SIZE;
Offset += FTW_LITE_RECORD_SIZE;
}
if (!IsErasedFlashBuffer (

View File

@ -20,7 +20,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiDxe.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Guid/SystemNvDataGuid.h>
#include <Protocol/FaultTolerantWriteLite.h>
#include <Protocol/FirmwareVolumeBlock.h>
@ -96,9 +95,7 @@ typedef struct {
//
// MACRO for FTW header and record
//
#define FTW_WORKING_QUEUE_SIZE (FTW_WORK_SPACE_SIZE - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER))
#define FTW_LITE_RECORD_SIZE (sizeof (EFI_FTW_LITE_RECORD))
#define WRITE_TOTAL_SIZE FTW_LITE_RECORD_SIZE
//
// EFI Fault tolerant protocol private data structure
@ -138,9 +135,9 @@ typedef struct {
This function is the entry point of the Fault Tolerant Write driver.
@param ImageHandle EFI_HANDLE: A handle for the image that is initializing
@param ImageHandle A handle for the image that is initializing
this driver
@param SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
@param SystemTable A pointer to the EFI system table
@retval EFI_SUCCESS FTW has finished the initialization
@retval EFI_ABORTED FTW initialization error

View File

@ -1,8 +1,11 @@
#/** @file
# Component description file for FtwLite module.
# 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.
#
# This driver provides fault tolerant write capability for block devices.
# Copyright (c) 2006 - 2007, Intel Corporation
# Copyright (c) 2006 - 2008, 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
@ -11,7 +14,6 @@
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
@ -33,26 +35,11 @@
FtwMisc.c
FtwLite.c
FtwLite.h
[Sources.Ia32]
Ia32/Ia32FtwMisc.c
[Sources.X64]
X64/X64FtwMisc.c
[Sources.IPF]
Ipf/IpfFtwMisc.c
[Sources.EBC]
Ia32/Ia32FtwMisc.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
@ -63,19 +50,12 @@
DevicePathLib
[Guids]
gEfiSystemNvDataFvGuid # ALWAYS_CONSUMED
gEfiSystemNvDataFvGuid # ALWAYS_CONSUMED, Signature of Working Space Header
[Protocols]
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiFaultTolerantWriteLiteProtocolGuid # PROTOCOL ALWAYS_PRODUCED
[Protocols.IA32]
gEfiPciRootBridgeIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
[Protocols.EBC]
gEfiPciRootBridgeIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
[Pcd.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase

View File

@ -1,6 +1,6 @@
/** @file
Internal generic functions to support fault tolerant write.
Internal generic functions to operate flash block.
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
@ -54,7 +54,7 @@ IsErasedFlashBuffer (
}
/**
To Erase one block. The size is FTW_BLOCK_SIZE
To erase the block with the spare block size.
@param FtwLiteDevice Calling context

View File

@ -109,7 +109,7 @@ InitWorkSpaceHeader (
&gEfiSystemNvDataFvGuid,
sizeof (EFI_GUID)
);
WorkingHeader->WriteQueueSize = FTW_WORKING_QUEUE_SIZE;
WorkingHeader->WriteQueueSize = (UINT64) (PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER));
//
// Crc is calculated with all the fields except Crc and STATE
@ -284,7 +284,7 @@ WorkSpaceRefresh (
// If work space has error or Record is out of the workspace limit, THEN
// call reclaim.
//
if (EFI_ERROR (Status) || (Offset + WRITE_TOTAL_SIZE >= FtwLiteDevice->FtwWorkSpaceSize)) {
if (EFI_ERROR (Status) || (Offset + FTW_LITE_RECORD_SIZE >= FtwLiteDevice->FtwWorkSpaceSize)) {
//
// reclaim work space in working block.
//
@ -388,7 +388,7 @@ FtwReclaimWorkSpace (
CopyMem (
(UINT8 *) Ptr + sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER),
Record,
WRITE_TOTAL_SIZE
FTW_LITE_RECORD_SIZE
);
}
}

View File

@ -1,372 +0,0 @@
/** @file
Ia32 platform related code to support FtwLite.
Copyright (c) 2006 - 2008, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "FtwLite.h"
//
// MACROs for boot block update
//
#define BOOT_BLOCK_BASE 0xFFFF0000
//
// (LPC -- D31:F0)
//
#define LPC_BUS_NUMBER 0x00
#define LPC_DEVICE_NUMBER 0x1F
#define LPC_IF 0xF0
//
// Top swap
//
#define GEN_STATUS 0xD4
#define TOP_SWAP_BIT (1 << 13)
/**
Read PCI register value.
This is a internal function.
@param Offset Offset of the register
@return The pci register value.
**/
UINT32
ReadPciRegister (
IN UINT32 Offset
)
{
EFI_STATUS Status;
UINT32 Value;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
Value = 0;
Status = gBS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID **) &PciRootBridgeIo);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "FtwLite: Locate PCI root bridge io protocol - %r", Status));
return 0;
}
Status = PciRootBridgeIo->Pci.Read (
PciRootBridgeIo,
EfiPciWidthUint32,
EFI_PCI_ADDRESS (
LPC_BUS_NUMBER,
LPC_DEVICE_NUMBER,
LPC_IF,
Offset
),
1,
&Value
);
ASSERT_EFI_ERROR (Status);
return Value;
}
/**
Get swap state
This is a internal function.
@param FtwLiteDevice Calling context
@param SwapState Swap state
@retval EFI_SUCCESS State successfully got
**/
EFI_STATUS
GetSwapState (
IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,
OUT BOOLEAN *SwapState
)
{
//
// Top swap status is 13 bit
//
*SwapState = (BOOLEAN) ((ReadPciRegister (GEN_STATUS) & TOP_SWAP_BIT) != 0);
return EFI_SUCCESS;
}
/**
Set swap state.
This is a internal function.
@param FtwLiteDevice Indicates a pointer to the calling context.
@param TopSwap New swap state
@retval EFI_SUCCESS The function completed successfully
Note:
the Top-Swap bit (bit 13, D31: F0, Offset D4h). Note that
software will not be able to clear the Top-Swap bit until the system is
rebooted without GNT[A]# being pulled down.
**/
EFI_STATUS
SetSwapState (
IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,
IN BOOLEAN TopSwap
)
{
UINT32 GenStatus;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_STATUS Status;
//
// Top-Swap bit (bit 13, D31: F0, Offset D4h)
//
GenStatus = ReadPciRegister (GEN_STATUS);
//
// Set 13 bit, according to input NewSwapState
//
if (TopSwap) {
GenStatus |= TOP_SWAP_BIT;
} else {
GenStatus &= ~TOP_SWAP_BIT;
}
Status = gBS->LocateProtocol (&gEfiPciRootBridgeIoProtocolGuid, NULL, (VOID **) &PciRootBridgeIo);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "FtwLite: Locate PCI root bridge io protocol - %r", Status));
return Status;
}
//
// Write back the GenStatus register
//
Status = PciRootBridgeIo->Pci.Write (
PciRootBridgeIo,
EfiPciWidthUint32,
EFI_PCI_ADDRESS (
LPC_BUS_NUMBER,
LPC_DEVICE_NUMBER,
LPC_IF,
GEN_STATUS
),
1,
&GenStatus
);
DEBUG_CODE_BEGIN ();
if (TopSwap) {
DEBUG ((EFI_D_ERROR, "SAR: Set top swap\n"));
} else {
DEBUG ((EFI_D_ERROR, "SAR: Clear top swap\n"));
}
DEBUG_CODE_END ();
return EFI_SUCCESS;
}
/**
Check whether the block is a boot block.
@param FtwLiteDevice Calling context
@param FvBlock Fvb protocol instance
@param Lba Lba value
@retval FALSE This is a boot block.
@retval TRUE This is not a boot block.
**/
BOOLEAN
IsBootBlock (
EFI_FTW_LITE_DEVICE *FtwLiteDevice,
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,
EFI_LBA Lba
)
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *BootFvb;
Status = GetFvbByAddress (BOOT_BLOCK_BASE, &BootFvb);
if (EFI_ERROR (Status)) {
return FALSE;
}
//
// Compare the Fvb
//
return (BOOLEAN) (FvBlock == BootFvb);
}
/**
Copy the content of spare block to a boot block. Size is FTW_BLOCK_SIZE.
Spare block is accessed by FTW backup FVB protocol interface. LBA is
FtwLiteDevice->FtwSpareLba.
Boot block is accessed by BootFvb protocol interface. LBA is 0.
@param FtwLiteDevice The private data of FTW_LITE driver
@retval EFI_SUCCESS Spare block content is copied to boot block
@retval EFI_INVALID_PARAMETER Input parameter error
@retval EFI_OUT_OF_RESOURCES Allocate memory error
@retval EFI_ABORTED The function could not complete successfully
Notes:
FTW will do extra work on boot block update.
FTW should depend on a protocol of EFI_ADDRESS_RANGE_SWAP_PROTOCOL,
which is produced by a chipset driver.
FTW updating boot block steps:
1. Erase top swap block (0xFFFE-0xFFFEFFFF) and write data to it ready
2. Read data from top swap block to memory buffer
3. SetSwapState(EFI_SWAPPED)
4. Erasing boot block (0xFFFF-0xFFFFFFFF)
5. Programming boot block until the boot block is ok.
6. SetSwapState(UNSWAPPED)
Notes:
1. Since the SwapState bit is saved in CMOS, FTW can restore and continue
even in the scenario of power failure.
2. FTW shall not allow to update boot block when battery state is error.
**/
EFI_STATUS
FlushSpareBlockToBootBlock (
EFI_FTW_LITE_DEVICE *FtwLiteDevice
)
{
EFI_STATUS Status;
UINTN Length;
UINT8 *Buffer;
UINTN Count;
UINT8 *Ptr;
UINTN Index;
BOOLEAN TopSwap;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *BootFvb;
EFI_LBA BootLba;
//
// Allocate a memory buffer
//
Length = FtwLiteDevice->SpareAreaLength;
Buffer = AllocatePool (Length);
if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Get TopSwap bit state
//
Status = GetSwapState (FtwLiteDevice, &TopSwap);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "FtwLite: Get Top Swapped status - %r\n", Status));
FreePool (Buffer);
return EFI_ABORTED;
}
if (TopSwap) {
//
// Get FVB of current boot block
//
Status = GetFvbByAddress (FtwLiteDevice->SpareAreaAddress + FTW_BLOCK_SIZE, &BootFvb);
if (EFI_ERROR (Status)) {
FreePool (Buffer);
return Status;
}
//
// Read data from current boot block
//
BootLba = 0;
Ptr = Buffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Count = FtwLiteDevice->SizeOfSpareBlock;
Status = BootFvb->Read (
BootFvb,
BootLba + Index,
0,
&Count,
Ptr
);
if (EFI_ERROR (Status)) {
FreePool (Buffer);
return Status;
}
Ptr += Count;
}
} else {
//
// Read data from spare block
//
Ptr = Buffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Count = FtwLiteDevice->SizeOfSpareBlock;
Status = FtwLiteDevice->FtwBackupFvb->Read (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
0,
&Count,
Ptr
);
if (EFI_ERROR (Status)) {
FreePool (Buffer);
return Status;
}
Ptr += Count;
}
//
// Set TopSwap bit
//
Status = SetSwapState (FtwLiteDevice, TRUE);
DEBUG ((EFI_D_ERROR, "FtwLite: Set Swap State - %r\n", Status));
ASSERT_EFI_ERROR (Status);
}
//
// Erase boot block. After setting TopSwap bit, it's spare block now!
//
Status = FtwEraseSpareBlock (FtwLiteDevice);
if (EFI_ERROR (Status)) {
FreePool (Buffer);
return EFI_ABORTED;
}
//
// Write memory buffer to currenet spare block
//
Ptr = Buffer;
for (Index = 0; Index < FtwLiteDevice->NumberOfSpareBlock; Index += 1) {
Count = FtwLiteDevice->SizeOfSpareBlock;
Status = FtwLiteDevice->FtwBackupFvb->Write (
FtwLiteDevice->FtwBackupFvb,
FtwLiteDevice->FtwSpareLba + Index,
0,
&Count,
Ptr
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_FTW_LITE, "FtwLite: FVB Write boot block - %r\n", Status));
FreePool (Buffer);
return Status;
}
Ptr += Count;
}
FreePool (Buffer);
//
// Clear TopSwap bit
//
Status = SetSwapState (FtwLiteDevice, FALSE);
DEBUG ((EFI_D_ERROR, "FtwLite: Clear Swap State - %r\n", Status));
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}

View File

@ -1,117 +0,0 @@
/** @file
Ipf platform related code to support FtwLite..
Copyright (c) 2006 - 2008, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "FtwLite.h"
//
// MACROs for boot block update
//
#define BOOT_BLOCK_BASE
/**
Get swap state
This is a internal function.
@param FtwLiteDevice Calling context
@param SwapState Swap state
@retval EFI_SUCCESS State successfully got
**/
EFI_STATUS
GetSwapState (
IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,
OUT BOOLEAN *SwapState
)
{
return EFI_SUCCESS;
}
/**
Set swap state.
This is a internal function.
@param FtwLiteDevice Indicates a pointer to the calling context.
@param TopSwap New swap state
@retval EFI_SUCCESS The function completed successfully
Note:
the Top-Swap bit (bit 13, D31: F0, Offset D4h). Note that
software will not be able to clear the Top-Swap bit until the system is
rebooted without GNT[A]# being pulled down.
**/
EFI_STATUS
SetSwapState (
IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,
IN BOOLEAN TopSwap
)
{
return EFI_SUCCESS;
}
/**
Check whether the block is a boot block.
@param FtwLiteDevice Calling context
@param FvBlock Fvb protocol instance
@param Lba Lba value
@retval FALSE This is a boot block.
@retval TRUE This is not a boot block.
**/
BOOLEAN
IsBootBlock (
EFI_FTW_LITE_DEVICE *FtwLiteDevice,
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,
EFI_LBA Lba
)
{
//
// IPF doesn't support safe bootblock update
// so treat bootblock as normal block
//
return FALSE;
}
/**
Copy the content of spare block to a boot block. Size is FTW_BLOCK_SIZE.
Spare block is accessed by FTW backup FVB protocol interface. LBA is
FtwLiteDevice->FtwSpareLba.
Boot block is accessed by BootFvb protocol interface. LBA is 0.
@param FtwLiteDevice The private data of FTW_LITE driver
@retval EFI_SUCCESS Spare block content is copied to boot block
@retval EFI_INVALID_PARAMETER Input parameter error
@retval EFI_OUT_OF_RESOURCES Allocate memory error
@retval EFI_ABORTED The function could not complete successfully
Notes:
**/
EFI_STATUS
FlushSpareBlockToBootBlock (
EFI_FTW_LITE_DEVICE *FtwLiteDevice
)
{
return EFI_SUCCESS;
}

View File

@ -1,112 +0,0 @@
/** @file
X64 platform related code to support FtwLite.
Copyright (c) 2006 - 2008, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "FtwLite.h"
//
// MACROs for boot block update
//
#define BOOT_BLOCK_BASE
/**
Get swap state.
@param FtwLiteDevice Calling context
@param SwapState Swap state
@retval EFI_SUCCESS State successfully read.
**/
EFI_STATUS
GetSwapState (
IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,
OUT BOOLEAN *SwapState
)
{
return EFI_SUCCESS;
}
/**
Set swap state.
@param FtwLiteDevice Indicates a pointer to the calling context.
@param TopSwap New swap state
@retval EFI_SUCCESS The function completed successfully
Note:
the Top-Swap bit (bit 13, D31: F0, Offset D4h). Note that
software will not be able to clear the Top-Swap bit until the system is
rebooted without GNT[A]# being pulled down.
**/
EFI_STATUS
SetSwapState (
IN EFI_FTW_LITE_DEVICE *FtwLiteDevice,
IN BOOLEAN TopSwap
)
{
return EFI_SUCCESS;
}
/**
Check whether the block is a boot block.
@param FtwLiteDevice Calling context
@param FvBlock Fvb protocol instance
@param Lba Lba value
@retval FALSE This is a boot block.
@retval TRUE This is not a boot block.
**/
BOOLEAN
IsBootBlock (
EFI_FTW_LITE_DEVICE *FtwLiteDevice,
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,
EFI_LBA Lba
)
{
return FALSE;
}
/**
Copy the content of spare block to a boot block. Size is FTW_BLOCK_SIZE.
Spare block is accessed by FTW backup FVB protocol interface. LBA is
FtwLiteDevice->FtwSpareLba.
Boot block is accessed by BootFvb protocol interface. LBA is 0.
@param FtwLiteDevice The private data of FTW_LITE driver
@retval EFI_SUCCESS Spare block content is copied to boot block
@retval EFI_INVALID_PARAMETER Input parameter error
@retval EFI_OUT_OF_RESOURCES Allocate memory error
@retval EFI_ABORTED The function could not complete successfully
Notes:
**/
EFI_STATUS
FlushSpareBlockToBootBlock (
EFI_FTW_LITE_DEVICE *FtwLiteDevice
)
{
return EFI_SUCCESS;
}

View File

@ -1,5 +1,5 @@
/** @file
PCD PEIM produces PCD database to manage all dynamic PCD in PEI phase and install Pcd Ppi.
All Pcd Ppi services are implemented here.
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
@ -1207,7 +1207,7 @@ SetPtrTypeSize (
(*CurrentSize == MAX_ADDRESS)) {
*CurrentSize = MaxSize;
return FALSE;
}
}
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0) {
//

View File

@ -1,5 +1,6 @@
/** @file
Private functions used by PCD PEIM.
The driver internal functions are implmented here.
They build Pei PCD database, and provide access service to PCD database.
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials

View File

@ -1,5 +1,5 @@
/** @file
Private functions used by PCD PEIM.
The internal header file declares the private functions used by PeiPcd driver.
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials