mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Kernel: Move common aarch64 asm functions into kernel folder and NS
This commit is contained in:
parent
68b5d00f42
commit
c2d7e200eb
6 changed files with 45 additions and 18 deletions
38
Kernel/Arch/aarch64/Aarch64Asm.h
Normal file
38
Kernel/Arch/aarch64/Aarch64Asm.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2021, James Mintram <me@jamesrm.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kernel/Arch/aarch64/Aarch64Registers.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
[[noreturn]] inline void halt()
|
||||
{
|
||||
for (;;) {
|
||||
asm volatile("wfi");
|
||||
}
|
||||
}
|
||||
|
||||
enum class ExceptionLevel : u8 {
|
||||
EL0 = 0,
|
||||
EL1 = 1,
|
||||
EL2 = 2,
|
||||
EL3 = 3,
|
||||
};
|
||||
|
||||
inline ExceptionLevel get_current_exception_level()
|
||||
{
|
||||
u64 current_exception_level;
|
||||
|
||||
asm("mrs %[value], CurrentEL"
|
||||
: [value] "=r"(current_exception_level));
|
||||
|
||||
current_exception_level = (current_exception_level >> 2) & 0x3;
|
||||
return static_cast<ExceptionLevel>(current_exception_level);
|
||||
}
|
||||
|
||||
}
|
|
@ -5,14 +5,6 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
.global get_current_exception_level
|
||||
.type get_current_exception_level, @function
|
||||
get_current_exception_level:
|
||||
mrs x0, CurrentEL
|
||||
lsr x0, x0, #2
|
||||
and x0, x0, #0x3
|
||||
ret
|
||||
|
||||
.global wait_cycles
|
||||
.type wait_cycles, @function
|
||||
wait_cycles:
|
||||
|
|
|
@ -6,14 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
enum class ExceptionLevel : u8 {
|
||||
EL0 = 0,
|
||||
EL1 = 1,
|
||||
EL2 = 2,
|
||||
EL3 = 3,
|
||||
};
|
||||
|
||||
extern "C" ExceptionLevel get_current_exception_level();
|
||||
extern "C" void wait_cycles(int n);
|
||||
|
||||
// CPU initialization functions
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/aarch64/Aarch64Asm.h>
|
||||
#include <Kernel/Arch/aarch64/Aarch64Registers.h>
|
||||
#include <Kernel/Prekernel/Arch/aarch64/Aarch64_asm_utils.h>
|
||||
#include <Kernel/Prekernel/Arch/aarch64/Prekernel.h>
|
||||
|
@ -81,7 +82,7 @@ static void set_up_el1()
|
|||
|
||||
void drop_to_exception_level_1()
|
||||
{
|
||||
switch (get_current_exception_level()) {
|
||||
switch (Kernel::get_current_exception_level()) {
|
||||
case ExceptionLevel::EL3:
|
||||
drop_to_el2();
|
||||
[[fallthrough]];
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
#include <Kernel/Arch/aarch64/Aarch64Asm.h>
|
||||
#include <Kernel/Prekernel/Arch/aarch64/Aarch64_asm_utils.h>
|
||||
#include <Kernel/Prekernel/Arch/aarch64/BootPPMParser.h>
|
||||
#include <Kernel/Prekernel/Arch/aarch64/Framebuffer.h>
|
||||
|
@ -36,7 +37,7 @@ extern "C" [[noreturn]] void init()
|
|||
uart.print_str("\r\n");
|
||||
|
||||
uart.print_str("CPU started in: EL");
|
||||
uart.print_num(static_cast<u64>(get_current_exception_level()));
|
||||
uart.print_num(static_cast<u64>(Kernel::get_current_exception_level()));
|
||||
uart.print_str("\r\n");
|
||||
|
||||
uart.print_str("Drop CPU to EL1\r\n");
|
||||
|
|
|
@ -23,6 +23,9 @@ 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
|
||||
|
|
Loading…
Reference in a new issue