4 #include "kernel_offset.h"
\r
5 #include "arch_offset.h"
\r
18 .type Irq_Handler, %function
\r
20 #define IRQ_ENABLE() cpsie i
\r
21 #define IRQ_DISABLE() cpsid i
\r
24 push {r4-r8,r10,r11,lr}
\r
26 mov.w r4,#LC_PATTERN
\r
27 str r4,[sp,#C_CONTEXT_OFFS]
\r
28 mov r0,sp // stack as first arg
\r
30 mov sp, r0 // pop from returned stack
\r
34 /* r0 - pcb for old task
\r
35 * r1 pcb for new task
\r
37 * -------------- higher addr
\r
40 * 4 - Large or Small context indicator
\r
42 * ---------- <- JABBA
\r
45 .global Os_ArchSwapContext
\r
46 .type Os_ArchSwapContext, %function
\r
49 push {r4-r8,r10,r11,lr}
\r
54 mov.w r4,#SC_PATTERN
\r
55 str r4,[sp,#C_CONTEXT_OFFS]
\r
56 // str r2,[sp,#C_SP_OFF]
\r
57 // ---> We have saved NVGPR+C
\r
59 // store old stack for old task
\r
61 str r4,[r0,#PCB_STACK_CURR_P]
\r
64 .global Os_ArchSwapContextTo
\r
65 .type Os_ArchSwapContextTo, %function
\r
66 Os_ArchSwapContextTo:
\r
68 // Get stack for new task
\r
69 ldr r2,[r1,#PCB_STACK_CURR_P]
\r
74 // TODO: Fix this for all arch's..call pre,post hooks. Done here or after?
\r
75 // Set new current pcb
\r
77 str r1,[r5,#SYS_CURR_PCB_P]
\r
79 // Restore C context
\r
80 ldr r6,[sp,#C_CONTEXT_OFFS]
\r
86 // TODO: Jump to error handler
\r
92 pop {r4-r8,r10,r11,lr}
\r
93 // ehh, we are in handler mode so a bx instruction works here
\r
99 pop {r4-r8,r10,r11,lr}
\r
100 // ehh, we are in handler mode so a bx instruction works here
\r