MdeModulePkg PartitionDxe: Some ISO images cannot be recognized properly

Some ISO images cannot be recognized properly when they are on media whose
block size is not 2048 bytes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
Hao Wu 2016-03-11 15:55:36 +08:00
parent ef95212963
commit 744c71687b

View File

@ -1,7 +1,7 @@
/** @file /** @file
Decode an El Torito formatted CD-ROM Decode an El Torito formatted CD-ROM
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -183,7 +183,7 @@ PartitionInstallElToritoChildHandles (
} }
SubBlockSize = 512; SubBlockSize = 512;
SectorCount = Catalog->Boot.SectorCount * (SIZE_2KB / Media->BlockSize); SectorCount = Catalog->Boot.SectorCount;
switch (Catalog->Boot.MediaType) { switch (Catalog->Boot.MediaType) {
@ -233,15 +233,15 @@ PartitionInstallElToritoChildHandles (
// //
// When the SectorCount < 2, set the Partition as the whole CD. // When the SectorCount < 2, set the Partition as the whole CD.
// //
if (VolSpaceSize > (Media->LastBlock + 1)) { if (VolSpaceSize * (SIZE_2KB / Media->BlockSize) > (Media->LastBlock + 1)) {
CdDev.PartitionSize = (UINT32)(Media->LastBlock - Catalog->Boot.Lba + 1); CdDev.PartitionSize = (UINT32)(Media->LastBlock - Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + 1);
} else { } else {
CdDev.PartitionSize = (UINT32)(VolSpaceSize - Catalog->Boot.Lba); CdDev.PartitionSize = (UINT32)(VolSpaceSize - Catalog->Boot.Lba) * (SIZE_2KB / Media->BlockSize);
} }
} else { } else {
CdDev.PartitionSize = DivU64x32 ( CdDev.PartitionSize = DivU64x32 (
MultU64x32 ( MultU64x32 (
SectorCount, SectorCount * (SIZE_2KB / Media->BlockSize),
SubBlockSize SubBlockSize
) + Media->BlockSize - 1, ) + Media->BlockSize - 1,
Media->BlockSize Media->BlockSize
@ -258,7 +258,7 @@ PartitionInstallElToritoChildHandles (
DevicePath, DevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &CdDev, (EFI_DEVICE_PATH_PROTOCOL *) &CdDev,
Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize), Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize),
MultU64x32 (Catalog->Boot.Lba + CdDev.PartitionSize - 1, SIZE_2KB / Media->BlockSize), Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + CdDev.PartitionSize - 1,
SubBlockSize, SubBlockSize,
FALSE FALSE
); );