diff options
author | James Mintram <me@jamesrm.com> | 2021-11-21 01:09:38 +0000 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-11-28 22:01:21 -0800 |
commit | 4a4a3193f84b53673b63d6ad520d98108c0710a6 (patch) | |
tree | 0c9eda2e8c2edb946abf326223489e70ade2c131 /Kernel/Prekernel | |
parent | 34709c8d39de840cc1680fe9e409cc2789a86f7a (diff) | |
download | serenity-4a4a3193f84b53673b63d6ad520d98108c0710a6.zip |
Kernel: Rename Aarch64Asm -> ASM_wrapper and add Aarch64::Asm namespace
Diffstat (limited to 'Kernel/Prekernel')
-rw-r--r-- | Kernel/Prekernel/Arch/aarch64/Prekernel.h | 7 | ||||
-rw-r--r-- | Kernel/Prekernel/Arch/aarch64/PrekernelCommon.cpp | 11 | ||||
-rw-r--r-- | Kernel/Prekernel/Arch/aarch64/PrekernelExceptions.cpp | 10 | ||||
-rw-r--r-- | Kernel/Prekernel/Arch/aarch64/PrekernelMMU.cpp | 8 | ||||
-rw-r--r-- | Kernel/Prekernel/Arch/aarch64/boot.S | 2 | ||||
-rw-r--r-- | Kernel/Prekernel/Arch/aarch64/init.cpp | 19 | ||||
-rw-r--r-- | Kernel/Prekernel/CMakeLists.txt | 3 |
7 files changed, 27 insertions, 33 deletions
diff --git a/Kernel/Prekernel/Arch/aarch64/Prekernel.h b/Kernel/Prekernel/Arch/aarch64/Prekernel.h index 94e31de607..4bb284f7cd 100644 --- a/Kernel/Prekernel/Arch/aarch64/Prekernel.h +++ b/Kernel/Prekernel/Arch/aarch64/Prekernel.h @@ -13,11 +13,6 @@ void init_prekernel_page_tables(); [[noreturn]] void panic(const char* msg); -[[noreturn]] inline void halt() -{ - for (;;) { - asm volatile("wfi"); - } -} +[[noreturn]] void halt(); } diff --git a/Kernel/Prekernel/Arch/aarch64/PrekernelCommon.cpp b/Kernel/Prekernel/Arch/aarch64/PrekernelCommon.cpp index 87a8d37dae..6a24efda4f 100644 --- a/Kernel/Prekernel/Arch/aarch64/PrekernelCommon.cpp +++ b/Kernel/Prekernel/Arch/aarch64/PrekernelCommon.cpp @@ -6,7 +6,7 @@ #include <Kernel/Prekernel/Arch/aarch64/Prekernel.h> -#include <Kernel/Arch/aarch64/Aarch64Asm.h> +#include <Kernel/Arch/aarch64/ASM_wrapper.h> #include <Kernel/Prekernel/Arch/aarch64/UART.h> namespace Prekernel { @@ -19,7 +19,14 @@ namespace Prekernel { uart.print_str(msg); } - Kernel::halt(); + Prekernel::halt(); +} + +[[noreturn]] void halt() +{ + for (;;) { + asm volatile("wfi"); + } } } diff --git a/Kernel/Prekernel/Arch/aarch64/PrekernelExceptions.cpp b/Kernel/Prekernel/Arch/aarch64/PrekernelExceptions.cpp index d665d48fda..03f1a43591 100644 --- a/Kernel/Prekernel/Arch/aarch64/PrekernelExceptions.cpp +++ b/Kernel/Prekernel/Arch/aarch64/PrekernelExceptions.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <Kernel/Arch/aarch64/Aarch64Asm.h> +#include <Kernel/Arch/aarch64/ASM_wrapper.h> #include <Kernel/Arch/aarch64/Registers.h> #include <Kernel/Prekernel/Arch/aarch64/Aarch64_asm_utils.h> #include <Kernel/Prekernel/Arch/aarch64/Prekernel.h> @@ -82,14 +82,14 @@ static void set_up_el1() void drop_to_exception_level_1() { - switch (Kernel::get_current_exception_level()) { - case ExceptionLevel::EL3: + switch (Kernel::Aarch64::Asm::get_current_exception_level()) { + case Kernel::Aarch64::Asm::ExceptionLevel::EL3: drop_to_el2(); [[fallthrough]]; - case ExceptionLevel::EL2: + case Kernel::Aarch64::Asm::ExceptionLevel::EL2: drop_to_el1(); [[fallthrough]]; - case ExceptionLevel::EL1: + case Kernel::Aarch64::Asm::ExceptionLevel::EL1: set_up_el1(); break; default: { diff --git a/Kernel/Prekernel/Arch/aarch64/PrekernelMMU.cpp b/Kernel/Prekernel/Arch/aarch64/PrekernelMMU.cpp index b72f156e71..3ef8d6170a 100644 --- a/Kernel/Prekernel/Arch/aarch64/PrekernelMMU.cpp +++ b/Kernel/Prekernel/Arch/aarch64/PrekernelMMU.cpp @@ -8,7 +8,7 @@ #include <Kernel/Prekernel/Arch/aarch64/Prekernel.h> -#include <Kernel/Arch/aarch64/Aarch64Asm.h> +#include <Kernel/Arch/aarch64/ASM_wrapper.h> #include <Kernel/Arch/aarch64/Registers.h> #include <Kernel/Prekernel/Arch/aarch64/UART.h> @@ -108,8 +108,8 @@ static void build_identity_map(page_table_t page_table) static void switch_to_page_table(u8* page_table) { - set_ttbr0_el1((FlatPtr)page_table); - set_ttbr1_el1((FlatPtr)page_table); + Aarch64::Asm::set_ttbr0_el1((FlatPtr)page_table); + Aarch64::Asm::set_ttbr1_el1((FlatPtr)page_table); } static void activate_mmu() @@ -144,7 +144,7 @@ static void activate_mmu() sctlr_el1.M = 1; //Enable MMU Aarch64::SCTLR_EL1::write(sctlr_el1); - flush(); + Aarch64::Asm::flush(); } void init_prekernel_page_tables() diff --git a/Kernel/Prekernel/Arch/aarch64/boot.S b/Kernel/Prekernel/Arch/aarch64/boot.S index d0d19966e6..4c44b5288a 100644 --- a/Kernel/Prekernel/Arch/aarch64/boot.S +++ b/Kernel/Prekernel/Arch/aarch64/boot.S @@ -13,7 +13,7 @@ start: // Let only core 0 continue, put other cores to sleep. mrs x13, MPIDR_EL1 and x13, x13, 0xff - cbnz x13, halt + 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, diff --git a/Kernel/Prekernel/Arch/aarch64/init.cpp b/Kernel/Prekernel/Arch/aarch64/init.cpp index 3bef14c64d..6d2d91a481 100644 --- a/Kernel/Prekernel/Arch/aarch64/init.cpp +++ b/Kernel/Prekernel/Arch/aarch64/init.cpp @@ -7,7 +7,7 @@ #include <AK/Types.h> -#include <Kernel/Arch/aarch64/Aarch64Asm.h> +#include <Kernel/Arch/aarch64/ASM_wrapper.h> #include <Kernel/Prekernel/Arch/aarch64/Aarch64_asm_utils.h> #include <Kernel/Prekernel/Arch/aarch64/BootPPMParser.h> #include <Kernel/Prekernel/Arch/aarch64/Framebuffer.h> @@ -20,6 +20,8 @@ static void draw_logo(); static u32 query_firmware_version(); +extern "C" void wait_cycles(int n); + extern "C" [[noreturn]] void halt(); extern "C" [[noreturn]] void init(); @@ -37,7 +39,7 @@ extern "C" [[noreturn]] void init() uart.print_str("\r\n"); uart.print_str("CPU started in: EL"); - uart.print_num(static_cast<u64>(Kernel::get_current_exception_level())); + uart.print_num(static_cast<u64>(Kernel::Aarch64::Asm::get_current_exception_level())); uart.print_str("\r\n"); uart.print_str("Drop CPU to EL1\r\n"); @@ -71,21 +73,14 @@ extern size_t __stack_chk_guard; size_t __stack_chk_guard; extern "C" [[noreturn]] void __stack_chk_fail(); -[[noreturn]] void halt() -{ - for (;;) { - asm volatile("wfi"); - } -} - void __stack_chk_fail() { - halt(); + Prekernel::halt(); } [[noreturn]] void __assertion_failed(char const*, char const*, unsigned int, char const*) { - halt(); + Prekernel::halt(); } class QueryFirmwareVersionMboxMessage : Prekernel::Mailbox::Message { @@ -160,7 +155,7 @@ static void draw_logo() break; default: Prekernel::warnln("Unsupported pixel format"); - halt(); + Prekernel::halt(); } logo_pixels += 3; diff --git a/Kernel/Prekernel/CMakeLists.txt b/Kernel/Prekernel/CMakeLists.txt index 84bef8659d..dbf1d8be8f 100644 --- a/Kernel/Prekernel/CMakeLists.txt +++ b/Kernel/Prekernel/CMakeLists.txt @@ -24,9 +24,6 @@ if ("${SERENITY_ARCH}" STREQUAL "aarch64") # Assembly Arch/aarch64/boot.S Arch/aarch64/Aarch64_asm_utils.S - - # Shared with kernel - ../Arch/aarch64/Aarch64Asm.cpp ) else() set(SOURCES |