StupidOS/kernel/mm/bootstrap.inc

45 lines
851 B
PHP
Raw Normal View History

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:
mov eax, szMsgMmBootstrap
2024-12-27 18:24:31 +00:00
call klog
; 0x400000
; 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
cmp esi, kend - KERNEL_VIRT_BASE
2024-12-27 18:24:31 +00:00
jb @b
; recusive page dir
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
2024-12-27 17:18:48 +00:00
ret
2024-12-27 18:24:31 +00:00
szMsgMmBootstrap db "MM: boostrap", 0