summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c')
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c119
1 files changed, 62 insertions, 57 deletions
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
index e2b028f733..977ded851e 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c
@@ -7,10 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#include "Partition.h"
-
/**
Install child handles if the Handle supports El Torito format.
@@ -57,10 +55,10 @@ PartitionInstallElToritoChildHandles (
UINT32 VolSpaceSize;
EFI_PARTITION_INFO_PROTOCOL PartitionInfo;
- Found = EFI_NOT_FOUND;
- Media = BlockIo->Media;
+ Found = EFI_NOT_FOUND;
+ Media = BlockIo->Media;
- VolSpaceSize = 0;
+ VolSpaceSize = 0;
//
// CD_ROM has the fixed block size as 2048 bytes (SIZE_2KB)
@@ -79,7 +77,7 @@ PartitionInstallElToritoChildHandles (
return EFI_NOT_FOUND;
}
- Catalog = (ELTORITO_CATALOG *) VolDescriptor;
+ Catalog = (ELTORITO_CATALOG *)VolDescriptor;
//
// Loop: handle one volume descriptor per time
@@ -87,7 +85,8 @@ PartitionInstallElToritoChildHandles (
//
for (VolDescriptorOffset = SIZE_32KB;
VolDescriptorOffset <= MultU64x32 (Media->LastBlock, Media->BlockSize);
- VolDescriptorOffset += SIZE_2KB) {
+ VolDescriptorOffset += SIZE_2KB)
+ {
Status = DiskIo->ReadDisk (
DiskIo,
Media->MediaId,
@@ -99,17 +98,20 @@ PartitionInstallElToritoChildHandles (
Found = Status;
break;
}
+
//
// Check for valid volume descriptor signature
//
- if (VolDescriptor->Unknown.Type == CDVOL_TYPE_END ||
- CompareMem (VolDescriptor->Unknown.Id, CDVOL_ID, sizeof (VolDescriptor->Unknown.Id)) != 0
- ) {
+ if ((VolDescriptor->Unknown.Type == CDVOL_TYPE_END) ||
+ (CompareMem (VolDescriptor->Unknown.Id, CDVOL_ID, sizeof (VolDescriptor->Unknown.Id)) != 0)
+ )
+ {
//
// end of Volume descriptor list
//
break;
}
+
//
// Read the Volume Space Size from Primary Volume Descriptor 81-88 byte,
// the 32-bit numerical values is stored in Both-byte orders
@@ -117,12 +119,14 @@ PartitionInstallElToritoChildHandles (
if (VolDescriptor->PrimaryVolume.Type == CDVOL_TYPE_CODED) {
VolSpaceSize = VolDescriptor->PrimaryVolume.VolSpaceSize[0];
}
+
//
// Is it an El Torito volume descriptor?
//
if (CompareMem (VolDescriptor->BootRecordVolume.SystemId, CDVOL_ELTORITO_ID, sizeof (CDVOL_ELTORITO_ID) - 1) != 0) {
continue;
}
+
//
// Read in the boot El Torito boot catalog
// The LBA unit used by El Torito boot catalog is 2KB unit
@@ -144,17 +148,18 @@ PartitionInstallElToritoChildHandles (
DEBUG ((DEBUG_ERROR, "EltCheckDevice: error reading catalog %r\n", Status));
continue;
}
+
//
// We don't care too much about the Catalog header's contents, but we do want
// to make sure it looks like a Catalog header
//
- if (Catalog->Catalog.Indicator != ELTORITO_ID_CATALOG || Catalog->Catalog.Id55AA != 0xAA55) {
+ if ((Catalog->Catalog.Indicator != ELTORITO_ID_CATALOG) || (Catalog->Catalog.Id55AA != 0xAA55)) {
DEBUG ((DEBUG_ERROR, "EltCheckBootCatalog: El Torito boot catalog header IDs not correct\n"));
continue;
}
Check = 0;
- CheckBuffer = (UINT16 *) Catalog;
+ CheckBuffer = (UINT16 *)Catalog;
for (Index = 0; Index < sizeof (ELTORITO_CATALOG) / sizeof (UINT16); Index += 1) {
Check += CheckBuffer[Index];
}
@@ -174,45 +179,45 @@ PartitionInstallElToritoChildHandles (
//
// Check this entry
//
- if (Catalog->Boot.Indicator != ELTORITO_ID_SECTION_BOOTABLE || Catalog->Boot.Lba == 0) {
+ if ((Catalog->Boot.Indicator != ELTORITO_ID_SECTION_BOOTABLE) || (Catalog->Boot.Lba == 0)) {
continue;
}
- SubBlockSize = 512;
- SectorCount = Catalog->Boot.SectorCount;
+ SubBlockSize = 512;
+ SectorCount = Catalog->Boot.SectorCount;
switch (Catalog->Boot.MediaType) {
-
- case ELTORITO_NO_EMULATION:
- SubBlockSize = Media->BlockSize;
- break;
-
- case ELTORITO_HARD_DISK:
- break;
-
- case ELTORITO_12_DISKETTE:
- SectorCount = 0x50 * 0x02 * 0x0F;
- break;
-
- case ELTORITO_14_DISKETTE:
- SectorCount = 0x50 * 0x02 * 0x12;
- break;
-
- case ELTORITO_28_DISKETTE:
- SectorCount = 0x50 * 0x02 * 0x24;
- break;
-
- default:
- DEBUG ((DEBUG_INIT, "EltCheckDevice: unsupported El Torito boot media type %x\n", Catalog->Boot.MediaType));
- SectorCount = 0;
- SubBlockSize = Media->BlockSize;
- break;
+ case ELTORITO_NO_EMULATION:
+ SubBlockSize = Media->BlockSize;
+ break;
+
+ case ELTORITO_HARD_DISK:
+ break;
+
+ case ELTORITO_12_DISKETTE:
+ SectorCount = 0x50 * 0x02 * 0x0F;
+ break;
+
+ case ELTORITO_14_DISKETTE:
+ SectorCount = 0x50 * 0x02 * 0x12;
+ break;
+
+ case ELTORITO_28_DISKETTE:
+ SectorCount = 0x50 * 0x02 * 0x24;
+ break;
+
+ default:
+ DEBUG ((DEBUG_INIT, "EltCheckDevice: unsupported El Torito boot media type %x\n", Catalog->Boot.MediaType));
+ SectorCount = 0;
+ SubBlockSize = Media->BlockSize;
+ break;
}
+
//
// Create child device handle
//
- CdDev.Header.Type = MEDIA_DEVICE_PATH;
- CdDev.Header.SubType = MEDIA_CDROM_DP;
+ CdDev.Header.Type = MEDIA_DEVICE_PATH;
+ CdDev.Header.SubType = MEDIA_CDROM_DP;
SetDevicePathNodeLength (&CdDev.Header, sizeof (CdDev));
if (Index == 1) {
@@ -222,7 +227,7 @@ PartitionInstallElToritoChildHandles (
BootEntry = 0;
}
- CdDev.BootEntry = (UINT32) BootEntry;
+ CdDev.BootEntry = (UINT32)BootEntry;
BootEntry++;
CdDev.PartitionStart = Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize);
if (SectorCount < 2) {
@@ -249,20 +254,20 @@ PartitionInstallElToritoChildHandles (
PartitionInfo.Type = PARTITION_TYPE_OTHER;
Status = PartitionInstallChildHandle (
- This,
- Handle,
- DiskIo,
- DiskIo2,
- BlockIo,
- BlockIo2,
- DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &CdDev,
- &PartitionInfo,
- Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize),
- Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + CdDev.PartitionSize - 1,
- SubBlockSize,
- NULL
- );
+ This,
+ Handle,
+ DiskIo,
+ DiskIo2,
+ BlockIo,
+ BlockIo2,
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&CdDev,
+ &PartitionInfo,
+ Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize),
+ Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + CdDev.PartitionSize - 1,
+ SubBlockSize,
+ NULL
+ );
if (!EFI_ERROR (Status)) {
Found = EFI_SUCCESS;
}