ptos: ke: Add BPAL layer groundwork

Signed-off-by: Chloe M. <chloe@yiffware.org>
This commit is contained in:
2026-07-10 05:09:53 +00:00
parent b2502c4ab1
commit d8d686352d
7 changed files with 121 additions and 0 deletions
+1
View File
@@ -12,6 +12,7 @@
# Export envs # Export envs
export PT_PROJECT_ROOT=$PT_PROJECT_ROOT export PT_PROJECT_ROOT=$PT_PROJECT_ROOT
export PT_TARGET_ARCH=$PT_TARGET_ARCH export PT_TARGET_ARCH=$PT_TARGET_ARCH
export PT_BOOT_PROTO=$PT_BOOT_PROTO
if [ "$PT_BUILD_SOURCED" != "1" ] if [ "$PT_BUILD_SOURCED" != "1" ]
then then
+1
View File
@@ -8,3 +8,4 @@
PT_PROJECT_ROOT=$(pwd) PT_PROJECT_ROOT=$(pwd)
PT_TARGET_ARCH=amd64 PT_TARGET_ARCH=amd64
PT_BOOT_PROTO=limine
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Boot protocol abstraction layer
* Author: Chloe M.
*/
#ifndef _KE_BPAL_H_
#define _KE_BPAL_H_ 1
#include <ptapi/status.h>
#include <ptdef.h>
/*
* Represents a handle for the boot protocol abstraction
* layer containing data filled in by the bootloader.
*
* @KernelBase: Represents the kernel load base
*/
typedef struct {
UPTR KernelBase;
} BPAL_HANDLE;
/*
* Initialize the boot protocol abstraction layer
*/
VOID KeBpalInit(VOID);
/*
* Obtain the BPAL handle
*
* @Result: Result is written here
*/
PT_STATUS KeBpalGetHandle(BPAL_HANDLE *Result);
/* Backend protocol init */
VOID KeBpalLimineInit(BPAL_HANDLE *Result);
#endif /* !_KE_BPAL_H_ */
+1
View File
@@ -19,6 +19,7 @@ CFLAGS = \
-D_KERNEL \ -D_KERNEL \
-DPRINTF_DISABLE_SUPPORT_PTRDIFF_T \ -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T \
-DPRINTF_DISABLE_SUPPORT_FLOAT \ -DPRINTF_DISABLE_SUPPORT_FLOAT \
-D_BOOT_PROTO="\"$(PT_BOOT_PROTO)\"" \
-I../xt/flanterm/src \ -I../xt/flanterm/src \
-I../head \ -I../head \
-I../target \ -I../target \
+46
View File
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: BPAL init logic
* Author: Chloe M.
*/
#include <ke/bpal.h>
#include <string.h>
#ifndef _BOOT_PROTO
#error "Boot protocol is undefined"
#else
#define BOOT_PROTO _BOOT_PROTO
#endif /* !_BOOT_PROTO */
/* Globals */
static BPAL_HANDLE BpalHandle;
PT_STATUS
KeBpalGetHandle(BPAL_HANDLE *Result)
{
if (Result == NULL) {
return STATUS_INVALID_PARAM;
}
*Result = BpalHandle;
return STATUS_SUCCESS;
}
VOID
KeBpalInit(VOID)
{
const CHAR *BootProto = BOOT_PROTO;
switch (*BootProto) {
case 'l':
if (RtlStrEq(BootProto, "limine")) {
KeBpalLimineInit(&BpalHandle);
return;
}
}
/* TODO: Bugcheck here */
}
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Limine backend
* Author: Chloe M.
*/
#include <ke/bpal.h>
#include <lib/limine.h>
/* HHDM request */
static struct limine_hhdm_response *HHDMResp = NULL;
static volatile struct limine_hhdm_request HHDMReq = {
.id = LIMINE_HHDM_REQUEST_ID,
.revision = 0
};
VOID
KeBpalLimineInit(BPAL_HANDLE *Result)
{
if (Result == NULL) {
return;
}
HHDMResp = HHDMReq.response;
Result->KernelBase = HHDMResp->offset;
}
+4
View File
@@ -7,6 +7,8 @@
*/ */
#include <ptdef.h> #include <ptdef.h>
#include <ke/bpal.h>
#include <string.h>
/* /*
* Starting here is where the world is brought up and system * Starting here is where the world is brought up and system
@@ -15,4 +17,6 @@
VOID VOID
KiKernelInit(VOID) KiKernelInit(VOID)
{ {
/* Initialize the boot protocol abstraction layer */
KeBpalInit();
} }