mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:17:35 +00: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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue