ptos/amd64+hal: Add virtual address space forking
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -260,3 +260,37 @@ HalMmuUnmapPage(MMU_VAS *Vas, UPTR VirtualBase, MMU_PAGESIZE PageSize)
|
||||
MdTlbFlushSingle(VirtualBase);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
PT_STATUS
|
||||
HalMmuForkVas(const MMU_VAS *Source, MMU_VAS *Result)
|
||||
{
|
||||
const UPTR *Src;
|
||||
UPTR *Dest;
|
||||
UPTR DestPhysBase;
|
||||
MM_PFN DestPfn;
|
||||
|
||||
if (Source == NULL || Result == NULL) {
|
||||
return STATUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
DestPfn = MmRequestFrame();
|
||||
if (DestPfn == PFN_ERROR) {
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
DestPhysBase = PFN_TO_ADDRESS(DestPfn);
|
||||
Src = PMA_TO_VMA((Source->Cr3 & PTE_ADDR_MASK));
|
||||
Dest = PMA_TO_VMA(DestPhysBase);
|
||||
|
||||
/* Begin copy */
|
||||
for (USIZE Idx = 0; Idx < 512; ++Idx) {
|
||||
if (Idx < 256) {
|
||||
Dest[Idx] = 0;
|
||||
} else {
|
||||
Dest[Idx] = Src[Idx];
|
||||
}
|
||||
}
|
||||
|
||||
Result->Cr3 = DestPhysBase;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user