mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:47:46 +00:00
Kernel: Rename Aarch64Asm -> ASM_wrapper and add Aarch64::Asm namespace
This commit is contained in:
parent
34709c8d39
commit
4a4a3193f8
8 changed files with 28 additions and 34 deletions
54
Kernel/Arch/aarch64/ASM_wrapper.h
Normal file
54
Kernel/Arch/aarch64/ASM_wrapper.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2021, James Mintram <me@jamesrm.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kernel/Arch/aarch64/Registers.h>
|
||||
|
||||
namespace Kernel::Aarch64::Asm {
|
||||
|
||||
inline void set_ttbr1_el1(FlatPtr ttbr1_el1)
|
||||
{
|
||||
asm("msr ttbr1_el1, %[value]" ::[value] "r"(ttbr1_el1));
|
||||
}
|
||||
|
||||
inline void set_ttbr0_el1(FlatPtr ttbr0_el1)
|
||||
{
|
||||
asm("msr ttbr0_el1, %[value]" ::[value] "r"(ttbr0_el1));
|
||||
}
|
||||
|
||||
inline void flush()
|
||||
{
|
||||
asm("dsb ish");
|
||||
asm("isb");
|
||||
}
|
||||
|
||||
[[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