Example OS written in C++??

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
User avatar
Scalpel
Posts: 15
Joined: Sat Dec 30, 2006 8:35 am
Location: Oslo, Norway

Example OS written in C++??

Post by Scalpel »

Are there any OS's written in C++ available for study somewhere? Any of the OSDev members written their OS in C++, with available sourcecode?

I've gotten my C++ kernel booting, and can perform simple text-to-screen operations, but am trying to determine which part I should focus on next. Memory management? Write a C++ library, f.instance string functions?

All help appreciated!
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

There is a a project called UnixLite that is a Unix type operating system with binary compatibility with Linux. It can even run a small web browser, and some unix utilities. (bash, gcc, etc.) Moreover, it's GPL and written in C++.
C8H10N4O2 | #446691 | Trust the nodes.
INF1n1t
Member
Member
Posts: 60
Joined: Fri Dec 22, 2006 5:32 pm
Location: Somewhere Down...

Re: Example OS written in C++??

Post by INF1n1t »

Scalpel wrote:Are there any OS's written in C++ available for study somewhere? Any of the OSDev members written their OS in C++, with available sourcecode?

I've gotten my C++ kernel booting, and can perform simple text-to-screen operations, but am trying to determine which part I should focus on next. Memory management? Write a C++ library, f.instance string functions?

All help appreciated!
I wrote my boot loader, which enters pmode (32 Bit) and does a far jump to the entry point of the kernel.bin. Now I'm gonna set up the compiler and linker to produce pure binary files. And after that I'm focusing right on the memory managment.
I think you should focus on the memory managment ;)
I think, I have problems with Bochs. The biggest one: Bochs hates me!
User avatar
Scalpel
Posts: 15
Joined: Sat Dec 30, 2006 8:35 am
Location: Oslo, Norway

Post by Scalpel »

Hmm, I'm thinking that perhaps some sort of minimal error handling needs to come first. Now the kernel crashes and burns easily. A simple

Code: Select all

int i = 5 / 0; //Division by Zero
causes the computer to reboot.

I also tried a simple memcpy library function (this one), but that crashed the kernel as well.

So exception handling is first priority. But then I probably need to write some basic library routines first anyway. Right now I've got squat. Not even a printf , malloc or strcpy. I guess I need some of those when writing an exception handler?

Any good documentation for writing exception handlers anywhere?
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

I suggest you work on a printf function first; even before memory management. This makes debugging much easier. However, in C++ you don't need to write a printf function. (Which isn't very fun...) Instead, you can just make something like cout, which is much funner to make. :D
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
Scalpel
Posts: 15
Joined: Sat Dec 30, 2006 8:35 am
Location: Oslo, Norway

Post by Scalpel »

Alboin wrote:I suggest you work on a printf function first; even before memory management. This makes debugging much easier. However, in C++ you don't need to write a printf function. (Which isn't very fun...) Instead, you can just make something like cout, which is much funner to make. :D
I've got a Video class with a function Video.write(char*), from David Stouts tutorial over at Bona Fide. I am able to write out strings, have enabled escape chars (\n, \b), but can't print out numbers yet. I need to figure out how to do formatting, f.instance:

Code: Select all

Video vid;
int numb = 123;
vid.write("Here is a number: %d", numb);
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

vid.write wasn't was I was going for. Hmmm...Uh, I was going for an overloading operator approach... Attached is what I was thinking...It should work if one does something like:

Code: Select all

int i = 12;
Monitor m ;
m << "Hi" << i; 
This means that one doesn't have to do any formatting except for '\n', '\t', etc.
I hope it works....
Attachments

[The extension cc has been deactivated and can no longer be displayed.]

C8H10N4O2 | #446691 | Trust the nodes.
User avatar
Scalpel
Posts: 15
Joined: Sat Dec 30, 2006 8:35 am
Location: Oslo, Norway

Post by Scalpel »

Thanks for the great example :)
Post Reply