Page 1 of 1

BIOS boot drive Number in PMode

Posted: Thu Apr 19, 2007 6:42 am
by AJ
Hi All,

I'm currently writing the device manager of my OS which is proving to be a little challenging, but I'll get there! I use GRUB to load the manager as a separate module, so until this point I have *no* disk access in my OS.

I have just detected the floppy disks and was thinking, how can I be sure that the boot drive # passed to me by the BIOS can be correctly interpreted in PMode.

For example, HDDs have bit 7 set, fine. But if someone is using SATA and PATA drives simultaneously, how do I know which drive is 0x80? The same question applies for USB devices...

Cheers,
Adam

Posted: Thu Apr 19, 2007 9:34 am
by Aali
its quite simple, dont rely on the BIOS

it is for this very reason linux needs a root=<device> parameter to boot

the BIOS may not even know about the device you are booting from

if you really _have to_ do this, look at the grub source, it tries to determine bios drive numbers when you run it from within linux

but its still a guessing game at best

Posted: Fri Apr 20, 2007 1:56 am
by AJ
OK, thanks. I'll certainly take a look at the GRUB source anyway...

Posted: Fri Apr 20, 2007 2:30 am
by pcmattman
You can tell GRUB to pass the boot drive number to you.

Posted: Fri Apr 20, 2007 2:43 am
by AJ
Yep - I get that already and then pass it to my device manager. The problem is more making sense of it in protected mode where there may be e.g. more than one type of ATA controller present.

Posted: Fri Apr 20, 2007 2:45 am
by pcmattman
Well, using the Identify Device command could be helpful. If you get the 'Packet device' signature back you know that it's something like a CD and you use the Identify Packet Device command.