feat(kernel): setup recursive page dir
This commit is contained in:
parent
1cd839c63a
commit
6510df8068
4 changed files with 46 additions and 8 deletions
|
@ -237,6 +237,8 @@ common32:
|
|||
mov edi, KERNEL_BASE
|
||||
rep movsb
|
||||
|
||||
;; XXX: refactor this code
|
||||
|
||||
; identity map first 1MB
|
||||
xor esi, esi
|
||||
xor ecx, ecx
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
PE_PRESENT = (1 shl 0)
|
||||
PE_WRITABLE = (1 shl 1)
|
||||
PE_USERMODE = (1 shl 2)
|
||||
PE_ACCESSED = (1 shl 5)
|
||||
PE_DIRTY = (1 shl 6)
|
||||
|
||||
|
|
@ -44,6 +44,10 @@ kmain:
|
|||
mov esi, szMsgBuildDate
|
||||
call klog
|
||||
|
||||
call mm_bootstrap
|
||||
|
||||
xchg bx, bx
|
||||
|
||||
; init pmm (kend, 0x400000)
|
||||
mov eax, kend
|
||||
mov ebx, 0xC0400000
|
||||
|
@ -117,6 +121,7 @@ kmain:
|
|||
include 'klog.inc'
|
||||
include 'dev/console.inc'
|
||||
include 'dev/dev.inc'
|
||||
include 'mm/bootstrap.inc'
|
||||
include 'mm/mm.old.inc'
|
||||
include 'lock.inc'
|
||||
include 'gdt.inc'
|
||||
|
|
|
@ -2,6 +2,44 @@
|
|||
;; Bootstrap whole PMM and MM
|
||||
|
||||
;; Function: mm_bootstrap
|
||||
;; Setup recursive page dir at 0xFFFFF000 and temporary identity map first 3GB
|
||||
;; Setup recursive paging.
|
||||
;; map page dir at 0xFFFFF000
|
||||
mm_bootstrap:
|
||||
mov esi, szMsgMmBootstrap
|
||||
call klog
|
||||
; 0x400000
|
||||
; PDE entry: 0x7ffc00 phys addr 0xC0 and curr virt addr: 0xc07ffc00
|
||||
|
||||
; map first 4MB at KERNEL_VIRT_BASE
|
||||
xor esi, esi
|
||||
mov edi, KERNEL_VIRT_BASE + 0x400000 + (768 * PAGE_SIZE)
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
mov edx, esi
|
||||
or edx, (PTE_P or PTE_W)
|
||||
mov [edi], edx
|
||||
add edi, 4
|
||||
add esi, PAGE_SIZE
|
||||
inc ecx
|
||||
cmp ecx, 1024
|
||||
jb @b
|
||||
|
||||
; recusive page dir
|
||||
mov edi, KERNEL_VIRT_BASE + 0x400000 + (1023 * PAGE_SIZE)
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
mov edx, esi
|
||||
or edx, (PTE_P or PTE_W)
|
||||
mov [edi], edx
|
||||
add edi, 4
|
||||
add esi, PAGE_SIZE
|
||||
inc ecx
|
||||
cmp ecx, 1024
|
||||
jb @b
|
||||
|
||||
mov eax, 0x400000 + (1023 * PAGE_SIZE)
|
||||
mov cr3, eax
|
||||
|
||||
ret
|
||||
|
||||
szMsgMmBootstrap db "MM: boostrap", 0
|
||||
|
|
Loading…
Reference in a new issue