Kernel/armv7 - Added IRQ stack, changed IRQs to be disabled until after handling
[tpg/acess2.git] / Kernel / arch / armv7 / proc.S
1 /*
2  * Acess2 ARM
3  * - By John Hodge (thePowersGang)
4  *
5  * arch/arm7/proc.S
6  * - Process management assembly
7  */
8
9 #include "include/assembly.h"
10
11 .globl KernelThreadHeader
12 @ SP+12: Argument 1
13 @ SP+8: Argument Count
14 @ SP+4: Function
15 @ SP+0: Thread Pointer
16 KernelThreadHeader:
17         ldr r0, [sp],#4
18         @ TODO: Do something with the thread pointer
19         
20         ldr r4, [sp],#4 @ Function
21         ldr r5, [sp],#4
22         @ Get arguments
23         sub r5, #1
24         ldrhs r0, [sp],#4
25 @       suble r5, #1
26 @       ldrhs r1, [sp],#4
27 @       suble r5, #1
28 @       ldrhs r2, [sp],#4
29 @       suble r5, #1
30 @       ldrhs r3, [sp],#4
31
32         blx r4
33         
34         ldr r0, =0
35         bl Threads_Exit
36         b .
37
38 .globl SwitchTask
39 @ R0: New stack
40 @ R1: Pointer to where to save old stack
41 @ R2: New IP
42 @ R3: Pointer to save old IP
43 @ SP+0: New address space
44 SwitchTask:
45         PUSH_GPRS
46
47         @ Save IP       
48         ldr r4, =.return
49         str r4, [r3]
50         @ Save SP
51         str sp, [r1]
52
53         @ Only update TTBR0 if the task has an explicit address space
54         ldr r1, [sp,#0x40]
55         tst r1, r1
56         mcrne p15, 0, r1, c2, c0, 0     @ Set TTBR0 to r0
57
58         @ Restore SP
59         mov sp, r0
60
61         bx r2
62
63 .return:
64         POP_GPRS
65         bx lr
66

UCC git Repository :: git.ucc.asn.au