Page 1 of 1

C++ Kernel - Understood but now what??

Posted: Sat Sep 01, 2007 9:55 pm
by brwarn
I read the following tutorial on C++ Kernels here and I understand everything (except the part about setting up global variables, but I'll learn that later).
This kernel seems simple enough but that is about the extent of my knowlege. I am new to OS dev (tried to read some tutorials) but many of them are difficult to understand and overall it's hard to figure out just where everything fits together.

Basically I would like to understand how to get from nothing(where I am now) to that kernel operating. I read some tutorials on bootloaders but none which got to the point of loading a kernel.

So I guess what I really need is:
How to I create a basic bootsector/loader
How do I use it to load a C++ kernel (as in above tut)
Anything else needed inbetween.

Posted: Sat Sep 01, 2007 10:04 pm
by neon
Check out my site:

OS Development Series

It covers creating a basic 2 stage bootloader from scratch, and loads a basic 32bit kernel; specifically meant for beginners to systems programming.

Please note that it is still being worked on. Im not quite up to the C/C++ Kernel yet, but it sets up the system so that one can.

If you wanted to, you can also use an existing bootloader, such as GRUB, to boot your C++ Kernel. This way you can start at the Kernel, and not worry about the ugly bootloader code.

Posted: Sat Sep 01, 2007 10:22 pm
by brwarn
GRUB sounds like it would save a lot of work, is there any pros/cons of using GRUB vs. making my own bootloader.

Also, any good tutorials of using GRUB in my situation

Posted: Sat Sep 01, 2007 10:37 pm
by frank
Unless you are really good with assembly and know how to read and write to disks without an OS present I would recommend using GRUB. This is coming from a person who spent 3 weeks debugging his kernel only to find that the boot loader was overwriting a portion of the kernel code with its stack. GRUB has thousands of hours of testing and debugging and will save you a lot of trouble.

EDIT: Although you may want to write a small hello world boot loader just for the experience. But don't spend too much time on it.

Posted: Sat Sep 01, 2007 10:57 pm
by brwarn
Thanks, I'll take your advice and use GRUB (but play around with some simple bootloader things "ie. Hello World" just for some practice and testing)

Posted: Sun Sep 02, 2007 3:05 am
by JamesM
GRUB is the way forward. There are actually much better C tutorials out there than C++, so I recommend that you firstly get hello,world working in C, then port straight to C++ (it's not a lot of work at that stage). Might save you some grief.

If you've tried the barebones and Bran's tutorials, maybe these might help:

http://www.jamesmolloy.co.uk
EDIT: these use GRUB, by the way, and talk you through how to use it properly.

They're 'basic-get-me-started-quick' tutorials I cooked up in some free time at work. Haven't got too far - up to the GDT and IDT, but it'll get you going. Sample code provided of course.

Once you have a C kernel up (that can print to screen, for example), read the C++ barebones article on the wiki and implement what it says.

Happy coding!