stos: vmm: Initialize virtual memory manager

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
Chloe M.
2026-06-22 23:27:26 +00:00
parent 32a1463b92
commit eb8861e641
3 changed files with 44 additions and 0 deletions
+5
View File
@@ -19,4 +19,9 @@
#define VMA_TO_PMA(VMA) \ #define VMA_TO_PMA(VMA) \
(UPTR)PTR_NOFFSET(VMA, KeBpalLoadBase()) (UPTR)PTR_NOFFSET(VMA, KeBpalLoadBase())
/*
* Initialize the virtual memory manager
*/
VOID MmInitVmm(VOID);
#endif /* !_MM_VMM_H_ */ #endif /* !_MM_VMM_H_ */
+4
View File
@@ -13,6 +13,7 @@
#include <hal/kpcr.h> #include <hal/kpcr.h>
#include <drivers/bootvid/fbio.h> #include <drivers/bootvid/fbio.h>
#include <mm/pmm.h> #include <mm/pmm.h>
#include <mm/vmm.h>
#include <stdef.h> #include <stdef.h>
#define DTRACE(Fmt, ...) \ #define DTRACE(Fmt, ...) \
@@ -52,6 +53,9 @@ KiKernelEntry(VOID)
/* Initialize physical memory */ /* Initialize physical memory */
MmInitPmm(); MmInitPmm();
/* Initialize virtual memory */
MmInitVmm();
/* Phase 1 initialization the bootstrap core */ /* Phase 1 initialization the bootstrap core */
HalKpcrP1Init(&BootstrapCore); HalKpcrP1Init(&BootstrapCore);
} }
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Virtual memory manager
* Author: Chloe M.
*/
#include <mm/vmm.h>
#include <hal/mmu.h>
#include <ex/trace.h>
#define DTRACE(Fmt, ...) \
TRACE("[ VMM ]: " Fmt, ##__VA_ARGS__)
static MMU_VAS KernelVas;
VOID
MmInitVmm(VOID)
{
MMU_VAS OldVas;
ST_STATUS Status;
DTRACE("breeding kvas from bootstrap instance...\n");
HalMmuReadVas(&OldVas);
Status = HalMmuForkVas(&OldVas, &KernelVas);
if (Status != STATUS_SUCCESS) {
/* TODO: Panic here */
return;
}
HalMmuWriteVas(&KernelVas);
DTRACE("ah!~... [ok @ %p]\n", VAS_BASE(&KernelVas));
}