mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
Kernel: Move Prekernel assembly utils to aarch64/ASM_wrapper.h
By moving these functions to the ASM_wrapper.h file, we can get rid of another Prekernel file.
This commit is contained in:
parent
e80d8d697c
commit
e7c5fd978b
8 changed files with 44 additions and 77 deletions
|
@ -1,5 +1,8 @@
|
|||
/*
|
||||
* Copyright (c) 2021, James Mintram <me@jamesrm.com>
|
||||
* Copyright (c) 2021, Nico Weber <thakis@chromium.org>
|
||||
* Copyright (c) 2021, Marcin Undak <mcinek@gmail.com>
|
||||
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -51,4 +54,38 @@ inline ExceptionLevel get_current_exception_level()
|
|||
return static_cast<ExceptionLevel>(current_exception_level);
|
||||
}
|
||||
|
||||
inline void wait_cycles(int n)
|
||||
{
|
||||
// This is probably too fast when caching and branch prediction is turned on.
|
||||
// FIXME: Make timer-based.
|
||||
asm("mov x0, %[value]\n"
|
||||
"0:\n"
|
||||
" subs x0, x0, #1\n"
|
||||
" bne 0b" ::[value] "r"(n)
|
||||
: "x0");
|
||||
}
|
||||
|
||||
inline void el1_vector_table_install(void* vector_table)
|
||||
{
|
||||
asm("msr VBAR_EL1, %[value]" ::[value] "r"(vector_table));
|
||||
}
|
||||
|
||||
inline void enter_el2_from_el3()
|
||||
{
|
||||
asm volatile(" adr x0, entered_el2\n"
|
||||
" msr elr_el3, x0\n"
|
||||
" eret\n"
|
||||
"entered_el2:" ::
|
||||
: "x0");
|
||||
}
|
||||
|
||||
inline void enter_el1_from_el2()
|
||||
{
|
||||
asm volatile(" adr x0, entered_el1\n"
|
||||
" msr elr_el2, x0\n"
|
||||
" eret\n"
|
||||
"entered_el1:" ::
|
||||
: "x0");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue