|
@@ -20,9 +20,6 @@
|
|
|
#include <Kernel/KSyms.h>
|
|
|
#include <Kernel/Panic.h>
|
|
|
|
|
|
-static void draw_logo();
|
|
|
-static u32 query_firmware_version();
|
|
|
-
|
|
|
struct TrapFrame {
|
|
|
u64 x[31]; // Saved general purpose registers
|
|
|
u64 spsr_el1; // Save Processor Status Register, EL1
|
|
@@ -31,9 +28,25 @@ struct TrapFrame {
|
|
|
u64 sp_el0; // EL0 stack pointer
|
|
|
};
|
|
|
|
|
|
-extern "C" [[noreturn]] void halt();
|
|
|
-extern "C" [[noreturn]] void init();
|
|
|
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;
|
|
|
+
|
|
|
+ if constexpr (print_stack_frame) {
|
|
|
+ dbgln("Exception Generated by processor!");
|
|
|
+
|
|
|
+ for (auto reg = 0; reg < 31; reg++) {
|
|
|
+ dbgln("x{}: {:x}", reg, trap_frame->x[reg]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Special registers
|
|
|
+ dbgln("spsr_el1: {:x}", trap_frame->spsr_el1);
|
|
|
+ dbgln("elr_el1: {:x}", trap_frame->elr_el1);
|
|
|
+ dbgln("tpidr_el1: {:x}", trap_frame->tpidr_el1);
|
|
|
+ dbgln("sp_el0: {:x}", trap_frame->sp_el0);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
typedef void (*ctor_func_t)();
|
|
|
extern ctor_func_t start_heap_ctors[];
|
|
@@ -41,10 +54,28 @@ extern ctor_func_t end_heap_ctors[];
|
|
|
extern ctor_func_t start_ctors[];
|
|
|
extern ctor_func_t end_ctors[];
|
|
|
|
|
|
-ALWAYS_INLINE static Kernel::Processor& bootstrap_processor()
|
|
|
+// FIXME: Share this with the Intel Prekernel.
|
|
|
+extern size_t __stack_chk_guard;
|
|
|
+size_t __stack_chk_guard;
|
|
|
+extern "C" [[noreturn]] void __stack_chk_fail();
|
|
|
+
|
|
|
+void __stack_chk_fail()
|
|
|
{
|
|
|
- alignas(Kernel::Processor) static u8 bootstrap_processor_storage[sizeof(Kernel::Processor)];
|
|
|
- return (Kernel::Processor&)bootstrap_processor_storage;
|
|
|
+ Kernel::Processor::halt();
|
|
|
+}
|
|
|
+
|
|
|
+namespace Kernel {
|
|
|
+
|
|
|
+static void draw_logo();
|
|
|
+static u32 query_firmware_version();
|
|
|
+
|
|
|
+extern "C" [[noreturn]] void halt();
|
|
|
+extern "C" [[noreturn]] void init();
|
|
|
+
|
|
|
+ALWAYS_INLINE static Processor& bootstrap_processor()
|
|
|
+{
|
|
|
+ alignas(Processor) static u8 bootstrap_processor_storage[sizeof(Processor)];
|
|
|
+ return (Processor&)bootstrap_processor_storage;
|
|
|
}
|
|
|
|
|
|
extern "C" [[noreturn]] void init()
|
|
@@ -54,7 +85,7 @@ extern "C" [[noreturn]] void init()
|
|
|
dbgln("Observed deviations from that ideal are shortcomings of your imagination.");
|
|
|
dbgln();
|
|
|
|
|
|
- new (&bootstrap_processor()) Kernel::Processor();
|
|
|
+ new (&bootstrap_processor()) Processor();
|
|
|
bootstrap_processor().initialize(0);
|
|
|
|
|
|
// We call the constructors of kmalloc.cpp separately, because other constructors in the Kernel
|
|
@@ -67,22 +98,22 @@ extern "C" [[noreturn]] void init()
|
|
|
for (ctor_func_t* ctor = start_ctors; ctor < end_ctors; ctor++)
|
|
|
(*ctor)();
|
|
|
|
|
|
- Kernel::load_kernel_symbol_table();
|
|
|
+ load_kernel_symbol_table();
|
|
|
|
|
|
auto firmware_version = query_firmware_version();
|
|
|
dbgln("Firmware version: {}", firmware_version);
|
|
|
|
|
|
dbgln("Initialize MMU");
|
|
|
- Kernel::init_prekernel_page_tables();
|
|
|
+ init_prekernel_page_tables();
|
|
|
|
|
|
- auto& framebuffer = Kernel::Framebuffer::the();
|
|
|
+ auto& framebuffer = Framebuffer::the();
|
|
|
if (framebuffer.initialized()) {
|
|
|
draw_logo();
|
|
|
}
|
|
|
|
|
|
dbgln("Enter loop");
|
|
|
|
|
|
- auto& timer = Kernel::Timer::the();
|
|
|
+ auto& timer = Timer::the();
|
|
|
u64 start_musec = 0;
|
|
|
for (;;) {
|
|
|
u64 now_musec;
|
|
@@ -93,41 +124,12 @@ extern "C" [[noreturn]] void init()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// FIXME: Share this with the Intel Prekernel.
|
|
|
-extern size_t __stack_chk_guard;
|
|
|
-size_t __stack_chk_guard;
|
|
|
-extern "C" [[noreturn]] void __stack_chk_fail();
|
|
|
-
|
|
|
-void __stack_chk_fail()
|
|
|
-{
|
|
|
- Kernel::Processor::halt();
|
|
|
-}
|
|
|
-
|
|
|
-extern "C" void exception_common(TrapFrame const* const trap_frame)
|
|
|
-{
|
|
|
- constexpr bool print_stack_frame = true;
|
|
|
-
|
|
|
- if constexpr (print_stack_frame) {
|
|
|
- dbgln("Exception Generated by processor!");
|
|
|
-
|
|
|
- for (auto reg = 0; reg < 31; reg++) {
|
|
|
- dbgln("x{}: {:x}", reg, trap_frame->x[reg]);
|
|
|
- }
|
|
|
-
|
|
|
- // Special registers
|
|
|
- dbgln("spsr_el1: {:x}", trap_frame->spsr_el1);
|
|
|
- dbgln("elr_el1: {:x}", trap_frame->elr_el1);
|
|
|
- dbgln("tpidr_el1: {:x}", trap_frame->tpidr_el1);
|
|
|
- dbgln("sp_el0: {:x}", trap_frame->sp_el0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-class QueryFirmwareVersionMboxMessage : Kernel::Mailbox::Message {
|
|
|
+class QueryFirmwareVersionMboxMessage : Mailbox::Message {
|
|
|
public:
|
|
|
u32 version;
|
|
|
|
|
|
QueryFirmwareVersionMboxMessage()
|
|
|
- : Kernel::Mailbox::Message(0x0000'0001, 4)
|
|
|
+ : Mailbox::Message(0x0000'0001, 4)
|
|
|
{
|
|
|
version = 0;
|
|
|
}
|
|
@@ -136,12 +138,12 @@ public:
|
|
|
static u32 query_firmware_version()
|
|
|
{
|
|
|
struct __attribute__((aligned(16))) {
|
|
|
- Kernel::Mailbox::MessageHeader header;
|
|
|
+ Mailbox::MessageHeader header;
|
|
|
QueryFirmwareVersionMboxMessage query_firmware_version;
|
|
|
- Kernel::Mailbox::MessageTail tail;
|
|
|
+ Mailbox::MessageTail tail;
|
|
|
} message_queue;
|
|
|
|
|
|
- if (!Kernel::Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
|
|
|
+ if (!Mailbox::the().send_queue(&message_queue, sizeof(message_queue))) {
|
|
|
return 0xffff'ffff;
|
|
|
}
|
|
|
|
|
@@ -153,7 +155,7 @@ extern "C" const u32 serenity_boot_logo_size;
|
|
|
|
|
|
static void draw_logo()
|
|
|
{
|
|
|
- Kernel::BootPPMParser logo_parser(reinterpret_cast<u8 const*>(&serenity_boot_logo_start), serenity_boot_logo_size);
|
|
|
+ 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;
|
|
@@ -161,7 +163,7 @@ static void draw_logo()
|
|
|
|
|
|
dbgln("Boot logo size: {} ({} x {})", serenity_boot_logo_size, logo_parser.image.width, logo_parser.image.height);
|
|
|
|
|
|
- auto& framebuffer = Kernel::Framebuffer::the();
|
|
|
+ auto& framebuffer = 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;
|
|
@@ -173,12 +175,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 Kernel::Framebuffer::PixelOrder::RGB:
|
|
|
+ case Framebuffer::PixelOrder::RGB:
|
|
|
fb_ptr[0] = logo_pixels[0];
|
|
|
fb_ptr[1] = logo_pixels[1];
|
|
|
fb_ptr[2] = logo_pixels[2];
|
|
|
break;
|
|
|
- case Kernel::Framebuffer::PixelOrder::BGR:
|
|
|
+ case Framebuffer::PixelOrder::BGR:
|
|
|
fb_ptr[0] = logo_pixels[2];
|
|
|
fb_ptr[1] = logo_pixels[1];
|
|
|
fb_ptr[2] = logo_pixels[0];
|
|
@@ -201,3 +203,5 @@ static void draw_logo()
|
|
|
fb_ptr += framebuffer.pitch() - framebuffer.width() * 4;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+}
|