How to get the boot drive?

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
EvolSoft
Posts: 9
Joined: Mon Dec 07, 2015 3:34 am
Libera.chat IRC: evolsoft

How to get the boot drive?

Post by EvolSoft »

Hi all,
How can we get the BIOS drive (int 13h drive) where the system was booted from in real mode?
For example if we boot the system from the first floppy unit it should be 0x00 and if we boot the system from the first hard drive it should be 0x80.
Thanks in advance :)
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: How to get the boot drive?

Post by FallenAvatar »

I was going to just link you to the wiki and tell you to find the answer yourself, but it is a bit buried.

The solution you need is outlined here: http://wiki.osdev.org/System_Initializa ... ronment.22

Specifically, when the BIOS hands control to your boot sector, the drive number you were booted from is in dl. NOTE: If you did not receive control for the BIOS and instead got control from a bootloader (like GRUB) dl may or may not contain the correct value. You should check the documentation for whatever bootloader you are using in this case.

- Monk
Post Reply