From 5f783c4e2d6dd11d366ffd9a8636a03b5819cd2f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 27 Apr 2010 22:12:11 +0000 Subject: [PATCH] [FREELDR] - Set the partition count to 0 for a floppy drive so it can be told apart from a cd-rom drive - Add a last-chance sector size detection algorithm based on the partition number - Add the same detection code to the xbox code too (it is essentially the same as what was already there just with more comments) - Change DiskNormalizeSystemPath so it doesn't try to "normalize" a floppy boot path - Fixes bug #5233 svn path=/trunk/; revision=47051 --- .../boot/freeldr/freeldr/arch/i386/hardware.c | 18 +++++++++++++++++- .../boot/freeldr/freeldr/arch/i386/xboxhw.c | 15 ++++++++++++++- reactos/boot/freeldr/freeldr/disk/disk.c | 2 +- reactos/boot/freeldr/freeldr/reactos/arcname.c | 2 +- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c index 1dff167c987..97577aa020c 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c @@ -452,7 +452,23 @@ static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) SectorCount = Geometry.Sectors; } else - return EINVAL; + { + DPRINTM(DPRINT_HWDETECT, "Using legacy sector size detection\n"); + + /* Fall back to legacy detection */ + if (DrivePartition == 0xff) + { + /* This is a CD-ROM device */ + SectorSize = 2048; + } + else + { + /* This is either a floppy disk device (DrivePartition == 0) or + * a hard disk device (DrivePartition != 0 && DrivePartition != 0xFF) but + * it doesn't matter which one because they both have 512 bytes per sector */ + SectorSize = 512; + } + } if (DrivePartition != 0xff && DrivePartition != 0) { diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c index 5c7680b17ae..ff325b3dd49 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c @@ -138,7 +138,20 @@ static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) if (!DissectArcPath(Path, FileName, &DriveNumber, &DrivePartition)) return EINVAL; - SectorSize = (DrivePartition == 0xff ? 2048 : 512); + + if (DrivePartition == 0xff) + { + /* This is a CD-ROM device */ + SectorSize = 2048; + } + else + { + /* This is either a floppy disk device (DrivePartition == 0) or + * a hard disk device (DrivePartition != 0 && DrivePartition != 0xFF) but + * it doesn't matter which one because they both have 512 bytes per sector */ + SectorSize = 512; + } + if (DrivePartition != 0xff && DrivePartition != 0) { if (!XboxDiskGetPartitionEntry(DriveNumber, DrivePartition, &PartitionTableEntry)) diff --git a/reactos/boot/freeldr/freeldr/disk/disk.c b/reactos/boot/freeldr/freeldr/disk/disk.c index 16ee1be7ad9..a5a65103aac 100644 --- a/reactos/boot/freeldr/freeldr/disk/disk.c +++ b/reactos/boot/freeldr/freeldr/disk/disk.c @@ -136,7 +136,7 @@ DiskNormalizeSystemPath(char *SystemPath, unsigned Size) return FALSE; } - if (0 != PartitionNumber) + if (0 != PartitionNumber || DriveNumber < 0x80) { return TRUE; } diff --git a/reactos/boot/freeldr/freeldr/reactos/arcname.c b/reactos/boot/freeldr/freeldr/reactos/arcname.c index 3ca69fadb51..3fe1fc6bd26 100644 --- a/reactos/boot/freeldr/freeldr/reactos/arcname.c +++ b/reactos/boot/freeldr/freeldr/reactos/arcname.c @@ -60,7 +60,7 @@ BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, ULONG* BootDrive, ULONG* B if (p == NULL) return FALSE; p++; - *BootPartition = 0xff; + *BootPartition = 0; } else if (_strnicmp(p, "cdrom(", 6) == 0) {