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