Enable paging

This commit is contained in:
Philipp Oppermann
2015-08-13 13:15:37 +02:00
parent b47699685f
commit 457a61341a

View File

@@ -24,6 +24,7 @@ start:
call check_long_mode
call setup_page_tables
call enable_paging
; print `OK` to screen
mov dword [0xb8000], 0x2f4b2f4f
@@ -40,6 +41,30 @@ setup_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
or eax, 1 << 16
mov cr0, eax
ret
; Prints `ERR: ` and the given error code to screen and hangs.
; parameter: error code (in ascii) in al
error: