diff --git a/xtoskrnl/mm/amd64/pte.cc b/xtoskrnl/mm/amd64/pte.cc index 796cd45..a077c27 100644 --- a/xtoskrnl/mm/amd64/pte.cc +++ b/xtoskrnl/mm/amd64/pte.cc @@ -139,6 +139,53 @@ MM::Pte::MapP5E(PVOID StartAddress, } } +/** + * Maps a range of virtual addresses at the PPE (Page Directory Pointer Entry) level. + * + * @param StartAddress + * The beginning of the virtual address range to map. + * + * @param EndAddress + * The end of the virtual address range to map. + * + * @param TemplatePpe + * A template PPE to use for creating new entries. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +MM::Pte::MapPPE(PVOID StartAddress, + PVOID EndAddress, + PMMPPE TemplatePpe) +{ + PMMPPE EndSpace, PointerPpe; + + /* Get PPE addresses */ + PointerPpe = MM::Paging::GetPpeAddress(StartAddress); + EndSpace = MM::Paging::GetPpeAddress(EndAddress); + + /* Iterate over all PPEs */ + while(PointerPpe <= EndSpace) + { + /* Check if PPE is already mapped */ + if(!MM::Paging::PteValid(PointerPpe)) + { + /* Map PPE */ + MM::Paging::SetPte(TemplatePpe, MM::Pfn::AllocateBootstrapPages(1), 0); + *PointerPpe = *TemplatePpe; + + /* Clear the page table */ + RtlZeroMemory(MM::Paging::GetPteVirtualAddress(PointerPpe), MM_PAGE_SIZE); + } + + /* Get next table entry */ + PointerPpe = MM::Paging::GetNextPte(PointerPpe); + } +} + /** * Maps a range of virtual addresses at the PXE (PML4) level. * diff --git a/xtoskrnl/mm/i686/pte.cc b/xtoskrnl/mm/i686/pte.cc index b425228..81eb6e3 100644 --- a/xtoskrnl/mm/i686/pte.cc +++ b/xtoskrnl/mm/i686/pte.cc @@ -73,3 +73,29 @@ MM::Pte::InitializePageTable(VOID) { UNIMPLEMENTED; } + +/* + * Maps a range of virtual addresses at the PPE (Page Directory Pointer Entry) level. + * + * @param StartAddress + * The beginning of the virtual address range to map. + * + * @param EndAddress + * The end of the virtual address range to map. + * + * @param TemplatePpe + * A template PPE to use for creating new entries. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +MM::Pte::MapPPE(PVOID StartAddress, + PVOID EndAddress, + PMMPPE TemplatePpe) +{ + /* Just a stub on i686 platform */ + return; +} diff --git a/xtoskrnl/mm/pte.cc b/xtoskrnl/mm/pte.cc index 5123d12..9874b2a 100644 --- a/xtoskrnl/mm/pte.cc +++ b/xtoskrnl/mm/pte.cc @@ -71,53 +71,6 @@ MM::Pte::MapPDE(PVOID StartAddress, } } -/** - * Maps a range of virtual addresses at the PPE (Page Directory Pointer Entry) level. - * - * @param StartAddress - * The beginning of the virtual address range to map. - * - * @param EndAddress - * The end of the virtual address range to map. - * - * @param TemplatePpe - * A template PPE to use for creating new entries. - * - * @return This routine does not return any value. - * - * @since XT 1.0 - */ -XTAPI -VOID -MM::Pte::MapPPE(PVOID StartAddress, - PVOID EndAddress, - PMMPPE TemplatePpe) -{ - PMMPPE EndSpace, PointerPpe; - - /* Get PPE addresses */ - PointerPpe = MM::Paging::GetPpeAddress(StartAddress); - EndSpace = MM::Paging::GetPpeAddress(EndAddress); - - /* Iterate over all PPEs */ - while(PointerPpe <= EndSpace) - { - /* Check if PPE is already mapped */ - if(!MM::Paging::PteValid(PointerPpe)) - { - /* Map PPE */ - MM::Paging::SetPte(TemplatePpe, MM::Pfn::AllocateBootstrapPages(1), 0); - *PointerPpe = *TemplatePpe; - - /* Clear the page table */ - RtlZeroMemory(MM::Paging::GetPteVirtualAddress(PointerPpe), MM_PAGE_SIZE); - } - - /* Get next table entry */ - PointerPpe = MM::Paging::GetNextPte(PointerPpe); - } -} - /** * Maps a range of virtual addresses at the PTE (Page Table Entry) level. *