]> rtime.felk.cvut.cz Git - arc.git/blob - arch/arm/arm_cm3/kernel/arch_krn.sx
Support for case insenstive make. msys make that is
[arc.git] / arch / arm / arm_cm3 / kernel / arch_krn.sx
1 \r
2 \r
3 #define _ASSEMBLER_\r
4 #include "kernel_offset.h"\r
5 #include "arch_offset.h"\r
6 #include "stack.h"\r
7 \r
8 .extern os_sys\r
9 \r
10         .syntax unified\r
11         .cpu cortex-m3\r
12         .fpu softvfp\r
13         .thumb\r
14 \r
15         .section .text\r
16 /* r0 - pcb for old task\r
17  * r1 pcb for new task\r
18  *\r
19  * -------------- higher addr\r
20  * r4-r8,etc\r
21  * -------\r
22  * 4 - Large or Small context indicator\r
23  * 0 - ?\r
24  * ----------    <- JABBA\r
25  *\r
26  */\r
27         .global os_arch_swap_context\r
28         .type   os_arch_swap_context, %function\r
29 os_arch_swap_context:\r
30 //    mov     r2, sp\r
31     push    {r4-r8,r10,r11,lr}\r
32 \r
33     // Store c-frame\r
34     sub.w   sp,sp,#C_SIZE\r
35 \r
36     mov.w   r4,#SC_PATTERN\r
37     str     r4,[sp,#C_CONTEXT_OFFS]\r
38 //    str     r2,[sp,#C_SP_OFF]\r
39         // ---> We have saved NVGPR+C\r
40 \r
41     // store old stack for old task\r
42     mov.w       r4,sp\r
43     str     r4,[r0,#PCB_STACK_CURR_P]\r
44 \r
45 // R1 - new PCB\r
46         .global os_arch_swap_context_to\r
47         .type   os_arch_swap_context_to, %function\r
48 os_arch_swap_context_to:\r
49 \r
50     // Get stack for new task\r
51     ldr         r2,[r1,#PCB_STACK_CURR_P]\r
52 //    msr               msp,r2\r
53     mov.w       sp,r2\r
54     \r
55 \r
56 // TODO: Fix this for all arch's..call pre,post hooks. Done here or after?\r
57 // Set new current pcb\r
58     ldr     r5,= os_sys\r
59     str     r1,[r5,#SYS_CURR_PCB_P]\r
60 \r
61 // Restore C context\r
62     ldr     r6,[sp,#C_CONTEXT_OFFS]\r
63     cmp     r6,#SC_PATTERN\r
64     beq     os_sc_restore\r
65     cmp     r6,#LC_PATTERN\r
66     beq     os_lc_restore\r
67 os_stack_problem:\r
68 // TODO: Jump to error handler\r
69     b os_stack_problem\r
70 \r
71 os_sc_restore:\r
72     add.w   sp,sp,#C_SIZE\r
73 \r
74     pop     {r4-r8,r10,r11,lr}\r
75         // ehh, we are in handler mode so a bx instruction works here\r
76     bx      lr\r
77 \r
78 os_lc_restore:\r
79     add.w   sp,sp,#C_SIZE\r
80     pop     {r4-r8,r10,r11,lr}\r
81     // ehh, we are in handler mode so a bx instruction works here\r
82     bx      lr\r
83 \r
84 \r
85 \r