Writing OS code

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Cogman

Lifer
Sep 19, 2000
10,286
147
106
Chris,

You might find this set of articles informative.

https://github.com/0xAX/linux-insides/blob/master/Booting/linux-bootstrap-1.md

which references this document that gets into the nitty gritty of the boot protocol between linux and the bootloader.

https://github.com/torvalds/linux/b...2018e0bd98eb93d973/Documentation/x86/boot.txt

Basically, there is a protocol and a fixed entry point that the loader knows about.

A "format" for the kernel doesn't really matter because the boot loader is just jumping to an agreed upon address after setting up the kernel in memory. It looks like the initial format is bz2 ;)

Does that help answer the question?
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
Yeah, I know what a bootloader does.

But answer me this: to what format do I assemble or compile OS source code?

Flat binary or something else?

That's up to you, really. Now, when control leaves the boot loader and first enters your OS, it will (to my knowledge) simply jump to an address. That means that the first piece of your OS to run must be straightforward, ready to execute 16 bit real mode x86 machine code. I assume this is what you mean by "flat binary". However, your whole OS doesn't have to be this way. Your OS loader can unzip a compressed file (what the linux kernel does), load pieces of the OS from your own custom file format, or whatever you want to do.

If you're really interested in writing your own OS, you should visit http://forum.osdev.org/index.php
 
  • Like
Reactions: mxnerd