2022-08-16 17:06:16 +00:00
|
|
|
# NOTE: I wish this wasn't AT&T Syntax its horrible
|
|
|
|
# REMINDER: INSTRUCTION FROM_REGISTER, TO_REGISTER
|
2021-11-03 19:03:38 +00:00
|
|
|
.globl enablePaging
|
|
|
|
enablePaging:
|
2022-08-16 17:06:16 +00:00
|
|
|
# Create a new call frame
|
2021-11-03 19:03:38 +00:00
|
|
|
push %ebp
|
|
|
|
mov %esp, %ebp
|
2022-08-16 17:06:16 +00:00
|
|
|
|
|
|
|
# Set the PG bit of CR0
|
2021-11-03 19:03:38 +00:00
|
|
|
mov %cr0, %eax
|
|
|
|
or $0x80000000, %eax
|
|
|
|
mov %eax, %cr0
|
2022-08-16 17:06:16 +00:00
|
|
|
|
|
|
|
# Restore to the previous call frame
|
2021-11-03 19:03:38 +00:00
|
|
|
mov %ebp, %esp
|
|
|
|
pop %ebp
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl loadPageDirectory
|
|
|
|
loadPageDirectory:
|
|
|
|
push %ebp
|
|
|
|
mov %esp, %ebp
|
2022-08-16 17:06:16 +00:00
|
|
|
|
|
|
|
/* NOTE: We should probably check if paging is already enabled.
|
|
|
|
Changing the CR3 register whilst paging is enabled might
|
|
|
|
result in unwanted behaviour (in the worst case) or cause a
|
|
|
|
fault (in the best case).
|
|
|
|
*/
|
|
|
|
|
|
|
|
mov 8(%esp), %eax # Move the first argument in the eax register
|
|
|
|
|
|
|
|
mov %eax, %cr3 # Move the value of eax into the CR3 register
|
|
|
|
|
|
|
|
/*
|
|
|
|
Moving the value of the argument passed to this function
|
|
|
|
into the CR3 register will allow the MMU to access the paging
|
|
|
|
structure we setup in memory once we enable paging
|
|
|
|
*/
|
|
|
|
|
2021-11-03 19:03:38 +00:00
|
|
|
mov %ebp, %esp
|
|
|
|
pop %ebp
|
|
|
|
ret
|
2022-08-16 17:06:16 +00:00
|
|
|
|
|
|
|
|