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,9 +1,10 @@
/**@file
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
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,
@ -94,7 +95,8 @@ EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
(FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) / FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
FixedPcdGet32 (PcdOvmfFlashNvStorageEventLogSize)) /
FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
FixedPcdGet32 (PcdOvmfFirmwareBlockSize),
}
} // BlockMap[1]
@ -118,7 +120,9 @@ GetFvbInfo (
UINTN Index;
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;
mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = 0;
Checksum = CalculateCheckSum16 (
@ -130,7 +134,9 @@ GetFvbInfo (
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) {
*FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
return EFI_SUCCESS;

View File

@ -1,17 +1,20 @@
## @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
# for a QEMU flash device.
# This DXE runtime driver implements and produces the Fimware Volue Block
# Protocol for a QEMU flash device.
#
# Copyright (c) 2006 - 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
# which accompanies this distribution. The full text of the license may be found at
# 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.
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
# IMPLIED.
#
##
@ -24,7 +27,8 @@
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
#
@ -53,7 +57,8 @@
PcdLib
[Guids]
gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED Create Event: EVENT_GROUP_GUID
gEfiEventVirtualAddressChangeGuid # ALWAYS_CONSUMED
# gEfiEventVirtualAddressChangeGuid # Create Event: EVENT_GROUP_GUID
[Protocols]
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED

View File

@ -1,9 +1,10 @@
/**@file
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
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,
@ -48,7 +49,8 @@ Revision History
#include "FwBlockService.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;
@ -130,7 +132,8 @@ Routine Description:
Call the passed in Child Notify event and convert the mFvbModuleGlobal
date items to there virtual address.
mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] - Physical copy of instance data
mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] - Physical copy of instance
data
mFvbModuleGlobal->FvInstance[FVB_VIRTUAL] - Virtual pointer to common
instance data.
@ -147,7 +150,8 @@ Returns:
EFI_FW_VOL_INSTANCE *FwhInstance;
UINTN Index;
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);
EfiConvertPointer (0x0,
(VOID **) &mFvbModuleGlobal->FvInstance[FVB_VIRTUAL]);
//
// Convert the base address of all the instances
@ -158,13 +162,15 @@ Returns:
EfiConvertPointer (0x0, (VOID **) &FwhInstance->FvBase[FVB_VIRTUAL]);
FwhInstance = (EFI_FW_VOL_INSTANCE *)
(
(UINTN) ((UINT8 *) FwhInstance) + FwhInstance->VolumeHeader.HeaderLength +
(UINTN) ((UINT8 *) FwhInstance) +
FwhInstance->VolumeHeader.HeaderLength +
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER))
);
Index++;
}
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]);
EfiConvertPointer (0x0,
(VOID **) &mFvbModuleGlobal->FvbScratchSpace[FVB_VIRTUAL]);
EfiConvertPointer (0x0, (VOID **) &mFvbModuleGlobal);
QemuFlashConvertPointers ();
}
@ -235,8 +241,8 @@ Arguments:
Instance - The FV instance whose base address is going to be
returned
Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
that on successful return, contains the base address
of the firmware volume.
that on successful return, contains the base
address of the firmware volume.
Global - Pointer to ESAL_FWB_GLOBAL that contains all
instance data
Virtual - Whether CPU is in virtual or physical mode
@ -421,8 +427,8 @@ Returns:
EFI_SUCCESS - Successfully returns
EFI_ACCESS_DENIED - The volume setting is locked and cannot be modified
EFI_INVALID_PARAMETER - Instance not found, or The attributes requested are
in conflict with the capabilities as declared in the
firmware volume header
in conflict with the capabilities as declared in
the firmware volume header
--*/
{
@ -441,7 +447,8 @@ Returns:
Status = GetFvbInstance (Instance, Global, &FwhInstance, Virtual);
ASSERT_EFI_ERROR (Status);
AttribPtr = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);
AttribPtr =
(EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);
OldAttributes = *AttribPtr;
Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \
EFI_FVB2_READ_ENABLED_CAP | \
@ -467,7 +474,8 @@ Returns:
//
// 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;
}
//
@ -546,8 +554,6 @@ Arguments:
This - Calling context
Address - Output buffer containing the address.
Returns:
Returns:
EFI_SUCCESS - Successfully returns
@ -557,7 +563,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbGetPhysicalAddress (FvbDevice->Instance, Address, mFvbModuleGlobal, EfiGoneVirtual ());
return FvbGetPhysicalAddress (FvbDevice->Instance, Address,
mFvbModuleGlobal, EfiGoneVirtual ());
}
EFI_STATUS
@ -628,7 +635,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());
return FvbGetVolumeAttributes (FvbDevice->Instance, Attributes,
mFvbModuleGlobal, EfiGoneVirtual ());
}
EFI_STATUS
@ -655,7 +663,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This);
return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes, mFvbModuleGlobal, EfiGoneVirtual ());
return FvbSetVolumeAttributes (FvbDevice->Instance, Attributes,
mFvbModuleGlobal, EfiGoneVirtual ());
}
EFI_STATUS
@ -669,11 +678,12 @@ FvbProtocolEraseBlocks (
Routine Description:
The EraseBlock() function erases one or more blocks as denoted by the
variable argument list. The entire parameter list of blocks must be verified
prior to erasing any blocks. If a block is requested that does not exist
within the associated firmware volume (it has a larger index than the last
block of the firmware volume), the EraseBlock() function must return
EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
variable argument list. The entire parameter list of blocks must be
verified prior to erasing any blocks. If a block is requested that does
not exist within the associated firmware volume (it has a larger index than
the last block of the firmware volume), the EraseBlock() function must
return EFI_INVALID_PARAMETER without modifying the contents of the firmware
volume.
Arguments:
This - Calling context
@ -699,7 +709,8 @@ Returns:
FvbDevice = FVB_DEVICE_FROM_THIS (This);
Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal, &FwhInstance, EfiGoneVirtual ());
Status = GetFvbInstance (FvbDevice->Instance, mFvbModuleGlobal,
&FwhInstance, EfiGoneVirtual ());
ASSERT_EFI_ERROR (Status);
NumOfBlocks = FwhInstance->NumOfBlocks;
@ -777,7 +788,8 @@ Arguments:
Lba - Block in which to begin write
Offset - Offset in the block at which to begin write
NumBytes - On input, indicates the requested write size. On
output, indicates the actual number of bytes written
output, indicates the actual number of bytes
written
Buffer - Buffer containing source data for the write.
Returns:
@ -792,7 +804,8 @@ Returns:
--*/
{
return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer);
return QemuFlashWrite ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,
(UINT8 *)Buffer);
}
EFI_STATUS
@ -827,8 +840,8 @@ Returns:
EFI_SUCCESS - The firmware volume was read successfully and
contents are in Buffer
EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output,
NumBytes contains the total number of bytes returned
in Buffer
NumBytes contains the total number of bytes
returned in Buffer
EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state
EFI_DEVICE_ERROR - The block device is not functioning correctly and
could not be read
@ -836,7 +849,8 @@ Returns:
--*/
{
return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes, (UINT8 *)Buffer);
return QemuFlashRead ((EFI_LBA)Lba, (UINTN)Offset, NumBytes,
(UINT8 *)Buffer);
}
EFI_STATUS
@ -853,7 +867,8 @@ Arguments:
Returns:
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
//
Checksum = CalculateSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength);
Checksum = CalculateSum16 ((UINT16 *) FwVolHeader,
FwVolHeader->HeaderLength);
if (Checksum != 0) {
UINT16 Expected;
@ -963,7 +979,8 @@ InitializeVariableFvHeader (
UINTN Offset;
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.
@ -1034,7 +1051,8 @@ Returns:
//
// 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;
}
@ -1050,7 +1068,8 @@ Returns:
Status = InitializeVariableFvHeader ();
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;
}
@ -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
// 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.
//
mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (BufferSize);
mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] = AllocateRuntimePool (
BufferSize);
ASSERT (mFvbModuleGlobal->FvInstance[FVB_PHYSICAL] != NULL);
//
@ -1093,13 +1116,16 @@ Returns:
FwhInstance->FvBase[FVB_PHYSICAL] = (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);
EfiInitializeLock (&(FwhInstance->FvbDevLock), TPL_HIGH_LEVEL);
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.
//
@ -1130,24 +1156,35 @@ Returns:
// Set up the devicepath
//
if (FwVolHeader->ExtHeaderOffset == 0) {
FV_MEMMAP_DEVICE_PATH *FvMemmapDevicePath;
//
// FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
//
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);
((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.StartingAddress = BaseAddress;
((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.EndingAddress = BaseAddress + FwVolHeader->FvLength - 1;
FvMemmapDevicePath = AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH),
&mFvMemmapDevicePathTemplate);
FvMemmapDevicePath->MemMapDevPath.StartingAddress = BaseAddress;
FvMemmapDevicePath->MemMapDevPath.EndingAddress =
BaseAddress + FwVolHeader->FvLength - 1;
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)FvMemmapDevicePath;
} 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 (
&((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName,
&FvPiwgDevicePath->FvDevPath.FvName,
(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)) {
//
// LocateDevicePath fails so install a new interface and device path

View File

@ -1,9 +1,10 @@
/**@file
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
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,
@ -44,8 +45,12 @@ typedef struct {
//
// Fvb Protocol instance data
//
#define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, 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_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, \
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')
typedef struct {

View File

@ -2,9 +2,10 @@
OVMF support for QEMU system firmware flash device
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
which accompanies this distribution. The full text of the license may be found at
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,

View File

@ -2,9 +2,10 @@
OVMF support for QEMU system firmware flash device
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
which accompanies this distribution. The full text of the license may be found at
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,