What are some of the things a boot sector should do before it loads the kernel?
~Raedius
What types of things should my boot sector do?
Re:What types of things should my boot sector do?
The bootsector is the first sector, on the first track, on the first head, on a disk. For bios, a valid bootsector must have a 0AA55h at offset 510.
You place your bootloader in the bootsector, which is executed by bios at boot time. A bootloader typically enables the A20line, converts from real mode to protected mode, loads your Kernel.
http://www.nondot.org/~sabre/os/articles/TheBootProcess/ is a good link explaining all this.
You place your bootloader in the bootsector, which is executed by bios at boot time. A bootloader typically enables the A20line, converts from real mode to protected mode, loads your Kernel.
http://www.nondot.org/~sabre/os/articles/TheBootProcess/ is a good link explaining all this.
Re:What types of things should my boot sector do?
Better: load a small second-stage loader from the disk, which still runs in real mode but can be longer than 512 bytes. That can then set up the system the way the kernel likes it, load the kernel, switch to protected mode, and continue booting the system.
Re:What types of things should my boot sector do?
you can do pretty much what ever you want. In the boot sector i am working on, I have built in a little shell with a few basic commands, then it will earch the drive for your a file name you enter and then load it. obviously it wont fit into the first 512 bytes so it will have to be a 2 stage loader.
Re:What types of things should my boot sector do?
Some things you could try to shoehorn in:
A20 enable
386+ processor detection
PIC remapping
A minimal GDT and pmode switch (You can load the real GDT later whilst inside pmode)
Vesa detection and default video mode setting.
Loading of your second stage from a filesystem.
Moving your second stage to where you want it in ram (Unless you can load it there straightaway)
If elf format second stage, perform the relocation on your loaded kernel (This will eat space, and ain't for the faint hearted).
But remember, you have 510 bytes to work in. To put that in context this small post (In ASCII chars) would not fit into the boot sector .
Curufir
A20 enable
386+ processor detection
PIC remapping
A minimal GDT and pmode switch (You can load the real GDT later whilst inside pmode)
Vesa detection and default video mode setting.
Loading of your second stage from a filesystem.
Moving your second stage to where you want it in ram (Unless you can load it there straightaway)
If elf format second stage, perform the relocation on your loaded kernel (This will eat space, and ain't for the faint hearted).
But remember, you have 510 bytes to work in. To put that in context this small post (In ASCII chars) would not fit into the boot sector .
Curufir
Re:What types of things should my boot sector do?
My recommendation - and my plan for LoIS - is to concentrate on file system support first, and then once you are sure you can load a kernel file (or at least a second stage loader). This is an aspect of booting too many OS coders don't consider beforehand, and it often costs them time later when they have to re-write their loading function to accomodate the requirements of a file system (esp. if it is a FAT12 or FAT16 file system, both of which have very specific structures that allow very little in the way of modification). Being able to use you file system is a higher priority than any of the other functions, and one of the hardest parts to get right.
Once you are sure that you can work with the file system and not mangle it you can try to fit an A20 Line activation function and perhaps simple p-mode switch into the boot loader. However, given space considerations, it is more likely that these will need to be implemented in the second stage loader. Keep in imnd that you will probably want to be able to se more than one file system, so tying your loading procedure too tightly to any one of them is a Bad Thing. This is another reason to use a two-stage loader - the second stage can be more general, and less fixed on the specific details of the file system.
You may also want to give some thought to a disk formatting and file-system building utility, like the DOS [tt]format[/tt] and [tt]sys[/t], or the Unix [tt]mkfs[/tt](1). While a difficult project, this will save you a lot of hassle very quickly.
Once you are sure that you can work with the file system and not mangle it you can try to fit an A20 Line activation function and perhaps simple p-mode switch into the boot loader. However, given space considerations, it is more likely that these will need to be implemented in the second stage loader. Keep in imnd that you will probably want to be able to se more than one file system, so tying your loading procedure too tightly to any one of them is a Bad Thing. This is another reason to use a two-stage loader - the second stage can be more general, and less fixed on the specific details of the file system.
You may also want to give some thought to a disk formatting and file-system building utility, like the DOS [tt]format[/tt] and [tt]sys[/t], or the Unix [tt]mkfs[/tt](1). While a difficult project, this will save you a lot of hassle very quickly.
Re:What types of things should my boot sector do?
Hey,
I am making a second stage loader, i got my bootsector to load the second sector of a disk (the second stage loader) How do i jump to it in real mode??
Could somebody please show some example code, i dont this it is very hard, but i dont know assembler.
NOTE: I use nasm.
Ciao
I am making a second stage loader, i got my bootsector to load the second sector of a disk (the second stage loader) How do i jump to it in real mode??
Could somebody please show some example code, i dont this it is very hard, but i dont know assembler.
NOTE: I use nasm.
Ciao