summaryrefslogtreecommitdiff
path: root/Kernel/Arch/aarch64/Prekernel/boot.S
diff options
context:
space:
mode:
authorJames Mintram <me@jamesrm.com>2022-04-03 21:42:10 +0100
committerLinus Groh <mail@linusgroh.de>2022-04-06 08:56:20 +0100
commitd94c7fa417f4fff749ffea5f6fbaa30a145fac88 (patch)
treed4f5b19f4138ba4e5fce0393abd667ce16a222e7 /Kernel/Arch/aarch64/Prekernel/boot.S
parentb884c5746d09efc333bb1848cdd46c597f857138 (diff)
downloadserenity-d94c7fa417f4fff749ffea5f6fbaa30a145fac88.zip
Kernel: Improve the aarch64 kernel source files disk layout
Diffstat (limited to 'Kernel/Arch/aarch64/Prekernel/boot.S')
-rw-r--r--Kernel/Arch/aarch64/Prekernel/boot.S33
1 files changed, 33 insertions, 0 deletions
diff --git a/Kernel/Arch/aarch64/Prekernel/boot.S b/Kernel/Arch/aarch64/Prekernel/boot.S
new file mode 100644
index 0000000000..4c44b5288a
--- /dev/null
+++ b/Kernel/Arch/aarch64/Prekernel/boot.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2021, Nico Weber <thakis@chromium.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+// In a specially-named text section so that the linker script can put it first in .text.
+.section ".text.first"
+
+.global start
+.type start, @function
+start:
+ // Let only core 0 continue, put other cores to sleep.
+ mrs x13, MPIDR_EL1
+ and x13, x13, 0xff
+ cbnz x13, _ZN9Prekernel4haltEv
+
+ // Let stack start before .text for now.
+ // 512 kiB (0x80000) of stack are probably not sufficient, especially once we give the other cores some stack too,
+ // but for now it's ok.
+ msr SPSel, #0 //Use the same SP as we descend into EL1
+ ldr x14, =start
+ mov sp, x14
+
+ // Clear BSS.
+ ldr x14, =start_of_bss
+ ldr x15, =size_of_bss_divided_by_8
+Lbss_clear_loop:
+ str xzr, [x14], #8
+ subs x15, x15, #1
+ bne Lbss_clear_loop
+
+ b init