Skip to content

Commit 2f514a5

Browse files
committed
[FREELDR] Workaround for BIOSes that report unusual geometry for CD-ROMs
This is needed for ISO filesystem driver to work correctly, as it assumes 2048 bytes per sector for CD-ROM media. Happens on 86Box with board `[i430FX] ASUS P/I-P55TP4XE`, Bochs emulator with `01/17/97-i440FX-2A69HV3CC-00` BIOS, and some other real machines. CORE-20640
1 parent f17d904 commit 2f514a5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎boot/freeldr/freeldr/arch/i386/hwdisk.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
9090
GEOMETRY Geometry;
9191
ULONGLONG SectorOffset;
9292
ULONGLONG SectorCount;
93+
static BOOLEAN PrintForce = FALSE;
9394

9495
if (DiskReadBufferSize == 0)
9596
{
@@ -141,6 +142,16 @@ DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
141142
if (!Context)
142143
return ENOMEM;
143144

145+
if (DriveType == CdromController && SectorSize != 2048)
146+
{
147+
/* Workaround for CORE-20640 */
148+
if (!PrintForce)
149+
{
150+
ERR("BIOS reports BytesPerSector = %d for CD-ROM, forcing 2048\n", SectorSize);
151+
PrintForce = TRUE;
152+
}
153+
SectorSize = 2048;
154+
}
144155
Context->DriveNumber = DriveNumber;
145156
Context->IsFloppy = (DriveType == FloppyDiskPeripheral);
146157
Context->SectorSize = SectorSize;

0 commit comments

Comments
 (0)