From 92f4720898de8261ed1947102f35c53be1f51cd1 Mon Sep 17 00:00:00 2001 From: Chloe M Date: Fri, 10 Jul 2026 19:06:53 -0400 Subject: [PATCH] ptos: vm: Add virtual memory related macros Signed-off-by: Chloe M --- service/ptos/head/mm/vm.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 service/ptos/head/mm/vm.h diff --git a/service/ptos/head/mm/vm.h b/service/ptos/head/mm/vm.h new file mode 100644 index 0000000..4365cad --- /dev/null +++ b/service/ptos/head/mm/vm.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2026, Chloe M. + * Provided under the BSD-3 clause. + * + * Description: Virtual memory management + * Author: Chloe M. + */ + +#ifndef _MM_VM_H_ +#define _MM_VM_H_ 1 + +#include + +/* + * Virtual memory allocation region. This is outside the + * higher half direct map and thus cannot be converted with + * PMA_TO_VMA() / VMA_TO_PMA() + */ +#define VALLOC_BASE 0xFFFF804000000000 + +/* + * Used to convert physical addresses to virtual addresses + * and vice versa only when they are within the higher half + * direct map. + */ +#define PMA_TO_VMA(PMA) \ + PTR_OFFSET((VOID *)PMA, KeBpalLoadBase()) +#define VMA_TO_PMA(VMA) \ + (UPTR)PTR_NOFFSET(VMA, KeBpalLoadBase()) + +#endif /* !_MM_VM_H_ */