21

Could someone guide me on what path/steps to take to create a simple bootable hello world program? I have the basic knowledge of C/C++.

My aim is to create a very simple OS.

I would like as much relevant links to references and samples as possible.

Shawn Mclean
  • 56,733
  • 95
  • 279
  • 406
  • 3
    Search for the term bootloader. Tons of resources available online. See: http://www.codeproject.com/KB/tips/boot-loader.aspx – dirkgently Feb 03 '10 at 18:06
  • I think the big question here would be "on what processor?" In most cases, I'd suggest looking at a bootloader for that processor to get an idea -- and yes, you will be writing some assembler, your basic output routines, etc. if you want the program to truly stand alone. – Arthur Shipkowski Feb 03 '10 at 18:06
  • Somewhat related http://stackoverflow.com/questions/2145501/writing-an-operating-system-in-c/2145556#2145556 – sud03r Feb 03 '10 at 18:18
  • 1
    No matter how many very's you put in front of it, even a simple OS is going to take time... especially when you want to start talking to the keyboard. :-) – Frank Krueger Feb 03 '10 at 18:25
  • @Frank Heck, it'd get hard just trying to print something to the screen. You'd need some sort of display driver/framebuffer driver AFAIK. – jonescb Feb 03 '10 at 19:55

2 Answers2

9

See this. It's a tutorial for a very basic boot loader. It doesn't have much to do with C/C++, but it has some really good information on the basic building blocks of a bootloader.

If you're really curious about the building blocks, there are more in-depth resources in the form of textbooks. This tutorial, for instance, doesn't explain why the boot loader must end with 55 AA. In addition, it's relatively narrow.

ramblinjan
  • 6,578
  • 3
  • 30
  • 38
sud03r
  • 19,109
  • 16
  • 77
  • 96
  • 1
    Thanks for plugging OSdever.net. If anyone has anyone questions try forums.osdever.net. We're pretty good at helping eachother out ;) – Brenden Aug 24 '11 at 19:02
  • 1
    This answer isn't really in the spirit of SO. I'm late, I know. – corazza Feb 26 '13 at 11:31
0

You want to build a statically linked binary (no ld.so involved), and you start it by jumping to its entry point. The entry point is usually the start of the .text section. Maye run objdump --section-headers image on it to find out its adress.

If you're trying to run on an embedded device, check out how the kernel of an embedded OS is built and booted. For example, see how U-Boot brings up an Ångström linux based system.

doppelfish
  • 963
  • 7
  • 18