From 7ce73ab81368e54f097e59d77c865b729139f1a6 Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Fri, 24 Jan 2025 15:27:11 +0200 Subject: [PATCH] kernel: refactor aarch64 boot code Signed-off-by: EnderIce2 --- .../arch/aarch64/bootstrap/{ => raspi}/boot.S | 0 .../bootstrap/{init.c => raspi/init.cpp} | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) rename Kernel/arch/aarch64/bootstrap/{ => raspi}/boot.S (100%) rename Kernel/arch/aarch64/bootstrap/{init.c => raspi/init.cpp} (56%) diff --git a/Kernel/arch/aarch64/bootstrap/boot.S b/Kernel/arch/aarch64/bootstrap/raspi/boot.S similarity index 100% rename from Kernel/arch/aarch64/bootstrap/boot.S rename to Kernel/arch/aarch64/bootstrap/raspi/boot.S diff --git a/Kernel/arch/aarch64/bootstrap/init.c b/Kernel/arch/aarch64/bootstrap/raspi/init.cpp similarity index 56% rename from Kernel/arch/aarch64/bootstrap/init.c rename to Kernel/arch/aarch64/bootstrap/raspi/init.cpp index 9ad979d1..52146228 100644 --- a/Kernel/arch/aarch64/bootstrap/init.c +++ b/Kernel/arch/aarch64/bootstrap/raspi/init.cpp @@ -16,9 +16,29 @@ */ #include +#include -__attribute__((section(".bootstrap.text"))) void _aarch64_start(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3) +#include "../../../../kernel.h" + +using namespace CPU::aarch64; + +extern "C" __attribute__((section(".bootstrap.text"))) void _aarch64_start(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3) { - while (1) - ; + MIDR_EL1 reg; + asmv("mrs %x0, midr_el1" : "=r"(reg.raw)); + + switch (reg.PartNum) + { + case 0xB76: /* Raspberry Pi 1 */ + case 0xC07: /* Raspberry Pi 2 */ + default: /* Unknown */ + CPU::Stop(); + case 0xD03: /* Raspberry Pi 3 */ + break; + case 0xD08: /* Raspberry Pi 4 */ + break; + } + + BootInfo *info = nullptr; + Entry(info); }