From 5ae13125bcd1f84d016aa82f0beadf37199d5be7 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 9 Jan 2020 22:42:41 +0100 Subject: [PATCH] New dynamic paging implementation (4) #67 --- kaleid/kernel/mm/paging.c | 16 ++++++++++++---- kaleid/kernel/sh/testcmds.c | Bin 8755 -> 8755 bytes 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index 653ffb9..4ba948e 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -182,7 +182,7 @@ void MmInitPaging(void) // // Get a page from an address // -static pte_t MmGetPageDescriptor(void *virtualAddr) +static pte_t MmGetPageDescriptorFromVirtual(void *virtualAddr) { ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1)); @@ -210,7 +210,7 @@ static pte_t MmGetPageDescriptor(void *virtualAddr) void *MmTransVirtToPhyAddr(void* virtualAddr) { ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1)); - pte_t page = MmGetPageDescriptor(virtualAddr); + pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr); if (page == (page & ~(KPAGESIZE - 1))) { return NULL; @@ -229,7 +229,7 @@ void *MmTransPhyToVirtAddr(void* physicalAddr) // void MmSetPage(void* virtualAddr, ulong flags) { - pte_t page = MmGetPageDescriptor(virtualAddr); + pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr); page |= flags; @@ -241,7 +241,7 @@ void MmSetPage(void* virtualAddr, ulong flags) // void MmUnsetPage(void* virtualAddr, ulong flags) { - pte_t page = MmGetPageDescriptor(virtualAddr); + pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr); page &= (~flags); @@ -253,7 +253,11 @@ void MmUnsetPage(void* virtualAddr, 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) { + pte_t page = MmGetPageDescriptorFromVirtual(virtualAddr); + page = 0; + + KeFlushTlbSingle(page); } //----------- diff --git a/kaleid/kernel/sh/testcmds.c b/kaleid/kernel/sh/testcmds.c index 025bdcc8497bce31ebf6caeb4228a8d685baab2c..d0421dde283c5139f95e1ffe3c2ee8e15c827adb 100644 GIT binary patch delta 29 kcmdn&ve{*WA*(=1Mt*6DLTXuRo