fdisk
fdisk copied to clipboard
BOOTNORM.ASM: Boot failure because broken BIOS trashes drive number in DL
Ben Russel wrote to the FreeDOS developer mailinglist:
This highlights a specific case where the "read error while reading drive" message will pop up on boot.
I have an HP Brio 8314 which has this problem. If you don't have this exact machine, 86Box has a machine with the same problem: Slot 1, "[i440LX] Micronics Spitfire". It is not a hardware bug, it is a BIOS bug.
For some reason, under some unknown circumstances, certain releases of PhoenixBIOS 4.0 Release 6.0 (with a copyright extending to 1997) will incorrectly set DL to 0x00 before jumping into the MBR code. This results in the MBR loader trying to load a partition boot sector from the first floppy drive.
The patch I am using right now is roughly equivalent to the following DEBUG patch (MBR extracted via FDISK /SMBR using the 1.3 Live CD release and the BOOTNORM loader):
debug boot.mbr
a11d
jmp 1fe0:7d10
a210
mov dl, 80
jmp 122
w
q
However, a proper fix for this should be something like this, executed before one attempts to use INT 0x13:
;; Work around a bug in 1997 PhoenixBIOS 4.0 Release 6.0,
;; where DL can be erroneously set to 0x00 (first floppy drive)
cmp dl, 0x00
jne nodlbug
mov dl, 0x80
nodlbug:
(I release all code in this email into the public domain.)
I'd need to do further analysis to see how a second hard drive behaves, but this will cover the most common case.
Two further points of note:
1. In the MS-DOS 4.00 sources, the drive number is loaded from the MBR in such a way that it gets forced to 0x80. But that makes it effectively impossible to boot from a different drive number.
2. The PnP BIOS specifications require DL to be set to the boot drive, and this BIOS does have PnP support. This confirms that the behaviour from the BIOS is a bug.
Regards,
Ben R
P.S. If you have a later version of FreeDOS FDISK and you used an earlier version with the /SMBR switch, *DO NOT USE THE /LOADMBR SWITCH!* You will lose all partitioning information and probably have to wipe your disk and reinstall everything. Use /LOADIPL in that case instead! (or the /AMBR alias, which is what you would have been using before.) Yes, I learnt this from experience, unfortunately.
The fix proposed by Ben looks ok to me. FDISK uses 0x80+ anyway for its disk IO. So if a drive is not exposed by the BIOS through drive number 0x80+, FDISK does not see it anyway. Therefore I think it is save to set DL to 0x80 in BOOTNORM.ASM, if it is set to zero by the BIOS.
implemented by v1.3.15