2022-05-09 07:14:20 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AK/Format.h>
|
|
|
|
|
|
|
|
|
|
#include <Kernel/Arch/Processor.h>
|
|
|
|
|
#include <Kernel/Arch/aarch64/ASM_wrapper.h>
|
2022-05-09 19:27:23 -03:00
|
|
|
#include <Kernel/Arch/aarch64/CPU.h>
|
2022-05-09 07:14:20 -03:00
|
|
|
|
|
|
|
|
extern "C" uintptr_t vector_table_el1;
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
|
|
Processor* g_current_processor;
|
|
|
|
|
|
|
|
|
|
void Processor::initialize(u32 cpu)
|
|
|
|
|
{
|
|
|
|
|
VERIFY(g_current_processor == nullptr);
|
|
|
|
|
|
2022-05-09 19:27:23 -03:00
|
|
|
auto current_exception_level = static_cast<u64>(Aarch64::Asm::get_current_exception_level());
|
2022-05-09 07:14:20 -03:00
|
|
|
dbgln("CPU{} started in: EL{}", cpu, current_exception_level);
|
|
|
|
|
|
|
|
|
|
dbgln("Drop CPU{} to EL1", cpu);
|
2022-05-09 19:27:23 -03:00
|
|
|
drop_to_exception_level_1();
|
2022-05-09 07:14:20 -03:00
|
|
|
|
|
|
|
|
// Load EL1 vector table
|
2022-05-09 19:27:23 -03:00
|
|
|
Aarch64::Asm::el1_vector_table_install(&vector_table_el1);
|
2022-05-09 07:14:20 -03:00
|
|
|
|
|
|
|
|
g_current_processor = this;
|
|
|
|
|
}
|
2022-05-09 08:33:35 -03:00
|
|
|
|
|
|
|
|
[[noreturn]] void Processor::halt()
|
|
|
|
|
{
|
2022-05-17 05:49:37 -03:00
|
|
|
disable_interrupts();
|
2022-05-09 08:33:35 -03:00
|
|
|
for (;;)
|
|
|
|
|
asm volatile("wfi");
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-17 07:38:58 -03:00
|
|
|
void Processor::flush_tlb_local(VirtualAddress, size_t)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Implement this
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-09 07:14:20 -03:00
|
|
|
}
|