From 709d173d7a72979b347391331483d5528a5b54d7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 26 Jun 2013 20:43:23 +0800 Subject: [PATCH] Kernel/x86 - Hack to return quickly when mapping <1MiB addreses --- KernelLand/Kernel/arch/x86/mm_virt.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/KernelLand/Kernel/arch/x86/mm_virt.c b/KernelLand/Kernel/arch/x86/mm_virt.c index 0eb60a18..216bc1e6 100644 --- a/KernelLand/Kernel/arch/x86/mm_virt.c +++ b/KernelLand/Kernel/arch/x86/mm_virt.c @@ -1029,12 +1029,17 @@ void MM_FreeTemp(void *VAddr) */ void *MM_MapHWPages(tPAddr PAddr, Uint Number) { - int i, j; + int j; PAddr &= ~0xFFF; - + + if( PAddr < 1024*1024 && (1024*1024-PAddr) >= Number * PAGE_SIZE ) + { + return (void*)(KERNEL_BASE + PAddr); + } + // Scan List - for( i = 0; i < NUM_HW_PAGES; i ++ ) + for( int i = 0; i < NUM_HW_PAGES; i ++ ) { // Check if addr used if( gaPageTable[ (HW_MAP_ADDR >> 12) + i ] & 1 ) @@ -1137,7 +1142,11 @@ void MM_UnmapHWPages(tVAddr VAddr, Uint Number) int i, j; //Log_Debug("VirtMem", "MM_UnmapHWPages: (VAddr=0x%08x, Number=%i)", VAddr, Number); - + + // + if( KERNEL_BASE <= VAddr && VAddr < KERNEL_BASE + 1024*1024 ) + return ; + // Sanity Check if(VAddr < HW_MAP_ADDR || VAddr+Number*0x1000 > HW_MAP_MAX) return; -- 2.20.1