Maintain legacy RTOS behavior before mbed-5
Fork of mbed-rtos by
rtx/TARGET_CORTEX_M/TARGET_M4/TOOLCHAIN_IAR/HAL_CM4.S@86:58c3b7759abf, 2015-07-01 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Jul 01 08:15:48 2015 +0100
- Revision:
- 86:58c3b7759abf
- Parent:
- rtx/TARGET_CORTEX_M/TARGET_M4/TOOLCHAIN_IAR/HAL_CM4.s@68:d3d0e710b443
Synchronized with git revision 7766e75dd858812cd79aedb3080349715f55dd56
Full URL: https://github.com/mbedmicro/mbed/commit/7766e75dd858812cd79aedb3080349715f55dd56/
GCC asm updates
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 | 55:5f5ceea4fc8a | 6 | * Rev.: V4.70 |
mbed_official | 55:5f5ceea4fc8a | 7 | *---------------------------------------------------------------------------- |
mbed_official | 55:5f5ceea4fc8a | 8 | * |
mbed_official | 55:5f5ceea4fc8a | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2013 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 | 55:5f5ceea4fc8a | 37 | #define TCB_STACKF 32 |
mbed_official | 59:28712e303960 | 38 | #define TCB_TSTACK 40 |
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 | 55:5f5ceea4fc8a | 123 | ; int _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 | 55:5f5ceea4fc8a | 179 | CBZ R1,SVC_Next /* Runtask deleted? */ |
mbed_official | 55:5f5ceea4fc8a | 180 | TST LR,#0x10 /* is it extended frame? */ |
mbed_official | 55:5f5ceea4fc8a | 181 | ITTE EQ |
mbed_official | 55:5f5ceea4fc8a | 182 | VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */ |
mbed_official | 55:5f5ceea4fc8a | 183 | MOVEQ R0,#0x01 /* os_tsk->stack_frame val */ |
mbed_official | 55:5f5ceea4fc8a | 184 | MOVNE R0,#0x00 |
mbed_official | 55:5f5ceea4fc8a | 185 | STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */ |
mbed_official | 55:5f5ceea4fc8a | 186 | STMDB R12!,{R4-R11} /* Save Old context */ |
mbed_official | 55:5f5ceea4fc8a | 187 | STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 188 | |
mbed_official | 55:5f5ceea4fc8a | 189 | PUSH {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 190 | BL rt_stk_check /* Check for Stack overflow */ |
mbed_official | 55:5f5ceea4fc8a | 191 | POP {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 192 | |
mbed_official | 55:5f5ceea4fc8a | 193 | SVC_Next: |
mbed_official | 55:5f5ceea4fc8a | 194 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
mbed_official | 55:5f5ceea4fc8a | 195 | |
mbed_official | 55:5f5ceea4fc8a | 196 | LDR R12,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 197 | LDMIA R12!,{R4-R11} /* Restore New Context */ |
mbed_official | 55:5f5ceea4fc8a | 198 | LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */ |
mbed_official | 55:5f5ceea4fc8a | 199 | CMP R0,#0 /* Basic/Extended Stack Frame */ |
mbed_official | 55:5f5ceea4fc8a | 200 | ITTE NE |
mbed_official | 55:5f5ceea4fc8a | 201 | VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */ |
mbed_official | 55:5f5ceea4fc8a | 202 | MVNNE LR,#~0xFFFFFFED /* set EXC_RETURN value */ |
mbed_official | 55:5f5ceea4fc8a | 203 | MVNEQ LR,#~0xFFFFFFFD |
mbed_official | 55:5f5ceea4fc8a | 204 | MSR PSP,R12 /* Write PSP */ |
mbed_official | 55:5f5ceea4fc8a | 205 | |
mbed_official | 55:5f5ceea4fc8a | 206 | SVC_Exit: |
mbed_official | 55:5f5ceea4fc8a | 207 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 208 | PUSH {LR} |
mbed_official | 55:5f5ceea4fc8a | 209 | POP {PC} |
mbed_official | 55:5f5ceea4fc8a | 210 | #else |
mbed_official | 55:5f5ceea4fc8a | 211 | BX LR |
mbed_official | 55:5f5ceea4fc8a | 212 | #endif |
mbed_official | 55:5f5ceea4fc8a | 213 | |
mbed_official | 55:5f5ceea4fc8a | 214 | /*------------------- User SVC ------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 215 | |
mbed_official | 55:5f5ceea4fc8a | 216 | SVC_User: |
mbed_official | 55:5f5ceea4fc8a | 217 | PUSH {R4,LR} /* Save Registers */ |
mbed_official | 55:5f5ceea4fc8a | 218 | LDR R2,=SVC_Count |
mbed_official | 55:5f5ceea4fc8a | 219 | LDR R2,[R2] |
mbed_official | 55:5f5ceea4fc8a | 220 | CMP R1,R2 |
mbed_official | 55:5f5ceea4fc8a | 221 | BHI SVC_Done /* Overflow */ |
mbed_official | 55:5f5ceea4fc8a | 222 | |
mbed_official | 55:5f5ceea4fc8a | 223 | LDR R4,=SVC_Table-4 |
mbed_official | 55:5f5ceea4fc8a | 224 | LDR R4,[R4,R1,LSL #2] /* Load SVC Function Address */ |
mbed_official | 55:5f5ceea4fc8a | 225 | |
mbed_official | 55:5f5ceea4fc8a | 226 | LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */ |
mbed_official | 55:5f5ceea4fc8a | 227 | BLX R4 /* Call SVC Function */ |
mbed_official | 55:5f5ceea4fc8a | 228 | |
mbed_official | 55:5f5ceea4fc8a | 229 | MRS R12,PSP |
mbed_official | 55:5f5ceea4fc8a | 230 | STM R12,{R0-R3} /* Function return values */ |
mbed_official | 55:5f5ceea4fc8a | 231 | SVC_Done: |
mbed_official | 55:5f5ceea4fc8a | 232 | POP {R4,PC} /* RETI */ |
mbed_official | 68:d3d0e710b443 | 233 | |
mbed_official | 55:5f5ceea4fc8a | 234 | |
mbed_official | 55:5f5ceea4fc8a | 235 | /*-------------------------- PendSV_Handler ---------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 236 | |
mbed_official | 55:5f5ceea4fc8a | 237 | ; void PendSV_Handler (void); |
mbed_official | 55:5f5ceea4fc8a | 238 | |
mbed_official | 55:5f5ceea4fc8a | 239 | PUBLIC PendSV_Handler |
mbed_official | 55:5f5ceea4fc8a | 240 | PendSV_Handler: |
mbed_official | 55:5f5ceea4fc8a | 241 | |
mbed_official | 55:5f5ceea4fc8a | 242 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 243 | PUBLIC PendSV_Handler_Veneer |
mbed_official | 55:5f5ceea4fc8a | 244 | PendSV_Handler_Veneer: |
mbed_official | 55:5f5ceea4fc8a | 245 | #endif |
mbed_official | 55:5f5ceea4fc8a | 246 | |
mbed_official | 55:5f5ceea4fc8a | 247 | PUSH {R4,LR} /* Save EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 248 | BL rt_pop_req |
mbed_official | 55:5f5ceea4fc8a | 249 | |
mbed_official | 55:5f5ceea4fc8a | 250 | Sys_Switch: |
mbed_official | 55:5f5ceea4fc8a | 251 | POP {R4,LR} /* Restore EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 252 | |
mbed_official | 55:5f5ceea4fc8a | 253 | LDR R3,=os_tsk |
mbed_official | 55:5f5ceea4fc8a | 254 | LDM R3,{R1,R2} /* os_tsk.run, os_tsk.new */ |
mbed_official | 55:5f5ceea4fc8a | 255 | CMP R1,R2 |
mbed_official | 55:5f5ceea4fc8a | 256 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 257 | ITT EQ |
mbed_official | 55:5f5ceea4fc8a | 258 | PUSHEQ {LR} |
mbed_official | 55:5f5ceea4fc8a | 259 | POPEQ {PC} |
mbed_official | 55:5f5ceea4fc8a | 260 | #else |
mbed_official | 55:5f5ceea4fc8a | 261 | IT EQ |
mbed_official | 55:5f5ceea4fc8a | 262 | BXEQ LR /* RETI, no task switch */ |
mbed_official | 55:5f5ceea4fc8a | 263 | #endif |
mbed_official | 55:5f5ceea4fc8a | 264 | |
mbed_official | 55:5f5ceea4fc8a | 265 | MRS R12,PSP /* Read PSP */ |
mbed_official | 55:5f5ceea4fc8a | 266 | TST LR,#0x10 /* is it extended frame? */ |
mbed_official | 55:5f5ceea4fc8a | 267 | ITTE EQ |
mbed_official | 55:5f5ceea4fc8a | 268 | VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */ |
mbed_official | 55:5f5ceea4fc8a | 269 | MOVEQ R0,#0x01 /* os_tsk->stack_frame val */ |
mbed_official | 55:5f5ceea4fc8a | 270 | MOVNE R0,#0x00 |
mbed_official | 55:5f5ceea4fc8a | 271 | STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */ |
mbed_official | 55:5f5ceea4fc8a | 272 | STMDB R12!,{R4-R11} /* Save Old context */ |
mbed_official | 55:5f5ceea4fc8a | 273 | STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 274 | |
mbed_official | 55:5f5ceea4fc8a | 275 | PUSH {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 276 | BL rt_stk_check /* Check for Stack overflow */ |
mbed_official | 55:5f5ceea4fc8a | 277 | POP {R2,R3} |
mbed_official | 55:5f5ceea4fc8a | 278 | |
mbed_official | 55:5f5ceea4fc8a | 279 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
mbed_official | 55:5f5ceea4fc8a | 280 | |
mbed_official | 55:5f5ceea4fc8a | 281 | LDR R12,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
mbed_official | 55:5f5ceea4fc8a | 282 | LDMIA R12!,{R4-R11} /* Restore New Context */ |
mbed_official | 55:5f5ceea4fc8a | 283 | LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */ |
mbed_official | 55:5f5ceea4fc8a | 284 | CMP R0,#0 /* Basic/Extended Stack Frame */ |
mbed_official | 55:5f5ceea4fc8a | 285 | ITTE NE |
mbed_official | 55:5f5ceea4fc8a | 286 | VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */ |
mbed_official | 55:5f5ceea4fc8a | 287 | MVNNE LR,#~0xFFFFFFED /* set EXC_RETURN value */ |
mbed_official | 55:5f5ceea4fc8a | 288 | MVNEQ LR,#~0xFFFFFFFD |
mbed_official | 55:5f5ceea4fc8a | 289 | MSR PSP,R12 /* Write PSP */ |
mbed_official | 55:5f5ceea4fc8a | 290 | |
mbed_official | 55:5f5ceea4fc8a | 291 | Sys_Exit: |
mbed_official | 55:5f5ceea4fc8a | 292 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 293 | PUSH {LR} |
mbed_official | 55:5f5ceea4fc8a | 294 | POP {PC} |
mbed_official | 55:5f5ceea4fc8a | 295 | #else |
mbed_official | 55:5f5ceea4fc8a | 296 | BX LR /* Return to Thread Mode */ |
mbed_official | 55:5f5ceea4fc8a | 297 | #endif |
mbed_official | 55:5f5ceea4fc8a | 298 | |
mbed_official | 55:5f5ceea4fc8a | 299 | |
mbed_official | 55:5f5ceea4fc8a | 300 | /*-------------------------- SysTick_Handler --------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 301 | |
mbed_official | 55:5f5ceea4fc8a | 302 | ; void SysTick_Handler (void); |
mbed_official | 55:5f5ceea4fc8a | 303 | |
mbed_official | 55:5f5ceea4fc8a | 304 | PUBLIC SysTick_Handler |
mbed_official | 55:5f5ceea4fc8a | 305 | SysTick_Handler: |
mbed_official | 55:5f5ceea4fc8a | 306 | #ifdef IFX_XMC4XXX |
mbed_official | 55:5f5ceea4fc8a | 307 | PUBLIC SysTick_Handler_Veneer |
mbed_official | 55:5f5ceea4fc8a | 308 | SysTick_Handler_Veneer: |
mbed_official | 55:5f5ceea4fc8a | 309 | #endif |
mbed_official | 55:5f5ceea4fc8a | 310 | |
mbed_official | 55:5f5ceea4fc8a | 311 | PUSH {R4,LR} /* Save EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 312 | BL rt_systick |
mbed_official | 55:5f5ceea4fc8a | 313 | B Sys_Switch |
mbed_official | 55:5f5ceea4fc8a | 314 | |
mbed_official | 55:5f5ceea4fc8a | 315 | |
mbed_official | 55:5f5ceea4fc8a | 316 | /*-------------------------- OS_Tick_Handler --------------------------------*/ |
mbed_official | 55:5f5ceea4fc8a | 317 | |
mbed_official | 55:5f5ceea4fc8a | 318 | ; void OS_Tick_Handler (void); |
mbed_official | 55:5f5ceea4fc8a | 319 | |
mbed_official | 55:5f5ceea4fc8a | 320 | PUBLIC OS_Tick_Handler |
mbed_official | 55:5f5ceea4fc8a | 321 | OS_Tick_Handler: |
mbed_official | 55:5f5ceea4fc8a | 322 | |
mbed_official | 55:5f5ceea4fc8a | 323 | PUSH {R4,LR} /* Save EXC_RETURN */ |
mbed_official | 55:5f5ceea4fc8a | 324 | BL os_tick_irqack |
mbed_official | 55:5f5ceea4fc8a | 325 | BL rt_systick |
mbed_official | 55:5f5ceea4fc8a | 326 | B Sys_Switch |
mbed_official | 55:5f5ceea4fc8a | 327 | |
mbed_official | 55:5f5ceea4fc8a | 328 | |
mbed_official | 55:5f5ceea4fc8a | 329 | END |
mbed_official | 55:5f5ceea4fc8a | 330 | |
mbed_official | 55:5f5ceea4fc8a | 331 | /*---------------------------------------------------------------------------- |
mbed_official | 55:5f5ceea4fc8a | 332 | * end of file |
mbed_official | 55:5f5ceea4fc8a | 333 | *---------------------------------------------------------------------------*/ |