4 #include "kernel_offset.h"
\r
5 #include "arch_offset.h"
\r
15 .global os_arch_swap_context_to
\r
16 .global os_arch_swap_context
\r
18 /* r0 - pcb for old task
\r
19 * r1 pcb for new task
\r
21 * -------------- higher addr
\r
24 * 4 - Large or Small context indicator
\r
26 * ---------- <- JABBA
\r
29 os_arch_swap_context:
\r
31 push {r0,r4-r8,r10,r11,lr}
\r
36 mov.w r4,#SC_PATTERN
\r
39 // store old stack for old task
\r
40 str sp,[r0,#PCB_STACK_CURR_P]
\r
41 os_arch_swap_context_to:
\r
42 // Get stack for new task
\r
43 ldr sp,[r1,#PCB_STACK_CURR_P]
\r
45 // TODO: Fix this for all arch's..call pre,post hooks. Done here or after?
\r
46 // Set new current pcb
\r
48 str r1,[r5,#SYS_CURR_PCB_P]
\r
50 // Restore C context
\r
57 // TODO: Jump to error handler
\r
62 pop {r4-r8,r10,r11,lr}
\r
63 // ehh, we are in handler mode so a bx instruction works here
\r
68 pop {r4-r8,r10,r11,lr}
\r
69 // ehh, we are in handler mode so a bx instruction works here
\r