mutex++
Dependents: header_main_publish
Fork of mbed-rtos by
rtx/TARGET_M0/TOOLCHAIN_GCC/HAL_CM0.s@13:869ef732a8a2, 2013-08-05 (annotated)
- Committer:
- bogdanm
- Date:
- Mon Aug 05 14:12:52 2013 +0300
- Revision:
- 13:869ef732a8a2
- Parent:
- rtx/LPC11U24/GCC_ARM/HAL_CM0.s@6:350b53afb889
Update sources to revision 64
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 6:350b53afb889 | 1 | /*---------------------------------------------------------------------------- |
emilmont | 6:350b53afb889 | 2 | * RL-ARM - RTX |
emilmont | 6:350b53afb889 | 3 | *---------------------------------------------------------------------------- |
emilmont | 6:350b53afb889 | 4 | * Name: HAL_CM0.S |
emilmont | 6:350b53afb889 | 5 | * Purpose: Hardware Abstraction Layer for Cortex-M0 |
emilmont | 6:350b53afb889 | 6 | * Rev.: V4.60 |
emilmont | 6:350b53afb889 | 7 | *---------------------------------------------------------------------------- |
emilmont | 6:350b53afb889 | 8 | * |
emilmont | 6:350b53afb889 | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH |
emilmont | 6:350b53afb889 | 10 | * All rights reserved. |
emilmont | 6:350b53afb889 | 11 | * Redistribution and use in source and binary forms, with or without |
emilmont | 6:350b53afb889 | 12 | * modification, are permitted provided that the following conditions are met: |
emilmont | 6:350b53afb889 | 13 | * - Redistributions of source code must retain the above copyright |
emilmont | 6:350b53afb889 | 14 | * notice, this list of conditions and the following disclaimer. |
emilmont | 6:350b53afb889 | 15 | * - Redistributions in binary form must reproduce the above copyright |
emilmont | 6:350b53afb889 | 16 | * notice, this list of conditions and the following disclaimer in the |
emilmont | 6:350b53afb889 | 17 | * documentation and/or other materials provided with the distribution. |
emilmont | 6:350b53afb889 | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
emilmont | 6:350b53afb889 | 19 | * to endorse or promote products derived from this software without |
emilmont | 6:350b53afb889 | 20 | * specific prior written permission. |
emilmont | 6:350b53afb889 | 21 | * |
emilmont | 6:350b53afb889 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
emilmont | 6:350b53afb889 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
emilmont | 6:350b53afb889 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
emilmont | 6:350b53afb889 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
emilmont | 6:350b53afb889 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
emilmont | 6:350b53afb889 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
emilmont | 6:350b53afb889 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
emilmont | 6:350b53afb889 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
emilmont | 6:350b53afb889 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
emilmont | 6:350b53afb889 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
emilmont | 6:350b53afb889 | 32 | * POSSIBILITY OF SUCH DAMAGE. |
emilmont | 6:350b53afb889 | 33 | *---------------------------------------------------------------------------*/ |
emilmont | 6:350b53afb889 | 34 | |
emilmont | 6:350b53afb889 | 35 | .file "HAL_CM0.S" |
emilmont | 6:350b53afb889 | 36 | .syntax unified |
emilmont | 6:350b53afb889 | 37 | |
emilmont | 6:350b53afb889 | 38 | .equ TCB_TSTACK, 36 |
emilmont | 6:350b53afb889 | 39 | |
emilmont | 6:350b53afb889 | 40 | |
emilmont | 6:350b53afb889 | 41 | /*---------------------------------------------------------------------------- |
emilmont | 6:350b53afb889 | 42 | * Functions |
emilmont | 6:350b53afb889 | 43 | *---------------------------------------------------------------------------*/ |
emilmont | 6:350b53afb889 | 44 | |
emilmont | 6:350b53afb889 | 45 | .thumb |
emilmont | 6:350b53afb889 | 46 | |
emilmont | 6:350b53afb889 | 47 | .section ".text" |
emilmont | 6:350b53afb889 | 48 | .align 2 |
emilmont | 6:350b53afb889 | 49 | |
emilmont | 6:350b53afb889 | 50 | |
emilmont | 6:350b53afb889 | 51 | /*--------------------------- rt_set_PSP ------------------------------------*/ |
emilmont | 6:350b53afb889 | 52 | |
emilmont | 6:350b53afb889 | 53 | # void rt_set_PSP (U32 stack); |
emilmont | 6:350b53afb889 | 54 | |
emilmont | 6:350b53afb889 | 55 | .thumb_func |
emilmont | 6:350b53afb889 | 56 | .type rt_set_PSP, %function |
emilmont | 6:350b53afb889 | 57 | .global rt_set_PSP |
emilmont | 6:350b53afb889 | 58 | rt_set_PSP: |
emilmont | 6:350b53afb889 | 59 | .fnstart |
emilmont | 6:350b53afb889 | 60 | .cantunwind |
emilmont | 6:350b53afb889 | 61 | |
emilmont | 6:350b53afb889 | 62 | MSR PSP,R0 |
emilmont | 6:350b53afb889 | 63 | BX LR |
emilmont | 6:350b53afb889 | 64 | |
emilmont | 6:350b53afb889 | 65 | .fnend |
emilmont | 6:350b53afb889 | 66 | .size rt_set_PSP, .-rt_set_PSP |
emilmont | 6:350b53afb889 | 67 | |
emilmont | 6:350b53afb889 | 68 | |
emilmont | 6:350b53afb889 | 69 | /*--------------------------- rt_get_PSP ------------------------------------*/ |
emilmont | 6:350b53afb889 | 70 | |
emilmont | 6:350b53afb889 | 71 | # U32 rt_get_PSP (void); |
emilmont | 6:350b53afb889 | 72 | |
emilmont | 6:350b53afb889 | 73 | .thumb_func |
emilmont | 6:350b53afb889 | 74 | .type rt_get_PSP, %function |
emilmont | 6:350b53afb889 | 75 | .global rt_get_PSP |
emilmont | 6:350b53afb889 | 76 | rt_get_PSP: |
emilmont | 6:350b53afb889 | 77 | .fnstart |
emilmont | 6:350b53afb889 | 78 | .cantunwind |
emilmont | 6:350b53afb889 | 79 | |
emilmont | 6:350b53afb889 | 80 | MRS R0,PSP |
emilmont | 6:350b53afb889 | 81 | BX LR |
emilmont | 6:350b53afb889 | 82 | |
emilmont | 6:350b53afb889 | 83 | .fnend |
emilmont | 6:350b53afb889 | 84 | .size rt_get_PSP, .-rt_get_PSP |
emilmont | 6:350b53afb889 | 85 | |
emilmont | 6:350b53afb889 | 86 | |
emilmont | 6:350b53afb889 | 87 | /*--------------------------- os_set_env ------------------------------------*/ |
emilmont | 6:350b53afb889 | 88 | |
emilmont | 6:350b53afb889 | 89 | # void os_set_env (void); |
emilmont | 6:350b53afb889 | 90 | /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ |
emilmont | 6:350b53afb889 | 91 | |
emilmont | 6:350b53afb889 | 92 | .thumb_func |
emilmont | 6:350b53afb889 | 93 | .type os_set_env, %function |
emilmont | 6:350b53afb889 | 94 | .global os_set_env |
emilmont | 6:350b53afb889 | 95 | os_set_env: |
emilmont | 6:350b53afb889 | 96 | .fnstart |
emilmont | 6:350b53afb889 | 97 | .cantunwind |
emilmont | 6:350b53afb889 | 98 | |
emilmont | 6:350b53afb889 | 99 | MOV R0,SP /* PSP = MSP */ |
emilmont | 6:350b53afb889 | 100 | MSR PSP,R0 |
emilmont | 6:350b53afb889 | 101 | LDR R0,=os_flags |
emilmont | 6:350b53afb889 | 102 | LDRB R0,[R0] |
emilmont | 6:350b53afb889 | 103 | LSLS R0,#31 |
emilmont | 6:350b53afb889 | 104 | BNE PrivilegedE |
emilmont | 6:350b53afb889 | 105 | MOVS R0,#0x03 /* Unprivileged Thread mode, use PSP */ |
emilmont | 6:350b53afb889 | 106 | MSR CONTROL,R0 |
emilmont | 6:350b53afb889 | 107 | BX LR |
emilmont | 6:350b53afb889 | 108 | PrivilegedE: |
emilmont | 6:350b53afb889 | 109 | MOVS R0,#0x02 /* Privileged Thread mode, use PSP */ |
emilmont | 6:350b53afb889 | 110 | MSR CONTROL,R0 |
emilmont | 6:350b53afb889 | 111 | BX LR |
emilmont | 6:350b53afb889 | 112 | |
emilmont | 6:350b53afb889 | 113 | .fnend |
emilmont | 6:350b53afb889 | 114 | .size os_set_env, .-os_set_env |
emilmont | 6:350b53afb889 | 115 | |
emilmont | 6:350b53afb889 | 116 | |
emilmont | 6:350b53afb889 | 117 | /*--------------------------- _alloc_box ------------------------------------*/ |
emilmont | 6:350b53afb889 | 118 | |
emilmont | 6:350b53afb889 | 119 | # void *_alloc_box (void *box_mem); |
emilmont | 6:350b53afb889 | 120 | /* Function wrapper for Unprivileged/Privileged mode. */ |
emilmont | 6:350b53afb889 | 121 | |
emilmont | 6:350b53afb889 | 122 | .thumb_func |
emilmont | 6:350b53afb889 | 123 | .type _alloc_box, %function |
emilmont | 6:350b53afb889 | 124 | .global _alloc_box |
emilmont | 6:350b53afb889 | 125 | _alloc_box: |
emilmont | 6:350b53afb889 | 126 | .fnstart |
emilmont | 6:350b53afb889 | 127 | .cantunwind |
emilmont | 6:350b53afb889 | 128 | |
emilmont | 6:350b53afb889 | 129 | LDR R3,=rt_alloc_box |
emilmont | 6:350b53afb889 | 130 | MOV R12,R3 |
emilmont | 6:350b53afb889 | 131 | MRS R3,IPSR |
emilmont | 6:350b53afb889 | 132 | LSLS R3,#24 |
emilmont | 6:350b53afb889 | 133 | BNE PrivilegedA |
emilmont | 6:350b53afb889 | 134 | MRS R3,CONTROL |
emilmont | 6:350b53afb889 | 135 | LSLS R3,#31 |
emilmont | 6:350b53afb889 | 136 | BEQ PrivilegedA |
emilmont | 6:350b53afb889 | 137 | SVC 0 |
emilmont | 6:350b53afb889 | 138 | BX LR |
emilmont | 6:350b53afb889 | 139 | PrivilegedA: |
emilmont | 6:350b53afb889 | 140 | BX R12 |
emilmont | 6:350b53afb889 | 141 | |
emilmont | 6:350b53afb889 | 142 | .fnend |
emilmont | 6:350b53afb889 | 143 | .size _alloc_box, .-_alloc_box |
emilmont | 6:350b53afb889 | 144 | |
emilmont | 6:350b53afb889 | 145 | |
emilmont | 6:350b53afb889 | 146 | /*--------------------------- _free_box -------------------------------------*/ |
emilmont | 6:350b53afb889 | 147 | |
emilmont | 6:350b53afb889 | 148 | # int _free_box (void *box_mem, void *box); |
emilmont | 6:350b53afb889 | 149 | /* Function wrapper for Unprivileged/Privileged mode. */ |
emilmont | 6:350b53afb889 | 150 | |
emilmont | 6:350b53afb889 | 151 | .thumb_func |
emilmont | 6:350b53afb889 | 152 | .type _free_box, %function |
emilmont | 6:350b53afb889 | 153 | .global _free_box |
emilmont | 6:350b53afb889 | 154 | _free_box: |
emilmont | 6:350b53afb889 | 155 | .fnstart |
emilmont | 6:350b53afb889 | 156 | .cantunwind |
emilmont | 6:350b53afb889 | 157 | |
emilmont | 6:350b53afb889 | 158 | LDR R3,=rt_free_box |
emilmont | 6:350b53afb889 | 159 | MOV R12,R3 |
emilmont | 6:350b53afb889 | 160 | MRS R3,IPSR |
emilmont | 6:350b53afb889 | 161 | LSLS R3,#24 |
emilmont | 6:350b53afb889 | 162 | BNE PrivilegedF |
emilmont | 6:350b53afb889 | 163 | MRS R3,CONTROL |
emilmont | 6:350b53afb889 | 164 | LSLS R3,#31 |
emilmont | 6:350b53afb889 | 165 | BEQ PrivilegedF |
emilmont | 6:350b53afb889 | 166 | SVC 0 |
emilmont | 6:350b53afb889 | 167 | BX LR |
emilmont | 6:350b53afb889 | 168 | PrivilegedF: |
emilmont | 6:350b53afb889 | 169 | BX R12 |
emilmont | 6:350b53afb889 | 170 | |
emilmont | 6:350b53afb889 | 171 | .fnend |
emilmont | 6:350b53afb889 | 172 | .size _free_box, .-_free_box |
emilmont | 6:350b53afb889 | 173 | |
emilmont | 6:350b53afb889 | 174 | |
emilmont | 6:350b53afb889 | 175 | /*-------------------------- SVC_Handler ------------------------------------*/ |
emilmont | 6:350b53afb889 | 176 | |
emilmont | 6:350b53afb889 | 177 | # void SVC_Handler (void); |
emilmont | 6:350b53afb889 | 178 | |
emilmont | 6:350b53afb889 | 179 | .thumb_func |
emilmont | 6:350b53afb889 | 180 | .type SVC_Handler, %function |
emilmont | 6:350b53afb889 | 181 | .global SVC_Handler |
emilmont | 6:350b53afb889 | 182 | SVC_Handler: |
emilmont | 6:350b53afb889 | 183 | .fnstart |
emilmont | 6:350b53afb889 | 184 | .cantunwind |
emilmont | 6:350b53afb889 | 185 | |
emilmont | 6:350b53afb889 | 186 | MRS R0,PSP /* Read PSP */ |
emilmont | 6:350b53afb889 | 187 | LDR R1,[R0,#24] /* Read Saved PC from Stack */ |
emilmont | 6:350b53afb889 | 188 | SUBS R1,R1,#2 /* Point to SVC Instruction */ |
emilmont | 6:350b53afb889 | 189 | LDRB R1,[R1] /* Load SVC Number */ |
emilmont | 6:350b53afb889 | 190 | CMP R1,#0 |
emilmont | 6:350b53afb889 | 191 | BNE SVC_User /* User SVC Number > 0 */ |
emilmont | 6:350b53afb889 | 192 | |
emilmont | 6:350b53afb889 | 193 | MOV LR,R4 |
emilmont | 6:350b53afb889 | 194 | LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */ |
emilmont | 6:350b53afb889 | 195 | MOV R12,R4 |
emilmont | 6:350b53afb889 | 196 | MOV R4,LR |
emilmont | 6:350b53afb889 | 197 | BLX R12 /* Call SVC Function */ |
emilmont | 6:350b53afb889 | 198 | |
emilmont | 6:350b53afb889 | 199 | MRS R3,PSP /* Read PSP */ |
emilmont | 6:350b53afb889 | 200 | STMIA R3!,{R0-R2} /* Store return values */ |
emilmont | 6:350b53afb889 | 201 | |
emilmont | 6:350b53afb889 | 202 | LDR R3,=os_tsk |
emilmont | 6:350b53afb889 | 203 | LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.new */ |
emilmont | 6:350b53afb889 | 204 | CMP R1,R2 |
emilmont | 6:350b53afb889 | 205 | BEQ SVC_Exit /* no task switch */ |
emilmont | 6:350b53afb889 | 206 | |
emilmont | 6:350b53afb889 | 207 | SUBS R3,#8 |
emilmont | 6:350b53afb889 | 208 | CMP R1,#0 /* Runtask deleted? */ |
emilmont | 6:350b53afb889 | 209 | BEQ SVC_Next |
emilmont | 6:350b53afb889 | 210 | |
emilmont | 6:350b53afb889 | 211 | MRS R0,PSP /* Read PSP */ |
emilmont | 6:350b53afb889 | 212 | SUBS R0,R0,#32 /* Adjust Start Address */ |
emilmont | 6:350b53afb889 | 213 | STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
emilmont | 6:350b53afb889 | 214 | STMIA R0!,{R4-R7} /* Save old context (R4-R7) */ |
emilmont | 6:350b53afb889 | 215 | MOV R4,R8 |
emilmont | 6:350b53afb889 | 216 | MOV R5,R9 |
emilmont | 6:350b53afb889 | 217 | MOV R6,R10 |
emilmont | 6:350b53afb889 | 218 | MOV R7,R11 |
emilmont | 6:350b53afb889 | 219 | STMIA R0!,{R4-R7} /* Save old context (R8-R11) */ |
emilmont | 6:350b53afb889 | 220 | |
emilmont | 6:350b53afb889 | 221 | PUSH {R2,R3} |
emilmont | 6:350b53afb889 | 222 | BL rt_stk_check /* Check for Stack overflow */ |
emilmont | 6:350b53afb889 | 223 | POP {R2,R3} |
emilmont | 6:350b53afb889 | 224 | |
emilmont | 6:350b53afb889 | 225 | SVC_Next: |
emilmont | 6:350b53afb889 | 226 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
emilmont | 6:350b53afb889 | 227 | |
emilmont | 6:350b53afb889 | 228 | LDR R0,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
emilmont | 6:350b53afb889 | 229 | ADDS R0,R0,#16 /* Adjust Start Address */ |
emilmont | 6:350b53afb889 | 230 | LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */ |
emilmont | 6:350b53afb889 | 231 | MOV R8,R4 |
emilmont | 6:350b53afb889 | 232 | MOV R9,R5 |
emilmont | 6:350b53afb889 | 233 | MOV R10,R6 |
emilmont | 6:350b53afb889 | 234 | MOV R11,R7 |
emilmont | 6:350b53afb889 | 235 | MSR PSP,R0 /* Write PSP */ |
emilmont | 6:350b53afb889 | 236 | SUBS R0,R0,#32 /* Adjust Start Address */ |
emilmont | 6:350b53afb889 | 237 | LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */ |
emilmont | 6:350b53afb889 | 238 | |
emilmont | 6:350b53afb889 | 239 | SVC_Exit: |
emilmont | 6:350b53afb889 | 240 | MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */ |
emilmont | 6:350b53afb889 | 241 | MVNS R0,R0 |
emilmont | 6:350b53afb889 | 242 | BX R0 /* RETI to Thread Mode, use PSP */ |
emilmont | 6:350b53afb889 | 243 | |
emilmont | 6:350b53afb889 | 244 | /*------------------- User SVC ------------------------------*/ |
emilmont | 6:350b53afb889 | 245 | |
emilmont | 6:350b53afb889 | 246 | SVC_User: |
emilmont | 6:350b53afb889 | 247 | PUSH {R4,LR} /* Save Registers */ |
emilmont | 6:350b53afb889 | 248 | LDR R2,=SVC_Count |
emilmont | 6:350b53afb889 | 249 | LDR R2,[R2] |
emilmont | 6:350b53afb889 | 250 | CMP R1,R2 |
emilmont | 6:350b53afb889 | 251 | BHI SVC_Done /* Overflow */ |
emilmont | 6:350b53afb889 | 252 | |
emilmont | 6:350b53afb889 | 253 | LDR R4,=SVC_Table-4 |
emilmont | 6:350b53afb889 | 254 | LSLS R1,R1,#2 |
emilmont | 6:350b53afb889 | 255 | LDR R4,[R4,R1] /* Load SVC Function Address */ |
emilmont | 6:350b53afb889 | 256 | MOV LR,R4 |
emilmont | 6:350b53afb889 | 257 | |
emilmont | 6:350b53afb889 | 258 | LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */ |
emilmont | 6:350b53afb889 | 259 | MOV R12,R4 |
emilmont | 6:350b53afb889 | 260 | BLX LR /* Call SVC Function */ |
emilmont | 6:350b53afb889 | 261 | |
emilmont | 6:350b53afb889 | 262 | MRS R4,PSP /* Read PSP */ |
emilmont | 6:350b53afb889 | 263 | STMIA R4!,{R0-R3} /* Function return values */ |
emilmont | 6:350b53afb889 | 264 | SVC_Done: |
emilmont | 6:350b53afb889 | 265 | POP {R4,PC} /* RETI */ |
emilmont | 6:350b53afb889 | 266 | |
emilmont | 6:350b53afb889 | 267 | .fnend |
emilmont | 6:350b53afb889 | 268 | .size SVC_Handler, .-SVC_Handler |
emilmont | 6:350b53afb889 | 269 | |
emilmont | 6:350b53afb889 | 270 | |
emilmont | 6:350b53afb889 | 271 | /*-------------------------- PendSV_Handler ---------------------------------*/ |
emilmont | 6:350b53afb889 | 272 | |
emilmont | 6:350b53afb889 | 273 | # void PendSV_Handler (void); |
emilmont | 6:350b53afb889 | 274 | |
emilmont | 6:350b53afb889 | 275 | .thumb_func |
emilmont | 6:350b53afb889 | 276 | .type PendSV_Handler, %function |
emilmont | 6:350b53afb889 | 277 | .global PendSV_Handler |
emilmont | 6:350b53afb889 | 278 | .global Sys_Switch |
emilmont | 6:350b53afb889 | 279 | PendSV_Handler: |
emilmont | 6:350b53afb889 | 280 | .fnstart |
emilmont | 6:350b53afb889 | 281 | .cantunwind |
emilmont | 6:350b53afb889 | 282 | |
emilmont | 6:350b53afb889 | 283 | BL rt_pop_req |
emilmont | 6:350b53afb889 | 284 | |
emilmont | 6:350b53afb889 | 285 | Sys_Switch: |
emilmont | 6:350b53afb889 | 286 | LDR R3,=os_tsk |
emilmont | 6:350b53afb889 | 287 | LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.new */ |
emilmont | 6:350b53afb889 | 288 | CMP R1,R2 |
emilmont | 6:350b53afb889 | 289 | BEQ Sys_Exit /* no task switch */ |
emilmont | 6:350b53afb889 | 290 | |
emilmont | 6:350b53afb889 | 291 | SUBS R3,#8 |
emilmont | 6:350b53afb889 | 292 | |
emilmont | 6:350b53afb889 | 293 | MRS R0,PSP /* Read PSP */ |
emilmont | 6:350b53afb889 | 294 | SUBS R0,R0,#32 /* Adjust Start Address */ |
emilmont | 6:350b53afb889 | 295 | STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
emilmont | 6:350b53afb889 | 296 | STMIA R0!,{R4-R7} /* Save old context (R4-R7) */ |
emilmont | 6:350b53afb889 | 297 | MOV R4,R8 |
emilmont | 6:350b53afb889 | 298 | MOV R5,R9 |
emilmont | 6:350b53afb889 | 299 | MOV R6,R10 |
emilmont | 6:350b53afb889 | 300 | MOV R7,R11 |
emilmont | 6:350b53afb889 | 301 | STMIA R0!,{R4-R7} /* Save old context (R8-R11) */ |
emilmont | 6:350b53afb889 | 302 | |
emilmont | 6:350b53afb889 | 303 | PUSH {R2,R3} |
emilmont | 6:350b53afb889 | 304 | BL rt_stk_check /* Check for Stack overflow */ |
emilmont | 6:350b53afb889 | 305 | POP {R2,R3} |
emilmont | 6:350b53afb889 | 306 | |
emilmont | 6:350b53afb889 | 307 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
emilmont | 6:350b53afb889 | 308 | |
emilmont | 6:350b53afb889 | 309 | LDR R0,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
emilmont | 6:350b53afb889 | 310 | ADDS R0,R0,#16 /* Adjust Start Address */ |
emilmont | 6:350b53afb889 | 311 | LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */ |
emilmont | 6:350b53afb889 | 312 | MOV R8,R4 |
emilmont | 6:350b53afb889 | 313 | MOV R9,R5 |
emilmont | 6:350b53afb889 | 314 | MOV R10,R6 |
emilmont | 6:350b53afb889 | 315 | MOV R11,R7 |
emilmont | 6:350b53afb889 | 316 | MSR PSP,R0 /* Write PSP */ |
emilmont | 6:350b53afb889 | 317 | SUBS R0,R0,#32 /* Adjust Start Address */ |
emilmont | 6:350b53afb889 | 318 | LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */ |
emilmont | 6:350b53afb889 | 319 | |
emilmont | 6:350b53afb889 | 320 | Sys_Exit: |
emilmont | 6:350b53afb889 | 321 | MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */ |
emilmont | 6:350b53afb889 | 322 | MVNS R0,R0 |
emilmont | 6:350b53afb889 | 323 | BX R0 /* RETI to Thread Mode, use PSP */ |
emilmont | 6:350b53afb889 | 324 | |
emilmont | 6:350b53afb889 | 325 | .fnend |
emilmont | 6:350b53afb889 | 326 | .size PendSV_Handler, .-PendSV_Handler |
emilmont | 6:350b53afb889 | 327 | |
emilmont | 6:350b53afb889 | 328 | |
emilmont | 6:350b53afb889 | 329 | /*-------------------------- SysTick_Handler --------------------------------*/ |
emilmont | 6:350b53afb889 | 330 | |
emilmont | 6:350b53afb889 | 331 | # void SysTick_Handler (void); |
emilmont | 6:350b53afb889 | 332 | |
emilmont | 6:350b53afb889 | 333 | .thumb_func |
emilmont | 6:350b53afb889 | 334 | .type SysTick_Handler, %function |
emilmont | 6:350b53afb889 | 335 | .global SysTick_Handler |
emilmont | 6:350b53afb889 | 336 | SysTick_Handler: |
emilmont | 6:350b53afb889 | 337 | .fnstart |
emilmont | 6:350b53afb889 | 338 | .cantunwind |
emilmont | 6:350b53afb889 | 339 | |
emilmont | 6:350b53afb889 | 340 | BL rt_systick |
emilmont | 6:350b53afb889 | 341 | B Sys_Switch |
emilmont | 6:350b53afb889 | 342 | |
emilmont | 6:350b53afb889 | 343 | .fnend |
emilmont | 6:350b53afb889 | 344 | .size SysTick_Handler, .-SysTick_Handler |
emilmont | 6:350b53afb889 | 345 | |
emilmont | 6:350b53afb889 | 346 | |
emilmont | 6:350b53afb889 | 347 | /*-------------------------- OS_Tick_Handler --------------------------------*/ |
emilmont | 6:350b53afb889 | 348 | |
emilmont | 6:350b53afb889 | 349 | # void OS_Tick_Handler (void); |
emilmont | 6:350b53afb889 | 350 | |
emilmont | 6:350b53afb889 | 351 | .thumb_func |
emilmont | 6:350b53afb889 | 352 | .type OS_Tick_Handler, %function |
emilmont | 6:350b53afb889 | 353 | .global OS_Tick_Handler |
emilmont | 6:350b53afb889 | 354 | OS_Tick_Handler: |
emilmont | 6:350b53afb889 | 355 | .fnstart |
emilmont | 6:350b53afb889 | 356 | .cantunwind |
emilmont | 6:350b53afb889 | 357 | |
emilmont | 6:350b53afb889 | 358 | BL os_tick_irqack |
emilmont | 6:350b53afb889 | 359 | BL rt_systick |
emilmont | 6:350b53afb889 | 360 | B Sys_Switch |
emilmont | 6:350b53afb889 | 361 | |
emilmont | 6:350b53afb889 | 362 | .fnend |
emilmont | 6:350b53afb889 | 363 | .size OS_Tick_Handler, .-OS_Tick_Handler |
emilmont | 6:350b53afb889 | 364 | |
emilmont | 6:350b53afb889 | 365 | |
emilmont | 6:350b53afb889 | 366 | .end |
emilmont | 6:350b53afb889 | 367 | |
emilmont | 6:350b53afb889 | 368 | /*---------------------------------------------------------------------------- |
emilmont | 6:350b53afb889 | 369 | * end of file |
emilmont | 6:350b53afb889 | 370 | *---------------------------------------------------------------------------*/ |