New dynamic paging implementation (4) #67

This commit is contained in:
Adrien Bourmault 2020-01-09 22:42:41 +01:00
parent 334e1bbae5
commit 5ae13125bc
2 changed files with 12 additions and 4 deletions

View File

@ -182,7 +182,7 @@ void MmInitPaging(void)
// //
// Get a page from an address // Get a page from an address
// //
static pte_t MmGetPageDescriptor(void *virtualAddr) static pte_t MmGetPageDescriptorFromVirtual(void *virtualAddr)
{ {
ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1)); ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1));
@ -210,7 +210,7 @@ static pte_t MmGetPageDescriptor(void *virtualAddr)
void *MmTransVirtToPhyAddr(void* virtualAddr) void *MmTransVirtToPhyAddr(void* virtualAddr)
{ {
ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1)); ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1));
pte_t page = MmGetPageDescriptor(virtualAddr); pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr);
if (page == (page & ~(KPAGESIZE - 1))) { if (page == (page & ~(KPAGESIZE - 1))) {
return NULL; return NULL;
@ -229,7 +229,7 @@ void *MmTransPhyToVirtAddr(void* physicalAddr)
// //
void MmSetPage(void* virtualAddr, ulong flags) void MmSetPage(void* virtualAddr, ulong flags)
{ {
pte_t page = MmGetPageDescriptor(virtualAddr); pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr);
page |= flags; page |= flags;
@ -241,7 +241,7 @@ void MmSetPage(void* virtualAddr, ulong flags)
// //
void MmUnsetPage(void* virtualAddr, ulong flags) void MmUnsetPage(void* virtualAddr, ulong flags)
{ {
pte_t page = MmGetPageDescriptor(virtualAddr); pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr);
page &= (~flags); page &= (~flags);
@ -253,7 +253,11 @@ void MmUnsetPage(void* virtualAddr, ulong flags)
// //
void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags) void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags)
{ {
pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr);
page = ((ulong)physicalAddr & ~(KPAGESIZE - 1)) | flags;
KeFlushTlbSingle(page);
} }
// //
@ -261,7 +265,11 @@ void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags)
// //
void MmUnmapPage(void* virtualAddr) void MmUnmapPage(void* virtualAddr)
{ {
pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr);
page = 0;
KeFlushTlbSingle(page);
} }
//----------- //-----------

Binary file not shown.