From 4b1c00ba437d5cc6acbd35f90b0b9c1b220b5dc0 Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Mon, 22 Jun 2026 02:08:45 +0000 Subject: [PATCH] stos: Add BPAL groundwork Signed-off-by: Chloe M. --- paw/stos/head/ke/bpal.h | 3 +++ paw/stos/init/init.c | 11 +++++++++-- paw/stos/ke/bpal/bpal.c | 33 +++++++++++++++++++++++++++++++++ paw/stos/ke/bpal/proto/limine.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 paw/stos/ke/bpal/bpal.c create mode 100644 paw/stos/ke/bpal/proto/limine.c diff --git a/paw/stos/head/ke/bpal.h b/paw/stos/head/ke/bpal.h index e00c56d..5a4fbb3 100644 --- a/paw/stos/head/ke/bpal.h +++ b/paw/stos/head/ke/bpal.h @@ -25,4 +25,7 @@ typedef struct { */ VOID KeBpalInit(VOID); +/* Backend init functions */ +VOID KeBpalLimineInit(VOID); + #endif /* !_KE_BPAL_H_ */ diff --git a/paw/stos/init/init.c b/paw/stos/init/init.c index 1c1de83..870e0cc 100644 --- a/paw/stos/init/init.c +++ b/paw/stos/init/init.c @@ -8,17 +8,21 @@ #include #include +#include #include #include +#define DTRACE(Fmt, ...) \ + TRACE("[ INIT ]: " Fmt, ##__VA_ARGS__) + /* * Display a boot banner */ static VOID BootBanner(VOID) { - TRACE("SystemPaw3 ~ %s\n", ST_VERSION); - TRACE("Booting SystemPaw3 !! <3\n"); + TRACE("-- SystemPaw3 ~ %s --\n", ST_VERSION); + DTRACE("booting SystemPaw3 !! <3\n"); } VOID @@ -29,4 +33,7 @@ KiKernelEntry(VOID) /* Write the boot banner */ BootBanner(); + + /* Initialize BPAL */ + KeBpalInit(); } diff --git a/paw/stos/ke/bpal/bpal.c b/paw/stos/ke/bpal/bpal.c new file mode 100644 index 0000000..d5e987d --- /dev/null +++ b/paw/stos/ke/bpal/bpal.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: Boot protocol abstraction layer + * Author: Chloe M. + */ + +#include +#include +#include + +#ifndef _BOOT_PROTO +#error "Boot protocol must be defined" +#else +#define BOOT_PROTO _BOOT_PROTO +#endif /* !_BOOT_PROTO */ + +VOID +KeBpalInit(VOID) +{ + const CHAR *BootProto = BOOT_PROTO; + + switch (*BootProto) { + case 'l': + if (RtlMemCmp(BootProto, "limine", 6) == 0) { + KeBpalLimineInit(); + return; + } + } + + /* TODO: PANIC HERE */ +} diff --git a/paw/stos/ke/bpal/proto/limine.c b/paw/stos/ke/bpal/proto/limine.c new file mode 100644 index 0000000..022d526 --- /dev/null +++ b/paw/stos/ke/bpal/proto/limine.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: Boot protocol abstraction layer + * Author: Chloe M. + */ + +#include +#include +#include + +#define DTRACE(Fmt, ...) \ + TRACE("[ BPAL ]: " Fmt, ##__VA_ARGS__) + +/* Bootloader information */ +static struct limine_bootloader_info_response *LoaderInfoResp = NULL; +static volatile struct limine_bootloader_info_request LoaderInfoReq = { + .id = LIMINE_BOOTLOADER_INFO_REQUEST_ID, + .revision = 0 +}; + +VOID +KeBpalLimineInit(VOID) +{ + LoaderInfoResp = LoaderInfoReq.response; + + DTRACE( + "slut handed control by %s %s\n", + LoaderInfoResp->name, + LoaderInfoResp->version + ); +}