Paging problem (doesn't work at all)
Posted: Sun Dec 09, 2007 6:42 am
This is my paging code so far (fasm code). When I enable paging by writing to cr0 the cpu resets. I am trying to identity map the first 4 megabytes. Obviously I did something very wrong, but what?
Code: Select all
; setup pdir
mov eax, tbl
or eax, PG_PRESENT or PG_WRITE
mov [dir+0*4], eax
; setup ptbl
mov eax, PG_PRESENT or PG_WRITE
mov ecx, 0
.pageloop:
mov [tbl+ecx*4], eax
add eax, PAGE_SIZE
add ecx, 1
cmp ecx, 1024
jne .pageloop
; enable paging
mov eax, tbl
mov cr3, eax
mov eax, cr0
or eax, PG_ENABLE_PAGING
mov cr0, eax
PAGE_SIZE = 4096
PG_ENABLE_PAGING = 80000000h
PG_PRESENT = 1
PG_WRITE = 2
PG_SUPERVISOR = 4
section '.bss' align 4096
dir rd 1024
tbl rd 1024