Boot question

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
crazygray1
Member
Member
Posts: 168
Joined: Thu Nov 22, 2007 7:18 pm
Location: USA,Hawaii,Honolulu(Seriously)

Boot question

Post by crazygray1 »

When the computer starts up what is the drive number of the boot drive?
Codname: Cipher
Working On: Design Doc(CFFS file system)
User avatar
Combuster
Member
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:

Post by Combuster »

DL
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Boot question

Post by Brendan »

Hi,
crazygray1 wrote:When the computer starts up what is the drive number of the boot drive?
There is no set drive number - it could be the first floppy, the first hard drive, a CD-ROM (with floppy emulation, hard disk emulation or no emulation), a network card, flash memory/USB, etc.

Where possible (e.g. when the BIOS boots some from some sort of storage device that actually has a drive number), the BIOS tells the boot loader which drive number the storage device is (or which drive number the emulated storage device is) in the DL register.

Often the drive number is either 0x00 (first floppy drive or an emulated floppy drive) or 0x80 (first hard drive or an emulated hard drive). Even for hard drives and floppy drives this isn't always the case - for example, a boot manager could boot (chain load) the second floppy drive and tell the boot loader it booted from drive 0x01.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
crazygray1
Member
Member
Posts: 168
Joined: Thu Nov 22, 2007 7:18 pm
Location: USA,Hawaii,Honolulu(Seriously)

Post by crazygray1 »

So I can have something like this at the beginning of my code?

Code: Select all

movb %dl,(BOOTDRIVE)
Codname: Cipher
Working On: Design Doc(CFFS file system)
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

Yep.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply