https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b48e27ada1604afe1b851…
commit b48e27ada1604afe1b851314f2f63222a6fea2b5
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue May 25 16:05:57 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Jun 9 11:27:18 2021 +0200
[NTOS:MM] Add a few MiP*eToP*e helpers
And turn some of the existing ones into inline functions for the sake of type
checking
---
ntoskrnl/include/internal/amd64/mm.h | 67 +++++++++++++++++++++++++++++++++---
1 file changed, 63 insertions(+), 4 deletions(-)
diff --git a/ntoskrnl/include/internal/amd64/mm.h b/ntoskrnl/include/internal/amd64/mm.h
index e62df71cfe0..3d45788222e 100644
--- a/ntoskrnl/include/internal/amd64/mm.h
+++ b/ntoskrnl/include/internal/amd64/mm.h
@@ -231,10 +231,69 @@ MiPxeToAddress(PMMPTE PointerPxe)
return (PVOID)(((LONG64)PointerPxe << 52) >> 16);
}
-/* Translate between P*Es */
-#define MiPdeToPte(_Pde) ((PMMPTE)MiPteToAddress(_Pde))
-#define MiPteToPde(_Pte) ((PMMPDE)MiAddressToPte(_Pte))
-#define MiPdeToPpe(_Pde) ((PMMPPE)MiAddressToPte(_Pde))
+/* Convert a PDE into its lowest PTE */
+FORCEINLINE
+PMMPTE
+MiPdeToPte(PMMPDE PointerPde)
+{
+ return (PMMPTE)MiPteToAddress(PointerPde);
+}
+
+/* Convert a PPE into its lowest PTE */
+FORCEINLINE
+PMMPTE
+MiPpeToPte(PMMPPE PointerPpe)
+{
+ return (PMMPTE)MiPdeToAddress(PointerPpe);
+}
+
+/* Convert a PXE into its lowest PTE */
+FORCEINLINE
+PMMPTE
+MiPxeToPte(PMMPXE PointerPxe)
+{
+ return (PMMPTE)MiPpeToAddress(PointerPxe);
+}
+
+/* Convert a PTE to a corresponding PDE */
+FORCEINLINE
+PMMPDE
+MiPteToPde(PMMPTE PointerPte)
+{
+ return (PMMPDE)MiAddressToPte(PointerPte);
+}
+
+/* Convert a PTE to a corresponding PPE */
+FORCEINLINE
+PMMPPE
+MiPteToPpe(PMMPTE PointerPte)
+{
+ return (PMMPPE)MiAddressToPde(PointerPte);
+}
+
+/* Convert a PTE to a corresponding PXE */
+FORCEINLINE
+PMMPXE
+MiPteToPxe(PMMPTE PointerPte)
+{
+ return (PMMPXE)MiAddressToPpe(PointerPte);
+}
+
+/* Convert a PDE to a corresponding PPE */
+FORCEINLINE
+PMMPDE
+MiPdeToPpe(PMMPDE PointerPde)
+{
+ return (PMMPPE)MiAddressToPte(PointerPde);
+}
+
+/* Convert a PDE to a corresponding PXE */
+FORCEINLINE
+PMMPXE
+MiPdeToPxe(PMMPDE PointerPde)
+{
+ return (PMMPXE)MiAddressToPde(PointerPde);
+}
/* Check P*E boundaries */
#define MiIsPteOnPdeBoundary(PointerPte) \