XINU
ctxsw.S
Go to the documentation of this file.
1 /**
2  * @file ctxsw.S
3  * @brief ARM (32bit)用のコンテキストスイッチを行う。
4  */
5 
6 
7  .text
8  .globl ctxsw
9 
10 /*------------------------------------------------------------------------
11  * ctxsw - ARM context switch; the call is ctxsw(&old_sp, &new_sp)
12  *------------------------------------------------------------------------
13  */
14 
15 ctxsw:
16  push {r0-r11, lr} /* Push regs 0 - 11 and lr */
17  push {lr} /* Push return address */
18  mrs r2, cpsr /* Obtain status from coprocess.*/
19  push {r2} /* and push onto stack */
20  str sp, [r0] /* Save old process's SP */
21  ldr sp, [r1] /* Pick up new process's SP */
22  pop {r0} /* Use status as argument and */
23  bl restore /* call restore to restore it */
24  pop {lr} /* Pick up the return address */
25  pop {r0-r12} /* Restore other registers */
26  mov pc, r12 /* Return to the new process */