diff options
Diffstat (limited to 'MdeModulePkg/Core/Dxe/FwVol')
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/Ffs.c | 51 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVol.c | 34 | ||||
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 16 |
3 files changed, 46 insertions, 55 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c index 7673352bba..00d07567f7 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c +++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c @@ -15,8 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <DxeMain.h>
-#define PHYSICAL_ADDRESS_TO_POINTER(Address) ((VOID *)((UINTN)(Address)))
-
/**
Get the FFS file state by checking the highest bit set in the header's state field.
@@ -47,7 +45,7 @@ GetFileState ( HighestBit >>= 1;
}
- return (EFI_FFS_FILE_STATE)HighestBit;
+ return (EFI_FFS_FILE_STATE) HighestBit;
}
@@ -183,24 +181,23 @@ 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.
@@ -223,17 +220,17 @@ IsValidFfsFile ( FileState = GetFileState (ErasePolarity, FfsHeader);
switch (FileState) {
- case EFI_FILE_DELETED:
- case EFI_FILE_DATA_VALID:
- case EFI_FILE_MARKED_FOR_UPDATE:
- //
- // Some other vliadation like file content checksum might be done here.
- // For performance issue, Tiano only do FileState check.
- //
- return TRUE;
+ case EFI_FILE_DELETED:
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ //
+ // Some other vliadation like file content checksum might be done here.
+ // For performance issue, Tiano only do FileState check.
+ //
+ 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 6a4d7b05b2..f14cce05c7 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c @@ -52,8 +52,6 @@ FV_DEVICE mFvDevice = { //
// FFS helper functions
//
-
-
/**
given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
copy the volume header into it.
@@ -122,8 +120,6 @@ GetFwVolHeader ( @param FvDevice pointer to the FvDevice to be freed.
- @return None.
-
**/
VOID
FreeFvDeviceResource (
@@ -149,7 +145,7 @@ FreeFvDeviceResource ( CoreFreePool (FfsFileEntry);
- FfsFileEntry = (FFS_FILE_LIST_ENTRY *)NextEntry;
+ FfsFileEntry = (FFS_FILE_LIST_ENTRY *) NextEntry;
}
@@ -169,9 +165,9 @@ FreeFvDeviceResource ( /**
- Check if a FV is consistent and allocate cache
+ Check if an FV is consistent and allocate cache for it.
- @param FvDevice pointer to the FvDevice to be checked.
+ @param FvDevice A pointer to the FvDevice to be checked.
@retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated.
@retval EFI_SUCCESS FV is consistent and cache is allocated.
@@ -245,11 +241,11 @@ FvCheck ( Size -= LbaOffset;
}
Status = Fvb->Read (Fvb,
- LbaIndex,
- LbaOffset,
- &Size,
- CacheLocation
- );
+ LbaIndex,
+ LbaOffset,
+ &Size,
+ CacheLocation
+ );
//
// Not check EFI_BAD_BUFFER_SIZE, for Size = BlockMap->Length
//
@@ -288,11 +284,11 @@ FvCheck ( //
// Build FFS list
//
- FfsHeader = (EFI_FFS_FILE_HEADER *)FvDevice->CachedFv;
+ FfsHeader = (EFI_FFS_FILE_HEADER *) FvDevice->CachedFv;
TopFvAddress = FvDevice->EndOfCachedFv;
- while ((UINT8 *)FfsHeader < TopFvAddress) {
+ while ((UINT8 *) FfsHeader < TopFvAddress) {
- TestLength = TopFvAddress - ((UINT8 *)FfsHeader);
+ TestLength = TopFvAddress - ((UINT8 *) FfsHeader);
if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
TestLength = sizeof (EFI_FFS_FILE_HEADER);
}
@@ -308,9 +304,7 @@ FvCheck ( if ((FileState == EFI_FILE_HEADER_INVALID) ||
(FileState == EFI_FILE_HEADER_CONSTRUCTION)) {
FfsHeader++;
-
continue;
-
} else {
//
// File system is corrputed
@@ -476,9 +470,9 @@ NotifyFwVolBlock ( return;
}
- FvDevice->Fvb = Fvb;
- FvDevice->Handle = Handle;
- FvDevice->FwVolHeader = FwVolHeader;
+ FvDevice->Fvb = Fvb;
+ FvDevice->Handle = Handle;
+ FvDevice->FwVolHeader = FwVolHeader;
FvDevice->Fv.ParentHandle = Fvb->ParentHandle;
//
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c index 81e3ad349e..7016ee5b90 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c @@ -200,7 +200,7 @@ FvGetNextFile ( // Return FileType, NameGuid, and Attributes
//
*FileType = FfsFileHeader->Type;
- CopyMem (NameGuid, &FfsFileHeader->Name, sizeof (EFI_GUID));
+ CopyGuid (NameGuid, &FfsFileHeader->Name);
*Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes);
//
@@ -280,7 +280,7 @@ FvReadFile ( EFI_FFS_FILE_HEADER *FfsHeader;
UINTN InputBufferSize;
- if (NULL == NameGuid) {
+ if (NameGuid == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -412,7 +412,7 @@ FvReadFileSection ( UINT8 *FileBuffer;
FFS_FILE_LIST_ENTRY *FfsEntry;
- if (NULL == NameGuid || Buffer == NULL) {
+ if (NameGuid == NULL || Buffer == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -434,7 +434,7 @@ FvReadFileSection ( //
// 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;
@@ -453,10 +453,10 @@ FvReadFileSection ( //
if (FfsEntry->StreamHandle == 0) {
Status = OpenSectionStream (
- FileSize,
- FileBuffer,
- &FfsEntry->StreamHandle
- );
+ FileSize,
+ FileBuffer,
+ &FfsEntry->StreamHandle
+ );
if (EFI_ERROR (Status)) {
goto Done;
}
|