A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/kernel/enable_paging.asm

24 lines
789 B

3 years ago
[bits 32] ; 32-bit mode
3 years ago
PAGING_ENABLE_FLAG equ 0x80000001
PAGE_DIRECTORY_ADDR equ 0xffffffff ; TODO: change me to something good
3 years ago
3 years ago
global enable_paging_registers ; make the SR "global" so that we can access it in the kernel etc
3 years ago
enable_paging_registers:
push eax
3 years ago
mov eax, PAGE_DIRECTORY_ADDR ; Move the address of the
; page register (page directory) into eax
3 years ago
; (Using eax as a middle-man register)
mov cr3, eax ; Put the address into the cr3 register (required by the MMU)
mov eax, cr0 ; eax as a middle-man register (again)
3 years ago
or eax, PAGING_ENABLE_FLAG ; perform the OR operation on eax (ex: 0b01 or 0b10 = 0b11)
3 years ago
; This is needed to enable paging (set the flag as "enabled")
mov cr0, eax ; Move it into cr0 to finally enable paging
pop eax
3 years ago
ret ; return to last location