[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

svn path=/trunk/; revision=74460
This commit is contained in:
Colin Finck 2017-05-03 14:53:57 +00:00
parent 895f97e0a2
commit 11cbbbb746
3 changed files with 10 additions and 72 deletions

View file

@ -310,10 +310,15 @@ found_drive:
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

View file

@ -575,69 +575,6 @@ PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
}
}
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)
{

View file

@ -100,10 +100,6 @@ BOOLEAN DiskIsDriveRemovable(UCHAR DriveNumber)
return TRUE;
}
extern BOOLEAN
DiskIsCdRomDrive(UCHAR DriveNumber);
BOOLEAN DiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
{
if (*FrldrBootPath)
@ -121,9 +117,9 @@ BOOLEAN DiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size)
/* 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