From 744c71687bc1cdff4ab20efdfba78f3b3525f747 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Fri, 11 Mar 2016 15:55:36 +0800 Subject: [PATCH] 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 Reviewed-by: Feng Tian --- .../Universal/Disk/PartitionDxe/ElTorito.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c index 22384499c5..2af38429dd 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c @@ -1,7 +1,7 @@ /** @file Decode an El Torito formatted CD-ROM -Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials 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 @@ -183,7 +183,7 @@ PartitionInstallElToritoChildHandles ( } SubBlockSize = 512; - SectorCount = Catalog->Boot.SectorCount * (SIZE_2KB / Media->BlockSize); + SectorCount = Catalog->Boot.SectorCount; switch (Catalog->Boot.MediaType) { @@ -233,15 +233,15 @@ PartitionInstallElToritoChildHandles ( // // When the SectorCount < 2, set the Partition as the whole CD. // - if (VolSpaceSize > (Media->LastBlock + 1)) { - CdDev.PartitionSize = (UINT32)(Media->LastBlock - Catalog->Boot.Lba + 1); + if (VolSpaceSize * (SIZE_2KB / Media->BlockSize) > (Media->LastBlock + 1)) { + CdDev.PartitionSize = (UINT32)(Media->LastBlock - Catalog->Boot.Lba * (SIZE_2KB / Media->BlockSize) + 1); } else { - CdDev.PartitionSize = (UINT32)(VolSpaceSize - Catalog->Boot.Lba); + CdDev.PartitionSize = (UINT32)(VolSpaceSize - Catalog->Boot.Lba) * (SIZE_2KB / Media->BlockSize); } } else { CdDev.PartitionSize = DivU64x32 ( MultU64x32 ( - SectorCount, + SectorCount * (SIZE_2KB / Media->BlockSize), SubBlockSize ) + Media->BlockSize - 1, Media->BlockSize @@ -258,7 +258,7 @@ PartitionInstallElToritoChildHandles ( DevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &CdDev, 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, FALSE );