My boot loader loads my kernel to 1000:0000. But kernel code copies itself to 1MB and then starts executing. Could i use Tim's GDT trick. I wanna enable paging n map my kernel to 3GB+.
Also I am bit confused with setting GDT entry while paging is enabled. Can u give an example in asm.
;D
problem in paging implementation
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:problem in paging implementation
Honnestly, Tim's trick is not the simplest thing to do if you're running your own bootloader. Instead, i'd suggest (if you can afford it), to setup paging straight in your bootloader so that the kernel is mapped at wished address (or even, that the whole first MB got mapped in 0xC000.0000 ... 0xC00F.FFFF)
Re:problem in paging implementation
Then how do you reference physical memory in order to make new page tables before the address of the new page table is mapped in?
I ask this as a question to all you guys who start paging up immediately in or after the bootloader. In my case once paging is enable I have a reserved kernel-space page table set up that maps to a high address (the last 4MB of address space, to be precise) with functions to map any physical page into that space, returning its new virtual address and unmap it, returning its physical address. The point of this is to map new page tables in somewhere, fill them with valid entries, then unmap them and put them in the page directory.
I ask this as a question to all you guys who start paging up immediately in or after the bootloader. In my case once paging is enable I have a reserved kernel-space page table set up that maps to a high address (the last 4MB of address space, to be precise) with functions to map any physical page into that space, returning its new virtual address and unmap it, returning its physical address. The point of this is to map new page tables in somewhere, fill them with valid entries, then unmap them and put them in the page directory.
Re:problem in paging implementation
I use the recursive directory mapping to manipulate page tables and the page directory of the active address space, normally I map in a new page table first (adjust the directory entry), and then intialize its content.
However I already thought of implementing these things with a universal 'page frame viewer' mechanism, that quite exactly works like you described it. This mechanism is superior when you want to manipulate several non-active address spaces in parallel (this is where the recursive mapping fails - for every address space you want to manipulate, you need a 4MB area of linear memory - quite a waste). Maybe I'll do that in a future revision of my paging code.
cheers Joe
However I already thought of implementing these things with a universal 'page frame viewer' mechanism, that quite exactly works like you described it. This mechanism is superior when you want to manipulate several non-active address spaces in parallel (this is where the recursive mapping fails - for every address space you want to manipulate, you need a 4MB area of linear memory - quite a waste). Maybe I'll do that in a future revision of my paging code.
cheers Joe
Re:problem in paging implementation
Finally I got my paging working, boot loader can load my kernel ;D anywhere,then it moves to 1MB and then maps to 0xC000000. I am little (a lot ) confused with recursive mapping. How could the page directory be at 0xFFFFF000 before enabling paging. Or will you map the page directory after enabling paging If so how to do that?
(Sorry for my poor english)
(Sorry for my poor english)
Re:problem in paging implementation
The page directory isn't at $FFFFF000. It's at its proper physical location, and you set the entry for $FFC00000 in the page directory to said physical address of the page directory. This causes the page directory entries, containing the physical addresses of page tables, to act as page table entries containing the addresses of tables, which in turn makes those entire last 4 MB of address space appear to be filled with the real page table entries as normal data.