ptos/amd64: mmu: Add virtual address space helpers

Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
2026-07-10 21:02:57 -04:00
parent cf7a1b88b2
commit eb009076b2
2 changed files with 71 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Platform MMU HAL interface
* Author: Chloe M.
*/
#include <hal/mmu.h>
#include <ptdef.h>
VOID
HalMmuReadVas(MMU_VAS *Result)
{
if (Result == NULL) {
return;
}
ASMV(
"mov %%cr3, %0"
: "=r" (Result->Cr3)
:
: "memory"
);
}
VOID
HalMmuWriteVas(const MMU_VAS *Vas)
{
if (Vas == NULL) {
return;
}
ASMV(
"mov %0, %%cr3"
:
: "r" (Vas->Cr3)
: "memory"
);
}
+31
View File
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Platform MMU HAL interface
* Author: Chloe M.
*/
#ifndef _HAL_MMU_H_
#define _HAL_MMU_H_ 1
#include <hal/vas.h>
#include <ptdef.h>
/*
* Read the current virtual address space into an
* MMU_VAS descriptor.
*
* @Result: Result is written here
*/
VOID HalMmuReadVas(MMU_VAS *Result);
/*
* Write a virtual address space into the current context
* from an MMU_VAS descriptor
*
* @Vas: VAS to write to current context
*/
VOID HalMmuWriteVas(const MMU_VAS *Vas);
#endif /* !_HAL_MMU_H_ */