C++ Kernel - Understood but now what??

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
brwarn
Posts: 3
Joined: Sat Sep 01, 2007 9:33 pm

C++ Kernel - Understood but now what??

Post 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.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
brwarn
Posts: 3
Joined: Sat Sep 01, 2007 9:33 pm

Post 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
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
brwarn
Posts: 3
Joined: Sat Sep 01, 2007 9:33 pm

Post 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)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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!
Post Reply