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

Dependents:   denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more

Deprecated

This is the mbed 2 rtos library. mbed OS 5 integrates the mbed library with mbed-rtos. With this, we have provided thread safety for all mbed APIs. If you'd like to learn about using mbed OS 5, please see the docs.

Committer:
mbed_official
Date:
Thu May 05 20:45:13 2016 +0100
Revision:
112:53ace74b190c
Parent:
101:3d9d2b8b8f17
Child:
123:58563e6cba1e
Synchronized with git revision 860fdd282b0dc3631a6c46b39442d4ab5343e534

Full URL: https://github.com/mbedmicro/mbed/commit/860fdd282b0dc3631a6c46b39442d4ab5343e534/

rtx update to v4.79

Who changed what in which revision?

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