stos: hal: Implement HalMmuForkVas()
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -187,6 +187,39 @@ MmuExtractLevel(MMU_VAS *Vas, UPTR Vma, PAGE_LEVEL Level, BOOLEAN Alloc)
|
|||||||
return PageMap;
|
return PageMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ST_STATUS
|
||||||
|
HalMmuForkVas(MMU_VAS *Old, MMU_VAS *NewResult)
|
||||||
|
{
|
||||||
|
UPTR *OldVma, *NewVma;
|
||||||
|
UPTR NewPma;
|
||||||
|
MM_PFN NewPfn;
|
||||||
|
|
||||||
|
if (Old == NULL || NewResult == NULL) {
|
||||||
|
return STATUS_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
NewPfn = MmRequestFrame();
|
||||||
|
if (NewPfn == 0) {
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
NewPma = NewPfn << LOG2_PAGESIZE;
|
||||||
|
NewVma = PMA_TO_VMA(NewPma);
|
||||||
|
OldVma = PMA_TO_VMA((Old->Cr3 & PTE_ADDR_MASK));
|
||||||
|
|
||||||
|
/* Start breeding the new VAS~ Fill it deep~ */
|
||||||
|
for (USHORT Off = 0; Off < 512; ++Off) {
|
||||||
|
if (Off < 256) {
|
||||||
|
NewVma[Off] = 0;
|
||||||
|
} else {
|
||||||
|
NewVma[Off] = OldVma[Off];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NewResult->Cr3 = NewPma;
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
HalMmuReadVas(MMU_VAS *Result)
|
HalMmuReadVas(MMU_VAS *Result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,19 @@ VOID HalMmuReadVas(MMU_VAS *Result);
|
|||||||
*/
|
*/
|
||||||
VOID HalMmuWriteVas(MMU_VAS *Vas);
|
VOID HalMmuWriteVas(MMU_VAS *Vas);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When starting other cute slut critter processes, we need a fresh
|
||||||
|
* VAS with the lower half gone so that it can be re-populated properly
|
||||||
|
* for user processes.
|
||||||
|
*
|
||||||
|
* This function does not breed the CR3 register and you'll manually
|
||||||
|
* need to do so with HalMmuWriteVas()
|
||||||
|
*
|
||||||
|
* @Old: Old VAS to fork
|
||||||
|
* @NewResult: New result is written here
|
||||||
|
*/
|
||||||
|
ST_STATUS HalMmuForkVas(MMU_VAS *Old, MMU_VAS *NewResult);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map a single page of memory
|
* Map a single page of memory
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user