flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Boot process

Author
Thread Post new topic Reply to topic
Platone



Joined: 09 Jun 2005
Posts: 6
Platone 18 Jun 2005, 19:08
Who can explane me (eventually with code) what is the boot process and what a bootloader must do?

Tnks
Post 18 Jun 2005, 19:08
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 18 Jun 2005, 19:44
The boot process is pretty simple when it comes down to it. The computer starts (in 16-bit real mode), then passes control to the BIOS. The BIOS then looks for a bootable disk (the exact order varies by BIOS and can often be configured). Normally it'll try a floppy first if you have one, then a CD-ROM, and finally one or more of the hard drives. (Some BIOSes can also boot from a network)

The BIOS will load one sector from the disk (to 0x7c00), checks to see if the last two bytes are 0x55 followed by 0xAA. If they are, the disk is assumed to be bootable. Control is passed to the loaded sector.

This first sector is responsible for loading the rest of the operating system. In my OS, it loads the next 8k from the boot floppy, enables the A20 line, then sets up protected mode. It relocates the 8k it loaded to 0x110000. Finally it jumps to 0x110000, where the kernel takes over.

The code for my boot loader is at http://retro.tunes.org/repos/retroforth/_darcs/current/native/source/raw.asm

It's worth noting that the boot sequence once the first sector gets control is specific to the operating system, so there's no standard beyond that.
Post 18 Jun 2005, 19:44
View user's profile Send private message Visit poster's website Reply with quote
Platone



Joined: 09 Jun 2005
Posts: 6
Platone 18 Jun 2005, 20:09
native.bin, in your code, is the kernel to load?
Post 18 Jun 2005, 20:09
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 18 Jun 2005, 20:32
Yes. (My boot sector uses a raw floppy (one that's not formatted), so I compile the kernel to a file named native.bin and include it immediately after the first sector.)
Post 18 Jun 2005, 20:32
View user's profile Send private message Visit poster's website Reply with quote
Platone



Joined: 09 Jun 2005
Posts: 6
Platone 19 Jun 2005, 08:07
well....I write the kernel and compile it as 'native.bin', and compile the bootloader...then I'll put the 2 bin into the floppy?? (for raw... can I use rawwritewin, can't I?)...that's right?
Post 19 Jun 2005, 08:07
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 19 Jun 2005, 13:09
The raw.bin will include the native.bin file inside itself. So you only have to put raw.bin on the floppy using rawwritewin.
Post 19 Jun 2005, 13:09
View user's profile Send private message Visit poster's website Reply with quote
Platone



Joined: 09 Jun 2005
Posts: 6
Platone 19 Jun 2005, 13:54
tnks for the help Wink
Post 19 Jun 2005, 13:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.