NewBie to OS Development

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
Raven
Member
Member
Posts: 41
Joined: Sun Feb 01, 2009 12:20 am

NewBie to OS Development

Post by Raven »

Well i am a newbie to OS development. I did following things :

1. Used GRUB to load the first sector of my os partition.
2. That sector searches for another file and loads and executes that.
3. That file checks for compatibilities and information like RAM size.
Now comes a problem:

Should I enable gateA20 here or in kernel?
Should I Remap PIC here or in Kernel?
Should I set GDT here or in kernel?
By the way is this enough that I am setting 4 GDT entries except null
(2 for ring0 code and data and 2 for ring3 code and data)? #-o
Should I set IDT here or in kernel?

Now these above question need yes/no, what is confusing me is Paging!
I mean I am using flat model where every Code/Data entry in GDT for ring 0 or ring 3 will have base=0 and limit=fffff while page tables will map them to exact location.This will help me in running a flat binary file but I not am able to decide where to put bitmap for pages and where to put page directories and tables?
Also how to do it dynamically on RAM size basis?
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: NewBie to OS Development

Post by yemista »

You should write your own bootloader, setup your gdt and the A20 line there, then you can remap the PIC and set the idt in the kernel. Itll slow you down a bit, but youll learn a lot of stuff that will help you a lot later on.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: NewBie to OS Development

Post by Love4Boobies »

Raven wrote:Should I enable gateA20 here or in kernel?
GRUB enables the A20 gate for you, you don't have to do anything.
Should I Remap PIC here or in Kernel?
It's better to keep out of the kernel whatever will only run once. It perfectly makes sense to put as much initialization as possible in the boot loader or booting stages.
Should I set GDT here or in kernel?
By here I suppose you mean the file that is loaded by GRUB, your third stage? You could set up the GDT in the 3rd stage, I suppose; note that GRUB only gives you a dummy GDT so it can jump to pmode.
By the way is this enough that I am setting 4 GDT entries except null
(2 for ring0 code and data and 2 for ring3 code and data)? #-o
It depends what you want to do with them... Later on, you will have the process manager set up GDT entries for your new processes.
Should I set IDT here or in kernel?
See point on GDT.
I mean I am using flat model where every Code/Data entry in GDT for ring 0 or ring 3 will have base=0 and limit=fffff while page tables will map them to exact location.This will help me in running a flat binary file but I not am able to decide where to put bitmap for pages and where to put page directories and tables?
If you're using paging, you don't necessarily need to have a 1:1 mapping. That's why paging is there, right? The point of the flat memory model is that each process thinks it has the whole RAM to itself. Paging + swapping makes that entirely possible and transparent to the application programs.
Also how to do it dynamically on RAM size basis?
You could set up a map of some sort (list/bitmap). I'm saying this because there are also holes in the RAM - data structures like the EBDA, or PCI mappings, etc., or even faulty RAM. Check out the wiki on how to detect memory, if you haven't already.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply