Paging for kernel which is linked to 0xc0100000

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
FlashBurn

Paging for kernel which is linked to 0xc0100000

Post by FlashBurn »

As the thread name says, my kernel is linked at 0xc0100000 and I use first segmentation for solving the problem (base 0x40000000) that it realy is at 0x100000. I then setup a PD and init the needed PTs and PGs. But when I enable paging, bochs resets (tripple fault). This is my code to enable paging:

Code: Select all

.enable_paging
   mov eax,cr0
   or eax,0x80000000
   mov cr0,eax
   
   jmp 0x08:.end
   
.end
   mov eax,10h
   mov ds,eax
   mov es,eax
   mov fs,eax
   mov fs,eax
   mov ss,eax
The problem is that I don?t know why it is tripple faulting.

Correct me if I?m wrong, but the address of the PD has to be a physically address, because it gives a **** to segmentation. This is also for the PTs and the PGs.

The most OSs here move the kernel space to the last GiB, aren?t they?! So how did you all solve the problem?
FlashBurn

Re:Paging for kernel which is linked to 0xc0100000

Post by FlashBurn »

OK, you need some more info.

If I want to map the first 4MiB (phys) to 0xc0000000 (virt) I use the following code:

Code: Select all

mov esi,addr_of_pd
add esi,0xc0000000
mov edi,[esi+4*768]
and edi,0xfffff000
add edi,0xc0000000
mov ecx,1024
xor edx,edx

.loop
 mov eax,edx
 or eax,3
 stosd

 add edx,0x1000

 dec ecx
 jnz .loop
Am I right, or am I doing something wrong?
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Paging for kernel which is linked to 0xc0100000

Post by Neo »

i think there is a lot of info about this right here on the website as well as on the net for exactly the questions you asked. you should try searching first.
Only Human
FlashBurn

Re:Paging for kernel which is linked to 0xc0100000

Post by FlashBurn »

OK, I solved the problem by myself. The problem was that the physical address where the kernel is also needs to be mapped 1:1! Because when I enable paging, I had only mapped the kernel to the virtual address 0xc0100000 and the pc tries now to get the next instruction from somewhere around 0x100000, but this region wasn?t mapped.
Post Reply