stos: bpal: Add helper to get bootloader module

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
Chloe M.
2026-06-23 02:13:57 +00:00
parent 1d1acee7f1
commit 2c7d55e950
2 changed files with 54 additions and 0 deletions
+41
View File
@@ -9,6 +9,7 @@
#include <ke/bpal.h>
#include <ex/trace.h>
#include <lib/limine.h>
#include <string.h>
#define FRAMEBUFFER FbResp->framebuffers[0]
@@ -50,6 +51,44 @@ static volatile struct limine_memmap_request MapReq = {
.revision = 0
};
/* Module request */
static struct limine_module_response *ModResp = NULL;
static volatile struct limine_module_request ModReq = {
.id = LIMINE_MODULE_REQUEST_ID,
.revision = 0
};
static ST_STATUS
LimineModuleLookup(CHAR *Path, BPAL_MODULE *Result)
{
struct limine_file *Module;
USIZE PathLen;
if (Path == NULL || Result == NULL) {
return STATUS_INVALID_PARAM;
}
if (ModResp == NULL) {
return STATUS_NOT_FOUND;
}
PathLen = RtlStrLen(Path);
for (USIZE Idx = 0; Idx < ModResp->module_count; ++Idx) {
Module = ModResp->modules[Idx];
if (*Module->path != *Path) {
continue;
}
if (RtlMemCmp(Module->path, Path, PathLen) == 0) {
Result->Data = Module->address;
Result->Length = Module->size;
return STATUS_SUCCESS;
}
}
return STATUS_NOT_FOUND;
}
VOID
BpalInitFramebuffer(BPAL_HANDLE *Handle)
{
@@ -94,6 +133,7 @@ KeBpalLimineInit(BPAL_HANDLE *Handle)
LoaderInfoResp = LoaderInfoReq.response;
LoaderPerfResp = LoaderPerReq.response;
HHDMResp = HHDMReq.response;
ModResp = ModReq.response;
FbResp = FbReq.response;
MapResp = MapReq.response;
@@ -116,4 +156,5 @@ KeBpalLimineInit(BPAL_HANDLE *Handle)
BpalInitFramebuffer(Handle);
Handle->KernelBase = HHDMResp->offset;
Handle->MemEntryIdx = LimineMemEntryIdx;
Handle->ModuleLookup = LimineModuleLookup;
}