Well i got it working at last. i realised that i was dividing instead of multiplying(real dumb huh?).
Anyway right now i just want to know if these steps which i am following currently are correct(Your comments are also welcome)
0) Link the kernel at 3GB and load at 1MB
1) Disable IRQ's
2) Remap the PIC's
3) Initialize paging
-- Map the first 4MB onto itself(using a 4KB PageTable)
-- Map the first 4MB of 3GB onto first 1-5MB(using another 4KB PageTable next to previous)
-- Map the last entry of PDE into itself(I'm not sure how we access the PDE yet. any explanations?)
-- Point the first entry of PDE to first PTE
-- Point the 0xC00'th entry of PDE to next PTE
-- Load the PageDirectory in CR3
-- Enable Paging
We are now running with Paging
4) Initialize the Low Level Memory manager
-- Determine bitmap size for RAM given by bootloader
-- Setup the bitmap at end of kernel
-- Allocate the pages for kernel by marking the bits(I've marked the entire first 1MB as kernel as the PDE,PTE's stack etc are located here)
5) Setup the IDT with the handlers (I've used a fixed base address 0x500 for the IDT. Is this okay?)
6) Initialize timer etc..
7) Enable IRQ's
Display some info and loop.
Now i have'nt written a memory mapping function because i don't know what exactly to do to map virtual and physical addresses. Should i use new Page tables etc??
I read somewhere that the first 4MB should be unmapped from itself after Enabling paging. Is this correct? If so then how do i access the interrupt handlers etc(IDT is at 0x500)??
Also if i want to map video mem onto 0xF000_0000(as in Mobius) what are the exact steps to be followed?
Last of all could someone explain the math & use behind mapping the PDE into itself.