summaryrefslogtreecommitdiffstats
path: root/FatPkg/FatPei/Mbr.c
diff options
context:
space:
mode:
Diffstat (limited to 'FatPkg/FatPei/Mbr.c')
-rw-r--r--FatPkg/FatPei/Mbr.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/FatPkg/FatPei/Mbr.c b/FatPkg/FatPei/Mbr.c
index 78e73fb811..0a6f1f505c 100644
--- a/FatPkg/FatPei/Mbr.c
+++ b/FatPkg/FatPei/Mbr.c
@@ -23,26 +23,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
BOOLEAN
PartitionValidMbr (
- IN MASTER_BOOT_RECORD *Mbr,
- IN EFI_PEI_LBA LastLba
+ IN MASTER_BOOT_RECORD *Mbr,
+ IN EFI_PEI_LBA LastLba
)
{
- UINT32 StartingLBA;
- UINT32 EndingLBA;
- UINT32 NewEndingLBA;
- INTN Index1;
- INTN Index2;
- BOOLEAN MbrValid;
+ UINT32 StartingLBA;
+ UINT32 EndingLBA;
+ UINT32 NewEndingLBA;
+ INTN Index1;
+ INTN Index2;
+ BOOLEAN MbrValid;
if (Mbr->Signature != MBR_SIGNATURE) {
return FALSE;
}
+
//
// The BPB also has this signature, so it can not be used alone.
//
MbrValid = FALSE;
for (Index1 = 0; Index1 < MAX_MBR_PARTITIONS; Index1++) {
- if (Mbr->Partition[Index1].OSIndicator == 0x00 || UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA) == 0) {
+ if ((Mbr->Partition[Index1].OSIndicator == 0x00) || (UNPACK_UINT32 (Mbr->Partition[Index1].SizeInLBA) == 0)) {
continue;
}
@@ -65,12 +66,12 @@ PartitionValidMbr (
}
for (Index2 = Index1 + 1; Index2 < MAX_MBR_PARTITIONS; Index2++) {
- if (Mbr->Partition[Index2].OSIndicator == 0x00 || UNPACK_INT32 (Mbr->Partition[Index2].SizeInLBA) == 0) {
+ if ((Mbr->Partition[Index2].OSIndicator == 0x00) || (UNPACK_INT32 (Mbr->Partition[Index2].SizeInLBA) == 0)) {
continue;
}
NewEndingLBA = UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) + UNPACK_UINT32 (Mbr->Partition[Index2].SizeInLBA) - 1;
- if (NewEndingLBA >= StartingLBA && UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) <= EndingLBA) {
+ if ((NewEndingLBA >= StartingLBA) && (UNPACK_UINT32 (Mbr->Partition[Index2].StartingLBA) <= EndingLBA)) {
//
// This region overlaps with the Index1'th region
//
@@ -78,6 +79,7 @@ PartitionValidMbr (
}
}
}
+
//
// Non of the regions overlapped so MBR is O.K.
//
@@ -98,8 +100,8 @@ PartitionValidMbr (
**/
BOOLEAN
FatFindMbrPartitions (
- IN PEI_FAT_PRIVATE_DATA *PrivateData,
- IN UINTN ParentBlockDevNo
+ IN PEI_FAT_PRIVATE_DATA *PrivateData,
+ IN UINTN ParentBlockDevNo
)
{
EFI_STATUS Status;
@@ -113,55 +115,56 @@ FatFindMbrPartitions (
return FALSE;
}
- ParentBlockDev = &(PrivateData->BlockDevice[ParentBlockDevNo]);
+ ParentBlockDev = &(PrivateData->BlockDevice[ParentBlockDevNo]);
if (ParentBlockDev->BlockSize > PEI_FAT_MAX_BLOCK_SIZE) {
- DEBUG((DEBUG_ERROR, "Device BlockSize %x exceeds FAT_MAX_BLOCK_SIZE\n", ParentBlockDev->BlockSize));
+ DEBUG ((DEBUG_ERROR, "Device BlockSize %x exceeds FAT_MAX_BLOCK_SIZE\n", ParentBlockDev->BlockSize));
return FALSE;
}
- Found = FALSE;
- Mbr = (MASTER_BOOT_RECORD *) PrivateData->BlockData;
+ Found = FALSE;
+ Mbr = (MASTER_BOOT_RECORD *)PrivateData->BlockData;
Status = FatReadBlock (
- PrivateData,
- ParentBlockDevNo,
- 0,
- ParentBlockDev->BlockSize,
- Mbr
- );
+ PrivateData,
+ ParentBlockDevNo,
+ 0,
+ ParentBlockDev->BlockSize,
+ Mbr
+ );
if (EFI_ERROR (Status) || !PartitionValidMbr (Mbr, ParentBlockDev->LastBlock)) {
goto Done;
}
+
//
// We have a valid mbr - add each partition
//
for (Index = 0; Index < MAX_MBR_PARTITIONS; Index++) {
- if (Mbr->Partition[Index].OSIndicator == 0x00 || UNPACK_INT32 (Mbr->Partition[Index].SizeInLBA) == 0) {
+ if ((Mbr->Partition[Index].OSIndicator == 0x00) || (UNPACK_INT32 (Mbr->Partition[Index].SizeInLBA) == 0)) {
//
// Don't use null MBR entries
//
continue;
}
+
//
// Register this partition
//
if (PrivateData->BlockDeviceCount < PEI_FAT_MAX_BLOCK_DEVICE) {
-
- Found = TRUE;
-
- BlockDev = &(PrivateData->BlockDevice[PrivateData->BlockDeviceCount]);
-
- BlockDev->BlockSize = MBR_SIZE;
- BlockDev->LastBlock = UNPACK_INT32 (Mbr->Partition[Index].SizeInLBA) - 1;
- BlockDev->IoAlign = ParentBlockDev->IoAlign;
- BlockDev->Logical = TRUE;
- BlockDev->PartitionChecked = FALSE;
- BlockDev->StartingPos = MultU64x32 (
- UNPACK_INT32 (Mbr->Partition[Index].StartingLBA),
- ParentBlockDev->BlockSize
- );
+ Found = TRUE;
+
+ BlockDev = &(PrivateData->BlockDevice[PrivateData->BlockDeviceCount]);
+
+ BlockDev->BlockSize = MBR_SIZE;
+ BlockDev->LastBlock = UNPACK_INT32 (Mbr->Partition[Index].SizeInLBA) - 1;
+ BlockDev->IoAlign = ParentBlockDev->IoAlign;
+ BlockDev->Logical = TRUE;
+ BlockDev->PartitionChecked = FALSE;
+ BlockDev->StartingPos = MultU64x32 (
+ UNPACK_INT32 (Mbr->Partition[Index].StartingLBA),
+ ParentBlockDev->BlockSize
+ );
BlockDev->ParentDevNo = ParentBlockDevNo;
PrivateData->BlockDeviceCount++;