Author: cfinck
Date: Wed May 3 14:53:57 2017
New Revision: 74460
URL:
http://svn.reactos.org/svn/reactos?rev=74460&view=rev
Log:
[FREELDR]
Set BootPartition (DH) to 0xFF in isoboot.S when booting from CD.
Then check for that 0xFF value in FreeLdr to unambiguously detect CD booting instead of
using BIOS functions (which don't work reliably on broken BIOSes) or checking for an
MBR (which doesn't work on hybrid ISOs).
CORE-12692
Modified:
trunk/reactos/boot/freeldr/bootsect/isoboot.S
trunk/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c
trunk/reactos/boot/freeldr/freeldr/disk/disk.c
Modified: trunk/reactos/boot/freeldr/bootsect/isoboot.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/bootsect/isob…
==============================================================================
--- trunk/reactos/boot/freeldr/bootsect/isoboot.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/bootsect/isoboot.S [iso-8859-1] Wed May 3 14:53:57 2017
@@ -310,10 +310,15 @@
mov cx, HEX(FFFF)
call getfssec
- // Fetch our stored drive number to DL and set the boot partition to 0 in DH.
- mov dl, byte ptr ds:[DriveNumber]
- mov dh, 0
-
+ // Pass two parameters to SETUPLDR:
+ // DL = BIOS Drive Number
+ // DH = Boot Partition (0 for HDD booting in hybrid mode, FFh for CD booting)
+ movzx dx, byte ptr ds:[DriveNumber]
+ cmp word ptr ds:[GetlinsecPtr], offset getlinsec_ebios
+ je .jump_to_setupldr
+ mov dh, HEX(FF)
+
+.jump_to_setupldr:
// Transfer execution to the bootloader.
ljmp16 0, FREELDR_BASE
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/pcdisk.c [iso-8859-1] Wed May 3 14:53:57
2017
@@ -575,69 +575,6 @@
}
}
-
-static BOOLEAN
-FallbackDiskIsCdRomDrive(UCHAR DriveNumber)
-{
- MASTER_BOOT_RECORD MasterBootRecord;
-
- TRACE("FallbackDiskIsCdRomDrive(0x%x)\n", DriveNumber);
-
- /* CD-ROM drive numbers are always > 0x80 */
- if (DriveNumber <= 0x80)
- return FALSE;
-
- /*
- * We suppose that a CD-ROM does not have a MBR
- * (not always true: example of the Hybrid USB-ISOs).
- */
- return !DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord);
-}
-
-BOOLEAN DiskIsCdRomDrive(UCHAR DriveNumber)
-{
- REGS RegsIn, RegsOut;
- PI386_CDROM_SPEC_PACKET Packet = (PI386_CDROM_SPEC_PACKET)(BIOSCALLBUFFER);
-
- TRACE("DiskIsCdRomDrive(0x%x)\n", DriveNumber);
-
- /* CD-ROM drive numbers are always > 0x80 */
- if (DriveNumber <= 0x80)
- return FALSE;
-
- /* Setup disk address packet */
- RtlZeroMemory(Packet, sizeof(*Packet));
- Packet->PacketSize = sizeof(*Packet);
-
- /*
- * BIOS Int 13h, function 4B01h - Bootable CD-ROM - Get Disk Emulation Status
- * AX = 4B01h
- * DL = drive number
- * DS:SI -> empty specification packet
- * Return:
- * CF clear if successful
- * CF set on error
- * AX = return codes
- * DS:SI specification packet filled
- */
- RegsIn.w.ax = 0x4B01;
- RegsIn.b.dl = DriveNumber;
- RegsIn.x.ds = BIOSCALLBUFSEGMENT; // DS:SI -> specification packet
- RegsIn.w.si = BIOSCALLBUFOFFSET;
-
- Int386(0x13, &RegsIn, &RegsOut);
-
- // return (INT386_SUCCESS(RegsOut) && (Packet->DriveNumber ==
DriveNumber));
- /*
- * If the simple test failed, try to use the fallback code,
- * but we can be on *very* thin ice.
- */
- if (!INT386_SUCCESS(RegsOut) || (Packet->DriveNumber != DriveNumber))
- return FallbackDiskIsCdRomDrive(DriveNumber);
- else
- return TRUE;
-}
-
BOOLEAN
PcDiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
{
Modified: trunk/reactos/boot/freeldr/freeldr/disk/disk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/disk/disk.c [iso-8859-1] Wed May 3 14:53:57 2017
@@ -100,10 +100,6 @@
return TRUE;
}
-
-extern BOOLEAN
-DiskIsCdRomDrive(UCHAR DriveNumber);
-
BOOLEAN DiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
{
if (*FrldrBootPath)
@@ -121,9 +117,9 @@
/* This is a floppy */
sprintf(FrldrBootPath, "multi(0)disk(0)fdisk(%u)", FrldrBootDrive);
}
- else if (DiskIsCdRomDrive(FrldrBootDrive))
+ else if (FrldrBootPartition == 0xFF)
{
- /* This is a CD-ROM drive */
+ /* Boot Partition 0xFF is the magic value that indicates booting from CD-ROM (see
isoboot.S) */
sprintf(FrldrBootPath, "multi(0)disk(0)cdrom(%u)", FrldrBootDrive -
0x80);
}
else