Page Setup
Posted: Mon Sep 09, 2002 7:26 am
Hi,
I am using this code below to setup a basic paging environment just to get it started, the code I have works without this stuff in it so I know that somewhere in here is the error, hopefully someone will see the problem.
; Page Directory Address = 0x400000
; Page Table 0 = 0x401000
; Page Table 1 = 0x402000
; Setup Page Directory
mov ebx, 0x400000 ; The PageDir Address
mov dword [ebx], 0x401003 ; Table 0 Address and Attributes
add ebx, 4
mov dword [ebx], 0x402003 ; Table 1 Address and Attributes
; Clear other page tables
mov cx, 0
mov ebx, 0x400008 ; Base Not Used
mov eax, 0x02 ; Attributes Only
ClearDirLoop:
cmp cx, 1022
je ClearDirDone
inc cx
mov dword [ebx], eax ; Setup Next Page
add ebx, 4 ; Next Page Table Entry
jmp ClearDirLoop
ClearDirDone:
; Map First 4MB
mov cx, 0
mov ebx, 0x401000 ; Page Table 0 Base
mov eax, 0x00000003 ; Page Address and Attributes
Page4MBLoop:
cmp cx, 1024
je Page4MBDone
inc cx
mov dword [ebx], eax ; Setup Next Page
add ebx, 4 ; Next Page Table Entry
add eax, 0x1000 ; Next Page Address
jmp Page4MBLoop
Page4MBDone:
; Map Second 4MB
mov cx, 0
mov ebx, 0x402000 ; Page Table 1 Base
mov eax, 0x00400003 ; Page Address and Attributes
Page8MBLoop:
cmp cx, 1024
je Page8MBDone
inc cx
mov dword [ebx], eax ; Setup Next Page
add ebx, 4 ; Next Page Table Entry
add eax, 0x1000 ; Next Page Address
jmp Page8MBLoop
Page8MBDone:
; Install the Pages
mov eax, 0x400000
mov cr3, eax
; Set PG Bit
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
; Jump into Page World! Tried both of these
; jmp 0x08:PageWorld
jmp PageWorld
PageWorld:
The error that I get from bochs is with
jmp 0x08:PageWorld is
jump_protected: S=1: descriptor not executable
jmp PageWorld is
3rd exception without resolution
I have interrupts disabled until after this code and the IDT setup code.
I am using this code below to setup a basic paging environment just to get it started, the code I have works without this stuff in it so I know that somewhere in here is the error, hopefully someone will see the problem.
; Page Directory Address = 0x400000
; Page Table 0 = 0x401000
; Page Table 1 = 0x402000
; Setup Page Directory
mov ebx, 0x400000 ; The PageDir Address
mov dword [ebx], 0x401003 ; Table 0 Address and Attributes
add ebx, 4
mov dword [ebx], 0x402003 ; Table 1 Address and Attributes
; Clear other page tables
mov cx, 0
mov ebx, 0x400008 ; Base Not Used
mov eax, 0x02 ; Attributes Only
ClearDirLoop:
cmp cx, 1022
je ClearDirDone
inc cx
mov dword [ebx], eax ; Setup Next Page
add ebx, 4 ; Next Page Table Entry
jmp ClearDirLoop
ClearDirDone:
; Map First 4MB
mov cx, 0
mov ebx, 0x401000 ; Page Table 0 Base
mov eax, 0x00000003 ; Page Address and Attributes
Page4MBLoop:
cmp cx, 1024
je Page4MBDone
inc cx
mov dword [ebx], eax ; Setup Next Page
add ebx, 4 ; Next Page Table Entry
add eax, 0x1000 ; Next Page Address
jmp Page4MBLoop
Page4MBDone:
; Map Second 4MB
mov cx, 0
mov ebx, 0x402000 ; Page Table 1 Base
mov eax, 0x00400003 ; Page Address and Attributes
Page8MBLoop:
cmp cx, 1024
je Page8MBDone
inc cx
mov dword [ebx], eax ; Setup Next Page
add ebx, 4 ; Next Page Table Entry
add eax, 0x1000 ; Next Page Address
jmp Page8MBLoop
Page8MBDone:
; Install the Pages
mov eax, 0x400000
mov cr3, eax
; Set PG Bit
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
; Jump into Page World! Tried both of these
; jmp 0x08:PageWorld
jmp PageWorld
PageWorld:
The error that I get from bochs is with
jmp 0x08:PageWorld is
jump_protected: S=1: descriptor not executable
jmp PageWorld is
3rd exception without resolution
I have interrupts disabled until after this code and the IDT setup code.