summaryrefslogtreecommitdiff
path: root/Kernel/Arch/aarch64/Processor.cpp
blob: 1cc104dfbdf501432f320430c9a1dc9ab9a0581c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * 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>
#include <Kernel/Arch/aarch64/Prekernel/Aarch64_asm_utils.h>
#include <Kernel/Arch/aarch64/Prekernel/Prekernel.h>

extern "C" uintptr_t vector_table_el1;

namespace Kernel {

Processor* g_current_processor;

void Processor::initialize(u32 cpu)
{
    VERIFY(g_current_processor == nullptr);

    auto current_exception_level = static_cast<u64>(Kernel::Aarch64::Asm::get_current_exception_level());
    dbgln("CPU{} started in: EL{}", cpu, current_exception_level);

    dbgln("Drop CPU{} to EL1", cpu);
    Prekernel::drop_to_exception_level_1();

    // Load EL1 vector table
    el1_vector_table_install(&vector_table_el1);

    g_current_processor = this;
}
}