aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86_64/boot/boot64.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86_64/boot/boot64.S')
-rw-r--r--src/arch/x86_64/boot/boot64.S26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/arch/x86_64/boot/boot64.S b/src/arch/x86_64/boot/boot64.S
new file mode 100644
index 0000000..848256f
--- /dev/null
+++ b/src/arch/x86_64/boot/boot64.S
@@ -0,0 +1,26 @@
+.code64
+
+.set KERNEL_VMA, 0xffffffff80000000
+.set GDT_KERNEL_CS, 0x10
+
+.section .boot64.text, "a"
+
+.global begin_long_mode
+begin_long_mode:
+ mov $GDT_KERNEL_CS, %ax
+ mov %ax, %ds
+ mov %ax, %es
+ mov %ax, %ss
+ mov %ax, %fs
+ mov %ax, %gs
+
+ add $KERNEL_VMA, %rsp
+ movabs $jump_main, %rax
+ jmp *%rax
+
+.section .text
+jump_main:
+ popq %rdi
+ popq %rsi
+ call kernel_main
+ hlt