Page 1 of 1

BIOS disk IDs

Posted: Sat Mar 19, 2016 3:13 pm
by velikiyv4
I've been googling this for a long time and I'm surprised I haven't found a solution but I haven't come across a full list of BIOS disk identifiers. I mean those ones for INT 13h, like 0x80 - First HDD. Could anybody give me a complete table of them?
P.S. Sorry for my English (I'm from Russia).

Re: BIOS disk IDs

Posted: Sat Mar 19, 2016 5:44 pm
by Nable
velikiyv4 wrote:I mean those ones for INT 13h, like 0x80 - First HDD. Could anybody give me a complete table of them?
They are dynamically assigned by BIOS every time when PC boots, so there can't be any static list. You can ask BIOS about accessible IDs (sometimes you can even get additional information via EDD BIOS services) but IMHO these numbers should be used only in bootloader (that receives boot drive ID from BIOS and should just use this number).

Re: BIOS disk IDs

Posted: Sun Mar 20, 2016 4:45 am
by velikiyv4
Nable wrote:
velikiyv4 wrote:I mean those ones for INT 13h, like 0x80 - First HDD. Could anybody give me a complete table of them?
They are dynamically assigned by BIOS every time when PC boots, so there can't be any static list. You can ask BIOS about accessible IDs (sometimes you can even get additional information via EDD BIOS services) but IMHO these numbers should be used only in bootloader (that receives boot drive ID from BIOS and should just use this number).
Well then, if I want to determine how to read a sector from the boot drive, how do I know what type of drive it is? AFAIK, BIOS only gives me such an ID so the only way to read it is to use INT 13h. But after I switch to protected mode and/or set my own IDT I can't do that anymore. So how do I know the type of the boot drive so I can read it?

Re: BIOS disk IDs

Posted: Sun Mar 20, 2016 10:08 am
by bontanu
You detect them ;)

Send an Identify command to IDE HDD's for example.
There are similar methods for CD-ROM's USB disks, SATA etc

Re: BIOS disk IDs

Posted: Sun Mar 20, 2016 10:08 am
by Nable
Early stage of bootloader should use this number and int 0x13 to load modules for next stage (that setups protected mode and works with native drivers) or to load OS kernel and its modules directly. Then your kernel (that works in protected or long mode) setups native drivers, redetects connected devices on it's own and mounts filesystems. Then boot device can be determined by some disk signatures or configuration files. Note that boot device that is accessed via 0x13 may be a virtual one, e.g. when you are booting from network or emulated floppy (such emulation is often used to boot legacy OSes from CDs and USB sticks).

Re: BIOS disk IDs

Posted: Sun Mar 20, 2016 11:09 am
by SpyderTL
The short answer is that there is no link between the BIOS drive number and the physical boot device. You'll have to come up with a way of finding the boot device after you've switched to 32-bit mode.

Or, you can just load everything you need in your boot loader before switching to 32-bit mode. If you need to load anything above 1MB, you will need to load it under 1MB first, then switch to 32-bit mode, then copy it above 1MB, and then switch back to 16-bit mode. Or you can use something like unreal mode.