Beginner's question

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
nitinjavakid
Member
Member
Posts: 65
Joined: Sat Oct 21, 2006 11:28 am
Location: Exams over!
Contact:

Beginner's question

Post by nitinjavakid »

I have been working on C and C++ for 7 years and would like to develop an operating system. But I am totally confused. How do I start off? Do I have to learn assembly? Are there any books for OS programming using C and C++?(the book sticky is tooo big).

Thanks for reading..
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

Yep. You MUST learn assembly for many operations.

If I was you (and everybody), I would start to make a bootloader in ASM (or you can use GRUB or other free bootloaders). Then, you must develop a kernel. You have two choices:

- REAL mode (memory up to 640K), 16-bit OS
- PROTECTED mode (32-bit OS)

You must remember, that you must NOT call any DOS functions - it wont work. In protected mode you must not call any BIOS functions too.

I am programming my OS in Pascal.

My specs:

-REAL mode (memory up to 2GB), 16-bit OS - using Alexei Frounzes mem managment.

inflater
User avatar
ces_mohab
Member
Member
Posts: 77
Joined: Wed Oct 18, 2006 3:08 am

Post by ces_mohab »

you can take a look at the osfaq2http://www.osdev.org/osfaq2/
I recomment you read http://www.osdev.org/osfaq2/index.php/Getting%20Started
and http://www.osdev.org/osfaq2/index.php/T ... notDoWithC
you can read minix book operating systems design and implementation.
start by letting grub boot your kernel.
spend some time on reading before coding.
:roll:
User avatar
nitinjavakid
Member
Member
Posts: 65
Joined: Sat Oct 21, 2006 11:28 am
Location: Exams over!
Contact:

Post by nitinjavakid »

Thanks people
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

inflater wrote: Then, you must develop a kernel. You have two choices:

- REAL mode (memory up to 640K), 16-bit OS
- PROTECTED mode (32-bit OS)

You must remember, that you must NOT call any DOS functions - it wont work. In protected mode you must not call any BIOS functions too.
That's not true anymore. Also, the distinction has sub-options that include their own limits.

You nowadays (since 4.5 years or so) have the choices of:
- Realmode, plain
- Realmode, as v86 mode in protected mode, you can do this if you regularly want to call some function in pmode or such, but usually want to work in realmode
- Protected mode, non-paged flat (no paging, no segmentation)
- Protected mode, paged flat (most common choice, Windows and Linux both use this, paging but no segmentation)
- Protected mode, non-paged segmented (no paging but some segmentation, easiest for embedded applications, since they usually boot once and stay in memory and this allows boot-time moving anywhere without relocation)
- Protected mode, paged segmented (not common, pretty hard to get right and only used in one common OS, OS/2)
- Long mode (and this is easy again, since you can't do any of the jokes mentioned above).

Then, for the paged pmode items you can choose either non-PAE for supporting more CPU's or PAE to support more memory (but less CPU's).

For my OS, I'm choosing these three common targets:
- Protected mode, paged flat without PAE
- Protected mode, paged flat with PAE
- Long mode

My boot loader supports booting to realmode, pmode paged with and without PAE and longmode, all from either a plain binary (entrypoint assumed to be the first byte - like a really big bootsector) or a plain ELF file in the appropriate format (which is checked). The only combination not supported is ELF in realmode, because there is no ELF standard for 16-bit code (afaik). If you know about a 16-bit ELF standard, tell me and I'll add it :)

That's a tad of a lie, the previous paragraph, I'm still hacking on the 32-bit support and the 32-bit pae target isn't baked in yet. Also, the paging setup is still in the ELF loader for 32-bit targets so you get an unpaged pmode for the hello world.
Post Reply