Add architecture-specific GetPteDistance

This commit is contained in:
2025-12-06 00:19:24 +01:00
parent c710ec4688
commit 7694df7744
7 changed files with 98 additions and 0 deletions

View File

@@ -289,6 +289,28 @@ MM::PageMap::GetPteAddress(IN PVOID Address)
return (PMMPTE)(PageMapInfo.PteBase + Offset);
}
/**
* Calculates the distance between two PTE pointers.
*
* @param EndPte
* Pointer to the ending Page Table Entry.
*
* @param StartPte
* Pointer to the starting Page Table Entry.
*
* @return This routine returns a signed value representing the number of PTEs between EndPte and StartPte.
*
* @since XT 1.0
*/
XTAPI
LONG
MM::PageMap::GetPteDistance(PMMPTE EndPte,
PMMPTE StartPte)
{
/* Return distance between PTE pointers */
return ((ULONG_PTR)EndPte - (ULONG_PTR)StartPte) / sizeof(MMPTE);
}
/**
* Gets the index of the PTE (Page Table Entry), that maps given address.
*

View File

@@ -317,6 +317,28 @@ MM::PageMapBasic::GetPageFrameNumber(IN PMMPTE Pte)
return Pte->Pml2.Hardware.PageFrameNumber;
}
/**
* Calculates the distance between two PTE pointers.
*
* @param EndPte
* Pointer to the ending Page Table Entry.
*
* @param StartPte
* Pointer to the starting Page Table Entry.
*
* @return This routine returns a signed value representing the number of PTEs between EndPte and StartPte.
*
* @since XT 1.0
*/
XTAPI
LONG
MM::PageMapBasic::GetPteDistance(PMMPTE EndPte,
PMMPTE StartPte)
{
/* Return distance between PTE pointers */
return ((ULONG_PTR)EndPte - (ULONG_PTR)StartPte) / sizeof(MMPML2_PTE);
}
/**
* Gets the size of a PTE for basic paging (PML2).
*
@@ -568,6 +590,28 @@ MM::PageMapXpa::GetPageFrameNumber(IN PMMPTE Pte)
return Pte->Pml3.Hardware.PageFrameNumber;
}
/**
* Calculates the distance between two PTE pointers.
*
* @param EndPte
* Pointer to the ending Page Table Entry.
*
* @param StartPte
* Pointer to the starting Page Table Entry.
*
* @return This routine returns a signed value representing the number of PTEs between EndPte and StartPte.
*
* @since XT 1.0
*/
XTAPI
LONG
MM::PageMapXpa::GetPteDistance(PMMPTE EndPte,
PMMPTE StartPte)
{
/* Return distance between PTE pointers */
return ((ULONG_PTR)EndPte - (ULONG_PTR)StartPte) / sizeof(MMPML3_PTE);
}
/**
* Gets the size of a PTE for XPA paging (PML3).
*

View File

@@ -311,6 +311,28 @@ MM::Paging::GetPteAddress(IN PVOID Address)
return PmlRoutines->GetPteAddress(Address);
}
/**
* Calculates the distance between two PTE pointers.
*
* @param EndPte
* Pointer to the ending Page Table Entry.
*
* @param StartPte
* Pointer to the starting Page Table Entry.
*
* @return This routine returns a signed value representing the number of PTEs between EndPte and StartPte.
*
* @since XT 1.0
*/
XTAPI
LONG
MM::Paging::GetPteDistance(PMMPTE EndPte,
PMMPTE StartPte)
{
/* Return distance between PTE pointers */
return PmlRoutines->GetPteDistance(EndPte, StartPte);
}
/**
* Gets the size of a PTE.
*