mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel: Remove Prekernel namespace in the aarch64 Kernel
Now that we merged all the Prekernel files into the Kernel files, we can get rid of the Prekernel namespace as well.
This commit is contained in:
parent
c96a3f0c48
commit
1f3977b303
Notes:
sideshowbarker
2024-07-17 10:56:04 +09:00
Author: https://github.com/FireFox317 Commit: https://github.com/SerenityOS/serenity/commit/1f3977b303 Pull-request: https://github.com/SerenityOS/serenity/pull/13996 Reviewed-by: https://github.com/linusg ✅ Reviewed-by: https://github.com/nico
23 changed files with 55 additions and 57 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "BootPPMParser.h"
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
BootPPMParser::BootPPMParser(u8 const* buffer, u32 buffer_size)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// Quick parser for .ppm image format (raw PortablePixMap)
|
||||
// This is much simpler version than userland implementation in PPMLoader.cpp
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#define PAGE_MASK (~(FlatPtr)0xfffu)
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
void drop_to_exception_level_1();
|
||||
void init_prekernel_page_tables();
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
#include <Kernel/Arch/aarch64/Registers.h>
|
||||
#include <Kernel/Panic.h>
|
||||
|
||||
using namespace Kernel;
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
static void drop_to_el2()
|
||||
{
|
||||
|
@ -80,14 +78,14 @@ static void set_up_el1()
|
|||
|
||||
void drop_to_exception_level_1()
|
||||
{
|
||||
switch (Kernel::Aarch64::Asm::get_current_exception_level()) {
|
||||
case Kernel::Aarch64::Asm::ExceptionLevel::EL3:
|
||||
switch (Aarch64::Asm::get_current_exception_level()) {
|
||||
case Aarch64::Asm::ExceptionLevel::EL3:
|
||||
drop_to_el2();
|
||||
[[fallthrough]];
|
||||
case Kernel::Aarch64::Asm::ExceptionLevel::EL2:
|
||||
case Aarch64::Asm::ExceptionLevel::EL2:
|
||||
drop_to_el1();
|
||||
[[fallthrough]];
|
||||
case Kernel::Aarch64::Asm::ExceptionLevel::EL1:
|
||||
case Aarch64::Asm::ExceptionLevel::EL1:
|
||||
set_up_el1();
|
||||
break;
|
||||
default: {
|
||||
|
|
|
@ -17,13 +17,11 @@
|
|||
// Documentation here for Aarch64 Address Translations
|
||||
// https://documentation-service.arm.com/static/5efa1d23dbdee951c1ccdec5?token=
|
||||
|
||||
using namespace Kernel;
|
||||
|
||||
// These come from the linker script
|
||||
extern u8 page_tables_phys_start[];
|
||||
extern u8 page_tables_phys_end[];
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// physical memory
|
||||
constexpr u32 START_OF_NORMAL_MEMORY = 0x00000000;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <Kernel/Arch/aarch64/MainIdRegister.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
MainIdRegister::MainIdRegister()
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
class MainIdRegister {
|
||||
public:
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#include <Kernel/Arch/aarch64/ASM_wrapper.h>
|
||||
#include <Kernel/Arch/aarch64/CPU.h>
|
||||
|
||||
extern "C" uintptr_t vector_table_el1;
|
||||
|
||||
|
@ -19,14 +20,14 @@ void Processor::initialize(u32 cpu)
|
|||
{
|
||||
VERIFY(g_current_processor == nullptr);
|
||||
|
||||
auto current_exception_level = static_cast<u64>(Kernel::Aarch64::Asm::get_current_exception_level());
|
||||
auto current_exception_level = static_cast<u64>(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();
|
||||
drop_to_exception_level_1();
|
||||
|
||||
// Load EL1 vector table
|
||||
Kernel::Aarch64::Asm::el1_vector_table_install(&vector_table_el1);
|
||||
Aarch64::Asm::el1_vector_table_install(&vector_table_el1);
|
||||
|
||||
g_current_processor = this;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <Kernel/Arch/aarch64/RPi/Framebuffer.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/FramebufferMailboxMessages.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
Framebuffer::Framebuffer()
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
class Framebuffer {
|
||||
public:
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <Kernel/Arch/aarch64/RPi/Mailbox.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
class FramebufferSetPhysicalSizeMboxMessage : public Mailbox::Message {
|
||||
public:
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <Kernel/Arch/aarch64/RPi/GPIO.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/MMIO.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// See BCM2835-ARM-Peripherals.pdf section "6 General Purpose I/O" or bcm2711-peripherals.pdf "Chapter 5. General Purpose I/O".
|
||||
|
||||
|
@ -72,7 +72,7 @@ void GPIO::internal_enable_pins(u32 enable[2], PullUpDownState state)
|
|||
m_registers->pull_up_down_enable = static_cast<u32>(state);
|
||||
|
||||
// 2. Wait 150 cycles – this provides the required set-up time for the control signal
|
||||
Kernel::Aarch64::Asm::wait_cycles(150);
|
||||
Aarch64::Asm::wait_cycles(150);
|
||||
|
||||
// 3. Write to GPPUDCLK0/1 to clock the control signal into the GPIO pads you wish to
|
||||
// modify – NOTE only the pads which receive a clock will be modified, all others will
|
||||
|
@ -81,7 +81,7 @@ void GPIO::internal_enable_pins(u32 enable[2], PullUpDownState state)
|
|||
m_registers->pull_up_down_enable_clock.bits[1] = enable[1];
|
||||
|
||||
// 4. Wait 150 cycles – this provides the required hold time for the control signal
|
||||
Kernel::Aarch64::Asm::wait_cycles(150);
|
||||
Aarch64::Asm::wait_cycles(150);
|
||||
|
||||
// 5. Write to GPPUD to remove the control signal
|
||||
m_registers->pull_up_down_enable = 0;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <AK/Array.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
struct GPIOControlRegisters;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <Kernel/Arch/aarch64/MainIdRegister.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/MMIO.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
MMIO::MMIO()
|
||||
: m_base_address(0xFE00'0000)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// Knows about memory-mapped IO addresses on the Broadcom family of SOCs used in Raspberry Pis.
|
||||
// RPi3 is the first Raspberry Pi that supports aarch64.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <Kernel/Arch/aarch64/RPi/MMIO.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/Mailbox.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// There's one mailbox at MBOX_BASE_OFFSET for reading responses from VideoCore, and one at MBOX_BASE_OFFSET + 0x20 for sending requests.
|
||||
// Each has its own status word.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// Can exchange mailbox messages with the Raspberry Pi's VideoCore chip.
|
||||
// https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <Kernel/Arch/aarch64/RPi/Mailbox.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/Timer.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// "12.1 System Timer Registers" / "10.2 System Timer Registers"
|
||||
struct TimerRegisters {
|
||||
|
@ -50,14 +50,14 @@ u64 Timer::microseconds_since_boot()
|
|||
return (static_cast<u64>(high) << 32) | low;
|
||||
}
|
||||
|
||||
class SetClockRateMboxMessage : Prekernel::Mailbox::Message {
|
||||
class SetClockRateMboxMessage : Mailbox::Message {
|
||||
public:
|
||||
u32 clock_id;
|
||||
u32 rate_hz;
|
||||
u32 skip_setting_turbo;
|
||||
|
||||
SetClockRateMboxMessage()
|
||||
: Prekernel::Mailbox::Message(0x0003'8002, 12)
|
||||
: Mailbox::Message(0x0003'8002, 12)
|
||||
{
|
||||
clock_id = 0;
|
||||
rate_hz = 0;
|
||||
|
@ -68,16 +68,16 @@ public:
|
|||
u32 Timer::set_clock_rate(ClockID clock_id, u32 rate_hz, bool skip_setting_turbo)
|
||||
{
|
||||
struct __attribute__((aligned(16))) {
|
||||
Prekernel::Mailbox::MessageHeader header;
|
||||
Mailbox::MessageHeader header;
|
||||
SetClockRateMboxMessage set_clock_rate;
|
||||
Prekernel::Mailbox::MessageTail tail;
|
||||
Mailbox::MessageTail tail;
|
||||
} message_queue;
|
||||
|
||||
message_queue.set_clock_rate.clock_id = static_cast<u32>(clock_id);
|
||||
message_queue.set_clock_rate.rate_hz = rate_hz;
|
||||
message_queue.set_clock_rate.skip_setting_turbo = skip_setting_turbo ? 1 : 0;
|
||||
|
||||
if (!Prekernel::Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
|
||||
if (!Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
|
||||
dbgln("Timer::set_clock_rate() failed!");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
struct TimerRegisters;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <Kernel/Arch/aarch64/RPi/Timer.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/UART.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
// "13.4 Register View" / "11.5 Register View"
|
||||
struct UARTRegisters {
|
||||
|
@ -104,10 +104,10 @@ UART::UART()
|
|||
u32 rate_in_hz = Timer::the().set_clock_rate(Timer::ClockID::UART, 16 * baud_rate);
|
||||
|
||||
// The BCM's PL011 UART is alternate function 0 on pins 14 and 15.
|
||||
auto& gpio = Prekernel::GPIO::the();
|
||||
gpio.set_pin_function(14, Prekernel::GPIO::PinFunction::Alternate0);
|
||||
gpio.set_pin_function(15, Prekernel::GPIO::PinFunction::Alternate0);
|
||||
gpio.set_pin_pull_up_down_state(Array { 14, 15 }, Prekernel::GPIO::PullUpDownState::Disable);
|
||||
auto& gpio = GPIO::the();
|
||||
gpio.set_pin_function(14, GPIO::PinFunction::Alternate0);
|
||||
gpio.set_pin_function(15, GPIO::PinFunction::Alternate0);
|
||||
gpio.set_pin_pull_up_down_state(Array { 14, 15 }, GPIO::PullUpDownState::Disable);
|
||||
|
||||
// Clock and pins are configured. Turn UART on.
|
||||
set_baud_rate(baud_rate, rate_in_hz);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Prekernel {
|
||||
namespace Kernel {
|
||||
|
||||
struct UARTRegisters;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#include <Kernel/Arch/aarch64/BootPPMParser.h>
|
||||
#include <Kernel/Arch/aarch64/CPU.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/Framebuffer.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/Mailbox.h>
|
||||
#include <Kernel/Arch/aarch64/RPi/Timer.h>
|
||||
|
@ -72,16 +73,16 @@ extern "C" [[noreturn]] void init()
|
|||
dbgln("Firmware version: {}", firmware_version);
|
||||
|
||||
dbgln("Initialize MMU");
|
||||
Prekernel::init_prekernel_page_tables();
|
||||
Kernel::init_prekernel_page_tables();
|
||||
|
||||
auto& framebuffer = Prekernel::Framebuffer::the();
|
||||
auto& framebuffer = Kernel::Framebuffer::the();
|
||||
if (framebuffer.initialized()) {
|
||||
draw_logo();
|
||||
}
|
||||
|
||||
dbgln("Enter loop");
|
||||
|
||||
auto& timer = Prekernel::Timer::the();
|
||||
auto& timer = Kernel::Timer::the();
|
||||
u64 start_musec = 0;
|
||||
for (;;) {
|
||||
u64 now_musec;
|
||||
|
@ -132,12 +133,12 @@ extern "C" void exception_common(TrapFrame const* const trap_frame)
|
|||
}
|
||||
}
|
||||
|
||||
class QueryFirmwareVersionMboxMessage : Prekernel::Mailbox::Message {
|
||||
class QueryFirmwareVersionMboxMessage : Kernel::Mailbox::Message {
|
||||
public:
|
||||
u32 version;
|
||||
|
||||
QueryFirmwareVersionMboxMessage()
|
||||
: Prekernel::Mailbox::Message(0x0000'0001, 4)
|
||||
: Kernel::Mailbox::Message(0x0000'0001, 4)
|
||||
{
|
||||
version = 0;
|
||||
}
|
||||
|
@ -146,12 +147,12 @@ public:
|
|||
static u32 query_firmware_version()
|
||||
{
|
||||
struct __attribute__((aligned(16))) {
|
||||
Prekernel::Mailbox::MessageHeader header;
|
||||
Kernel::Mailbox::MessageHeader header;
|
||||
QueryFirmwareVersionMboxMessage query_firmware_version;
|
||||
Prekernel::Mailbox::MessageTail tail;
|
||||
Kernel::Mailbox::MessageTail tail;
|
||||
} message_queue;
|
||||
|
||||
if (!Prekernel::Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
|
||||
if (!Kernel::Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
|
||||
return 0xffff'ffff;
|
||||
}
|
||||
|
||||
|
@ -163,7 +164,7 @@ extern "C" const u32 serenity_boot_logo_size;
|
|||
|
||||
static void draw_logo()
|
||||
{
|
||||
Prekernel::BootPPMParser logo_parser(reinterpret_cast<u8 const*>(&serenity_boot_logo_start), serenity_boot_logo_size);
|
||||
Kernel::BootPPMParser logo_parser(reinterpret_cast<u8 const*>(&serenity_boot_logo_start), serenity_boot_logo_size);
|
||||
if (!logo_parser.parse()) {
|
||||
dbgln("Failed to parse boot logo.");
|
||||
return;
|
||||
|
@ -171,7 +172,7 @@ static void draw_logo()
|
|||
|
||||
dbgln("Boot logo size: {} ({} x {})", serenity_boot_logo_size, logo_parser.image.width, logo_parser.image.height);
|
||||
|
||||
auto& framebuffer = Prekernel::Framebuffer::the();
|
||||
auto& framebuffer = Kernel::Framebuffer::the();
|
||||
auto fb_ptr = framebuffer.gpu_buffer();
|
||||
auto image_left = (framebuffer.width() - logo_parser.image.width) / 2;
|
||||
auto image_right = image_left + logo_parser.image.width;
|
||||
|
@ -183,12 +184,12 @@ static void draw_logo()
|
|||
for (u32 x = 0; x < framebuffer.width(); x++) {
|
||||
if (x >= image_left && x < image_right && y >= image_top && y < image_bottom) {
|
||||
switch (framebuffer.pixel_order()) {
|
||||
case Prekernel::Framebuffer::PixelOrder::RGB:
|
||||
case Kernel::Framebuffer::PixelOrder::RGB:
|
||||
fb_ptr[0] = logo_pixels[0];
|
||||
fb_ptr[1] = logo_pixels[1];
|
||||
fb_ptr[2] = logo_pixels[2];
|
||||
break;
|
||||
case Prekernel::Framebuffer::PixelOrder::BGR:
|
||||
case Kernel::Framebuffer::PixelOrder::BGR:
|
||||
fb_ptr[0] = logo_pixels[2];
|
||||
fb_ptr[1] = logo_pixels[1];
|
||||
fb_ptr[2] = logo_pixels[0];
|
||||
|
|
|
@ -14,7 +14,7 @@ void kernelputstr(char const* characters, size_t length)
|
|||
if (!characters)
|
||||
return;
|
||||
|
||||
auto& uart = Prekernel::UART::the();
|
||||
auto& uart = Kernel::UART::the();
|
||||
uart.print_str(characters, length);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ void kernelcriticalputstr(char const* characters, size_t length)
|
|||
if (!characters)
|
||||
return;
|
||||
|
||||
auto& uart = Prekernel::UART::the();
|
||||
auto& uart = Kernel::UART::the();
|
||||
uart.print_str(characters, length);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,6 @@ void kernelearlyputstr(char const* characters, size_t length)
|
|||
if (!characters)
|
||||
return;
|
||||
|
||||
auto& uart = Prekernel::UART::the();
|
||||
auto& uart = Kernel::UART::the();
|
||||
uart.print_str(characters, length);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue