Luca
Fork of mbed-rtos by
rtx/TARGET_CORTEX_M/TARGET_RTOS_M4_M7/TOOLCHAIN_IAR/HAL_CM4.S@123:58563e6cba1e, 2016-11-14 (annotated)
- Committer:
- c1728p9
- Date:
- Mon Nov 14 17:14:42 2016 -0600
- Revision:
- 123:58563e6cba1e
- Parent:
- 112:53ace74b190c
Configure RTOS to behave as it did before 5.0
Who changed what in which revision?
User | Revision | Line number | New 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? */ |
c1728p9 | 123:58563e6cba1e | 191 | #if (__FPU_PRESENT == 1) |
mbed_official | 55:5f5ceea4fc8a | 192 | ITTE EQ |
mbed_official | 55:5f5ceea4fc8a | 193 | VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */ |
c1728p9 | 123:58563e6cba1e | 194 | #else |
c1728p9 | 123:58563e6cba1e | 195 | ITE EQ |
c1728p9 | 123:58563e6cba1e | 196 | #endif |
mbed_official | 55:5f5ceea4fc8a | 197 | MOVEQ R0,#0x01 /* os_tsk->stack_frame val */ |
mbed_official | 55:5f5ceea4fc8a | 198 | MOVNE R0,#0x00 |
mbed_official | 55:5f5ceea4fc8a | 199 | STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */ |
mbed_official | 55:5f5ceea4fc8a | 200 | STMDB R12!,{R4-R11} /* Save Old context */ |
mbed_official | 55:5f5ceea4fc8a | 201 | STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 202 | |
mbed_official | 55:5f5ceea4fc8a | 203 | PUSH {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 204 | BL rt_stk_check /* Check for Stack overflow */ |
mbed_official | 55:5f5ceea4fc8a | 205 | POP {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 206 | |
mbed_official | 112:53ace74b190c | 207 | SVC_ContextRestore: |
mbed_official | 55:5f5ceea4fc8a | 208 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
mbed_official | 55:5f5ceea4fc8a | 209 | |
mbed_official | 55:5f5ceea4fc8a | 210 | LDR R12,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 211 | LDMIA R12!,{R4-R11} /* Restore New Context */ |
mbed_official | 55:5f5ceea4fc8a | 212 | LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */ |
mbed_official | 55:5f5ceea4fc8a | 213 | CMP R0,#0 /* Basic/Extended Stack Frame */ |
c1728p9 | 123:58563e6cba1e | 214 | #if (__FPU_PRESENT == 1) |
mbed_official | 112:53ace74b190c | 215 | ITEE EQ |
c1728p9 | 123:58563e6cba1e | 216 | #else |
c1728p9 | 123:58563e6cba1e | 217 | ITE EQ |
c1728p9 | 123:58563e6cba1e | 218 | #endif |
mbed_official | 112:53ace74b190c | 219 | MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */ |
mbed_official | 112:53ace74b190c | 220 | MVNNE LR,#~0xFFFFFFED |
c1728p9 | 123:58563e6cba1e | 221 | #if (__FPU_PRESENT == 1) |
mbed_official | 55:5f5ceea4fc8a | 222 | VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */ |
c1728p9 | 123:58563e6cba1e | 223 | #endif |
mbed_official | 55:5f5ceea4fc8a | 224 | MSR PSP,R12 /* Write PSP */ |
mbed_official | 55:5f5ceea4fc8a | 225 | |
mbed_official | 55:5f5ceea4fc8a | 226 | SVC_Exit: |
mbed_official | 55:5f5ceea4fc8a | 227 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 228 | PUSH {LR} |
mbed_official | 55:5f5ceea4fc8a | 229 | POP {PC} |
mbed_official | 55:5f5ceea4fc8a | 230 | #else |
mbed_official | 55:5f5ceea4fc8a | 231 | BX LR |
mbed_official | 55:5f5ceea4fc8a | 232 | #endif |
mbed_official | 55:5f5ceea4fc8a | 233 | |
mbed_official | 55:5f5ceea4fc8a | 234 | /*------------------- User SVC ------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 235 | |
mbed_official | 55:5f5ceea4fc8a | 236 | SVC_User: |
mbed_official | 55:5f5ceea4fc8a | 237 | PUSH {R4,LR} /* Save Registers */ |
mbed_official | 55:5f5ceea4fc8a | 238 | LDR R2,=SVC_Count |
mbed_official | 55:5f5ceea4fc8a | 239 | LDR R2,[R2] |
mbed_official | 55:5f5ceea4fc8a | 240 | CMP R1,R2 |
mbed_official | 55:5f5ceea4fc8a | 241 | BHI SVC_Done /* Overflow */ |
mbed_official | 55:5f5ceea4fc8a | 242 | |
mbed_official | 55:5f5ceea4fc8a | 243 | LDR R4,=SVC_Table-4 |
mbed_official | 55:5f5ceea4fc8a | 244 | LDR R4,[R4,R1,LSL #2] /* Load SVC Function Address */ |
mbed_official | 55:5f5ceea4fc8a | 245 | |
mbed_official | 55:5f5ceea4fc8a | 246 | LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */ |
mbed_official | 55:5f5ceea4fc8a | 247 | BLX R4 /* Call SVC Function */ |
mbed_official | 55:5f5ceea4fc8a | 248 | |
mbed_official | 55:5f5ceea4fc8a | 249 | MRS R12,PSP |
mbed_official | 55:5f5ceea4fc8a | 250 | STM R12,{R0-R3} /* Function return values */ |
mbed_official | 55:5f5ceea4fc8a | 251 | SVC_Done: |
mbed_official | 55:5f5ceea4fc8a | 252 | POP {R4,PC} /* RETI */ |
mbed_official | 68:d3d0e710b443 | 253 | |
mbed_official | 55:5f5ceea4fc8a | 254 | |
mbed_official | 55:5f5ceea4fc8a | 255 | /*-------------------------- PendSV_Handler ---------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 256 | |
mbed_official | 55:5f5ceea4fc8a | 257 | ; void PendSV_Handler (void); |
mbed_official | 55:5f5ceea4fc8a | 258 | |
mbed_official | 55:5f5ceea4fc8a | 259 | PUBLIC PendSV_Handler |
mbed_official | 55:5f5ceea4fc8a | 260 | PendSV_Handler: |
mbed_official | 55:5f5ceea4fc8a | 261 | |
mbed_official | 55:5f5ceea4fc8a | 262 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 263 | PUBLIC PendSV_Handler_Veneer |
mbed_official | 55:5f5ceea4fc8a | 264 | PendSV_Handler_Veneer: |
mbed_official | 55:5f5ceea4fc8a | 265 | #endif |
mbed_official | 55:5f5ceea4fc8a | 266 | |
mbed_official | 55:5f5ceea4fc8a | 267 | PUSH {R4,LR} /* Save EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 268 | BL rt_pop_req |
mbed_official | 55:5f5ceea4fc8a | 269 | |
mbed_official | 55:5f5ceea4fc8a | 270 | Sys_Switch: |
mbed_official | 55:5f5ceea4fc8a | 271 | POP {R4,LR} /* Restore EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 272 | |
mbed_official | 55:5f5ceea4fc8a | 273 | LDR R3,=os_tsk |
mbed_official | 55:5f5ceea4fc8a | 274 | LDM R3,{R1,R2} /* os_tsk.run, os_tsk.new */ |
mbed_official | 55:5f5ceea4fc8a | 275 | CMP R1,R2 |
mbed_official | 55:5f5ceea4fc8a | 276 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 277 | ITT EQ |
mbed_official | 55:5f5ceea4fc8a | 278 | PUSHEQ {LR} |
mbed_official | 55:5f5ceea4fc8a | 279 | POPEQ {PC} |
mbed_official | 55:5f5ceea4fc8a | 280 | #else |
mbed_official | 55:5f5ceea4fc8a | 281 | IT EQ |
mbed_official | 55:5f5ceea4fc8a | 282 | BXEQ LR /* RETI, no task switch */ |
mbed_official | 55:5f5ceea4fc8a | 283 | #endif |
mbed_official | 55:5f5ceea4fc8a | 284 | |
mbed_official | 55:5f5ceea4fc8a | 285 | MRS R12,PSP /* Read PSP */ |
mbed_official | 55:5f5ceea4fc8a | 286 | TST LR,#0x10 /* is it extended frame? */ |
c1728p9 | 123:58563e6cba1e | 287 | #if (__FPU_PRESENT == 1) |
mbed_official | 55:5f5ceea4fc8a | 288 | ITTE EQ |
mbed_official | 55:5f5ceea4fc8a | 289 | VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */ |
c1728p9 | 123:58563e6cba1e | 290 | #else |
c1728p9 | 123:58563e6cba1e | 291 | ITE EQ |
c1728p9 | 123:58563e6cba1e | 292 | #endif |
mbed_official | 55:5f5ceea4fc8a | 293 | MOVEQ R0,#0x01 /* os_tsk->stack_frame val */ |
mbed_official | 55:5f5ceea4fc8a | 294 | MOVNE R0,#0x00 |
mbed_official | 55:5f5ceea4fc8a | 295 | STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */ |
mbed_official | 55:5f5ceea4fc8a | 296 | STMDB R12!,{R4-R11} /* Save Old context */ |
mbed_official | 55:5f5ceea4fc8a | 297 | STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 298 | |
mbed_official | 55:5f5ceea4fc8a | 299 | PUSH {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 300 | BL rt_stk_check /* Check for Stack overflow */ |
mbed_official | 55:5f5ceea4fc8a | 301 | POP {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 302 | |
mbed_official | 55:5f5ceea4fc8a | 303 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
mbed_official | 55:5f5ceea4fc8a | 304 | |
mbed_official | 55:5f5ceea4fc8a | 305 | LDR R12,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 306 | LDMIA R12!,{R4-R11} /* Restore New Context */ |
mbed_official | 55:5f5ceea4fc8a | 307 | LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */ |
mbed_official | 55:5f5ceea4fc8a | 308 | CMP R0,#0 /* Basic/Extended Stack Frame */ |
c1728p9 | 123:58563e6cba1e | 309 | #if (__FPU_PRESENT == 1) |
mbed_official | 112:53ace74b190c | 310 | ITEE EQ |
c1728p9 | 123:58563e6cba1e | 311 | #else |
c1728p9 | 123:58563e6cba1e | 312 | ITE EQ |
c1728p9 | 123:58563e6cba1e | 313 | #endif |
mbed_official | 112:53ace74b190c | 314 | MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */ |
mbed_official | 112:53ace74b190c | 315 | MVNNE LR,#~0xFFFFFFED |
c1728p9 | 123:58563e6cba1e | 316 | #if (__FPU_PRESENT == 1) |
mbed_official | 55:5f5ceea4fc8a | 317 | VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */ |
c1728p9 | 123:58563e6cba1e | 318 | #endif |
mbed_official | 55:5f5ceea4fc8a | 319 | MSR PSP,R12 /* Write PSP */ |
mbed_official | 55:5f5ceea4fc8a | 320 | |
mbed_official | 55:5f5ceea4fc8a | 321 | Sys_Exit: |
mbed_official | 55:5f5ceea4fc8a | 322 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 323 | PUSH {LR} |
mbed_official | 55:5f5ceea4fc8a | 324 | POP {PC} |
mbed_official | 55:5f5ceea4fc8a | 325 | #else |
mbed_official | 55:5f5ceea4fc8a | 326 | BX LR /* Return to Thread Mode */ |
mbed_official | 55:5f5ceea4fc8a | 327 | #endif |
mbed_official | 55:5f5ceea4fc8a | 328 | |
mbed_official | 55:5f5ceea4fc8a | 329 | |
mbed_official | 55:5f5ceea4fc8a | 330 | /*-------------------------- SysTick_Handler --------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 331 | |
mbed_official | 55:5f5ceea4fc8a | 332 | ; void SysTick_Handler (void); |
mbed_official | 55:5f5ceea4fc8a | 333 | |
mbed_official | 55:5f5ceea4fc8a | 334 | PUBLIC SysTick_Handler |
mbed_official | 55:5f5ceea4fc8a | 335 | SysTick_Handler: |
mbed_official | 55:5f5ceea4fc8a | 336 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 337 | PUBLIC SysTick_Handler_Veneer |
mbed_official | 55:5f5ceea4fc8a | 338 | SysTick_Handler_Veneer: |
mbed_official | 55:5f5ceea4fc8a | 339 | #endif |
mbed_official | 55:5f5ceea4fc8a | 340 | |
mbed_official | 55:5f5ceea4fc8a | 341 | PUSH {R4,LR} /* Save EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 342 | BL rt_systick |
mbed_official | 55:5f5ceea4fc8a | 343 | B Sys_Switch |
mbed_official | 55:5f5ceea4fc8a | 344 | |
mbed_official | 55:5f5ceea4fc8a | 345 | |
mbed_official | 55:5f5ceea4fc8a | 346 | /*-------------------------- OS_Tick_Handler --------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 347 | |
mbed_official | 55:5f5ceea4fc8a | 348 | ; void OS_Tick_Handler (void); |
mbed_official | 55:5f5ceea4fc8a | 349 | |
mbed_official | 55:5f5ceea4fc8a | 350 | PUBLIC OS_Tick_Handler |
mbed_official | 55:5f5ceea4fc8a | 351 | OS_Tick_Handler: |
mbed_official | 55:5f5ceea4fc8a | 352 | |
mbed_official | 55:5f5ceea4fc8a | 353 | PUSH {R4,LR} /* Save EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 354 | BL os_tick_irqack |
mbed_official | 55:5f5ceea4fc8a | 355 | BL rt_systick |
mbed_official | 55:5f5ceea4fc8a | 356 | B Sys_Switch |
mbed_official | 55:5f5ceea4fc8a | 357 | |
mbed_official | 55:5f5ceea4fc8a | 358 | |
mbed_official | 55:5f5ceea4fc8a | 359 | END |
mbed_official | 55:5f5ceea4fc8a | 360 | |
mbed_official | 55:5f5ceea4fc8a | 361 | /*---------------------------------------------------------------------------- |
mbed_official | 55:5f5ceea4fc8a | 362 | * end of file |
mbed_official | 55:5f5ceea4fc8a | 363 | *---------------------------------------------------------------------------*/ |