X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Farmv7%2Fproc.S;h=4d7c89f714933623fcdbc6b81e85e97970de6394;hb=1baac59e0cea8985a60093e7415a1796bad138ae;hp=841764b6ddc49180de164def39822b7735359650;hpb=acc4756d2e22346862ec098be4a18f52846f6dc4;p=tpg%2Facess2.git diff --git a/Kernel/arch/armv7/proc.S b/Kernel/arch/armv7/proc.S index 841764b6..4d7c89f7 100644 --- a/Kernel/arch/armv7/proc.S +++ b/Kernel/arch/armv7/proc.S @@ -6,39 +6,7 @@ * - Process management assembly */ -#define PUSH_GPRS \ - str r0, [sp,#-1*4];\ - str r1, [sp,#-2*4];\ - str r2, [sp,#-3*4];\ - str r3, [sp,#-4*4];\ - str r4, [sp,#-5*4];\ - str r5, [sp,#-6*4];\ - str r6, [sp,#-7*4];\ - str r7, [sp,#-8*4];\ - str r8, [sp,#-9*4];\ - str r9, [sp,#-10*4];\ - str r10, [sp,#-11*4];\ - str r11, [sp,#-12*4];\ - str r12, [sp,#-13*4];\ - str sp, [sp,#-14*4];\ - str lr, [sp,#-15*4];\ - sub sp, #16*4 - -#define POP_GPRS add sp, #16*4; \ - ldr r0, [sp,#-1*4]; \ - ldr r1, [sp,#-2*4]; \ - ldr r2, [sp,#-3*4]; \ - ldr r3, [sp,#-4*4]; \ - ldr r4, [sp,#-5*4]; \ - ldr r5, [sp,#-6*4]; \ - ldr r6, [sp,#-7*4]; \ - ldr r7, [sp,#-8*4]; \ - ldr r8, [sp,#-9*4]; \ - ldr r9, [sp,#-10*4]; \ - ldr r10, [sp,#-11*4]; \ - ldr r11, [sp,#-12*4]; \ - ldr r12, [sp,#-13*4]; \ - ldr lr, [sp,#-15*4]; +#include "include/assembly.h" .globl KernelThreadHeader @ SP+12: Argument 1 @@ -50,19 +18,10 @@ KernelThreadHeader: @ TODO: Do something with the thread pointer ldr r4, [sp],#4 @ Function - ldr r5, [sp],#4 - @ Get arguments - sub r5, #1 - ldrhs r0, [sp],#4 - sub r5, #1 - ldrhs r1, [sp],#4 - sub r5, #1 - ldrhs r2, [sp],#4 - sub r5, #1 - ldrhs r3, [sp],#4 + @ Get argument + ldr r0, [sp],#4 - mov lr, pc - mov pc, r4 + blx r4 ldr r0, =0 bl Threads_Exit @@ -75,21 +34,69 @@ KernelThreadHeader: @ R3: Pointer to save old IP @ SP+0: New address space SwitchTask: - PUSH_GPRS - + push {r4-r12,lr} + + @ Save IP ldr r4, =.return str r4, [r3] + @ Save SP str sp, [r1] - mov r0, sp - + @ Only update TTBR0 if the task has an explicit address space - ldr r0, [sp,#0x40] - tst r0, r0 - mcrne p15, 0, r0, c2, c0, 0 @ Set TTBR0 to r0 + ldr r1, [sp,#4*10] + tst r1, r1 + mcrne p15, 0, r1, c2, c0, 0 @ Set TTBR0 to r0 + mov r1, #0 + mcrne p15, 0, r1, c8, c7, 0 @ Invalidate all (HACK! But it fixes things) - mov pc, r2 + @ Restore SP + mov sp, r0 + + bx r2 .return: - POP_GPRS - bx lr + pop {r4-r12,pc} + +.extern MM_Clone +.extern MM_DumpTables +.globl Proc_CloneInt +Proc_CloneInt: + @ R0: SP Destination + @ R1: Mem Destination + push {r4-r12,lr} + mov r4, r1 @ Save mem destination + str sp, [r0] @ Save SP to SP dest + + bl MM_Clone + str r0, [r4] @ Save clone return to Mem Dest + + ldr r0, =Proc_CloneInt_new + pop {r4-r12,pc} +Proc_CloneInt_new: + mov r0, #0 + pop {r4-r12,pc} + +@ R0: New user SP +@ Return: Old user SP +.globl Proc_int_SwapUserSP +Proc_int_SwapUserSP: + cps #31 @ Go to system mode + mov r1, sp + tst r0, r0 @ Only update if non-zero + movne sp, r0 + mov r0, r1 + cps #19 + mov pc, lr + +.section .usertext, "ax" +.globl Proc_int_DropToUser +@ R0: User IP +@ R1: User SP +Proc_int_DropToUser: + cps #16 + mov sp, r1 + mov pc, r0 +.section .rodata +csProc_CloneInt_NewTaskMessage: + .asciz "New task"