revert between 56095 -> 55830 in arch
[AROS.git] / arch / arm-all / exec / stackswap-armeb.S
blobb4dbf77942e24dfe86a4ffdae99d837b44306fe6
1 /*
2     Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3     $Id$
4 */
6         #include <aros/armeb/asm.h>
8         .text
9         .balign 4
10         .globl  AROS_SLIB_ENTRY(StackSwap,Exec,122)
12 AROS_SLIB_ENTRY(StackSwap,Exec,122):
14         // r0 contains parameter 'newStack'
15         // r1 contains ExecBase
16         // lr contains the return address
18         stmfd sp!, {r0, r1, lr}     // save some useful registers
19         mov r0, #0
20         ldr ip, [r1, #-196]         // Call FindTask(NULL)
21         blx ip
22         mov r2, r0                  // copy result to r2 register
23         ldmfd sp!, {r0, r1, lr}     // restore r0, r1 and lr
24         mov     r3, r0                  // newstack to r3       
26         /* Disable interrupts */
27         stmfd   sp!, {r0, r1, r2, r3, lr}
28         ldr     ip, [r1, Disable]     // ip = GETVECADDR(Disable)
29         mov     r0, r1                // One argument = SysBase
30         blx     ip
31         ldmfd   sp!, {r0, r1, r2, r3, lr}
33         /* Swap Lower boundaries, use ip as scratch register (r1 holds SysBase!!!!) */
34         ldr     r0, [r2, tc_SPLower]  // r0 holds old contents of tc_SPLower
35         ldr     ip, [r3, stk_Lower]   // ip holds new contents of tc_SPLower
36         str     ip, [r2, tc_SPLower]  // write new contents
37         str     r0, [r3, stk_Lower]   // save old contents back into passed struct 
38                                       // postinc r3
40         /* Swap higher boundaries */
41         ldr     r0, [r2, tc_SPUpper] // r0 holds old contents of tc_SPHigher
42         ldr     ip, [r3, stk_Upper]  // ip holds new contents of tc_SPHigher
43         str     ip, [r2, tc_SPUpper] // write new contents
44         str     r0, [r3, stk_Upper]  // save old contents back into passed struct
46         /* Swap stackpointers */
47         mov     r0, sp                // current stack pointer to r0
48         ldr     sp, [r3, stk_Pointer] // get desired stack pointer
49         str     r0, [r3, stk_Pointer] // save old stack pointer
51         /* Enable interupts */
52         stmfd   sp!, {r0, r1, lr}
53         ldr     ip, [r1, Enable]      // ip = GETVECADDR(Enable)
54         mov     r0, r1                // One argument = SysBase
55         blx     ip
56         ldmfd   sp!, {r0, r1, lr}
58         /* Return from this function. There's no 'rts' instruction...*/
59         bx      lr