1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:57:46 +00:00

Kernel: Move TrapFrame into its own header on aarch64

This commit is contained in:
Filiph Sandström 2022-08-06 04:16:24 +02:00 committed by Sam Atkins
parent 4aaf38e4f7
commit 99ae4fa161
7 changed files with 88 additions and 20 deletions

View file

@ -54,7 +54,7 @@ u64 Timer::microseconds_since_boot()
bool Timer::handle_irq(RegisterState const&)
{
dbgln("Timer fired: {} us", m_current_timer_value);
dmesgln("Timer fired: {} us", m_current_timer_value);
m_current_timer_value += m_interrupt_interval;
set_compare(TimerID::Timer1, m_current_timer_value);

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <AK/Platform.h>
namespace Kernel {
struct TrapFrame {
u64 x[31]; // Saved general purpose registers
u64 spsr_el1; // Save Processor Status Register, EL1
u64 elr_el1; // Exception Link Reigster, EL1
u64 tpidr_el1; // EL0 thread ID
u64 sp_el0; // EL0 stack pointer
};
}

View file

@ -3,6 +3,7 @@
* Copyright (c) 2021, Marcin Undak <mcinek@gmail.com>
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -20,19 +21,13 @@
#include <Kernel/Arch/aarch64/RPi/Timer.h>
#include <Kernel/Arch/aarch64/RPi/UART.h>
#include <Kernel/Arch/aarch64/Registers.h>
#include <Kernel/Arch/aarch64/TrapFrame.h>
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
#include <Kernel/KSyms.h>
#include <Kernel/Panic.h>
struct TrapFrame {
u64 x[31]; // Saved general purpose registers
u64 spsr_el1; // Save Processor Status Register, EL1
u64 elr_el1; // Exception Link Reigster, EL1
u64 tpidr_el1; // EL0 thread ID
u64 sp_el0; // EL0 stack pointer
};
extern "C" void exception_common(TrapFrame const* const trap_frame);
extern "C" void exception_common(TrapFrame const* const trap_frame)
extern "C" void exception_common(Kernel::TrapFrame const* const trap_frame);
extern "C" void exception_common(Kernel::TrapFrame const* const trap_frame)
{
constexpr bool print_stack_frame = true;
@ -86,6 +81,8 @@ ALWAYS_INLINE static Processor& bootstrap_processor()
return (Processor&)bootstrap_processor_storage;
}
Atomic<Graphics::Console*> g_boot_console;
extern "C" [[noreturn]] void init()
{
dbgln("Welcome to Serenity OS!");
@ -108,26 +105,28 @@ extern "C" [[noreturn]] void init()
load_kernel_symbol_table();
auto& framebuffer = RPi::Framebuffer::the();
if (framebuffer.initialized()) {
g_boot_console = &try_make_ref_counted<Graphics::BootFramebufferConsole>(framebuffer.gpu_buffer(), framebuffer.width(), framebuffer.width(), framebuffer.pitch()).value().leak_ref();
draw_logo();
}
dmesgln("Starting SerenityOS...");
initialize_interrupts();
InterruptManagement::initialize();
Processor::enable_interrupts();
auto firmware_version = query_firmware_version();
dbgln("Firmware version: {}", firmware_version);
dmesgln("Firmware version: {}", firmware_version);
dbgln("Initialize MMU");
dmesgln("Initialize MMU");
init_page_tables();
auto& framebuffer = RPi::Framebuffer::the();
if (framebuffer.initialized()) {
draw_logo();
}
auto& timer = RPi::Timer::the();
timer.set_interrupt_interval_usec(1'000'000);
timer.enable_interrupt_mode();
dbgln("Enter loop");
dmesgln("Enter loop");
// This will not disable interrupts, so the timer will still fire and show that
// interrupts are working!

View file

@ -4,11 +4,24 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Types.h>
#include <Kernel/Arch/aarch64/RPi/UART.h>
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
#include <Kernel/kstdio.h>
// FIXME: Merge the code in this file with Kernel/kprintf.cpp once the proper abstractions are in place.
namespace Kernel {
extern Atomic<Graphics::Console*> g_boot_console;
}
static void console_out(char ch)
{
if (auto* boot_console = g_boot_console.load()) {
boot_console->write(ch, true);
}
}
void kernelputstr(char const* characters, size_t length)
{
if (!characters)
@ -16,6 +29,9 @@ void kernelputstr(char const* characters, size_t length)
auto& uart = Kernel::RPi::UART::the();
uart.print_str(characters, length);
for (size_t i = 0; i < length; ++i)
console_out(characters[i]);
}
void kernelcriticalputstr(char const* characters, size_t length)