how to setup pages, before jump to 2GB kernel space?

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
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

how to setup pages, before jump to 2GB kernel space?

Post by blackoil »

Hi,

I want to make the kernel runs at 2GB virtual space, 0x80000000
for PD[0,1023], I initialize PD[512] entry only, that is the beginning of 0x80000000 vaddress
then I got instruction unavaliable in BOCHS, right after

Code: Select all

mov eax,cr0
or eax,0x80000000
mov cr0,eax
so i think mapping the first 1MB physical address was needed, before jump to 0x80000000
How do you guys implement this?
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: how to setup pages, before jump to 2GB kernel space?

Post by xyzzy »

Yes, you need to map the memory where your kernel is currently running before you jump to its virtual address. To make your life easier you can use the large (4MB) page support on x86 CPUs. Using this, you can identity map the first 4MB by setting the first page directory to point to 0x0 and setting the large page bit (bit 7) on it - make sure you enable PSE in CR4 first. Have a look at http://wiki.osdev.org/Higher_Half_bare_bones
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Re: how to setup pages, before jump to 2GB kernel space?

Post by blackoil »

thanks alex!

when in 2gb vaddress, clear PD[0,511], mark it for user space. done.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: how to setup pages, before jump to 2GB kernel space?

Post by egos »

blackoil wrote:so i think mapping the first 1MB physical address was needed, before jump to 0x80000000
You are right if your kernel image and initial stack are placed in conventional memory. I had made identity mapping for first 640 kb. When kernel is starting, it allocates and maps global memory region at KERNEL_BASE virtual address (usually 0x80000000 or 0xC0000000) and then copies the SYMBOLS section into this region.
If you have seen bad English in my words, tell me what's wrong, please.
Post Reply