diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2021-12-05 14:54:02 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-07 17:24:28 +0000 |
commit | 1436aea4d5707e672672a11bda72be2c63c936c3 (patch) | |
tree | 370c9d5bd8823aa8ea7bce71a0f29bff71feff67 /MdeModulePkg/Core/Dxe/FwVol | |
parent | 7c7184e201a90a1d2376e615e55e3f4074731468 (diff) | |
download | edk2-1436aea4d5707e672672a11bda72be2c63c936c3.zip edk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.gz edk2-1436aea4d5707e672672a11bda72be2c63c936c3.tar.bz2 |
MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737
Apply uncrustify changes to .c/.h files in the MdeModulePkg package
Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg/Core/Dxe/FwVol')
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/Ffs.c | 103 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVol.c | 221 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c | 39 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h | 105 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 172 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c | 3 |
6 files changed, 299 insertions, 344 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c index 199c7f8..17e599c 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c +++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c @@ -6,11 +6,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "DxeMain.h"
#include "FwVolDriver.h"
-
/**
Get the FFS file state by checking the highest bit set in the header's state field.
@@ -26,13 +24,13 @@ GetFileState ( IN EFI_FFS_FILE_HEADER *FfsHeader
)
{
- EFI_FFS_FILE_STATE FileState;
- UINT8 HighestBit;
+ EFI_FFS_FILE_STATE FileState;
+ UINT8 HighestBit;
FileState = FfsHeader->State;
if (ErasePolarity != 0) {
- FileState = (EFI_FFS_FILE_STATE)~FileState;
+ FileState = (EFI_FFS_FILE_STATE) ~FileState;
}
HighestBit = 0x80;
@@ -40,11 +38,9 @@ GetFileState ( HighestBit >>= 1;
}
- return (EFI_FFS_FILE_STATE) HighestBit;
+ return (EFI_FFS_FILE_STATE)HighestBit;
}
-
-
/**
Check if a block of buffer is erased.
@@ -58,16 +54,16 @@ GetFileState ( **/
BOOLEAN
IsBufferErased (
- IN UINT8 ErasePolarity,
- IN VOID *InBuffer,
- IN UINTN BufferSize
+ IN UINT8 ErasePolarity,
+ IN VOID *InBuffer,
+ IN UINTN BufferSize
)
{
- UINTN Count;
- UINT8 EraseByte;
- UINT8 *Buffer;
+ UINTN Count;
+ UINT8 EraseByte;
+ UINT8 *Buffer;
- if(ErasePolarity == 1) {
+ if (ErasePolarity == 1) {
EraseByte = 0xFF;
} else {
EraseByte = 0;
@@ -83,8 +79,6 @@ IsBufferErased ( return TRUE;
}
-
-
/**
Verify checksum of the firmware volume header.
@@ -96,12 +90,12 @@ IsBufferErased ( **/
BOOLEAN
VerifyFvHeaderChecksum (
- IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
)
{
UINT16 Checksum;
- Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength);
+ Checksum = CalculateSum16 ((UINT16 *)FvHeader, FvHeader->HeaderLength);
if (Checksum == 0) {
return TRUE;
@@ -110,7 +104,6 @@ VerifyFvHeaderChecksum ( }
}
-
/**
Verify checksum of the FFS file header.
@@ -125,14 +118,15 @@ VerifyHeaderChecksum ( IN EFI_FFS_FILE_HEADER *FfsHeader
)
{
- UINT8 HeaderChecksum;
+ UINT8 HeaderChecksum;
if (IS_FFS_FILE2 (FfsHeader)) {
- HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER2));
+ HeaderChecksum = CalculateSum8 ((UINT8 *)FfsHeader, sizeof (EFI_FFS_FILE_HEADER2));
} else {
- HeaderChecksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));
+ HeaderChecksum = CalculateSum8 ((UINT8 *)FfsHeader, sizeof (EFI_FFS_FILE_HEADER));
}
- HeaderChecksum = (UINT8) (HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);
+
+ HeaderChecksum = (UINT8)(HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File);
if (HeaderChecksum == 0) {
return TRUE;
@@ -141,8 +135,6 @@ VerifyHeaderChecksum ( }
}
-
-
/**
Check if it's a valid FFS file header.
@@ -164,23 +156,22 @@ IsValidFfsHeader ( *FileState = GetFileState (ErasePolarity, FfsHeader);
switch (*FileState) {
- case EFI_FILE_HEADER_VALID:
- case EFI_FILE_DATA_VALID:
- case EFI_FILE_MARKED_FOR_UPDATE:
- case EFI_FILE_DELETED:
- //
- // Here we need to verify header checksum
- //
- return VerifyHeaderChecksum (FfsHeader);
-
- case EFI_FILE_HEADER_CONSTRUCTION:
- case EFI_FILE_HEADER_INVALID:
- default:
- return FALSE;
+ case EFI_FILE_HEADER_VALID:
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ case EFI_FILE_DELETED:
+ //
+ // Here we need to verify header checksum
+ //
+ return VerifyHeaderChecksum (FfsHeader);
+
+ case EFI_FILE_HEADER_CONSTRUCTION:
+ case EFI_FILE_HEADER_INVALID:
+ default:
+ return FALSE;
}
}
-
/**
Check if it's a valid FFS file.
Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
@@ -203,25 +194,23 @@ IsValidFfsFile ( FileState = GetFileState (ErasePolarity, FfsHeader);
switch (FileState) {
+ case EFI_FILE_DELETED:
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ DataCheckSum = FFS_FIXED_CHECKSUM;
+ if ((FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) == FFS_ATTRIB_CHECKSUM) {
+ if (IS_FFS_FILE2 (FfsHeader)) {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *)FfsHeader + sizeof (EFI_FFS_FILE_HEADER2), FFS_FILE2_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER2));
+ } else {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *)FfsHeader + sizeof (EFI_FFS_FILE_HEADER), FFS_FILE_SIZE (FfsHeader) - sizeof (EFI_FFS_FILE_HEADER));
+ }
+ }
- case EFI_FILE_DELETED:
- case EFI_FILE_DATA_VALID:
- case EFI_FILE_MARKED_FOR_UPDATE:
- DataCheckSum = FFS_FIXED_CHECKSUM;
- if ((FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) == FFS_ATTRIB_CHECKSUM) {
- if (IS_FFS_FILE2 (FfsHeader)) {
- DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2), FFS_FILE2_SIZE (FfsHeader) - sizeof(EFI_FFS_FILE_HEADER2));
- } else {
- DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER), FFS_FILE_SIZE (FfsHeader) - sizeof(EFI_FFS_FILE_HEADER));
+ if (FfsHeader->IntegrityCheck.Checksum.File == DataCheckSum) {
+ return TRUE;
}
- }
- if (FfsHeader->IntegrityCheck.Checksum.File == DataCheckSum) {
- return TRUE;
- }
- default:
- return FALSE;
+ default:
+ return FALSE;
}
}
-
-
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c index 0059b0f..153bfec 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c @@ -11,14 +11,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "DxeMain.h"
#include "FwVolDriver.h"
-
//
// Protocol notify related globals
//
-VOID *gEfiFwVolBlockNotifyReg;
-EFI_EVENT gEfiFwVolBlockEvent;
+VOID *gEfiFwVolBlockNotifyReg;
+EFI_EVENT gEfiFwVolBlockEvent;
-FV_DEVICE mFvDevice = {
+FV_DEVICE mFvDevice = {
FV2_DEVICE_SIGNATURE,
NULL,
NULL,
@@ -29,7 +28,7 @@ FV_DEVICE mFvDevice = { FvReadFileSection,
FvWriteFile,
FvGetNextFile,
- sizeof (UINTN),
+ sizeof (UINTN),
NULL,
FvGetVolumeInfo,
FvSetVolumeInfo
@@ -38,17 +37,17 @@ FV_DEVICE mFvDevice = { NULL,
NULL,
NULL,
- { NULL, NULL },
+ { NULL, NULL},
0,
0,
FALSE,
FALSE
};
-
//
// FFS helper functions
//
+
/**
Read data from Firmware Block by FVB protocol Read.
The data may cross the multi block ranges.
@@ -68,27 +67,27 @@ FV_DEVICE mFvDevice = { **/
EFI_STATUS
ReadFvbData (
- IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
- IN OUT EFI_LBA *StartLba,
- IN OUT UINTN *Offset,
- IN UINTN DataSize,
- OUT UINT8 *Data
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
+ IN OUT EFI_LBA *StartLba,
+ IN OUT UINTN *Offset,
+ IN UINTN DataSize,
+ OUT UINT8 *Data
)
{
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- UINTN BlockIndex;
- UINTN ReadDataSize;
- EFI_STATUS Status;
+ UINTN BlockSize;
+ UINTN NumberOfBlocks;
+ UINTN BlockIndex;
+ UINTN ReadDataSize;
+ EFI_STATUS Status;
//
// Try read data in current block
//
BlockIndex = 0;
ReadDataSize = DataSize;
- Status = Fvb->Read (Fvb, *StartLba, *Offset, &ReadDataSize, Data);
+ Status = Fvb->Read (Fvb, *StartLba, *Offset, &ReadDataSize, Data);
if (Status == EFI_SUCCESS) {
- *Offset += DataSize;
+ *Offset += DataSize;
return EFI_SUCCESS;
} else if (Status != EFI_BAD_BUFFER_SIZE) {
//
@@ -118,9 +117,10 @@ ReadFvbData ( if (EFI_ERROR (Status)) {
return Status;
}
- Data += BlockSize;
+
+ Data += BlockSize;
DataSize -= BlockSize;
- BlockIndex ++;
+ BlockIndex++;
}
//
@@ -150,7 +150,7 @@ ReadFvbData ( // Update Lba and Offset used by the following read.
//
*StartLba += BlockIndex;
- *Offset = DataSize;
+ *Offset = DataSize;
return EFI_SUCCESS;
}
@@ -173,8 +173,8 @@ ReadFvbData ( **/
EFI_STATUS
GetFwVolHeader (
- IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
- OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
+ OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
)
{
EFI_STATUS Status;
@@ -187,10 +187,10 @@ GetFwVolHeader ( //
// Read the standard FV header
//
- StartLba = 0;
- Offset = 0;
+ StartLba = 0;
+ Offset = 0;
FvhLength = sizeof (EFI_FIRMWARE_VOLUME_HEADER);
- Status = ReadFvbData (Fvb, &StartLba, &Offset, FvhLength, (UINT8 *)&TempFvh);
+ Status = ReadFvbData (Fvb, &StartLba, &Offset, FvhLength, (UINT8 *)&TempFvh);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -207,7 +207,8 @@ GetFwVolHeader ( // understand it...
//
if ((!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem2Guid)) &&
- (!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem3Guid))) {
+ (!CompareGuid (&TempFvh.FileSystemGuid, &gEfiFirmwareFileSystem3Guid)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -228,8 +229,8 @@ GetFwVolHeader ( // Read the rest of the header
//
FvhLength = TempFvh.HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER);
- Buffer = (UINT8 *)*FwVolHeader + sizeof (EFI_FIRMWARE_VOLUME_HEADER);
- Status = ReadFvbData (Fvb, &StartLba, &Offset, FvhLength, Buffer);
+ Buffer = (UINT8 *)*FwVolHeader + sizeof (EFI_FIRMWARE_VOLUME_HEADER);
+ Status = ReadFvbData (Fvb, &StartLba, &Offset, FvhLength, Buffer);
if (EFI_ERROR (Status)) {
//
// Read failed so free buffer
@@ -240,8 +241,6 @@ GetFwVolHeader ( return Status;
}
-
-
/**
Free FvDevice resource when error happens
@@ -253,8 +252,8 @@ FreeFvDeviceResource ( IN FV_DEVICE *FvDevice
)
{
- FFS_FILE_LIST_ENTRY *FfsFileEntry;
- LIST_ENTRY *NextEntry;
+ FFS_FILE_LIST_ENTRY *FfsFileEntry;
+ LIST_ENTRY *NextEntry;
//
// Free File List Entry
@@ -279,7 +278,7 @@ FreeFvDeviceResource ( CoreFreePool (FfsFileEntry);
- FfsFileEntry = (FFS_FILE_LIST_ENTRY *) NextEntry;
+ FfsFileEntry = (FFS_FILE_LIST_ENTRY *)NextEntry;
}
if (!FvDevice->IsMemoryMapped) {
@@ -297,8 +296,6 @@ FreeFvDeviceResource ( return;
}
-
-
/**
Check if an FV is consistent and allocate cache for it.
@@ -314,30 +311,30 @@ FvCheck ( IN OUT FV_DEVICE *FvDevice
)
{
- EFI_STATUS Status;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;
- EFI_FVB_ATTRIBUTES_2 FvbAttributes;
- EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
- FFS_FILE_LIST_ENTRY *FfsFileEntry;
- EFI_FFS_FILE_HEADER *FfsHeader;
- UINT8 *CacheLocation;
- UINTN Index;
- EFI_LBA LbaIndex;
- UINTN Size;
- EFI_FFS_FILE_STATE FileState;
- UINT8 *TopFvAddress;
- UINTN TestLength;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
- BOOLEAN FileCached;
- UINTN WholeFileSize;
- EFI_FFS_FILE_HEADER *CacheFfsHeader;
-
- FileCached = FALSE;
+ EFI_STATUS Status;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExtHeader;
+ EFI_FVB_ATTRIBUTES_2 FvbAttributes;
+ EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
+ FFS_FILE_LIST_ENTRY *FfsFileEntry;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINT8 *CacheLocation;
+ UINTN Index;
+ EFI_LBA LbaIndex;
+ UINTN Size;
+ EFI_FFS_FILE_STATE FileState;
+ UINT8 *TopFvAddress;
+ UINTN TestLength;
+ EFI_PHYSICAL_ADDRESS PhysicalAddress;
+ BOOLEAN FileCached;
+ UINTN WholeFileSize;
+ EFI_FFS_FILE_HEADER *CacheFfsHeader;
+
+ FileCached = FALSE;
CacheFfsHeader = NULL;
- Fvb = FvDevice->Fvb;
+ Fvb = FvDevice->Fvb;
FwVolHeader = FvDevice->FwVolHeader;
Status = Fvb->GetAttributes (Fvb, &FvbAttributes);
@@ -345,7 +342,7 @@ FvCheck ( return Status;
}
- Size = (UINTN) FwVolHeader->FvLength;
+ Size = (UINTN)FwVolHeader->FvLength;
if ((FvbAttributes & EFI_FVB2_MEMORY_MAPPED) != 0) {
FvDevice->IsMemoryMapped = TRUE;
@@ -357,10 +354,10 @@ FvCheck ( //
// Don't cache memory mapped FV really.
//
- FvDevice->CachedFv = (UINT8 *) (UINTN) PhysicalAddress;
+ FvDevice->CachedFv = (UINT8 *)(UINTN)PhysicalAddress;
} else {
FvDevice->IsMemoryMapped = FALSE;
- FvDevice->CachedFv = AllocatePool (Size);
+ FvDevice->CachedFv = AllocatePool (Size);
if (FvDevice->CachedFv == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -376,9 +373,9 @@ FvCheck ( //
// Copy FV into memory using the block map.
//
- BlockMap = FwVolHeader->BlockMap;
+ BlockMap = FwVolHeader->BlockMap;
CacheLocation = FvDevice->CachedFv;
- LbaIndex = 0;
+ LbaIndex = 0;
while ((BlockMap->NumBlocks != 0) || (BlockMap->Length != 0)) {
//
// read the FV data
@@ -417,7 +414,6 @@ FvCheck ( FvDevice->ErasePolarity = 0;
}
-
//
// go through the whole FV cache, check the consistence of the FV.
// Make a linked list of all the Ffs file headers
@@ -432,21 +428,21 @@ FvCheck ( //
// Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.
//
- FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) (FvDevice->CachedFv + FwVolHeader->ExtHeaderOffset);
- FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize);
+ FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(FvDevice->CachedFv + FwVolHeader->ExtHeaderOffset);
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolExtHeader + FwVolExtHeader->ExtHeaderSize);
} else {
- FfsHeader = (EFI_FFS_FILE_HEADER *) (FvDevice->CachedFv + FwVolHeader->HeaderLength);
+ FfsHeader = (EFI_FFS_FILE_HEADER *)(FvDevice->CachedFv + FwVolHeader->HeaderLength);
}
- FfsHeader = (EFI_FFS_FILE_HEADER *) ALIGN_POINTER (FfsHeader, 8);
- TopFvAddress = FvDevice->EndOfCachedFv;
- while (((UINTN) FfsHeader >= (UINTN) FvDevice->CachedFv) && ((UINTN) FfsHeader <= (UINTN) ((UINTN) TopFvAddress - sizeof (EFI_FFS_FILE_HEADER)))) {
+ FfsHeader = (EFI_FFS_FILE_HEADER *)ALIGN_POINTER (FfsHeader, 8);
+ TopFvAddress = FvDevice->EndOfCachedFv;
+ while (((UINTN)FfsHeader >= (UINTN)FvDevice->CachedFv) && ((UINTN)FfsHeader <= (UINTN)((UINTN)TopFvAddress - sizeof (EFI_FFS_FILE_HEADER)))) {
if (FileCached) {
CoreFreePool (CacheFfsHeader);
FileCached = FALSE;
}
- TestLength = TopFvAddress - ((UINT8 *) FfsHeader);
+ TestLength = TopFvAddress - ((UINT8 *)FfsHeader);
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
TestLength = sizeof (EFI_FFS_FILE_HEADER);
}
@@ -460,15 +456,18 @@ FvCheck ( if (!IsValidFfsHeader (FvDevice->ErasePolarity, FfsHeader, &FileState)) {
if ((FileState == EFI_FILE_HEADER_INVALID) ||
- (FileState == EFI_FILE_HEADER_CONSTRUCTION)) {
+ (FileState == EFI_FILE_HEADER_CONSTRUCTION))
+ {
if (IS_FFS_FILE2 (FfsHeader)) {
if (!FvDevice->IsFfs3Fv) {
DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsHeader->Name));
}
- FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2));
+
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsHeader + sizeof (EFI_FFS_FILE_HEADER2));
} else {
- FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER));
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsHeader + sizeof (EFI_FFS_FILE_HEADER));
}
+
continue;
} else {
//
@@ -487,12 +486,13 @@ FvCheck ( // Here is to cache FFS file to memory buffer for following checksum calculating.
// And then, the cached file buffer can be also used for FvReadFile.
//
- WholeFileSize = IS_FFS_FILE2 (CacheFfsHeader) ? FFS_FILE2_SIZE (CacheFfsHeader): FFS_FILE_SIZE (CacheFfsHeader);
+ WholeFileSize = IS_FFS_FILE2 (CacheFfsHeader) ? FFS_FILE2_SIZE (CacheFfsHeader) : FFS_FILE_SIZE (CacheFfsHeader);
CacheFfsHeader = AllocateCopyPool (WholeFileSize, CacheFfsHeader);
if (CacheFfsHeader == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
FileCached = TRUE;
}
}
@@ -509,11 +509,11 @@ FvCheck ( ASSERT (FFS_FILE2_SIZE (CacheFfsHeader) > 0x00FFFFFF);
if (!FvDevice->IsFfs3Fv) {
DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &CacheFfsHeader->Name));
- FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + FFS_FILE2_SIZE (CacheFfsHeader));
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsHeader + FFS_FILE2_SIZE (CacheFfsHeader));
//
// Adjust pointer to the next 8-byte aligned boundary.
//
- FfsHeader = (EFI_FFS_FILE_HEADER *) (((UINTN) FfsHeader + 7) & ~0x07);
+ FfsHeader = (EFI_FFS_FILE_HEADER *)(((UINTN)FfsHeader + 7) & ~0x07);
continue;
}
}
@@ -533,23 +533,22 @@ FvCheck ( goto Done;
}
- FfsFileEntry->FfsHeader = CacheFfsHeader;
+ FfsFileEntry->FfsHeader = CacheFfsHeader;
FfsFileEntry->FileCached = FileCached;
- FileCached = FALSE;
+ FileCached = FALSE;
InsertTailList (&FvDevice->FfsFileListHeader, &FfsFileEntry->Link);
}
if (IS_FFS_FILE2 (CacheFfsHeader)) {
- FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + FFS_FILE2_SIZE (CacheFfsHeader));
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsHeader + FFS_FILE2_SIZE (CacheFfsHeader));
} else {
- FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + FFS_FILE_SIZE (CacheFfsHeader));
+ FfsHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsHeader + FFS_FILE_SIZE (CacheFfsHeader));
}
//
// Adjust pointer to the next 8-byte aligned boundary.
//
FfsHeader = (EFI_FFS_FILE_HEADER *)(((UINTN)FfsHeader + 7) & ~0x07);
-
}
Done:
@@ -558,14 +557,13 @@ Done: CoreFreePool (CacheFfsHeader);
FileCached = FALSE;
}
+
FreeFvDeviceResource (FvDevice);
}
return Status;
}
-
-
/**
This notification function is invoked when an instance of the
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL is produced. It layers an instance of the
@@ -579,32 +577,33 @@ Done: VOID
EFIAPI
NotifyFwVolBlock (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_HANDLE Handle;
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
- FV_DEVICE *FvDevice;
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+ FV_DEVICE *FvDevice;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+
//
// Examine all new handles
//
- for (;;) {
+ for ( ; ;) {
//
// Get the next handle
//
BufferSize = sizeof (Handle);
- Status = CoreLocateHandle (
- ByRegisterNotify,
- NULL,
- gEfiFwVolBlockNotifyReg,
- &BufferSize,
- &Handle
- );
+ Status = CoreLocateHandle (
+ ByRegisterNotify,
+ NULL,
+ gEfiFwVolBlockNotifyReg,
+ &BufferSize,
+ &Handle
+ );
//
// If not found, we're done
@@ -631,6 +630,7 @@ NotifyFwVolBlock ( if (EFI_ERROR (Status)) {
continue;
}
+
ASSERT (FwVolHeader != NULL);
if (!VerifyFvHeaderChecksum (FwVolHeader)) {
@@ -653,7 +653,6 @@ NotifyFwVolBlock ( //
FvDevice->Fvb = Fvb;
}
-
} else {
//
// No FwVol protocol on the handle so create a new one
@@ -678,11 +677,11 @@ NotifyFwVolBlock ( // Install an New FV protocol on the existing handle
//
Status = CoreInstallProtocolInterface (
- &Handle,
- &gEfiFirmwareVolume2ProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &FvDevice->Fv
- );
+ &Handle,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &FvDevice->Fv
+ );
ASSERT_EFI_ERROR (Status);
} else {
//
@@ -696,8 +695,6 @@ NotifyFwVolBlock ( return;
}
-
-
/**
This routine is the driver initialization entry point. It registers
a notification function. This notification function are responsible
@@ -712,8 +709,8 @@ NotifyFwVolBlock ( EFI_STATUS
EFIAPI
FwVolDriverInit (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
gEfiFwVolBlockEvent = EfiCreateProtocolNotifyEvent (
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c index ab7b3fe..eed9f86 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c @@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "DxeMain.h"
#include "FwVolDriver.h"
-
/**
Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter.
@@ -23,17 +22,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_STATUS
EFIAPI
FvGetVolumeAttributes (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- OUT EFI_FV_ATTRIBUTES *Attributes
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ OUT EFI_FV_ATTRIBUTES *Attributes
)
{
- EFI_STATUS Status;
- FV_DEVICE *FvDevice;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
- EFI_FVB_ATTRIBUTES_2 FvbAttributes;
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FVB_ATTRIBUTES_2 FvbAttributes;
FvDevice = FV_DEVICE_FROM_THIS (This);
- Fvb = FvDevice->Fvb;
+ Fvb = FvDevice->Fvb;
//
// First get the Firmware Volume Block Attributes
@@ -50,8 +49,6 @@ FvGetVolumeAttributes ( return Status;
}
-
-
/**
Sets current attributes for volume
@@ -72,7 +69,6 @@ FvSetVolumeAttributes ( return EFI_UNSUPPORTED;
}
-
/**
Return information of type InformationType for the requested firmware
volume.
@@ -89,17 +85,15 @@ FvSetVolumeAttributes ( EFI_STATUS
EFIAPI
FvGetVolumeInfo (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN CONST EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
return EFI_UNSUPPORTED;
}
-
-
/**
Set information of type InformationType for the requested firmware
volume.
@@ -116,14 +110,11 @@ FvGetVolumeInfo ( EFI_STATUS
EFIAPI
FvSetVolumeInfo (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN CONST EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN CONST VOID *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN CONST VOID *Buffer
)
{
return EFI_UNSUPPORTED;
}
-
-
-
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h index 19ad398..3403c81 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h @@ -10,40 +10,39 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __FW_VOL_DRIVER_H_
#define __FW_VOL_DRIVER_H_
-
-#define FV2_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '2')
+#define FV2_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '2')
//
// Used to track all non-deleted files
//
typedef struct {
- LIST_ENTRY Link;
- EFI_FFS_FILE_HEADER *FfsHeader;
- UINTN StreamHandle;
- BOOLEAN FileCached;
+ LIST_ENTRY Link;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINTN StreamHandle;
+ BOOLEAN FileCached;
} FFS_FILE_LIST_ENTRY;
typedef struct {
- UINTN Signature;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
- EFI_HANDLE Handle;
- EFI_FIRMWARE_VOLUME2_PROTOCOL Fv;
+ UINTN Signature;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_HANDLE Handle;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL Fv;
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
- UINT8 *CachedFv;
- UINT8 *EndOfCachedFv;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ UINT8 *CachedFv;
+ UINT8 *EndOfCachedFv;
- FFS_FILE_LIST_ENTRY *LastKey;
+ FFS_FILE_LIST_ENTRY *LastKey;
- LIST_ENTRY FfsFileListHeader;
+ LIST_ENTRY FfsFileListHeader;
- UINT32 AuthenticationStatus;
- UINT8 ErasePolarity;
- BOOLEAN IsFfs3Fv;
- BOOLEAN IsMemoryMapped;
+ UINT32 AuthenticationStatus;
+ UINT8 ErasePolarity;
+ BOOLEAN IsFfs3Fv;
+ BOOLEAN IsMemoryMapped;
} FV_DEVICE;
-#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)
+#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV2_DEVICE_SIGNATURE)
/**
Retrieves attributes, insures positive polarity of attribute bits, returns
@@ -58,11 +57,10 @@ typedef struct { EFI_STATUS
EFIAPI
FvGetVolumeAttributes (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- OUT EFI_FV_ATTRIBUTES *Attributes
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ OUT EFI_FV_ATTRIBUTES *Attributes
);
-
/**
Sets current attributes for volume
@@ -80,7 +78,6 @@ FvSetVolumeAttributes ( IN OUT EFI_FV_ATTRIBUTES *Attributes
);
-
/**
Given the input key, search for the next matching file in the volume.
@@ -130,16 +127,14 @@ FvSetVolumeAttributes ( EFI_STATUS
EFIAPI
FvGetNextFile (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN OUT VOID *Key,
- IN OUT EFI_FV_FILETYPE *FileType,
- OUT EFI_GUID *NameGuid,
- OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
- OUT UINTN *Size
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN OUT VOID *Key,
+ IN OUT EFI_FV_FILETYPE *FileType,
+ OUT EFI_GUID *NameGuid,
+ OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
+ OUT UINTN *Size
);
-
-
/**
Locates a file in the firmware volume and
copies it to the supplied buffer.
@@ -183,16 +178,15 @@ FvGetNextFile ( EFI_STATUS
EFIAPI
FvReadFile (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN CONST EFI_GUID *NameGuid,
- IN OUT VOID **Buffer,
- IN OUT UINTN *BufferSize,
- OUT EFI_FV_FILETYPE *FoundType,
- OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
- OUT UINT32 *AuthenticationStatus
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *NameGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_FV_FILETYPE *FoundType,
+ OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
+ OUT UINT32 *AuthenticationStatus
);
-
/**
Locates a section in a given FFS File and
copies it to the supplied buffer (not including section header).
@@ -233,7 +227,6 @@ FvReadFileSection ( OUT UINT32 *AuthenticationStatus
);
-
/**
Writes one or more files to the firmware volume.
@@ -264,7 +257,6 @@ FvWriteFile ( IN EFI_FV_WRITE_FILE_DATA *FileData
);
-
/**
Return information of type InformationType for the requested firmware
volume.
@@ -281,14 +273,12 @@ FvWriteFile ( EFI_STATUS
EFIAPI
FvGetVolumeInfo (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN CONST EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
);
-
-
/**
Set information of type InformationType for the requested firmware
volume.
@@ -305,14 +295,12 @@ FvGetVolumeInfo ( EFI_STATUS
EFIAPI
FvSetVolumeInfo (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN CONST EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN CONST VOID *Buffer
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN CONST VOID *Buffer
);
-
-
/**
Check if a block of buffer is erased.
@@ -326,12 +314,11 @@ FvSetVolumeInfo ( **/
BOOLEAN
IsBufferErased (
- IN UINT8 ErasePolarity,
- IN VOID *InBuffer,
- IN UINTN BufferSize
+ IN UINT8 ErasePolarity,
+ IN VOID *InBuffer,
+ IN UINTN BufferSize
);
-
/**
Get the FFS file state by checking the highest bit set in the header's state field.
@@ -347,7 +334,6 @@ GetFileState ( IN EFI_FFS_FILE_HEADER *FfsHeader
);
-
/**
Set the FFS file state.
@@ -381,7 +367,6 @@ IsValidFfsHeader ( OUT EFI_FFS_FILE_STATE *FileState
);
-
/**
Check if it's a valid FFS file.
Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c index 8dcbbeb..2ff22c9 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c @@ -29,8 +29,8 @@ Required Alignment Alignment Value in FFS FFS_ATTRIB_DATA_ALIGNMENT2 Align 8 MB 6 1 23
16 MB 7 1 24
**/
-UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};
-UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24};
+UINT8 mFvAttributes[] = { 0, 4, 7, 9, 10, 12, 15, 16 };
+UINT8 mFvAttributes2[] = { 17, 18, 19, 20, 21, 22, 23, 24 };
/**
Convert the FFS File Attributes to FV File Attributes
@@ -42,19 +42,19 @@ UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24}; **/
EFI_FV_FILE_ATTRIBUTES
FfsAttributes2FvFileAttributes (
- IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes
+ IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes
)
{
- UINT8 DataAlignment;
- EFI_FV_FILE_ATTRIBUTES FileAttribute;
+ UINT8 DataAlignment;
+ EFI_FV_FILE_ATTRIBUTES FileAttribute;
- DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);
+ DataAlignment = (UINT8)((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);
ASSERT (DataAlignment < 8);
if ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT_2) != 0) {
- FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes2[DataAlignment];
+ FileAttribute = (EFI_FV_FILE_ATTRIBUTES)mFvAttributes2[DataAlignment];
} else {
- FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];
+ FileAttribute = (EFI_FV_FILE_ATTRIBUTES)mFvAttributes[DataAlignment];
}
if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {
@@ -113,26 +113,26 @@ FfsAttributes2FvFileAttributes ( EFI_STATUS
EFIAPI
FvGetNextFile (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN OUT VOID *Key,
- IN OUT EFI_FV_FILETYPE *FileType,
- OUT EFI_GUID *NameGuid,
- OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
- OUT UINTN *Size
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN OUT VOID *Key,
+ IN OUT EFI_FV_FILETYPE *FileType,
+ OUT EFI_GUID *NameGuid,
+ OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
+ OUT UINTN *Size
)
{
- EFI_STATUS Status;
- FV_DEVICE *FvDevice;
- EFI_FV_ATTRIBUTES FvAttributes;
- EFI_FFS_FILE_HEADER *FfsFileHeader;
- UINTN *KeyValue;
- LIST_ENTRY *Link;
- FFS_FILE_LIST_ENTRY *FfsFileEntry;
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_FV_ATTRIBUTES FvAttributes;
+ EFI_FFS_FILE_HEADER *FfsFileHeader;
+ UINTN *KeyValue;
+ LIST_ENTRY *Link;
+ FFS_FILE_LIST_ENTRY *FfsFileEntry;
FvDevice = FV_DEVICE_FROM_THIS (This);
Status = FvGetVolumeAttributes (This, &FvAttributes);
- if (EFI_ERROR (Status)){
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -151,7 +151,7 @@ FvGetNextFile ( }
KeyValue = (UINTN *)Key;
- for (;;) {
+ for ( ; ;) {
if (*KeyValue == 0) {
//
// Search for 1st matching file
@@ -171,7 +171,7 @@ FvGetNextFile ( return EFI_NOT_FOUND;
}
- FfsFileEntry = (FFS_FILE_LIST_ENTRY *)Link->ForwardLink;
+ FfsFileEntry = (FFS_FILE_LIST_ENTRY *)Link->ForwardLink;
FfsFileHeader = (EFI_FFS_FILE_HEADER *)FfsFileEntry->FfsHeader;
//
@@ -199,7 +199,6 @@ FvGetNextFile ( //
break;
}
-
}
//
@@ -224,8 +223,6 @@ FvGetNextFile ( return EFI_SUCCESS;
}
-
-
/**
Locates a file in the firmware volume and
copies it to the supplied buffer.
@@ -269,25 +266,25 @@ FvGetNextFile ( EFI_STATUS
EFIAPI
FvReadFile (
- IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
- IN CONST EFI_GUID *NameGuid,
- IN OUT VOID **Buffer,
- IN OUT UINTN *BufferSize,
- OUT EFI_FV_FILETYPE *FoundType,
- OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
- OUT UINT32 *AuthenticationStatus
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *NameGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_FV_FILETYPE *FoundType,
+ OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
+ OUT UINT32 *AuthenticationStatus
)
{
- EFI_STATUS Status;
- FV_DEVICE *FvDevice;
- EFI_GUID SearchNameGuid;
- EFI_FV_FILETYPE LocalFoundType;
- EFI_FV_FILE_ATTRIBUTES LocalAttributes;
- UINTN FileSize;
- UINT8 *SrcPtr;
- EFI_FFS_FILE_HEADER *FfsHeader;
- UINTN InputBufferSize;
- UINTN WholeFileSize;
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_GUID SearchNameGuid;
+ EFI_FV_FILETYPE LocalFoundType;
+ EFI_FV_FILE_ATTRIBUTES LocalAttributes;
+ UINTN FileSize;
+ UINT8 *SrcPtr;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINTN InputBufferSize;
+ UINTN WholeFileSize;
if (NameGuid == NULL) {
return EFI_INVALID_PARAMETER;
@@ -295,7 +292,6 @@ FvReadFile ( FvDevice = FV_DEVICE_FROM_THIS (This);
-
//
// Keep looking until we find the matching NameGuid.
// The Key is really a FfsFileEntry
@@ -303,14 +299,14 @@ FvReadFile ( FvDevice->LastKey = 0;
do {
LocalFoundType = 0;
- Status = FvGetNextFile (
- This,
- &FvDevice->LastKey,
- &LocalFoundType,
- &SearchNameGuid,
- &LocalAttributes,
- &FileSize
- );
+ Status = FvGetNextFile (
+ This,
+ &FvDevice->LastKey,
+ &LocalFoundType,
+ &SearchNameGuid,
+ &LocalAttributes,
+ &FileSize
+ );
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
@@ -328,15 +324,16 @@ FvReadFile ( //
// Cache FFS file to memory buffer.
//
- WholeFileSize = IS_FFS_FILE2 (FfsHeader) ? FFS_FILE2_SIZE (FfsHeader): FFS_FILE_SIZE (FfsHeader);
- FfsHeader = AllocateCopyPool (WholeFileSize, FfsHeader);
+ WholeFileSize = IS_FFS_FILE2 (FfsHeader) ? FFS_FILE2_SIZE (FfsHeader) : FFS_FILE_SIZE (FfsHeader);
+ FfsHeader = AllocateCopyPool (WholeFileSize, FfsHeader);
if (FfsHeader == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Let FfsHeader in FfsFileEntry point to the cached file buffer.
//
- FvDevice->LastKey->FfsHeader = FfsHeader;
+ FvDevice->LastKey->FfsHeader = FfsHeader;
FvDevice->LastKey->FileCached = TRUE;
}
}
@@ -349,16 +346,17 @@ FvReadFile ( //
// Calculate return values
//
- *FoundType = FfsHeader->Type;
+ *FoundType = FfsHeader->Type;
*FileAttributes = FfsAttributes2FvFileAttributes (FfsHeader->Attributes);
- if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {
- *FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;
- }
+ if ((FvDevice->FwVolHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {
+ *FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;
+ }
+
//
// Inherit the authentication status.
//
*AuthenticationStatus = FvDevice->AuthenticationStatus;
- *BufferSize = FileSize;
+ *BufferSize = FileSize;
if (Buffer == NULL) {
//
@@ -371,9 +369,9 @@ FvReadFile ( // Skip over file header
//
if (IS_FFS_FILE2 (FfsHeader)) {
- SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);
+ SrcPtr = ((UINT8 *)FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);
} else {
- SrcPtr = ((UINT8 *) FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);
+ SrcPtr = ((UINT8 *)FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);
}
Status = EFI_SUCCESS;
@@ -389,7 +387,7 @@ FvReadFile ( //
// Callers buffer was not big enough
//
- Status = EFI_WARN_BUFFER_TOO_SMALL;
+ Status = EFI_WARN_BUFFER_TOO_SMALL;
FileSize = InputBufferSize;
}
@@ -401,8 +399,6 @@ FvReadFile ( return Status;
}
-
-
/**
Locates a section in a given FFS File and
copies it to the supplied buffer (not including section header).
@@ -443,15 +439,15 @@ FvReadFileSection ( OUT UINT32 *AuthenticationStatus
)
{
- EFI_STATUS Status;
- FV_DEVICE *FvDevice;
- EFI_FV_FILETYPE FileType;
- EFI_FV_FILE_ATTRIBUTES FileAttributes;
- UINTN FileSize;
- UINT8 *FileBuffer;
- FFS_FILE_LIST_ENTRY *FfsEntry;
-
- if (NameGuid == NULL || Buffer == NULL) {
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_FV_FILETYPE FileType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINTN FileSize;
+ UINT8 *FileBuffer;
+ FFS_FILE_LIST_ENTRY *FfsEntry;
+
+ if ((NameGuid == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -461,27 +457,29 @@ FvReadFileSection ( // Read the file
//
Status = FvReadFile (
- This,
- NameGuid,
- NULL,
- &FileSize,
- &FileType,
- &FileAttributes,
- AuthenticationStatus
- );
+ This,
+ NameGuid,
+ NULL,
+ &FileSize,
+ &FileType,
+ &FileAttributes,
+ AuthenticationStatus
+ );
//
// Get the last key used by our call to FvReadFile as it is the FfsEntry for this file.
//
- FfsEntry = (FFS_FILE_LIST_ENTRY *) FvDevice->LastKey;
+ FfsEntry = (FFS_FILE_LIST_ENTRY *)FvDevice->LastKey;
if (EFI_ERROR (Status)) {
return Status;
}
+
if (IS_FFS_FILE2 (FfsEntry->FfsHeader)) {
- FileBuffer = ((UINT8 *) FfsEntry->FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);
+ FileBuffer = ((UINT8 *)FfsEntry->FfsHeader) + sizeof (EFI_FFS_FILE_HEADER2);
} else {
- FileBuffer = ((UINT8 *) FfsEntry->FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);
+ FileBuffer = ((UINT8 *)FfsEntry->FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);
}
+
//
// Check to see that the file actually HAS sections before we go any further.
//
@@ -532,5 +530,3 @@ FvReadFileSection ( Done:
return Status;
}
-
-
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c index 3a3b569..6e3a59b 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolWrite.c @@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "DxeMain.h"
#include "FwVolDriver.h"
-
/**
Writes one or more files to the firmware volume.
@@ -42,5 +41,3 @@ FvWriteFile ( {
return EFI_UNSUPPORTED;
}
-
-
|