Also note that when I manually(software) interrupt 0xE(14) I get a page fault.
What I think should cause a page fault.
Code: Select all
char* addr = (char*)0x1900000; // I have only defined pages up to 1000000
char val = *addr;
my paging code: (Page_Tables and Page_Directory are defined in bss section)
Code: Select all
start:
cli
mov esp, $stack_top
; Load GDT
mov dword [GDTDescriptor + 2], GDT
mov dword eax, GDTDescriptor
lgdt [eax]
mov dword eax, 0x10
mov word ds, eax
mov word es, eax
mov word fs, eax
mov word gs, eax
mov word ss, eax
jmp 8:FlushGDT
FlushGDT:
call SetupPaging
call LoadIDT
sti
call kernel_main
cli
_loop:
hlt
jmp _loop
SetupPaging:
lea eax, [Page_Tables]
mov ebx, 7
mov ecx, (1024 * 4) ; Page Tables - 4
.Loop1:
mov [eax], ebx
add eax, 4
add ebx, 4096
loop .Loop1
lea edx, [Page_Directory]
lea ebx, [Page_Tables]
or ebx, 7
mov ecx, 1024
.Loop2:
mov [edx], ebx
add edx, 4
add ebx, 4096
loop .Loop2
lea ecx, [Page_Directory]
mov cr3, ecx
mov ecx, cr0
or ecx, 0x80000000
mov cr0, ecx
ret