2024-12-27 17:18:48 +00:00
|
|
|
;; File: bootstrap.inc
|
|
|
|
;; Bootstrap whole PMM and MM
|
|
|
|
|
|
|
|
;; Function: mm_bootstrap
|
2024-12-27 18:24:31 +00:00
|
|
|
;; Setup recursive paging.
|
|
|
|
;; map page dir at 0xFFFFF000
|
2024-12-27 17:18:48 +00:00
|
|
|
mm_bootstrap:
|
2024-12-30 19:27:11 +00:00
|
|
|
mov eax, szMsgMmBootstrap
|
2024-12-27 18:24:31 +00:00
|
|
|
call klog
|
|
|
|
; 0x400000
|
2024-12-28 11:38:21 +00:00
|
|
|
; PDE entry: 0x7ffc00 phys addr and curr virt addr: 0xc07ffc00
|
2024-12-27 18:24:31 +00:00
|
|
|
|
|
|
|
; map first 4MB at KERNEL_VIRT_BASE
|
|
|
|
xor esi, esi
|
|
|
|
mov edi, KERNEL_VIRT_BASE + 0x400000 + (768 * PAGE_SIZE)
|
|
|
|
@@:
|
|
|
|
mov edx, esi
|
|
|
|
or edx, (PTE_P or PTE_W)
|
|
|
|
mov [edi], edx
|
|
|
|
add edi, 4
|
|
|
|
add esi, PAGE_SIZE
|
2024-12-28 11:38:21 +00:00
|
|
|
cmp esi, kend - KERNEL_VIRT_BASE
|
2024-12-27 18:24:31 +00:00
|
|
|
jb @b
|
|
|
|
|
|
|
|
; recusive page dir
|
2024-12-28 11:38:21 +00:00
|
|
|
mov esi, 0x400000
|
2024-12-27 18:24:31 +00:00
|
|
|
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
|
2025-01-13 15:15:34 +00:00
|
|
|
|
2024-12-27 17:18:48 +00:00
|
|
|
ret
|
2024-12-27 18:24:31 +00:00
|
|
|
|
|
|
|
szMsgMmBootstrap db "MM: boostrap", 0
|