Paging Help.... Still Waiting
Posted: Tue Sep 10, 2002 9:48 am
Hi Guys,
I am stuck on this and cannot go on without it, which is why I am being so persistent. I have tried many examples, but this just will not work.
I have worked out that this code crahses as soon as I write the PG bit in cr0, I get an error from bochs that says '3rd Exception without Resolution'.
I really cannot go on until I have this done, and I have been trying to solve it myself, but without any luck.
The page directory and tables are 4kb aligned because I start the directory at 0x400000 and the tables at 4kb intervals after this.
; ===================================================
; Page Directory Address = 0x400000
; Page Table 0 = 0x401000
; Page Table 1 = 0x402000
; Format Page Directory Area
mov ax, 0x10 ; Load the Data Segment
mov es, ax ; Load the Segment Descriptor into ES
xor edi, edi ; Clear EDI
mov edi, 0x400000 ; Starting Offset = 4MB
mov eax, 0x00000002 ; Table Address = 0, Supervisor, Read/Write, Not Present
mov cx, 0x400 ; Store 1024 DWORDs (EAX)
cld ; Force EDI to be Incremented
rep stosd ; Store the Data
; Setup the Page Directory
mov dword [0x400000], 0x401003 ; Store Table0 Address, Supervisor, Read/Write, Present
mov dword [0x400004], 0x402003 ; Store Table1 Address, Supervisor, Read/Write, Present
; Indentity Map (0MB - 8MB)
xor edi, edi ; Clear EDI
mov edi, 0x401000 ; Table0 Absolute Address
mov eax, 0x00000003 ; Starting Base Address = 0, Supervisor, Read/Write, Present
mov cx, 0x800 ; Store 2048 DWORDs (EAX)
cld ; Force EDI to be Incremented
Map08MB:
stosd ; EAX -> ES:EDI
add eax, 0x1000 ; Next Page Base Address
loop Map08MB ; Do Next Store
; Install the Page Directory
mov eax, 0x400000
mov cr3, eax
; Turn Paging On
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
; Jump into Paging
jmp 0x08:Paging
Paging:
; should be using paging now!!!
; =====================================================
Thanks.
I am stuck on this and cannot go on without it, which is why I am being so persistent. I have tried many examples, but this just will not work.
I have worked out that this code crahses as soon as I write the PG bit in cr0, I get an error from bochs that says '3rd Exception without Resolution'.
I really cannot go on until I have this done, and I have been trying to solve it myself, but without any luck.
The page directory and tables are 4kb aligned because I start the directory at 0x400000 and the tables at 4kb intervals after this.
; ===================================================
; Page Directory Address = 0x400000
; Page Table 0 = 0x401000
; Page Table 1 = 0x402000
; Format Page Directory Area
mov ax, 0x10 ; Load the Data Segment
mov es, ax ; Load the Segment Descriptor into ES
xor edi, edi ; Clear EDI
mov edi, 0x400000 ; Starting Offset = 4MB
mov eax, 0x00000002 ; Table Address = 0, Supervisor, Read/Write, Not Present
mov cx, 0x400 ; Store 1024 DWORDs (EAX)
cld ; Force EDI to be Incremented
rep stosd ; Store the Data
; Setup the Page Directory
mov dword [0x400000], 0x401003 ; Store Table0 Address, Supervisor, Read/Write, Present
mov dword [0x400004], 0x402003 ; Store Table1 Address, Supervisor, Read/Write, Present
; Indentity Map (0MB - 8MB)
xor edi, edi ; Clear EDI
mov edi, 0x401000 ; Table0 Absolute Address
mov eax, 0x00000003 ; Starting Base Address = 0, Supervisor, Read/Write, Present
mov cx, 0x800 ; Store 2048 DWORDs (EAX)
cld ; Force EDI to be Incremented
Map08MB:
stosd ; EAX -> ES:EDI
add eax, 0x1000 ; Next Page Base Address
loop Map08MB ; Do Next Store
; Install the Page Directory
mov eax, 0x400000
mov cr3, eax
; Turn Paging On
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
; Jump into Paging
jmp 0x08:Paging
Paging:
; should be using paging now!!!
; =====================================================
Thanks.