summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-09-06 13:11:16 -0400
committerLinus Groh <mail@linusgroh.de>2021-09-06 21:57:59 +0100
commit62bc238ac3b2482033358deac0c728d351c16f57 (patch)
tree556c951034d2a4f1209e54d40dea710d620895cd
parentf1d1418256639775bfcafff51bbe920df4a30e65 (diff)
downloadserenity-62bc238ac3b2482033358deac0c728d351c16f57.zip
Kernel: Let aarch64 port call into C++
Put all but the first core into a loop, make room for some stack, and call init().
-rw-r--r--Kernel/Prekernel/Arch/aarch64/boot.S13
-rw-r--r--Kernel/Prekernel/Arch/aarch64/init.cpp11
-rw-r--r--Kernel/Prekernel/CMakeLists.txt1
3 files changed, 24 insertions, 1 deletions
diff --git a/Kernel/Prekernel/Arch/aarch64/boot.S b/Kernel/Prekernel/Arch/aarch64/boot.S
index 25c0fcb7ea..acb60dc455 100644
--- a/Kernel/Prekernel/Arch/aarch64/boot.S
+++ b/Kernel/Prekernel/Arch/aarch64/boot.S
@@ -9,7 +9,18 @@
.global start
.type start, @function
start:
- b Lhalt
+ // Let only core 0 continue, put other cores to sleep.
+ mrs x13, MPIDR_EL1
+ and x13, x13, 0xff
+ cbnz x13, Lhalt
+
+ // Let stack start before .text for now.
+ // 512 kiB (0x8000) of stack are probably not sufficient, especially once we give the other cores some stack too,
+ // but for now it's ok.
+ ldr x14, =start
+ mov sp, x14
+
+ b init
Lhalt:
wfi
diff --git a/Kernel/Prekernel/Arch/aarch64/init.cpp b/Kernel/Prekernel/Arch/aarch64/init.cpp
new file mode 100644
index 0000000000..86af24a419
--- /dev/null
+++ b/Kernel/Prekernel/Arch/aarch64/init.cpp
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2021, Nico Weber <thakis@chromium.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+extern "C" [[noreturn]] void init();
+extern "C" [[noreturn]] void init()
+{
+ for (;;) { }
+}
diff --git a/Kernel/Prekernel/CMakeLists.txt b/Kernel/Prekernel/CMakeLists.txt
index 9c71f6bd70..d3bd1a7538 100644
--- a/Kernel/Prekernel/CMakeLists.txt
+++ b/Kernel/Prekernel/CMakeLists.txt
@@ -3,6 +3,7 @@ set(SOURCES
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(SOURCES
${SOURCES}
+ Arch/aarch64/init.cpp
Arch/aarch64/boot.S
)
else()