mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
Kernel: Move TrapFrame into its own header on aarch64
This commit is contained in:
parent
4aaf38e4f7
commit
99ae4fa161
7 changed files with 88 additions and 20 deletions
|
@ -54,7 +54,7 @@ u64 Timer::microseconds_since_boot()
|
||||||
|
|
||||||
bool Timer::handle_irq(RegisterState const&)
|
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;
|
m_current_timer_value += m_interrupt_interval;
|
||||||
set_compare(TimerID::Timer1, m_current_timer_value);
|
set_compare(TimerID::Timer1, m_current_timer_value);
|
||||||
|
|
23
Kernel/Arch/aarch64/TrapFrame.h
Normal file
23
Kernel/Arch/aarch64/TrapFrame.h
Normal 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
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
* Copyright (c) 2021, Marcin Undak <mcinek@gmail.com>
|
* Copyright (c) 2021, Marcin Undak <mcinek@gmail.com>
|
||||||
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
||||||
* Copyright (c) 2022, the SerenityOS developers.
|
* Copyright (c) 2022, the SerenityOS developers.
|
||||||
|
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -20,19 +21,13 @@
|
||||||
#include <Kernel/Arch/aarch64/RPi/Timer.h>
|
#include <Kernel/Arch/aarch64/RPi/Timer.h>
|
||||||
#include <Kernel/Arch/aarch64/RPi/UART.h>
|
#include <Kernel/Arch/aarch64/RPi/UART.h>
|
||||||
#include <Kernel/Arch/aarch64/Registers.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/KSyms.h>
|
||||||
#include <Kernel/Panic.h>
|
#include <Kernel/Panic.h>
|
||||||
|
|
||||||
struct TrapFrame {
|
extern "C" void exception_common(Kernel::TrapFrame const* const trap_frame);
|
||||||
u64 x[31]; // Saved general purpose registers
|
extern "C" void exception_common(Kernel::TrapFrame const* const trap_frame)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
constexpr bool print_stack_frame = true;
|
constexpr bool print_stack_frame = true;
|
||||||
|
|
||||||
|
@ -86,6 +81,8 @@ ALWAYS_INLINE static Processor& bootstrap_processor()
|
||||||
return (Processor&)bootstrap_processor_storage;
|
return (Processor&)bootstrap_processor_storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Atomic<Graphics::Console*> g_boot_console;
|
||||||
|
|
||||||
extern "C" [[noreturn]] void init()
|
extern "C" [[noreturn]] void init()
|
||||||
{
|
{
|
||||||
dbgln("Welcome to Serenity OS!");
|
dbgln("Welcome to Serenity OS!");
|
||||||
|
@ -108,26 +105,28 @@ extern "C" [[noreturn]] void init()
|
||||||
|
|
||||||
load_kernel_symbol_table();
|
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();
|
initialize_interrupts();
|
||||||
InterruptManagement::initialize();
|
InterruptManagement::initialize();
|
||||||
Processor::enable_interrupts();
|
Processor::enable_interrupts();
|
||||||
|
|
||||||
auto firmware_version = query_firmware_version();
|
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();
|
init_page_tables();
|
||||||
|
|
||||||
auto& framebuffer = RPi::Framebuffer::the();
|
|
||||||
if (framebuffer.initialized()) {
|
|
||||||
draw_logo();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& timer = RPi::Timer::the();
|
auto& timer = RPi::Timer::the();
|
||||||
timer.set_interrupt_interval_usec(1'000'000);
|
timer.set_interrupt_interval_usec(1'000'000);
|
||||||
timer.enable_interrupt_mode();
|
timer.enable_interrupt_mode();
|
||||||
|
|
||||||
dbgln("Enter loop");
|
dmesgln("Enter loop");
|
||||||
|
|
||||||
// This will not disable interrupts, so the timer will still fire and show that
|
// This will not disable interrupts, so the timer will still fire and show that
|
||||||
// interrupts are working!
|
// interrupts are working!
|
||||||
|
|
|
@ -4,11 +4,24 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/Types.h>
|
||||||
#include <Kernel/Arch/aarch64/RPi/UART.h>
|
#include <Kernel/Arch/aarch64/RPi/UART.h>
|
||||||
|
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
||||||
#include <Kernel/kstdio.h>
|
#include <Kernel/kstdio.h>
|
||||||
|
|
||||||
// FIXME: Merge the code in this file with Kernel/kprintf.cpp once the proper abstractions are in place.
|
// 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)
|
void kernelputstr(char const* characters, size_t length)
|
||||||
{
|
{
|
||||||
if (!characters)
|
if (!characters)
|
||||||
|
@ -16,6 +29,9 @@ void kernelputstr(char const* characters, size_t length)
|
||||||
|
|
||||||
auto& uart = Kernel::RPi::UART::the();
|
auto& uart = Kernel::RPi::UART::the();
|
||||||
uart.print_str(characters, length);
|
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)
|
void kernelcriticalputstr(char const* characters, size_t length)
|
||||||
|
|
|
@ -459,6 +459,9 @@ else()
|
||||||
MiniStdLib.cpp
|
MiniStdLib.cpp
|
||||||
UBSanitizer.cpp
|
UBSanitizer.cpp
|
||||||
|
|
||||||
|
Graphics/Console/BootFramebufferConsole.cpp
|
||||||
|
Graphics/Console/GenericFramebufferConsole.cpp
|
||||||
|
|
||||||
Memory/AddressSpace.cpp
|
Memory/AddressSpace.cpp
|
||||||
Memory/AnonymousVMObject.cpp
|
Memory/AnonymousVMObject.cpp
|
||||||
Memory/InodeVMObject.cpp
|
Memory/InodeVMObject.cpp
|
||||||
|
|
|
@ -6,18 +6,34 @@
|
||||||
|
|
||||||
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
||||||
#include <Kernel/Locking/Spinlock.h>
|
#include <Kernel/Locking/Spinlock.h>
|
||||||
#include <Kernel/Memory/MemoryManager.h>
|
// FIXME: Port MemoryManager to aarch64
|
||||||
|
#if !ARCH(AARCH64)
|
||||||
|
# include <Kernel/Memory/MemoryManager.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Kernel::Graphics {
|
namespace Kernel::Graphics {
|
||||||
|
|
||||||
|
// FIXME: Port MemoryManager to aarch64
|
||||||
|
#if ARCH(AARCH64)
|
||||||
|
BootFramebufferConsole::BootFramebufferConsole(u8* framebuffer_addr, size_t width, size_t height, size_t pitch)
|
||||||
|
: GenericFramebufferConsoleImpl(width, height, pitch)
|
||||||
|
, m_framebuffer(framebuffer_addr)
|
||||||
|
#else
|
||||||
BootFramebufferConsole::BootFramebufferConsole(PhysicalAddress framebuffer_addr, size_t width, size_t height, size_t pitch)
|
BootFramebufferConsole::BootFramebufferConsole(PhysicalAddress framebuffer_addr, size_t width, size_t height, size_t pitch)
|
||||||
: GenericFramebufferConsoleImpl(width, height, pitch)
|
: GenericFramebufferConsoleImpl(width, height, pitch)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
// FIXME: Port MemoryManager to aarch64
|
||||||
|
#if ARCH(AARCH64)
|
||||||
|
m_framebuffer_data = framebuffer_addr;
|
||||||
|
#else
|
||||||
// NOTE: We're very early in the boot process, memory allocations shouldn't really fail
|
// NOTE: We're very early in the boot process, memory allocations shouldn't really fail
|
||||||
auto framebuffer_end = Memory::page_round_up(framebuffer_addr.offset(height * pitch * sizeof(u32)).get()).release_value();
|
auto framebuffer_end = Memory::page_round_up(framebuffer_addr.offset(height * pitch * sizeof(u32)).get()).release_value();
|
||||||
m_framebuffer = MM.allocate_kernel_region(framebuffer_addr.page_base(), framebuffer_end - framebuffer_addr.page_base().get(), "Boot Framebuffer"sv, Memory::Region::Access::ReadWrite).release_value();
|
m_framebuffer = MM.allocate_kernel_region(framebuffer_addr.page_base(), framebuffer_end - framebuffer_addr.page_base().get(), "Boot Framebuffer"sv, Memory::Region::Access::ReadWrite).release_value();
|
||||||
|
|
||||||
[[maybe_unused]] auto result = m_framebuffer->set_write_combine(true);
|
[[maybe_unused]] auto result = m_framebuffer->set_write_combine(true);
|
||||||
m_framebuffer_data = m_framebuffer->vaddr().offset(framebuffer_addr.offset_in_page()).as_ptr();
|
m_framebuffer_data = m_framebuffer->vaddr().offset(framebuffer_addr.offset_in_page()).as_ptr();
|
||||||
|
#endif
|
||||||
memset(m_framebuffer_data, 0, height * pitch * sizeof(u32));
|
memset(m_framebuffer_data, 0, height * pitch * sizeof(u32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +46,7 @@ void BootFramebufferConsole::clear(size_t x, size_t y, size_t length)
|
||||||
|
|
||||||
void BootFramebufferConsole::clear_glyph(size_t x, size_t y)
|
void BootFramebufferConsole::clear_glyph(size_t x, size_t y)
|
||||||
{
|
{
|
||||||
|
|
||||||
VERIFY(m_lock.is_locked());
|
VERIFY(m_lock.is_locked());
|
||||||
GenericFramebufferConsoleImpl::clear_glyph(x, y);
|
GenericFramebufferConsoleImpl::clear_glyph(x, y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,24 @@ public:
|
||||||
virtual void flush(size_t, size_t, size_t, size_t) override { }
|
virtual void flush(size_t, size_t, size_t, size_t) override { }
|
||||||
virtual void set_resolution(size_t, size_t, size_t) override { }
|
virtual void set_resolution(size_t, size_t, size_t) override { }
|
||||||
|
|
||||||
|
// FIXME: Port MemoryManager to aarch64
|
||||||
|
#if ARCH(AARCH64)
|
||||||
|
BootFramebufferConsole(u8* framebuffer_addr, size_t width, size_t height, size_t pitch);
|
||||||
|
#else
|
||||||
BootFramebufferConsole(PhysicalAddress framebuffer_addr, size_t width, size_t height, size_t pitch);
|
BootFramebufferConsole(PhysicalAddress framebuffer_addr, size_t width, size_t height, size_t pitch);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void clear_glyph(size_t x, size_t y) override;
|
virtual void clear_glyph(size_t x, size_t y) override;
|
||||||
|
|
||||||
virtual u8* framebuffer_data() override;
|
virtual u8* framebuffer_data() override;
|
||||||
|
|
||||||
|
// FIXME: Port MemoryManager to aarch64
|
||||||
|
#if ARCH(AARCH64)
|
||||||
|
u8* m_framebuffer;
|
||||||
|
#else
|
||||||
OwnPtr<Memory::Region> m_framebuffer;
|
OwnPtr<Memory::Region> m_framebuffer;
|
||||||
|
#endif
|
||||||
u8* m_framebuffer_data {};
|
u8* m_framebuffer_data {};
|
||||||
mutable Spinlock m_lock;
|
mutable Spinlock m_lock;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue