FatPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the FatPkg 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: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:53:58 -08:00
committed by mergify[bot]
parent a550d468a6
commit bcdcc4160d
30 changed files with 2153 additions and 2047 deletions

View File

@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "FatLitePeim.h"
/**
Check if there is a valid FAT in the corresponding Block device
of the volume and if yes, fill in the relevant fields for the
@@ -49,25 +48,25 @@ FatGetBpbInfo (
// Read in the BPB
//
Status = FatReadDisk (
PrivateData,
Volume->BlockDeviceNo,
0,
sizeof (PEI_FAT_BOOT_SECTOR_EX),
&BpbEx
);
PrivateData,
Volume->BlockDeviceNo,
0,
sizeof (PEI_FAT_BOOT_SECTOR_EX),
&BpbEx
);
if (EFI_ERROR (Status)) {
return Status;
}
CopyMem (
(UINT8 *) (&Bpb),
(UINT8 *) (&BpbEx),
(UINT8 *)(&Bpb),
(UINT8 *)(&BpbEx),
sizeof (PEI_FAT_BOOT_SECTOR)
);
Volume->FatType = FatUnknown;
Sectors = Bpb.Sectors;
Sectors = Bpb.Sectors;
if (Sectors == 0) {
Sectors = Bpb.LargeSectors;
}
@@ -77,60 +76,65 @@ FatGetBpbInfo (
SectorsPerFat = BpbEx.LargeSectorsPerFat;
Volume->FatType = Fat32;
}
//
// Filter out those not a FAT
//
if (Bpb.Ia32Jump[0] != 0xe9 && Bpb.Ia32Jump[0] != 0xeb && Bpb.Ia32Jump[0] != 0x49) {
if ((Bpb.Ia32Jump[0] != 0xe9) && (Bpb.Ia32Jump[0] != 0xeb) && (Bpb.Ia32Jump[0] != 0x49)) {
return EFI_NOT_FOUND;
}
if (Bpb.ReservedSectors == 0 || Bpb.NoFats == 0 || Sectors == 0) {
if ((Bpb.ReservedSectors == 0) || (Bpb.NoFats == 0) || (Sectors == 0)) {
return EFI_NOT_FOUND;
}
if (Bpb.SectorsPerCluster != 1 &&
Bpb.SectorsPerCluster != 2 &&
Bpb.SectorsPerCluster != 4 &&
Bpb.SectorsPerCluster != 8 &&
Bpb.SectorsPerCluster != 16 &&
Bpb.SectorsPerCluster != 32 &&
Bpb.SectorsPerCluster != 64 &&
Bpb.SectorsPerCluster != 128
) {
if ((Bpb.SectorsPerCluster != 1) &&
(Bpb.SectorsPerCluster != 2) &&
(Bpb.SectorsPerCluster != 4) &&
(Bpb.SectorsPerCluster != 8) &&
(Bpb.SectorsPerCluster != 16) &&
(Bpb.SectorsPerCluster != 32) &&
(Bpb.SectorsPerCluster != 64) &&
(Bpb.SectorsPerCluster != 128)
)
{
return EFI_NOT_FOUND;
}
if (Volume->FatType == Fat32 && (SectorsPerFat == 0 || BpbEx.FsVersion != 0)) {
if ((Volume->FatType == Fat32) && ((SectorsPerFat == 0) || (BpbEx.FsVersion != 0))) {
return EFI_NOT_FOUND;
}
if (Bpb.Media != 0xf0 &&
Bpb.Media != 0xf8 &&
Bpb.Media != 0xf9 &&
Bpb.Media != 0xfb &&
Bpb.Media != 0xfc &&
Bpb.Media != 0xfd &&
Bpb.Media != 0xfe &&
Bpb.Media != 0xff &&
if ((Bpb.Media != 0xf0) &&
(Bpb.Media != 0xf8) &&
(Bpb.Media != 0xf9) &&
(Bpb.Media != 0xfb) &&
(Bpb.Media != 0xfc) &&
(Bpb.Media != 0xfd) &&
(Bpb.Media != 0xfe) &&
(Bpb.Media != 0xff) &&
//
// FujitsuFMR
//
Bpb.Media != 0x00 &&
Bpb.Media != 0x01 &&
Bpb.Media != 0xfa
) {
(Bpb.Media != 0x00) &&
(Bpb.Media != 0x01) &&
(Bpb.Media != 0xfa)
)
{
return EFI_NOT_FOUND;
}
if (Volume->FatType != Fat32 && Bpb.RootEntries == 0) {
if ((Volume->FatType != Fat32) && (Bpb.RootEntries == 0)) {
return EFI_NOT_FOUND;
}
//
// If this is fat32, refuse to mount mirror-disabled volumes
//
if (Volume->FatType == Fat32 && ((BpbEx.ExtendedFlags & 0x80) != 0)) {
if ((Volume->FatType == Fat32) && ((BpbEx.ExtendedFlags & 0x80) != 0)) {
return EFI_NOT_FOUND;
}
//
// Fill in the volume structure fields
// (Sectors & SectorsPerFat is computed earlier already)
@@ -141,22 +145,21 @@ FatGetBpbInfo (
RootDirSectors = ((Volume->RootEntries * sizeof (FAT_DIRECTORY_ENTRY)) + (Volume->SectorSize - 1)) / Volume->SectorSize;
FatLba = Bpb.ReservedSectors;
RootLba = Bpb.NoFats * SectorsPerFat + FatLba;
FirstClusterLba = RootLba + RootDirSectors;
FatLba = Bpb.ReservedSectors;
RootLba = Bpb.NoFats * SectorsPerFat + FatLba;
FirstClusterLba = RootLba + RootDirSectors;
Volume->VolumeSize = MultU64x32 (Sectors, Volume->SectorSize);
Volume->FatPos = MultU64x32 (FatLba, Volume->SectorSize);
Volume->RootDirPos = MultU64x32 (RootLba, Volume->SectorSize);
Volume->FirstClusterPos = MultU64x32 (FirstClusterLba, Volume->SectorSize);
Volume->MaxCluster = (UINT32) (Sectors - FirstClusterLba) / Bpb.SectorsPerCluster;
Volume->MaxCluster = (UINT32)(Sectors - FirstClusterLba) / Bpb.SectorsPerCluster;
Volume->RootDirCluster = BpbEx.RootDirFirstCluster;
//
// If this is not a fat32, determine if it's a fat16 or fat12
//
if (Volume->FatType != Fat32) {
if (Volume->MaxCluster >= 65525) {
return EFI_NOT_FOUND;
}
@@ -167,7 +170,6 @@ FatGetBpbInfo (
return EFI_SUCCESS;
}
/**
Gets the next cluster in the cluster chain
@@ -198,7 +200,7 @@ FatGetNextCluster (
if (Volume->FatType == Fat32) {
FatEntryPos = Volume->FatPos + MultU64x32 (4, Cluster);
Status = FatReadDisk (PrivateData, Volume->BlockDeviceNo, FatEntryPos, 4, NextCluster);
Status = FatReadDisk (PrivateData, Volume->BlockDeviceNo, FatEntryPos, 4, NextCluster);
*NextCluster &= 0x0fffffff;
//
@@ -207,11 +209,10 @@ FatGetNextCluster (
if ((*NextCluster) >= 0x0ffffff7) {
*NextCluster |= (-1 &~0xf);
}
} else if (Volume->FatType == Fat16) {
FatEntryPos = Volume->FatPos + MultU64x32 (2, Cluster);
Status = FatReadDisk (PrivateData, Volume->BlockDeviceNo, FatEntryPos, 2, NextCluster);
Status = FatReadDisk (PrivateData, Volume->BlockDeviceNo, FatEntryPos, 2, NextCluster);
//
// Pad high bits for our FAT_CLUSTER_... macro definitions to work
@@ -219,17 +220,17 @@ FatGetNextCluster (
if ((*NextCluster) >= 0xfff7) {
*NextCluster |= (-1 &~0xf);
}
} else {
FatEntryPos = Volume->FatPos + DivU64x32Remainder (MultU64x32 (3, Cluster), 2, &Dummy);
Status = FatReadDisk (PrivateData, Volume->BlockDeviceNo, FatEntryPos, 2, NextCluster);
Status = FatReadDisk (PrivateData, Volume->BlockDeviceNo, FatEntryPos, 2, NextCluster);
if ((Cluster & 0x01) != 0) {
*NextCluster = (*NextCluster) >> 4;
} else {
*NextCluster = (*NextCluster) & 0x0fff;
}
//
// Pad high bits for our FAT_CLUSTER_... macro definitions to work
//
@@ -243,10 +244,8 @@ FatGetNextCluster (
}
return EFI_SUCCESS;
}
/**
Set a file's CurrentPos and CurrentCluster, then compute StraightReadAmount.
@@ -274,31 +273,29 @@ FatSetFilePos (
UINT32 PrevCluster;
if (File->IsFixedRootDir) {
if (Pos >= MultU64x32 (File->Volume->RootEntries, 32) - File->CurrentPos) {
return EFI_INVALID_PARAMETER;
}
File->CurrentPos += Pos;
File->StraightReadAmount = (UINT32) (MultU64x32 (File->Volume->RootEntries, 32) - File->CurrentPos);
File->CurrentPos += Pos;
File->StraightReadAmount = (UINT32)(MultU64x32 (File->Volume->RootEntries, 32) - File->CurrentPos);
} else {
DivU64x32Remainder (File->CurrentPos, File->Volume->ClusterSize, &Offset);
AlignedPos = (UINT32) File->CurrentPos - (UINT32) Offset;
AlignedPos = (UINT32)File->CurrentPos - (UINT32)Offset;
while
(
!FAT_CLUSTER_FUNCTIONAL (File->CurrentCluster) &&
AlignedPos + File->Volume->ClusterSize <= File->CurrentPos + Pos
) {
!FAT_CLUSTER_FUNCTIONAL (File->CurrentCluster) &&
AlignedPos + File->Volume->ClusterSize <= File->CurrentPos + Pos
)
{
AlignedPos += File->Volume->ClusterSize;
Status = FatGetNextCluster (
PrivateData,
File->Volume,
File->CurrentCluster,
&File->CurrentCluster
);
Status = FatGetNextCluster (
PrivateData,
File->Volume,
File->CurrentCluster,
&File->CurrentCluster
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -313,12 +310,12 @@ FatSetFilePos (
// Calculate the amount of consecutive cluster occupied by the file.
// FatReadFile() will use it to read these blocks once.
//
File->StraightReadAmount = 0;
Cluster = File->CurrentCluster;
File->StraightReadAmount = 0;
Cluster = File->CurrentCluster;
while (!FAT_CLUSTER_FUNCTIONAL (Cluster)) {
File->StraightReadAmount += File->Volume->ClusterSize;
PrevCluster = Cluster;
Status = FatGetNextCluster (PrivateData, File->Volume, Cluster, &Cluster);
PrevCluster = Cluster;
Status = FatGetNextCluster (PrivateData, File->Volume, Cluster, &Cluster);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -329,14 +326,12 @@ FatSetFilePos (
}
DivU64x32Remainder (File->CurrentPos, File->Volume->ClusterSize, &Offset);
File->StraightReadAmount -= (UINT32) Offset;
File->StraightReadAmount -= (UINT32)Offset;
}
return EFI_SUCCESS;
}
/**
Reads file data. Updates the file's CurrentPos.
@@ -375,53 +370,52 @@ FatReadFile (
}
Status = FatReadDisk (
PrivateData,
File->Volume->BlockDeviceNo,
File->Volume->RootDirPos + File->CurrentPos,
Size,
Buffer
);
File->CurrentPos += (UINT32) Size;
PrivateData,
File->Volume->BlockDeviceNo,
File->Volume->RootDirPos + File->CurrentPos,
Size,
Buffer
);
File->CurrentPos += (UINT32)Size;
return Status;
} else {
if ((File->Attributes & FAT_ATTR_DIRECTORY) == 0) {
Size = Size < (File->FileSize - File->CurrentPos) ? Size : (File->FileSize - File->CurrentPos);
}
//
// This is a normal cluster based file
//
while (Size != 0) {
DivU64x32Remainder (File->CurrentPos, File->Volume->ClusterSize, &Offset);
PhysicalAddr = File->Volume->FirstClusterPos + MultU64x32 (File->Volume->ClusterSize, File->CurrentCluster - 2);
PhysicalAddr = File->Volume->FirstClusterPos + MultU64x32 (File->Volume->ClusterSize, File->CurrentCluster - 2);
Amount = File->StraightReadAmount;
Amount = Size > Amount ? Amount : Size;
Amount = File->StraightReadAmount;
Amount = Size > Amount ? Amount : Size;
Status = FatReadDisk (
PrivateData,
File->Volume->BlockDeviceNo,
PhysicalAddr + Offset,
Amount,
BufferPtr
);
PrivateData,
File->Volume->BlockDeviceNo,
PhysicalAddr + Offset,
Amount,
BufferPtr
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
//
// Advance the file's current pos and current cluster
//
FatSetFilePos (PrivateData, File, (UINT32) Amount);
FatSetFilePos (PrivateData, File, (UINT32)Amount);
BufferPtr += Amount;
Size -= Amount;
Size -= Amount;
}
return EFI_SUCCESS;
}
}
/**
This function reads the next item in the parent directory and
initializes the output parameter SubFile (CurrentPos is initialized to 0).
@@ -446,13 +440,13 @@ FatReadNextDirectoryEntry (
OUT PEI_FAT_FILE *SubFile
)
{
EFI_STATUS Status;
FAT_DIRECTORY_ENTRY DirEntry;
CHAR16 *Pos;
CHAR16 BaseName[9];
CHAR16 Ext[4];
EFI_STATUS Status;
FAT_DIRECTORY_ENTRY DirEntry;
CHAR16 *Pos;
CHAR16 BaseName[9];
CHAR16 Ext[4];
ZeroMem ((UINT8 *) SubFile, sizeof (PEI_FAT_FILE));
ZeroMem ((UINT8 *)SubFile, sizeof (PEI_FAT_FILE));
//
// Pick a valid directory entry
@@ -465,6 +459,7 @@ FatReadNextDirectoryEntry (
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
//
// We only search for *FILE* in root directory
// Long file name entry is *NOT* supported
@@ -472,35 +467,38 @@ FatReadNextDirectoryEntry (
if (((DirEntry.Attributes & FAT_ATTR_DIRECTORY) == FAT_ATTR_DIRECTORY) || (DirEntry.Attributes == FAT_ATTR_LFN)) {
continue;
}
//
// if this is a terminator dir entry, just return EFI_NOT_FOUND
//
if (DirEntry.FileName[0] == EMPTY_ENTRY_MARK) {
return EFI_NOT_FOUND;
}
//
// If this not an invalid entry neither an empty entry, this is what we want.
// otherwise we will start a new loop to continue to find something meaningful
//
if ((UINT8) DirEntry.FileName[0] != DELETE_ENTRY_MARK) {
if ((UINT8)DirEntry.FileName[0] != DELETE_ENTRY_MARK) {
break;
}
}
//
// fill in the output parameter
//
EngFatToStr (8, DirEntry.FileName, BaseName);
EngFatToStr (3, DirEntry.FileName + 8, Ext);
Pos = (UINT16 *) SubFile->FileName;
SetMem ((UINT8 *) Pos, FAT_MAX_FILE_NAME_LENGTH, 0);
CopyMem ((UINT8 *) Pos, (UINT8 *) BaseName, 2 * (StrLen (BaseName) + 1));
Pos = (UINT16 *)SubFile->FileName;
SetMem ((UINT8 *)Pos, FAT_MAX_FILE_NAME_LENGTH, 0);
CopyMem ((UINT8 *)Pos, (UINT8 *)BaseName, 2 * (StrLen (BaseName) + 1));
if (Ext[0] != 0) {
Pos += StrLen (BaseName);
*Pos = '.';
Pos++;
CopyMem ((UINT8 *) Pos, (UINT8 *) Ext, 2 * (StrLen (Ext) + 1));
CopyMem ((UINT8 *)Pos, (UINT8 *)Ext, 2 * (StrLen (Ext) + 1));
}
SubFile->Attributes = DirEntry.Attributes;
@@ -509,10 +507,10 @@ FatReadNextDirectoryEntry (
SubFile->CurrentCluster |= DirEntry.FileClusterHigh << 16;
}
SubFile->CurrentPos = 0;
SubFile->FileSize = DirEntry.FileSize;
SubFile->StartingCluster = SubFile->CurrentCluster;
SubFile->Volume = ParentDir->Volume;
SubFile->CurrentPos = 0;
SubFile->FileSize = DirEntry.FileSize;
SubFile->StartingCluster = SubFile->CurrentCluster;
SubFile->Volume = ParentDir->Volume;
//
// in Pei phase, time parameters do not need to be filled for minimum use.