mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Enable paging
This commit is contained in:
@@ -10,6 +10,7 @@ start:
|
|||||||
call check_long_mode
|
call check_long_mode
|
||||||
|
|
||||||
call set_up_page_tables
|
call set_up_page_tables
|
||||||
|
call enable_paging
|
||||||
|
|
||||||
; print `OK` to screen
|
; print `OK` to screen
|
||||||
mov dword [0xb8000], 0x2f4b2f4f
|
mov dword [0xb8000], 0x2f4b2f4f
|
||||||
@@ -103,6 +104,29 @@ set_up_page_tables:
|
|||||||
|
|
||||||
ret
|
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.
|
; Prints `ERR: ` and the given error code to screen and hangs.
|
||||||
; parameter: error code (in ascii) in al
|
; parameter: error code (in ascii) in al
|
||||||
error:
|
error:
|
||||||
|
|||||||
Reference in New Issue
Block a user