summaryrefslogtreecommitdiff
path: root/arch/i386
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2023-11-26 18:17:39 -0600
committerDanny Holman <dholman@gymli.org>2023-11-26 18:17:39 -0600
commitf63f92582552af06d8ad7bc4ccd235e51ad651b7 (patch)
tree17e1f74dcea6321e66237913c4af64dddd03c5cd /arch/i386
parentb3afa2373aeb7ff119dcd8a2c0bea4114799604a (diff)
arch: i386: boot.s: define functions for page management
Define the load_page_dir and enable_paging functions in assembly. This allows normal C code to initialize the CR3 register and control paging without using inline assembler. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'arch/i386')
-rw-r--r--arch/i386/boot/boot.s27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/i386/boot/boot.s b/arch/i386/boot/boot.s
index 4a6ddd1..48f9f29 100644
--- a/arch/i386/boot/boot.s
+++ b/arch/i386/boot/boot.s
@@ -76,6 +76,33 @@ _start:
1: hlt
jmp 1b
+.global load_page_dir
+.type load_page_dir, @function
+load_page_dir:
+ pushl %ebp
+ movl %esp, %ebp
+
+ movl 8(%ebp), %eax
+ movl %eax, %cr3
+
+ movl %ebp, %esp
+ popl %ebp
+ ret
+
+.global enable_paging
+.type enable_paging, @function
+enable_paging:
+ pushl %ebp
+ movl %esp, %ebp
+
+ movl %cr0, %eax
+ orl $0x80000001, %eax
+ movl %eax, %cr0
+
+ movl %ebp, %esp
+ popl %ebp
+ ret
+
.global flush_gdt
.type flush_gdt, @function
flush_gdt: