ptos: ke: Add BPAL layer groundwork
Signed-off-by: Chloe M. <chloe@yiffware.org>
This commit is contained in:
@@ -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_ */
|
||||
@@ -19,6 +19,7 @@ CFLAGS = \
|
||||
-D_KERNEL \
|
||||
-DPRINTF_DISABLE_SUPPORT_PTRDIFF_T \
|
||||
-DPRINTF_DISABLE_SUPPORT_FLOAT \
|
||||
-D_BOOT_PROTO="\"$(PT_BOOT_PROTO)\"" \
|
||||
-I../xt/flanterm/src \
|
||||
-I../head \
|
||||
-I../target \
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
#include <ptdef.h>
|
||||
#include <ke/bpal.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Starting here is where the world is brought up and system
|
||||
@@ -15,4 +17,6 @@
|
||||
VOID
|
||||
KiKernelInit(VOID)
|
||||
{
|
||||
/* Initialize the boot protocol abstraction layer */
|
||||
KeBpalInit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user