From 62bc238ac3b2482033358deac0c728d351c16f57 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 6 Sep 2021 13:11:16 -0400 Subject: Kernel: Let aarch64 port call into C++ Put all but the first core into a loop, make room for some stack, and call init(). --- Kernel/Prekernel/Arch/aarch64/boot.S | 13 ++++++++++++- Kernel/Prekernel/Arch/aarch64/init.cpp | 11 +++++++++++ Kernel/Prekernel/CMakeLists.txt | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Kernel/Prekernel/Arch/aarch64/init.cpp 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 + * + * 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() -- cgit v1.2.3