Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   LEDFun NetTester

Fork of mbed-rtos by mbed official

Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Committer:
emilmont
Date:
Thu May 30 17:08:58 2013 +0100
Revision:
12:58b30ac3f00e
Add LPC4088 target
Fix rtos memory model for GCC toolchains

Who changed what in which revision?

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