OvmfPkg: QemuFlashFvbServicesRuntimeDxe: rewrap source code to 79 chars

Some of the line lengths in this driver are atrocious. While we have to
put up with the status quo outside of OvmfPkg, we can at least rewrap this
driver before refactoring it.

In the FvbInitialize() function there's no way around introducing two
local variables, just for the sake of sensibly rewrapping the code.

Furthermore, in "FwBlockService.c" the function comment blocks are now
indented; their original position causes diff to print bogus function
names at the top of hunks.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18666 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Laszlo Ersek 2015-10-26 14:58:08 +00:00 committed by lersek
parent 141f0c6445
commit ea0d111efe
6 changed files with 337 additions and 282 deletions

View File

@ -1,22 +1,23 @@
/**@file /**@file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
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, This program and the accompanying materials are licensed and made available
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 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
Module Name: THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
FvbInfo.c Module Name:
Abstract: FvbInfo.c
Defines data structure that is the volume header found.These data is intent Abstract:
to decouple FVB driver with FV header.
Defines data structure that is the volume header found.These data is intent
to decouple FVB driver with FV header.
**/ **/
@ -94,7 +95,8 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
(FixedPcdGet32 (PcdFlashNvStorageVariableSize) + (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) + FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) + FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdOvmfFirmwareBlockSize), FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) /
FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
FixedPcdGet32 (PcdOvmfFirmwareBlockSize), FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
} }
} // BlockMap[1] } // BlockMap[1]
@ -118,7 +120,9 @@ GetFvbInfo (
UINTN Index; UINTN Index;
if (!Checksummed) { if (!Checksummed) {
for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) { for (Index = 0;
Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
Index += 1) {
UINT16 Checksum; UINT16 Checksum;
mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = 0; mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = 0;
Checksum = CalculateCheckSum16 ( Checksum = CalculateCheckSum16 (
@ -130,7 +134,9 @@ GetFvbInfo (
Checksummed = TRUE; Checksummed = TRUE;
} }
for (Index = 0; Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO); Index += 1) { for (Index = 0;
Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
Index += 1) {
if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) { if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
*FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo; *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -1,17 +1,20 @@
## @file ## @file
# Component description file for QEMU Flash Fimware Volume Block DXE driver module. # Component description file for QEMU Flash Fimware Volume Block DXE driver
# module.
# #
# This DXE runtime driver implements and produces the Fimware Volue Block Protocol # This DXE runtime driver implements and produces the Fimware Volue Block
# for a QEMU flash device. # Protocol for a QEMU flash device.
# #
# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials are licensed and made available
# are licensed and made available under the terms and conditions of the BSD License # under the terms and conditions of the BSD License which accompanies this
# which accompanies this distribution. The full text of the license may be found at # distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
# IMPLIED.
# #
## ##
@ -24,7 +27,8 @@
ENTRY_POINT = FvbInitialize ENTRY_POINT = FvbInitialize
# #
# The following information is for reference only and not required by the build tools. # The following information is for reference only and not required by the build
# tools.
# #
# VALID_ARCHITECTURES = IA32 # VALID_ARCHITECTURES = IA32
# #
@ -53,7 +57,8 @@
PcdLib PcdLib
[Guids] [Guids]
gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED Create Event: EVENT_GROUP_GUID gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED
# gEfiEventVirtualAddressChangeGuid # Create Event: EVENT_GROUP_GUID
[Protocols] [Protocols]
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED

View File

@ -1,21 +1,22 @@
/**@file /**@file
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
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, This program and the accompanying materials are licensed and made available
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 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
Module Name: THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
FWBlockService.c Module Name:
Abstract: FWBlockService.c
Revision History Abstract:
Revision History
**/ **/
@ -48,7 +49,8 @@ Revision History
#include "FwBlockService.h" #include "FwBlockService.h"
#include "QemuFlash.h" #include "QemuFlash.h"
#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS) #define EFI_FVB2_STATUS \
(EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
ESAL_FWB_GLOBAL *mFvbModuleGlobal; ESAL_FWB_GLOBAL *mFvbModuleGlobal;
@ -124,30 +126,32 @@ FvbVirtualddressChangeEvent (
) )
/*++ /*++
Routine Description: Routine Description:
Fixup internal data so that EFI and SAL can be call in virtual mode. Fixup internal data so that EFI and SAL can be call in virtual mode.
Call the passed in Child Notify event and convert the mFvbModuleGlobal Call the passed in Child Notify event and convert the mFvbModuleGlobal
date items to there virtual address. date items to there virtual address.
mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] - Physical copy of instance data mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] - Physical copy of instance
mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] - Virtual pointer to common data
instance data. mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] - Virtual pointer to common
instance data.
Arguments: Arguments:
(Standard EFI notify event - EFI_EVENT_NOTIFY) (Standard EFI notify event - EFI_EVENT_NOTIFY)
Returns: Returns:
None None
--*/ --*/
{ {
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance;
UINTN Index; UINTN Index;
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]); EfiConvertPointer (0x0,
(VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);
// //
// Convert the base address of all the instances // Convert the base address of all the instances
@ -158,13 +162,15 @@ Returns:
EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]); EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);
FwhInstance = (EFI_FW_VOL_INSTANCE *) FwhInstance = (EFI_FW_VOL_INSTANCE *)
( (
(UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength + (UINTN) ((UINT8 *) FwhInstance) +
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)) FwhInstance->VolumeHeader.HeaderLength +
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
); );
Index++; Index++;
} }
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]); EfiConvertPointer (0x0,
(VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]);
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal); EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);
QemuFlashConvertPointers (); QemuFlashConvertPointers ();
} }
@ -178,20 +184,20 @@ GetFvbInstance (
) )
/*++ /*++
Routine Description: Routine Description:
Retrieves the physical address of a memory mapped FV Retrieves the physical address of a memory mapped FV
Arguments: Arguments:
Instance - The FV instance whose base address is going to be Instance - The FV instance whose base address is going to be
returned returned
Global - Pointer to ESAL_FWB_GLOBAL that contains all Global - Pointer to ESAL_FWB_GLOBAL that contains all
instance data instance data
FwhInstance - The EFI_FW_VOL_INSTANCE fimrware instance structure FwhInstance - The EFI_FW_VOL_INSTANCE fimrware instance structure
Virtual - Whether CPU is in virtual or physical mode Virtual - Whether CPU is in virtual or physical mode
Returns: Returns:
EFI_SUCCESS - Successfully returns EFI_SUCCESS - Successfully returns
EFI_INVALID_PARAMETER - Instance not found EFI_INVALID_PARAMETER - Instance not found
--*/ --*/
{ {
@ -228,22 +234,22 @@ FvbGetPhysicalAddress (
) )
/*++ /*++
Routine Description: Routine Description:
Retrieves the physical address of a memory mapped FV Retrieves the physical address of a memory mapped FV
Arguments: Arguments:
Instance - The FV instance whose base address is going to be Instance - The FV instance whose base address is going to be
returned returned
Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
that on successful return, contains the base address that on successful return, contains the base
of the firmware volume. address of the firmware volume.
Global - Pointer to ESAL_FWB_GLOBAL that contains all Global - Pointer to ESAL_FWB_GLOBAL that contains all
instance data instance data
Virtual - Whether CPU is in virtual or physical mode Virtual - Whether CPU is in virtual or physical mode
Returns: Returns:
EFI_SUCCESS - Successfully returns EFI_SUCCESS - Successfully returns
EFI_INVALID_PARAMETER - Instance not found EFI_INVALID_PARAMETER - Instance not found
--*/ --*/
{ {
@ -269,21 +275,21 @@ FvbGetVolumeAttributes (
) )
/*++ /*++
Routine Description: Routine Description:
Retrieves attributes, insures positive polarity of attribute bits, returns Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter resulting attributes in output parameter
Arguments: Arguments:
Instance - The FV instance whose attributes is going to be Instance - The FV instance whose attributes is going to be
returned returned
Attributes - Output buffer which contains attributes Attributes - Output buffer which contains attributes
Global - Pointer to ESAL_FWB_GLOBAL that contains all Global - Pointer to ESAL_FWB_GLOBAL that contains all
instance data instance data
Virtual - Whether CPU is in virtual or physical mode Virtual - Whether CPU is in virtual or physical mode
Returns: Returns:
EFI_SUCCESS - Successfully returns EFI_SUCCESS - Successfully returns
EFI_INVALID_PARAMETER - Instance not found EFI_INVALID_PARAMETER - Instance not found
--*/ --*/
{ {
@ -312,26 +318,26 @@ FvbGetLbaAddress (
) )
/*++ /*++
Routine Description: Routine Description:
Retrieves the starting address of an LBA in an FV Retrieves the starting address of an LBA in an FV
Arguments: Arguments:
Instance - The FV instance which the Lba belongs to Instance - The FV instance which the Lba belongs to
Lba - The logical block address Lba - The logical block address
LbaAddress - On output, contains the physical starting address LbaAddress - On output, contains the physical starting address
of the Lba of the Lba
LbaLength - On output, contains the length of the block LbaLength - On output, contains the length of the block
NumOfBlocks - A pointer to a caller allocated UINTN in which the NumOfBlocks - A pointer to a caller allocated UINTN in which the
number of consecutive blocks starting with Lba is number of consecutive blocks starting with Lba is
returned. All blocks in this range have a size of returned. All blocks in this range have a size of
BlockSize BlockSize
Global - Pointer to ESAL_FWB_GLOBAL that contains all Global - Pointer to ESAL_FWB_GLOBAL that contains all
instance data instance data
Virtual - Whether CPU is in virtual or physical mode Virtual - Whether CPU is in virtual or physical mode
Returns: Returns:
EFI_SUCCESS - Successfully returns EFI_SUCCESS - Successfully returns
EFI_INVALID_PARAMETER - Instance not found EFI_INVALID_PARAMETER - Instance not found
--*/ --*/
{ {
@ -402,27 +408,27 @@ FvbSetVolumeAttributes (
) )
/*++ /*++
Routine Description: Routine Description:
Modifies the current settings of the firmware volume according to the Modifies the current settings of the firmware volume according to the
input parameter, and returns the new setting of the volume input parameter, and returns the new setting of the volume
Arguments: Arguments:
Instance - The FV instance whose attributes is going to be Instance - The FV instance whose attributes is going to be
modified modified
Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2 Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2
containing the desired firmware volume settings. containing the desired firmware volume settings.
On successful return, it contains the new settings On successful return, it contains the new settings
of the firmware volume of the firmware volume
Global - Pointer to ESAL_FWB_GLOBAL that contains all Global - Pointer to ESAL_FWB_GLOBAL that contains all
instance data instance data
Virtual - Whether CPU is in virtual or physical mode Virtual - Whether CPU is in virtual or physical mode
Returns: Returns:
EFI_SUCCESS - Successfully returns EFI_SUCCESS - Successfully returns
EFI_ACCESS_DENIED - The volume setting is locked and cannot be modified EFI_ACCESS_DENIED - The volume setting is locked and cannot be modified
EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are
in conflict with the capabilities as declared in the in conflict with the capabilities as declared in
firmware volume header the firmware volume header
--*/ --*/
{ {
@ -441,7 +447,8 @@ Returns:
Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual); Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
AttribPtr = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes); AttribPtr =
(EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);
OldAttributes = *AttribPtr; OldAttributes = *AttribPtr;
Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \ Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \
EFI_FVB2_READ_ENABLED_CAP | \ EFI_FVB2_READ_ENABLED_CAP | \
@ -467,7 +474,8 @@ Returns:
// //
// Some attributes of FV is read only can *not* be set // Some attributes of FV is read only can *not* be set
// //
if ((OldAttributes & UnchangedAttributes) ^ (*Attributes & UnchangedAttributes)) { if ((OldAttributes & UnchangedAttributes) ^
(*Attributes & UnchangedAttributes)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
@ -537,19 +545,17 @@ FvbProtocolGetPhysicalAddress (
) )
/*++ /*++
Routine Description: Routine Description:
Retrieves the physical address of the device. Retrieves the physical address of the device.
Arguments: Arguments:
This - Calling context This - Calling context
Address - Output buffer containing the address. Address - Output buffer containing the address.
Returns: Returns:
EFI_SUCCESS - Successfully returns
Returns:
EFI_SUCCESS - Successfully returns
--*/ --*/
{ {
@ -557,7 +563,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ()); return FvbGetPhysicalAddress (FvbDevice->Instance, Address,
mFvbModuleGlobal, EfiGoneVirtual ());
} }
EFI_STATUS EFI_STATUS
@ -570,22 +577,22 @@ FvbProtocolGetBlockSize (
) )
/*++ /*++
Routine Description: Routine Description:
Retrieve the size of a logical block Retrieve the size of a logical block
Arguments: Arguments:
This - Calling context This - Calling context
Lba - Indicates which block to return the size for. Lba - Indicates which block to return the size for.
BlockSize - A pointer to a caller allocated UINTN in which BlockSize - A pointer to a caller allocated UINTN in which
the size of the block is returned the size of the block is returned
NumOfBlocks - a pointer to a caller allocated UINTN in which the NumOfBlocks - a pointer to a caller allocated UINTN in which the
number of consecutive blocks starting with Lba is number of consecutive blocks starting with Lba is
returned. All blocks in this range have a size of returned. All blocks in this range have a size of
BlockSize BlockSize
Returns: Returns:
EFI_SUCCESS - The firmware volume was read successfully and EFI_SUCCESS - The firmware volume was read successfully and
contents are in Buffer contents are in Buffer
--*/ --*/
{ {
@ -612,15 +619,15 @@ FvbProtocolGetAttributes (
) )
/*++ /*++
Routine Description: Routine Description:
Retrieves Volume attributes. No polarity translations are done. Retrieves Volume attributes. No polarity translations are done.
Arguments: Arguments:
This - Calling context This - Calling context
Attributes - output buffer which contains attributes Attributes - output buffer which contains attributes
Returns: Returns:
EFI_SUCCESS - Successfully returns EFI_SUCCESS - Successfully returns
--*/ --*/
{ {
@ -628,7 +635,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ()); return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes,
mFvbModuleGlobal, EfiGoneVirtual ());
} }
EFI_STATUS EFI_STATUS
@ -639,15 +647,15 @@ FvbProtocolSetAttributes (
) )
/*++ /*++
Routine Description: Routine Description:
Sets Volume attributes. No polarity translations are done. Sets Volume attributes. No polarity translations are done.
Arguments: Arguments:
This - Calling context This - Calling context
Attributes - output buffer which contains attributes Attributes - output buffer which contains attributes
Returns: Returns:
EFI_SUCCESS - Successfully returns EFI_SUCCESS - Successfully returns
--*/ --*/
{ {
@ -655,7 +663,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ()); return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes,
mFvbModuleGlobal, EfiGoneVirtual ());
} }
EFI_STATUS EFI_STATUS
@ -666,26 +675,27 @@ FvbProtocolEraseBlocks (
) )
/*++ /*++
Routine Description: Routine Description:
The EraseBlock() function erases one or more blocks as denoted by the The EraseBlock() function erases one or more blocks as denoted by the
variable argument list. The entire parameter list of blocks must be verified variable argument list. The entire parameter list of blocks must be
prior to erasing any blocks. If a block is requested that does not exist verified prior to erasing any blocks. If a block is requested that does
within the associated firmware volume (it has a larger index than the last not exist within the associated firmware volume (it has a larger index than
block of the firmware volume), the EraseBlock() function must return the last block of the firmware volume), the EraseBlock() function must
EFI_INVALID_PARAMETER without modifying the contents of the firmware volume. return EFI_INVALID_PARAMETER without modifying the contents of the firmware
volume.
Arguments: Arguments:
This - Calling context This - Calling context
... - Starting LBA followed by Number of Lba to erase. ... - Starting LBA followed by Number of Lba to erase.
a -1 to terminate the list. a -1 to terminate the list.
Returns: Returns:
EFI_SUCCESS - The erase request was successfully completed EFI_SUCCESS - The erase request was successfully completed
EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state
EFI_DEVICE_ERROR - The block device is not functioning correctly and EFI_DEVICE_ERROR - The block device is not functioning correctly and
could not be written. Firmware device may have been could not be written. Firmware device may have been
partially erased partially erased
--*/ --*/
{ {
@ -699,7 +709,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ()); Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal,
&FwhInstance, EfiGoneVirtual ());
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
NumOfBlocks = FwhInstance->NumOfBlocks; NumOfBlocks = FwhInstance->NumOfBlocks;
@ -763,36 +774,38 @@ FvbProtocolWrite (
) )
/*++ /*++
Routine Description: Routine Description:
Writes data beginning at Lba:Offset from FV. The write terminates either Writes data beginning at Lba:Offset from FV. The write terminates either
when *NumBytes of data have been written, or when a block boundary is when *NumBytes of data have been written, or when a block boundary is
reached. *NumBytes is updated to reflect the actual number of bytes reached. *NumBytes is updated to reflect the actual number of bytes
written. The write opertion does not include erase. This routine will written. The write opertion does not include erase. This routine will
attempt to write only the specified bytes. If the writes do not stick, attempt to write only the specified bytes. If the writes do not stick,
it will return an error. it will return an error.
Arguments: Arguments:
This - Calling context This - Calling context
Lba - Block in which to begin write Lba - Block in which to begin write
Offset - Offset in the block at which to begin write Offset - Offset in the block at which to begin write
NumBytes - On input, indicates the requested write size. On NumBytes - On input, indicates the requested write size. On
output, indicates the actual number of bytes written output, indicates the actual number of bytes
Buffer - Buffer containing source data for the write. written
Buffer - Buffer containing source data for the write.
Returns: Returns:
EFI_SUCCESS - The firmware volume was written successfully EFI_SUCCESS - The firmware volume was written successfully
EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output, EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output,
NumBytes contains the total number of bytes NumBytes contains the total number of bytes
actually written actually written
EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state
EFI_DEVICE_ERROR - The block device is not functioning correctly and EFI_DEVICE_ERROR - The block device is not functioning correctly and
could not be written could not be written
EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL
--*/ --*/
{ {
return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer); return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,
(UINT8 *)Buffer);
} }
EFI_STATUS EFI_STATUS
@ -806,37 +819,38 @@ FvbProtocolRead (
) )
/*++ /*++
Routine Description: Routine Description:
Reads data beginning at Lba:Offset from FV. The Read terminates either Reads data beginning at Lba:Offset from FV. The Read terminates either
when *NumBytes of data have been read, or when a block boundary is when *NumBytes of data have been read, or when a block boundary is
reached. *NumBytes is updated to reflect the actual number of bytes reached. *NumBytes is updated to reflect the actual number of bytes
written. The write opertion does not include erase. This routine will written. The write opertion does not include erase. This routine will
attempt to write only the specified bytes. If the writes do not stick, attempt to write only the specified bytes. If the writes do not stick,
it will return an error. it will return an error.
Arguments: Arguments:
This - Calling context This - Calling context
Lba - Block in which to begin Read Lba - Block in which to begin Read
Offset - Offset in the block at which to begin Read Offset - Offset in the block at which to begin Read
NumBytes - On input, indicates the requested write size. On NumBytes - On input, indicates the requested write size. On
output, indicates the actual number of bytes Read output, indicates the actual number of bytes Read
Buffer - Buffer containing source data for the Read. Buffer - Buffer containing source data for the Read.
Returns: Returns:
EFI_SUCCESS - The firmware volume was read successfully and EFI_SUCCESS - The firmware volume was read successfully and
contents are in Buffer contents are in Buffer
EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output, EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output,
NumBytes contains the total number of bytes returned NumBytes contains the total number of bytes
in Buffer returned in Buffer
EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state
EFI_DEVICE_ERROR - The block device is not functioning correctly and EFI_DEVICE_ERROR - The block device is not functioning correctly and
could not be read could not be read
EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL
--*/ --*/
{ {
return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer); return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,
(UINT8 *)Buffer);
} }
EFI_STATUS EFI_STATUS
@ -845,15 +859,16 @@ ValidateFvHeader (
) )
/*++ /*++
Routine Description: Routine Description:
Check the integrity of firmware volume header Check the integrity of firmware volume header
Arguments: Arguments:
FwVolHeader - A pointer to a firmware volume header FwVolHeader - A pointer to a firmware volume header
Returns: Returns:
EFI_SUCCESS - The firmware volume is consistent EFI_SUCCESS - The firmware volume is consistent
EFI_NOT_FOUND - The firmware volume has corrupted. So it is not an FV EFI_NOT_FOUND - The firmware volume has corrupted. So it is not an
FV
--*/ --*/
{ {
@ -876,7 +891,8 @@ Returns:
// Verify the header checksum // Verify the header checksum
// //
Checksum = CalculateSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength); Checksum = CalculateSum16 ((UINT16 *) FwVolHeader,
FwVolHeader->HeaderLength);
if (Checksum != 0) { if (Checksum != 0) {
UINT16 Expected; UINT16 Expected;
@ -963,7 +979,8 @@ InitializeVariableFvHeader (
UINTN Offset; UINTN Offset;
UINTN Start; UINTN Start;
DEBUG ((EFI_D_INFO, "Variable FV header is not valid. It will be reinitialized.\n")); DEBUG ((EFI_D_INFO,
"Variable FV header is not valid. It will be reinitialized.\n"));
// //
// Get FvbInfo to provide in FwhInstance. // Get FvbInfo to provide in FwhInstance.
@ -1007,12 +1024,12 @@ FvbInitialize (
) )
/*++ /*++
Routine Description: Routine Description:
This function does common initialization for FVB services This function does common initialization for FVB services
Arguments: Arguments:
Returns: Returns:
--*/ --*/
{ {
@ -1034,7 +1051,8 @@ Returns:
// //
// Return an error so image will be unloaded // Return an error so image will be unloaded
// //
DEBUG ((EFI_D_INFO, "QEMU flash was not detected. Writable FVB is not being installed.\n")); DEBUG ((EFI_D_INFO,
"QEMU flash was not detected. Writable FVB is not being installed.\n"));
return EFI_WRITE_PROTECTED; return EFI_WRITE_PROTECTED;
} }
@ -1050,7 +1068,8 @@ Returns:
Status = InitializeVariableFvHeader (); Status = InitializeVariableFvHeader ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_INFO, "QEMU Flash: Unable to initialize variable FV header\n")); DEBUG ((EFI_D_INFO,
"QEMU Flash: Unable to initialize variable FV header\n"));
return EFI_WRITE_PROTECTED; return EFI_WRITE_PROTECTED;
} }
@ -1067,14 +1086,18 @@ Returns:
} }
} }
BufferSize = (sizeof (EFI_FW_VOL_INSTANCE) + FwVolHeader->HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER)); BufferSize = (sizeof (EFI_FW_VOL_INSTANCE) +
FwVolHeader->HeaderLength -
sizeof (EFI_FIRMWARE_VOLUME_HEADER)
);
// //
// Only need to allocate once. There is only one copy of physical memory for // Only need to allocate once. There is only one copy of physical memory for
// the private data of each FV instance. But in virtual mode or in physical // the private data of each FV instance. But in virtual mode or in physical
// mode, the address of the the physical memory may be different. // mode, the address of the the physical memory may be different.
// //
mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (BufferSize); mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (
BufferSize);
ASSERT (mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] != NULL); ASSERT (mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] != NULL);
// //
@ -1093,13 +1116,16 @@ Returns:
FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress; FwhInstance->FvBase[FVB_PHYSICAL] = (UINTN) BaseAddress;
FwhInstance->FvBase[FVB_VIRTUAL] = (UINTN) BaseAddress; FwhInstance->FvBase[FVB_VIRTUAL] = (UINTN) BaseAddress;
CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader, FwVolHeader->HeaderLength); CopyMem ((UINTN *) &(FwhInstance->VolumeHeader), (UINTN *) FwVolHeader,
FwVolHeader->HeaderLength);
FwVolHeader = &(FwhInstance->VolumeHeader); FwVolHeader = &(FwhInstance->VolumeHeader);
EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL); EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);
NumOfBlocks = 0; NumOfBlocks = 0;
for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) { for (PtrBlockMapEntry = FwVolHeader->BlockMap;
PtrBlockMapEntry->NumBlocks != 0;
PtrBlockMapEntry++) {
// //
// Get the maximum size of a block. // Get the maximum size of a block.
// //
@ -1130,24 +1156,35 @@ Returns:
// Set up the devicepath // Set up the devicepath
// //
if (FwVolHeader->ExtHeaderOffset == 0) { if (FwVolHeader->ExtHeaderOffset == 0) {
FV_MEMMAP_DEVICE_PATH *FvMemmapDevicePath;
// //
// FV does not contains extension header, then produce MEMMAP_DEVICE_PATH // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
// //
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate); FvMemmapDevicePath = AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH),
((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.StartingAddress = BaseAddress; &mFvMemmapDevicePathTemplate);
((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.EndingAddress = BaseAddress + FwVolHeader->FvLength - 1; FvMemmapDevicePath->MemMapDevPath.StartingAddress = BaseAddress;
FvMemmapDevicePath->MemMapDevPath.EndingAddress =
BaseAddress + FwVolHeader->FvLength - 1;
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvMemmapDevicePath;
} else { } else {
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate); FV_PIWG_DEVICE_PATH *FvPiwgDevicePath;
FvPiwgDevicePath = AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH),
&mFvPIWGDevicePathTemplate);
CopyGuid ( CopyGuid (
&((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName, &FvPiwgDevicePath->FvDevPath.FvName,
(GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset) (GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset)
); );
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvPiwgDevicePath;
} }
// //
// Find a handle with a matching device path that has supports FW Block protocol // Find a handle with a matching device path that has supports FW Block
// protocol
// //
Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &FvbDevice->DevicePath, &FwbHandle); Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid,
&FvbDevice->DevicePath, &FwbHandle);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
// LocateDevicePath fails so install a new interface and device path // LocateDevicePath fails so install a new interface and device path

View File

@ -1,21 +1,22 @@
/**@file /**@file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
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, This program and the accompanying materials are licensed and made available
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 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
Module Name: THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
FwBlockService.h Module Name:
Abstract: FwBlockService.h
Firmware volume block driver for Intel Firmware Hub (FWH) device Abstract:
Firmware volume block driver for Intel Firmware Hub (FWH) device
**/ **/
@ -44,8 +45,12 @@ typedef struct {
// //
// Fvb Protocol instance data // Fvb Protocol instance data
// //
#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE) #define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, \
#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE) FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, \
FvbExtension, FVB_DEVICE_SIGNATURE)
#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N') #define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N')
typedef struct { typedef struct {

View File

@ -2,9 +2,10 @@
OVMF support for QEMU system firmware flash device OVMF support for QEMU system firmware flash device
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR> Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License This program and the accompanying materials are licensed and made available
which accompanies this distribution. The full text of the license may be found at 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 http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,

View File

@ -2,9 +2,10 @@
OVMF support for QEMU system firmware flash device OVMF support for QEMU system firmware flash device
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR> Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License This program and the accompanying materials are licensed and made available
which accompanies this distribution. The full text of the license may be found at 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 http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,