aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-12-03 14:02:07 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-12-03 14:02:07 +0100
commita08847ded5fba25859e7a3ad06ae3fed342d4d6a (patch)
tree607addb6a707fc39b39eb69779467841fc6d7356
parent9331afdcbbe95bc1bd79d657f0d7c5b91a19a375 (diff)
downloadteachos-a08847ded5fba25859e7a3ad06ae3fed342d4d6a.tar.xz
teachos-a08847ded5fba25859e7a3ad06ae3fed342d4d6a.zip
x86_64/boot: move stack to higher half
-rw-r--r--arch/x86_64/src/boot/boot32.S11
-rw-r--r--arch/x86_64/src/boot/entry64.s9
2 files changed, 13 insertions, 7 deletions
diff --git a/arch/x86_64/src/boot/boot32.S b/arch/x86_64/src/boot/boot32.S
index 27eed4d..79b3ec7 100644
--- a/arch/x86_64/src/boot/boot32.S
+++ b/arch/x86_64/src/boot/boot32.S
@@ -27,12 +27,9 @@ page_maps_size = page_maps_end - page_maps_start
.section .boot_stack, "aw", @nobits
.align 16
-.global stack_size
-.global stack_bottom
-
-stack_bottom: .skip 1 << 20
-stack_top:
-stack_size = stack_top - stack_bottom
+early_stack_bottom: .skip 1 << 8
+early_stack_top:
+early_stack_size = early_stack_top - early_stack_bottom
/**
* @brief Constants for the bootstrapping process.
@@ -122,7 +119,7 @@ _start:
0:
pop %esi
- lea (stack_top - 0b)(%esi), %ecx
+ lea (early_stack_top - 0b)(%esi), %ecx
mov %ecx, %esp
mov %esp, %ebp
diff --git a/arch/x86_64/src/boot/entry64.s b/arch/x86_64/src/boot/entry64.s
index 636e4cd..2932354 100644
--- a/arch/x86_64/src/boot/entry64.s
+++ b/arch/x86_64/src/boot/entry64.s
@@ -11,6 +11,12 @@
.global bootstrap_information
bootstrap_information: .skip 16
+.align 16
+.global stack_top
+stack_bottom: .skip 1 << 20
+stack_top:
+stack_size = stack_top - stack_bottom
+
.section .boot_text, "ax", @progbits
.code64
@@ -23,6 +29,9 @@ _entry64:
mov %rax, %fs
mov %rax, %gs
+ mov $stack_top, %rsp
+ mov %rsp, %rbp
+
mov multiboot_information_pointer, %rax
mov vga_buffer_pointer, %rdx
sub $0xb8000, %rdx