Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to retrieve the device ID in which the BIOS found and loaded a boot sector?

I know that the BIOS goes through connected storage devices (floppy disks, CDs, hard drives … etc) in the order it is configured to (which can be changed in the BIOS settings), looking for the magic 16-bit value (0xAA55) at the end of the first sector of each, and upon finding one it loads (what just became) the boot sector and calls it.

Let’s name the device containing the loaded boot sector X. My question is: Instead of looping through all devices, can you identify X and use the BIOS’ disk interrupt function to read from it without having to test every connected device? For instance, does BIOS store X’s ID somewhere?

Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

P.S. I’m working on an IA-32 machine emulated using BOCHS, I’m always loading from floppy disk #1 so I can hardcode the reading from it, but for the sake of writing clean code and learning I’m asking. I acknowledge that testing all devices is definitely practical.

>Solution :

When the BIOS passes control to the boot loader it stores "BIOS device ID" in the DL register, so boot loader can just use the device ID it was told to use for all subsequent BIOS functions.

The main problem is that "BIOS device ID" is relatively useless after early boot (after the OS starts using its own disk drivers and stops using BIOS functions); because there’s no easy way to determine which device happened to be given which "BIOS device ID"; especially for cases like "RAID 1 mirror" where you might have 2 mostly identical hard drives with mostly identical contents.

I acknowledge that testing all devices is definitely practical.

Heh, no. Install 2 separate copies of the OS on 2 different hard drives (so that you’ve got 2 boot loaders, one for each copy of the OS) and it becomes impossible for "test all devices" to tell the difference between the OS you booted and the OS you didn’t boot.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading