From: John Hodge Date: Tue, 22 May 2012 07:57:17 +0000 (+0800) Subject: Kernel - Applying MM_MapTemp changes to armv7 and amd64 X-Git-Tag: rel0.15~611^2~74 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f1be22d04cb96b70d08b6ed79eb1725364cffb35;p=tpg%2Facess2.git Kernel - Applying MM_MapTemp changes to armv7 and amd64 --- diff --git a/KernelLand/Kernel/arch/armv7/mm_virt.c b/KernelLand/Kernel/arch/armv7/mm_virt.c index 90655b63..4583b7b2 100644 --- a/KernelLand/Kernel/arch/armv7/mm_virt.c +++ b/KernelLand/Kernel/arch/armv7/mm_virt.c @@ -535,7 +535,7 @@ void MM_int_CloneTable(Uint32 *DestEnt, int Table) cur += 256*Table; - tmp_map = (void*)MM_MapTemp(table); + tmp_map = MM_MapTemp(table); for( i = 0; i < 1024; i ++ ) { @@ -559,10 +559,10 @@ void MM_int_CloneTable(Uint32 *DestEnt, int Table) tPAddr newpage; newpage = MM_AllocPhys(); src = (void*)( (Table*256+i)*0x1000 ); - dst = (void*)MM_MapTemp(newpage); + dst = MM_MapTemp(newpage); // Debug("Taking a copy of kernel page %p (%P)", src, cur[i] & ~0xFFF); memcpy(dst, src, PAGE_SIZE); - MM_FreeTemp( (tVAddr)dst ); + MM_FreeTemp( dst ); tmp_map[i] = newpage | (cur[i] & 0xFFF); } else @@ -575,7 +575,7 @@ void MM_int_CloneTable(Uint32 *DestEnt, int Table) break; } } - MM_FreeTemp( (tVAddr) tmp_map ); + MM_FreeTemp( tmp_map ); DestEnt[0] = table + 0*0x400 + 1; DestEnt[1] = table + 1*0x400 + 1; @@ -595,8 +595,8 @@ tPAddr MM_Clone(void) ret = MM_AllocateRootTable(); cur = (void*)MM_TABLE0USER; - new_lvl1_1 = (void*)MM_MapTemp(ret); - new_lvl1_2 = (void*)MM_MapTemp(ret+0x1000); + new_lvl1_1 = MM_MapTemp(ret); + new_lvl1_2 = MM_MapTemp(ret+0x1000); tmp_map = new_lvl1_1; for( i = 0; i < 0x800-4; i ++ ) { @@ -626,7 +626,7 @@ tPAddr MM_Clone(void) { int j, num; tPAddr tmp = MM_AllocPhys(); - Uint32 *table = (void*)MM_MapTemp(tmp); + Uint32 *table = MM_MapTemp(tmp); Uint32 sp; register Uint32 __SP asm("sp"); @@ -673,16 +673,16 @@ tPAddr MM_Clone(void) // Log("page = %P", page); table[j] = page | 0x813; - tmp_page = (void*)MM_MapTemp(page); + tmp_page = MM_MapTemp(page); memcpy(tmp_page, (void*)sp, 0x1000); - MM_FreeTemp( (tVAddr) tmp_page ); + MM_FreeTemp( tmp_page ); } - MM_FreeTemp( (tVAddr)table ); + MM_FreeTemp( table ); } - MM_FreeTemp( (tVAddr)new_lvl1_1 ); - MM_FreeTemp( (tVAddr)new_lvl1_2 ); + MM_FreeTemp( new_lvl1_1 ); + MM_FreeTemp( new_lvl1_2 ); // Log("MM_Clone: ret = %P", ret); @@ -764,7 +764,7 @@ void MM_ClearUser(void) // MM_DumpTables(0, 0x80000000); } -tVAddr MM_MapTemp(tPAddr PAddr) +void *MM_MapTemp(tPAddr PAddr) { tVAddr ret; tMM_PageInfo pi; @@ -778,14 +778,15 @@ tVAddr MM_MapTemp(tPAddr PAddr) MM_RefPhys(PAddr); // Counter the MM_Deallocate in FreeTemp MM_Map(ret, PAddr); - return ret; + return (void*)ret; } Log_Warning("MMVirt", "MM_MapTemp: All slots taken"); return 0; } -void MM_FreeTemp(tVAddr VAddr) +void MM_FreeTemp(void *Ptr) { + tVAddr VAddr = (tVAddr)Ptr; if( VAddr < MM_TMPMAP_BASE || VAddr >= MM_TMPMAP_END ) { Log_Warning("MMVirt", "MM_FreeTemp: Passed an addr not from MM_MapTemp (%p)", VAddr); return ; @@ -1040,10 +1041,10 @@ void MM_PageFault(Uint32 PC, Uint32 Addr, Uint32 DFSR, int bPrefetch) Log_Error("MMVirt", "Unable to allocate new page for COW"); for(;;); } - dst = (void*)MM_MapTemp(newpage); + dst = MM_MapTemp(newpage); src = (void*)(Addr & ~(PAGE_SIZE-1)); memcpy( dst, src, PAGE_SIZE ); - MM_FreeTemp( (tVAddr)dst ); + MM_FreeTemp( dst ); #if TRACE_COW Log_Notice("MMVirt", "COW %p caused by %p, %P duped to %P (RefCnt(%i)--)", Addr, PC, diff --git a/KernelLand/Kernel/arch/x86_64/mm_virt.c b/KernelLand/Kernel/arch/x86_64/mm_virt.c index 89aeaa15..3d723e19 100644 --- a/KernelLand/Kernel/arch/x86_64/mm_virt.c +++ b/KernelLand/Kernel/arch/x86_64/mm_virt.c @@ -128,9 +128,9 @@ void MM_int_ClonePageEnt( Uint64 *Ent, void *NextLevel, tVAddr Addr, int bTable ASSERT(paddr != curpage); - tmp = (void*)MM_MapTemp(paddr); + tmp = MM_MapTemp(paddr); memcpy( tmp, NextLevel, 0x1000 ); - MM_FreeTemp( (tVAddr)tmp ); + MM_FreeTemp( tmp ); #if TRACE_COW Log_Debug("MMVirt", "COW ent at %p (%p) from %P to %P", Ent, NextLevel, curpage, paddr); @@ -860,7 +860,7 @@ tVAddr MM_AllocDMA(int Pages, int MaxBits, tPAddr *PhysAddr) } // --- Tempory Mappings --- -tVAddr MM_MapTemp(tPAddr PAddr) +void *MM_MapTemp(tPAddr PAddr) { const int max_slots = (MM_TMPMAP_END - MM_TMPMAP_BASE) / PAGE_SIZE; tVAddr ret = MM_TMPMAP_BASE; @@ -879,14 +879,14 @@ tVAddr MM_MapTemp(tPAddr PAddr) *ent = PAddr | 3; MM_RefPhys(PAddr); INVLPG(ret); - return ret; + return (void*)ret; } return 0; } -void MM_FreeTemp(tVAddr VAddr) +void MM_FreeTemp(void *Ptr) { - MM_Deallocate(VAddr); + MM_Deallocate((tVAddr)Ptr); return ; } @@ -966,14 +966,14 @@ tPAddr MM_Clone(void) for( i = 1; i < KERNEL_STACK_SIZE/0x1000; i ++ ) { tPAddr phys = MM_AllocPhys(); - tVAddr tmpmapping; + void *tmpmapping; MM_MapEx(kstackbase+i*0x1000, phys, 1, 0); tmpmapping = MM_MapTemp(phys); if( MM_GetPhysAddr( kstackbase+i*0x1000 ) ) - memcpy((void*)tmpmapping, (void*)(kstackbase+i*0x1000), 0x1000); + memcpy(tmpmapping, (void*)(kstackbase+i*0x1000), 0x1000); else - memset((void*)tmpmapping, 0, 0x1000); + memset(tmpmapping, 0, 0x1000); // if( i == 0xF ) // Debug_HexDump("MM_Clone: *tmpmapping = ", (void*)tmpmapping, 0x1000); MM_FreeTemp(tmpmapping); @@ -1064,10 +1064,10 @@ tVAddr MM_NewWorkerStack(void *StackData, size_t StackSize) Log_Error("MM", "MM_NewWorkerStack: StackSize(0x%x) > 0x1000, cbf handling", StackSize); } else { - tVAddr tmp_addr, dest; + void *tmp_addr, *dest; tmp_addr = MM_MapTemp(phys); - dest = tmp_addr + (0x1000 - StackSize); - memcpy( (void*)dest, StackData, StackSize ); + dest = (char*)tmp_addr + (0x1000 - StackSize); + memcpy( dest, StackData, StackSize ); Log_Debug("MM", "MM_NewWorkerStack: %p->%p %i bytes (i=%i)", StackData, dest, StackSize, i); Log_Debug("MM", "MM_NewWorkerStack: ret = %p", ret); MM_FreeTemp(tmp_addr);