Page 1 of 1

What to do after boot loader tutorials

Posted: Sun Nov 10, 2013 1:54 pm
by longbeard71
Hello. I have browsed the internet, and have found many tutorials about how to make a boot loader.
I successfully followed a few tutorials, and managed to get a basic boot loader that would respond to a couple basic commands like help. I used dd to write the boot loader to the first 512 bytes of a USB flash drive. It successfully booted.
My question is how do I program a boot loader that can load a kernel. If I have the boot loader on the first 512 bytes, and the rest of the assembly directly after it on a USB flash drive, how do I load the rest of it, then jump to it? Are there any tutorials that would show how to do this?
Thanks!

Re: What to do after boot loader tutorials

Posted: Sun Nov 10, 2013 7:35 pm
by mrstobbe
A 1-sector first-stage bootloader is usually highly contextual to it's purpose. For example, a bootsector specifically for a FAT12 volume/floppy/flash drive does nothing more than try and find the stage2 loader/kernel, load it up, and transfer control to it. You can't do much more in 512 bytes.

You don't want to do what a lot of tutorials say and just hard-copy your kernel into the next sectors. Use the file system itself.

This means that writing a bootsector is like writing an super-minimal, self-contained, file system driver. If you want to write your own then pick a file system you want to try first (FAT is undoubtedly the easiest) and start there. No user input or pointless "loading" messages... just try to find the stage2/kernel, load it into memory, and transfer control. You'll find out quickly that those 512 bytes disappear fast.

After that, you can do anything.

See also:
http://www.brokenthorn.com/Resources/OSDev3.html

Re: What to do after boot loader tutorials

Posted: Mon Nov 11, 2013 4:54 am
by Combuster