From: John Hodge Date: Thu, 20 Oct 2011 11:13:56 +0000 (+0800) Subject: Kernel/armv7 - Fixed MM_Clone bug, moved cache invalidate to main.c X-Git-Tag: rel0.13~23 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=439370a78b75a6f015e815ac6a42d55e46cf7d0a;p=tpg%2Facess2.git Kernel/armv7 - Fixed MM_Clone bug, moved cache invalidate to main.c --- diff --git a/Kernel/arch/armv7/main.c b/Kernel/arch/armv7/main.c index 9e864822..b182e516 100644 --- a/Kernel/arch/armv7/main.c +++ b/Kernel/arch/armv7/main.c @@ -4,6 +4,8 @@ * ARM7 Entrypoint * arch/arm7/main.c */ +#define DEBUG 1 + #include #include @@ -16,6 +18,7 @@ extern void System_Init(const char *Commandline); // === PROTOTYPES === int kmain(void); +Uint32 ARMv7_int_HandleSyscalls(Uint32 Num, Uint32 *Args); // === CODE === int kmain(void) @@ -52,3 +55,38 @@ void Arch_LoadBootModules(void) { } +Uint32 ARMv7_int_HandleSyscalls(Uint32 Num, Uint32 *Args) +{ + Uint32 ret = -1, err = 0; + Uint32 addr; + ENTER("iNum xArgs[0] xArgs[1] xArgs[2] xArgs[3]", + Num, Args[0], Args[1], Args[2], Args[3] + ); + switch(Num) + { + case 1: + Log_Debug("ARMv7", "__clear_cache(%p, %p)", Args[0], Args[1]); + // Align + Args[0] &= ~0xFFF; + Args[1] += 0xFFF; Args[1] &= ~0xFFF; + // Invalidate! + for( addr = Args[0]; addr < Args[1]; addr += 0x1000 ) + { + LOG("addr = %p", addr); + __asm__ __volatile__ ( + "mcrlt p15, 0, %0, c7, c5, 1;\n\t" + "mcrlt p15, 0, %0, c7, c6, 1;\n\t" + : + : "r" (addr) + ); + } + ret = 0; + break; + } + Args[0] = ret; // RetLow + Args[1] = 0; // RetHi + Args[2] = err; // Errno + LEAVE('x', ret); + return ret; +} + diff --git a/Kernel/arch/armv7/mm_virt.c b/Kernel/arch/armv7/mm_virt.c index 887b10b8..03c8cc7d 100644 --- a/Kernel/arch/armv7/mm_virt.c +++ b/Kernel/arch/armv7/mm_virt.c @@ -491,7 +491,7 @@ void MM_int_CloneTable(Uint32 *DestEnt, int Table) { tPAddr table; Uint32 *tmp_map; - Uint32 *cur = (void*)MM_TABLE0USER; + Uint32 *cur = (void*)MM_TABLE1USER; // Uint32 *cur = &FRACTAL(MM_TABLE1USER,0); int i; @@ -502,12 +502,13 @@ void MM_int_CloneTable(Uint32 *DestEnt, int Table) for( i = 0; i < 1024; i ++ ) { - switch(cur[i] & 3) +// Log_Debug("MMVirt", "cur[%i] (%p) = %x", Table*256+i, &cur[Table*256+i], cur[Table*256+i]); + switch(cur[Table*256+i] & 3) { case 0: tmp_map[i] = 0; break; case 1: tmp_map[i] = 0; - Log_Error("MMVirt", "TODO: Support large pages in MM_int_CloneTable"); + Log_Error("MMVirt", "TODO: Support large pages in MM_int_CloneTable (%p)", (Table*256+i)*0x1000); // Large page? break; case 2: @@ -533,6 +534,8 @@ tPAddr MM_Clone(void) Uint32 *new_lvl1_1, *new_lvl1_2, *cur; Uint32 *tmp_map; int i; + +// MM_DumpTables(0, KERNEL_BASE); ret = MM_AllocateRootTable(); diff --git a/Kernel/arch/armv7/proc.S b/Kernel/arch/armv7/proc.S index 801909c9..f62100e6 100644 --- a/Kernel/arch/armv7/proc.S +++ b/Kernel/arch/armv7/proc.S @@ -89,10 +89,10 @@ Proc_CloneInt: Proc_CloneInt_new: cps #18 - mov r0, #0 - mov r1, #0 - sub r1, #1 - bl MM_DumpTables +@ mov r0, #0 +@ mov r1, #0 +@ sub r1, #1 +@ bl MM_DumpTables @ ldr r0, =csProc_CloneInt_NewTaskMessage @ bl Log diff --git a/Kernel/arch/armv7/start.S b/Kernel/arch/armv7/start.S index 5a8e4eb4..3a5a062a 100644 --- a/Kernel/arch/armv7/start.S +++ b/Kernel/arch/armv7/start.S @@ -93,40 +93,12 @@ SVC_Handler: rfeia sp! @ Pop state (actually RFEFD) .arm_specifics: and r4, #0xFF + mov r0, r4 @ Number + mov r1, sp @ Arguments + + ldr r4, =ARMv7_int_HandleSyscalls + blx r4 -@ -@ Cache invalidation - cmp r4, #0x001 - bne 1f - @ Page align - mov r2, #0x1000 - sub r2, #1 - add r1, r2 - mvn r2, r2 - and r0, r2 - and r1, r2 - cmp r0, #0x78000000 - cmpls r1, #0x78000000 - movge r0, #-1 - movge r1, #0 - movge r2, #1 - bge .ret - -2: - cmp r0, r1 - mcrlt p15, 0, r0, c7, c5, 1 - mcrlt p15, 0, r0, c7, c6, 1 - addlt r0, #0x1000 - blt 2b - mov r0, #0 - mov r1, #0 - mov r2, #0 - b .ret -1: - mov r0, #-1 - mov r1, #0 - mov r2, #-1 -.ret: add sp, #4*4 pop {r4-r12} rfeia sp!