I started implementing paging in my os. Everything works fine, except for far jumps. The cpu generates a page fault, when I try to perform a far jump.
The far jump works, when I leave the first entry of the page directory mapped to the first 4MB.
Here's my code:
Code: Select all
;prepare paging
mov eax, cr3
and eax, 0xFFF
or eax, 0x105000 ;addr of page dir
mov cr3, eax
;map the first 4MB of the 3GB to the 1GB
mov edi, 0x105C00 ;3GB entry in page dir
mov eax, 0x106000 ;addr of page table
or eax, 0x3 ;present & super user
stosd
;map the first 4MB of the 1GB to the 1GB
mov edi, 0x105000
mov eax, 0x106000
or eax, 0x3
stosd
;page table at 0x106000
mov edi, 0x106000
mov ecx, 1024
mov eax, 0x3
fill_page_table:
stosd
add eax, 0x1000 ;prepare next run (next 4KB)
loop fill_page_table
;enable paging
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
jmp 0x8:(next + 0xC0010000) ;jump to 3GB
next:
;remove first entry from the page directory
mov edi, 0xC0105000
mov eax, 0x0
stosd
mov esp, 0xC0090000
;;;;;; everything works fine till here
jmp 0x8:(here + 0xC0010000) ;this causes a page fault
here:
jmp $
Thanks for your replies in advance.
N43