Hi all. I'm trying to load my kernel reading filesystem and I don't know which disk should I read.
Does anybody have any idea how can I get the device which was booted? If it was HDD or floppy, primary or secondary bus, master or slave....
I don't think that reading first sector on each drive and then comparing it with actual bootsector would be accurate (there can be same OS on two HDDs).
[SOLVED] Get device booted
[SOLVED] Get device booted
Last edited by HugeCode on Tue Apr 16, 2013 9:49 am, edited 1 time in total.
Re: Get device booted
BIOS gives the bootloader information about boot device in DL upon giving it control.
It's up to bootloader to save it. iirc GRUB puts it into boot_device variable somewhere in multiboot info block.
It's up to bootloader to save it. iirc GRUB puts it into boot_device variable somewhere in multiboot info block.
Learn to read.
Re: Get device booted
Thanks... BTW does the DL=3 mean primary bus slave, or secondary bus master?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Get device booted
No, it most likely means a bug.
Re: Get device booted
Unless you are booting from the third floppy disk on the system.Combuster wrote:No, it most likely means a bug.
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
If you're new, check this out.
Re: Get device booted
Oh uh oh. What about DL=0x80/0x81? Master/Slave or Primary/Secondary bus?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Get device booted
I've actually seen drive 0x80 to be:
- ATA primary master
- ATA primary slave
- ATA secondary master
- A bootable CD
- SCSI drive
- SATA drive (various channels)
- All other options I haven't seen with my own eyes.
I've also seen fixed drives changing numbers and/or disappearing from your system when booting from removable media, and some hard drives never being given a number at all.
You get the idea yet?
If you're in an emulator with just your OS, you can bet on it that a harddisk boot will give DL=0x80 for that harddisk, and floppy boots give 0x00. On real machines, guessing is the best you can do.
- ATA primary master
- ATA primary slave
- ATA secondary master
- A bootable CD
- SCSI drive
- SATA drive (various channels)
- All other options I haven't seen with my own eyes.
I've also seen fixed drives changing numbers and/or disappearing from your system when booting from removable media, and some hard drives never being given a number at all.
You get the idea yet?
If you're in an emulator with just your OS, you can bet on it that a harddisk boot will give DL=0x80 for that harddisk, and floppy boots give 0x00. On real machines, guessing is the best you can do.