Kernel/arm7 - Fiddling on process switching
[tpg/acess2.git] / Kernel / arch / arm7 / proc.S
1 /*
2  * Acess2 ARM
3  * - By John Hodge (thePowersGang)
4  *
5  * arch/arm7/proc.S
6  * - Process management assembly
7  */
8
9 #define PUSH_GPRS \
10         str r0, [sp,#1*4];\
11         str r1, [sp,#2*4];\
12         str r2, [sp,#3*4];\
13         str r3, [sp,#4*4];\
14         str r4, [sp,#5*4];\
15         str r5, [sp,#6*4];\
16         str r6, [sp,#7*4];\
17         str r7, [sp,#8*4];\
18         str r8, [sp,#9*4];\
19         str r9, [sp,#10*4];\
20         str r10, [sp,#11*4];\
21         str r11, [sp,#12*4];\
22         str r12, [sp,#13*4];\
23         str sp, [sp,#14*4];\
24         str lr, [sp,#15*4];\
25         sub sp, #16*4
26
27 #define POP_GPRS add sp, #16*4; \
28         ldr r0, [sp,#1*4]; \
29         ldr r1, [sp,#2*4]; \
30         ldr r2, [sp,#3*4]; \
31         ldr r3, [sp,#4*4]; \
32         ldr r4, [sp,#5*4]; \
33         ldr r5, [sp,#6*4]; \
34         ldr r6, [sp,#7*4]; \
35         ldr r7, [sp,#8*4]; \
36         ldr r8, [sp,#9*4]; \
37         ldr r9, [sp,#10*4]; \
38         ldr r10, [sp,#11*4]; \
39         ldr r11, [sp,#12*4]; \
40         ldr r12, [sp,#13*4]; \
41         ldr lr, [sp,#15*4];
42
43 .globl SwitchStacks
44 @ R0: New stack
45 @ R1: Pointer to where to save old stack
46 @ R2: New address space
47 SwitchStacks:
48         PUSH_GPRS
49         
50         str sp, [r1]
51         mov r0, sp
52         
53         @ Only update TTBR0 if the task has an explicit address space
54         tst r2, r2
55         mcrne p15, 0, r2, c2, c0, 0     @ Set TTBR0 to r2
56
57         POP_GPRS
58         bx lr

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