Enable paging

master
Philipp Oppermann 8 years ago
parent b199b02578
commit 936e2073a9

@ -10,6 +10,7 @@ start:
call check_long_mode
call set_up_page_tables
call enable_paging
; print `OK` to screen
mov dword [0xb8000], 0x2f4b2f4f
@ -103,6 +104,29 @@ set_up_page_tables:
ret
enable_paging:
; load P4 to cr3 register (cpu uses this to access the P4 table)
mov eax, p4_table
mov cr3, eax
; enable PAE-flag in cr4 (Physical Address Extension)
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
; set the long mode bit in the EFER MSR (model specific register)
mov ecx, 0xC0000080
rdmsr
or eax, 1 << 8
wrmsr
; enable paging in the cr0 register
mov eax, cr0
or eax, 1 << 31
mov cr0, eax
ret
; Prints `ERR: ` and the given error code to screen and hangs.
; parameter: error code (in ascii) in al
error:

Loading…
Cancel
Save