BIOS boot drive Number in PMode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

BIOS boot drive Number in PMode

Post 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
Aali
Member
Member
Posts: 58
Joined: Sat Apr 14, 2007 12:13 pm

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

OK, thanks. I'll certainly take a look at the GRUB source anyway...
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

You can tell GRUB to pass the boot drive number to you.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
Post Reply