What to do after boot loader tutorials

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
longbeard71
Posts: 1
Joined: Sun Nov 10, 2013 12:48 pm

What to do after boot loader tutorials

Post 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!
mrstobbe
Member
Member
Posts: 62
Joined: Fri Nov 08, 2013 7:40 pm

Re: What to do after boot loader tutorials

Post 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
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:

Re: What to do after boot loader tutorials

Post by Combuster »

"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 ]
Post Reply