forked from xt-sys/exectos
Split paging interface into arch-specific code
This commit is contained in:
@@ -12,10 +12,10 @@
|
||||
#include <xtos.hh>
|
||||
|
||||
#include XTOS_ARCH_HEADER(mm, pagemap.hh)
|
||||
#include XTOS_ARCH_HEADER(mm, paging.hh)
|
||||
|
||||
#include <mm/hlpool.hh>
|
||||
#include <mm/init.hh>
|
||||
#include <mm/kpool.hh>
|
||||
#include <mm/paging.hh>
|
||||
|
||||
#endif /* __XTOSKRNL_MM_HH */
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtoskrnl/includes/mm/paging.hh
|
||||
* DESCRIPTION: Low level page management support
|
||||
* FILE: xtoskrnl/includes/mm/amd64/paging.hh
|
||||
* DESCRIPTION: Low level page management support for AMD64
|
||||
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef __XTOSKRNL_MM_PAGING_HH
|
||||
#define __XTOSKRNL_MM_PAGING_HH
|
||||
#ifndef __XTOSKRNL_MM_AMD64_PAGING_HH
|
||||
#define __XTOSKRNL_MM_AMD64_PAGING_HH
|
||||
|
||||
#include <xtos.hh>
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace MM
|
||||
STATIC XTAPI BOOLEAN GetOneEntry(IN PMMPTE Pte);
|
||||
STATIC XTAPI PMMPDE GetP5eAddress(IN PVOID Address);
|
||||
STATIC XTAPI PVOID GetP5eVirtualAddress(IN PMMPTE P5ePointer);
|
||||
STATIC XTAPI USHORT GetPageMapLevel();
|
||||
STATIC XTAPI PFN_NUMBER GetPageFrameNumber(IN PMMPTE Pte);
|
||||
STATIC XTAPI PMMPDE GetPdeAddress(IN PVOID Address);
|
||||
STATIC XTAPI PVOID GetPdeVirtualAddress(IN PMMPXE PdePointer);
|
||||
@@ -42,8 +43,6 @@ namespace MM
|
||||
STATIC XTAPI PVOID GetPteVirtualAddress(IN PMMPXE PtePointer);
|
||||
STATIC XTAPI PMMPXE GetPxeAddress(IN PVOID Address);
|
||||
STATIC XTAPI PVOID GetPxeVirtualAddress(IN PMMPXE PxePointer);
|
||||
STATIC XTAPI BOOLEAN GetXpaStatus();
|
||||
STATIC XTAPI VOID InitializeSystemSpaceMapping(VOID);
|
||||
STATIC XTAPI VOID InitializePageMapSupport(VOID);
|
||||
STATIC XTAPI BOOLEAN PteValid(IN PMMPTE PtePointer);
|
||||
STATIC XTAPI VOID SetNextEntry(IN PMMPTE Pte,
|
||||
@@ -65,4 +64,4 @@ namespace MM
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __XTOSKRNL_MM_PAGING_HH */
|
||||
#endif /* __XTOSKRNL_MM_AMD64_PAGING_HH */
|
||||
63
xtoskrnl/includes/mm/i686/paging.hh
Normal file
63
xtoskrnl/includes/mm/i686/paging.hh
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtoskrnl/includes/mm/i686/paging.hh
|
||||
* DESCRIPTION: Low level page management support for i686
|
||||
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef __XTOSKRNL_MM_I686_PAGING_HH
|
||||
#define __XTOSKRNL_MM_I686_PAGING_HH
|
||||
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/* Memory Manager */
|
||||
namespace MM
|
||||
{
|
||||
class Paging
|
||||
{
|
||||
private:
|
||||
STATIC PPAGEMAP PmlRoutines;
|
||||
|
||||
public:
|
||||
STATIC XTAPI PMMPTE AdvancePte(IN PMMPTE Pte,
|
||||
IN LONG Count);
|
||||
STATIC XTAPI VOID ClearPte(IN PMMPTE PtePointer);
|
||||
STATIC XTAPI VOID FlushTlb(VOID);
|
||||
STATIC XTAPI ULONG_PTR GetEmptyPteList(VOID);
|
||||
STATIC XTAPI BOOLEAN GetExtendedPhysicalAddressingStatus(VOID);
|
||||
STATIC XTAPI ULONG_PTR GetNextEntry(IN PMMPTE Pte);
|
||||
STATIC XTAPI PMMPTE GetNextPte(IN PMMPTE Pte);
|
||||
STATIC XTAPI BOOLEAN GetOneEntry(IN PMMPTE Pte);
|
||||
STATIC XTAPI USHORT GetPageMapLevel();
|
||||
STATIC XTAPI PFN_NUMBER GetPageFrameNumber(IN PMMPTE Pte);
|
||||
STATIC XTAPI PMMPDE GetPdeAddress(IN PVOID Address);
|
||||
STATIC XTAPI PVOID GetPdeVirtualAddress(IN PMMPXE PdePointer);
|
||||
STATIC XTAPI PMMPPE GetPpeAddress(IN PVOID Address);
|
||||
STATIC XTAPI PVOID GetPpeVirtualAddress(IN PMMPXE PpePointer);
|
||||
STATIC XTAPI PMMPTE GetPteAddress(IN PVOID Address);
|
||||
STATIC XTAPI ULONG GetPteSize(VOID);
|
||||
STATIC XTAPI PVOID GetPteVirtualAddress(IN PMMPXE PtePointer);
|
||||
STATIC XTAPI VOID InitializePageMapSupport(VOID);
|
||||
STATIC XTAPI BOOLEAN PteValid(IN PMMPTE PtePointer);
|
||||
STATIC XTAPI VOID SetNextEntry(IN PMMPTE Pte,
|
||||
IN ULONG_PTR Value);
|
||||
STATIC XTAPI VOID SetOneEntry(IN PMMPTE Pte,
|
||||
IN BOOLEAN Value);
|
||||
STATIC XTAPI VOID SetPte(IN PMMPTE PtePointer,
|
||||
IN PFN_NUMBER PageFrameNumber,
|
||||
IN ULONG_PTR AttributesMask);
|
||||
STATIC XTAPI VOID SetPteCaching(IN PMMPTE PtePointer,
|
||||
IN BOOLEAN CacheDisable,
|
||||
IN BOOLEAN WriteThrough);
|
||||
STATIC XTFASTCALL VOID ZeroPages(IN PVOID Address,
|
||||
IN ULONG Size);
|
||||
|
||||
private:
|
||||
STATIC XTAPI PPAGEMAP GetPageMapBasicRoutines(VOID);
|
||||
STATIC XTAPI PPAGEMAP GetPageMapXpaRoutines(VOID);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* __XTOSKRNL_MM_I686_PAGING_HH */
|
||||
@@ -25,6 +25,78 @@ MM::Paging::GetExtendedPhysicalAddressingStatus(VOID)
|
||||
return ((AR::CpuFunc::ReadControlRegister(4) & CR4_LA57) != 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address of the P5E (Page Map Level 5 Entry), that maps given address.
|
||||
*
|
||||
* @param Address
|
||||
* Specifies the virtual address for which to retrieve the corresponding P5E.
|
||||
*
|
||||
* @return This routine returns the address of the P5E, or NULLPTR if LA57 is not enabled.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PMMPDE
|
||||
MM::Paging::GetP5eAddress(IN PVOID Address)
|
||||
{
|
||||
/* Return PDE address */
|
||||
return PmlRoutines->GetP5eAddress(Address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual address that is mapped by a given Page Map Level 5 Entry.
|
||||
*
|
||||
* @param P5ePointer
|
||||
* Specifies the address of the P5E.
|
||||
*
|
||||
* @return This routine returns the virtual address mapped by the P5E, or NULLPTR if LA57 is not enabled.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PVOID
|
||||
MM::Paging::GetP5eVirtualAddress(IN PMMPTE P5ePointer)
|
||||
{
|
||||
/* Return PTE virtual address */
|
||||
return PmlRoutines->GetP5eVirtualAddress(P5ePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address of the PXE (Extended Page Entry), that maps given address.
|
||||
*
|
||||
* @param Address
|
||||
* Specifies the virtual address for which to retrieve the corresponding PXE.
|
||||
*
|
||||
* @return This routine returns the address of the PXE.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PMMPXE
|
||||
MM::Paging::GetPxeAddress(IN PVOID Address)
|
||||
{
|
||||
/* Return PXE address */
|
||||
return PmlRoutines->GetPxeAddress(Address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual address that is mapped by a given Extended Page Entry.
|
||||
*
|
||||
* @param PxePointer
|
||||
* Specifies the address of the PXE.
|
||||
*
|
||||
* @return This routine returns the virtual address mapped by the PXE.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PVOID
|
||||
MM::Paging::GetPxeVirtualAddress(IN PMMPXE PxePointer)
|
||||
{
|
||||
/* Return PXE virtual address */
|
||||
return PmlRoutines->GetPxeVirtualAddress(PxePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills a section of memory with zeroes like RtlZeroMemory(), but in more efficient way.
|
||||
*
|
||||
|
||||
@@ -170,42 +170,6 @@ MM::Paging::GetOneEntry(IN PMMPTE Pte)
|
||||
return PmlRoutines->GetOneEntry(Pte);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address of the P5E (Page Map Level 5 Entry), that maps given address.
|
||||
*
|
||||
* @param Address
|
||||
* Specifies the virtual address for which to retrieve the corresponding P5E.
|
||||
*
|
||||
* @return This routine returns the address of the P5E, or NULLPTR if LA57 is not enabled.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PMMPDE
|
||||
MM::Paging::GetP5eAddress(IN PVOID Address)
|
||||
{
|
||||
/* Return PDE address */
|
||||
return PmlRoutines->GetP5eAddress(Address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual address that is mapped by a given Page Map Level 5 Entry.
|
||||
*
|
||||
* @param P5ePointer
|
||||
* Specifies the address of the P5E.
|
||||
*
|
||||
* @return This routine returns the virtual address mapped by the P5E, or NULLPTR if LA57 is not enabled.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PVOID
|
||||
MM::Paging::GetP5eVirtualAddress(IN PMMPTE P5ePointer)
|
||||
{
|
||||
/* Return PTE virtual address */
|
||||
return PmlRoutines->GetP5eVirtualAddress(P5ePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the page frame number from a corresponding PTE.
|
||||
*
|
||||
@@ -240,6 +204,20 @@ MM::Paging::GetPageMapBasicRoutines(VOID)
|
||||
return &PageMapBasicRoutines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current paging mode level.
|
||||
*
|
||||
* @return This routine returns 5 if 5-level paging (XPA) is enabled, otherwise 4 for 4-level paging.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
USHORT
|
||||
MM::Paging::GetPageMapLevel()
|
||||
{
|
||||
return PmlRoutines->GetXpaStatus() ? 5 : 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the page map routines for eXtended Physical Addressing (XPA) mode.
|
||||
*
|
||||
@@ -380,56 +358,6 @@ MM::Paging::GetPteVirtualAddress(IN PMMPTE PtePointer)
|
||||
return PmlRoutines->GetPteVirtualAddress(PtePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address of the PXE (Extended Page Entry), that maps given address.
|
||||
*
|
||||
* @param Address
|
||||
* Specifies the virtual address for which to retrieve the corresponding PXE.
|
||||
*
|
||||
* @return This routine returns the address of the PXE.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PMMPXE
|
||||
MM::Paging::GetPxeAddress(IN PVOID Address)
|
||||
{
|
||||
/* Return PXE address */
|
||||
return PmlRoutines->GetPxeAddress(Address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual address that is mapped by a given Extended Page Entry.
|
||||
*
|
||||
* @param PxePointer
|
||||
* Specifies the address of the PXE.
|
||||
*
|
||||
* @return This routine returns the virtual address mapped by the PXE.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
PVOID
|
||||
MM::Paging::GetPxeVirtualAddress(IN PMMPXE PxePointer)
|
||||
{
|
||||
/* Return PXE virtual address */
|
||||
return PmlRoutines->GetPxeVirtualAddress(PxePointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status of Extended Paging Address (XPA) mode.
|
||||
*
|
||||
* @return This routine returns TRUE if XPA is enabled, FALSE otherwise.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
BOOLEAN
|
||||
MM::Paging::GetXpaStatus()
|
||||
{
|
||||
return PmlRoutines->GetXpaStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects if eXtended Physical Addressing (XPA) is enabled and initializes page map support.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user