![](/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_ARM/HAL_CM4.c@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 | * RL-ARM - RTX |
mbedAustin | 11:cada08fc8a70 | 3 | *---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 4 | * Name: HAL_CM4.C |
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 | #include "rt_TypeDef.h" |
mbedAustin | 11:cada08fc8a70 | 36 | #include "RTX_Conf.h" |
mbedAustin | 11:cada08fc8a70 | 37 | #include "rt_System.h" |
mbedAustin | 11:cada08fc8a70 | 38 | #include "rt_HAL_CM.h" |
mbedAustin | 11:cada08fc8a70 | 39 | #include "rt_Task.h" |
mbedAustin | 11:cada08fc8a70 | 40 | #include "rt_MemBox.h" |
mbedAustin | 11:cada08fc8a70 | 41 | |
mbedAustin | 11:cada08fc8a70 | 42 | |
mbedAustin | 11:cada08fc8a70 | 43 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 44 | * Functions |
mbedAustin | 11:cada08fc8a70 | 45 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 46 | |
mbedAustin | 11:cada08fc8a70 | 47 | |
mbedAustin | 11:cada08fc8a70 | 48 | /*--------------------------- rt_set_PSP ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 49 | |
mbedAustin | 11:cada08fc8a70 | 50 | __asm void rt_set_PSP (U32 stack) { |
mbedAustin | 11:cada08fc8a70 | 51 | MSR PSP,R0 |
mbedAustin | 11:cada08fc8a70 | 52 | BX LR |
mbedAustin | 11:cada08fc8a70 | 53 | } |
mbedAustin | 11:cada08fc8a70 | 54 | |
mbedAustin | 11:cada08fc8a70 | 55 | |
mbedAustin | 11:cada08fc8a70 | 56 | /*--------------------------- rt_get_PSP ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 57 | |
mbedAustin | 11:cada08fc8a70 | 58 | __asm U32 rt_get_PSP (void) { |
mbedAustin | 11:cada08fc8a70 | 59 | MRS R0,PSP |
mbedAustin | 11:cada08fc8a70 | 60 | BX LR |
mbedAustin | 11:cada08fc8a70 | 61 | } |
mbedAustin | 11:cada08fc8a70 | 62 | |
mbedAustin | 11:cada08fc8a70 | 63 | |
mbedAustin | 11:cada08fc8a70 | 64 | /*--------------------------- os_set_env ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 65 | |
mbedAustin | 11:cada08fc8a70 | 66 | __asm void os_set_env (void) { |
mbedAustin | 11:cada08fc8a70 | 67 | /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ |
mbedAustin | 11:cada08fc8a70 | 68 | MOV R0,SP ; PSP = MSP |
mbedAustin | 11:cada08fc8a70 | 69 | MSR PSP,R0 |
mbedAustin | 11:cada08fc8a70 | 70 | LDR R0,=__cpp(&os_flags) |
mbedAustin | 11:cada08fc8a70 | 71 | LDRB R0,[R0] |
mbedAustin | 11:cada08fc8a70 | 72 | LSLS R0,#31 |
mbedAustin | 11:cada08fc8a70 | 73 | MOVNE R0,#0x02 ; Privileged Thread mode, use PSP |
mbedAustin | 11:cada08fc8a70 | 74 | MOVEQ R0,#0x03 ; Unprivileged Thread mode, use PSP |
mbedAustin | 11:cada08fc8a70 | 75 | MSR CONTROL,R0 |
mbedAustin | 11:cada08fc8a70 | 76 | BX LR |
mbedAustin | 11:cada08fc8a70 | 77 | |
mbedAustin | 11:cada08fc8a70 | 78 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 79 | } |
mbedAustin | 11:cada08fc8a70 | 80 | |
mbedAustin | 11:cada08fc8a70 | 81 | |
mbedAustin | 11:cada08fc8a70 | 82 | /*--------------------------- _alloc_box ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 83 | |
mbedAustin | 11:cada08fc8a70 | 84 | __asm void *_alloc_box (void *box_mem) { |
mbedAustin | 11:cada08fc8a70 | 85 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbedAustin | 11:cada08fc8a70 | 86 | LDR R12,=__cpp(rt_alloc_box) |
mbedAustin | 11:cada08fc8a70 | 87 | MRS R3,IPSR |
mbedAustin | 11:cada08fc8a70 | 88 | LSLS R3,#24 |
mbedAustin | 11:cada08fc8a70 | 89 | BXNE R12 |
mbedAustin | 11:cada08fc8a70 | 90 | MRS R3,CONTROL |
mbedAustin | 11:cada08fc8a70 | 91 | LSLS R3,#31 |
mbedAustin | 11:cada08fc8a70 | 92 | BXEQ R12 |
mbedAustin | 11:cada08fc8a70 | 93 | SVC 0 |
mbedAustin | 11:cada08fc8a70 | 94 | BX LR |
mbedAustin | 11:cada08fc8a70 | 95 | |
mbedAustin | 11:cada08fc8a70 | 96 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 97 | } |
mbedAustin | 11:cada08fc8a70 | 98 | |
mbedAustin | 11:cada08fc8a70 | 99 | |
mbedAustin | 11:cada08fc8a70 | 100 | /*--------------------------- _free_box -------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 101 | |
mbedAustin | 11:cada08fc8a70 | 102 | __asm int _free_box (void *box_mem, void *box) { |
mbedAustin | 11:cada08fc8a70 | 103 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbedAustin | 11:cada08fc8a70 | 104 | LDR R12,=__cpp(rt_free_box) |
mbedAustin | 11:cada08fc8a70 | 105 | MRS R3,IPSR |
mbedAustin | 11:cada08fc8a70 | 106 | LSLS R3,#24 |
mbedAustin | 11:cada08fc8a70 | 107 | BXNE R12 |
mbedAustin | 11:cada08fc8a70 | 108 | MRS R3,CONTROL |
mbedAustin | 11:cada08fc8a70 | 109 | LSLS R3,#31 |
mbedAustin | 11:cada08fc8a70 | 110 | BXEQ R12 |
mbedAustin | 11:cada08fc8a70 | 111 | SVC 0 |
mbedAustin | 11:cada08fc8a70 | 112 | BX LR |
mbedAustin | 11:cada08fc8a70 | 113 | |
mbedAustin | 11:cada08fc8a70 | 114 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 115 | } |
mbedAustin | 11:cada08fc8a70 | 116 | |
mbedAustin | 11:cada08fc8a70 | 117 | |
mbedAustin | 11:cada08fc8a70 | 118 | /*-------------------------- SVC_Handler ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 119 | |
mbedAustin | 11:cada08fc8a70 | 120 | __asm void SVC_Handler (void) { |
mbedAustin | 11:cada08fc8a70 | 121 | PRESERVE8 |
mbedAustin | 11:cada08fc8a70 | 122 | |
mbedAustin | 11:cada08fc8a70 | 123 | IMPORT SVC_Count |
mbedAustin | 11:cada08fc8a70 | 124 | IMPORT SVC_Table |
mbedAustin | 11:cada08fc8a70 | 125 | IMPORT rt_stk_check |
mbedAustin | 11:cada08fc8a70 | 126 | |
mbedAustin | 11:cada08fc8a70 | 127 | #ifdef IFX_XMC4XXX |
mbedAustin | 11:cada08fc8a70 | 128 | EXPORT SVC_Handler_Veneer |
mbedAustin | 11:cada08fc8a70 | 129 | SVC_Handler_Veneer |
mbedAustin | 11:cada08fc8a70 | 130 | #endif |
mbedAustin | 11:cada08fc8a70 | 131 | |
mbedAustin | 11:cada08fc8a70 | 132 | MRS R0,PSP ; Read PSP |
mbedAustin | 11:cada08fc8a70 | 133 | LDR R1,[R0,#24] ; Read Saved PC from Stack |
mbedAustin | 11:cada08fc8a70 | 134 | LDRB R1,[R1,#-2] ; Load SVC Number |
mbedAustin | 11:cada08fc8a70 | 135 | CBNZ R1,SVC_User |
mbedAustin | 11:cada08fc8a70 | 136 | |
mbedAustin | 11:cada08fc8a70 | 137 | LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack |
mbedAustin | 11:cada08fc8a70 | 138 | PUSH {R4,LR} ; Save EXC_RETURN |
mbedAustin | 11:cada08fc8a70 | 139 | BLX R12 ; Call SVC Function |
mbedAustin | 11:cada08fc8a70 | 140 | POP {R4,LR} ; Restore EXC_RETURN |
mbedAustin | 11:cada08fc8a70 | 141 | |
mbedAustin | 11:cada08fc8a70 | 142 | MRS R12,PSP ; Read PSP |
mbedAustin | 11:cada08fc8a70 | 143 | STM R12,{R0-R2} ; Store return values |
mbedAustin | 11:cada08fc8a70 | 144 | |
mbedAustin | 11:cada08fc8a70 | 145 | LDR R3,=__cpp(&os_tsk) |
mbedAustin | 11:cada08fc8a70 | 146 | LDM R3,{R1,R2} ; os_tsk.run, os_tsk.new |
mbedAustin | 11:cada08fc8a70 | 147 | CMP R1,R2 |
mbedAustin | 11:cada08fc8a70 | 148 | #ifdef IFX_XMC4XXX |
mbedAustin | 11:cada08fc8a70 | 149 | PUSHEQ {LR} |
mbedAustin | 11:cada08fc8a70 | 150 | POPEQ {PC} |
mbedAustin | 11:cada08fc8a70 | 151 | #else |
mbedAustin | 11:cada08fc8a70 | 152 | BXEQ LR ; RETI, no task switch |
mbedAustin | 11:cada08fc8a70 | 153 | #endif |
mbedAustin | 11:cada08fc8a70 | 154 | |
mbedAustin | 11:cada08fc8a70 | 155 | CBZ R1,SVC_Next ; Runtask deleted? |
mbedAustin | 11:cada08fc8a70 | 156 | TST LR,#0x10 ; is it extended frame? |
mbedAustin | 11:cada08fc8a70 | 157 | VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs |
mbedAustin | 11:cada08fc8a70 | 158 | MOVEQ R0,#0x01 ; os_tsk->stack_frame val |
mbedAustin | 11:cada08fc8a70 | 159 | MOVNE R0,#0x00 |
mbedAustin | 11:cada08fc8a70 | 160 | STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val |
mbedAustin | 11:cada08fc8a70 | 161 | STMDB R12!,{R4-R11} ; Save Old context |
mbedAustin | 11:cada08fc8a70 | 162 | STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack |
mbedAustin | 11:cada08fc8a70 | 163 | |
mbedAustin | 11:cada08fc8a70 | 164 | PUSH {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 165 | BL rt_stk_check ; Check for Stack overflow |
mbedAustin | 11:cada08fc8a70 | 166 | POP {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 167 | |
mbedAustin | 11:cada08fc8a70 | 168 | SVC_Next |
mbedAustin | 11:cada08fc8a70 | 169 | STR R2,[R3] ; os_tsk.run = os_tsk.new |
mbedAustin | 11:cada08fc8a70 | 170 | |
mbedAustin | 11:cada08fc8a70 | 171 | LDR R12,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack |
mbedAustin | 11:cada08fc8a70 | 172 | LDMIA R12!,{R4-R11} ; Restore New Context |
mbedAustin | 11:cada08fc8a70 | 173 | LDRB R0,[R2,#TCB_STACKF] ; Stack Frame |
mbedAustin | 11:cada08fc8a70 | 174 | CMP R0,#0 ; Basic/Extended Stack Frame |
mbedAustin | 11:cada08fc8a70 | 175 | VLDMIANE R12!,{S16-S31} ; restore VFP hi-registers |
mbedAustin | 11:cada08fc8a70 | 176 | MVNNE LR,#:NOT:0xFFFFFFED ; set EXC_RETURN value |
mbedAustin | 11:cada08fc8a70 | 177 | MVNEQ LR,#:NOT:0xFFFFFFFD |
mbedAustin | 11:cada08fc8a70 | 178 | MSR PSP,R12 ; Write PSP |
mbedAustin | 11:cada08fc8a70 | 179 | |
mbedAustin | 11:cada08fc8a70 | 180 | SVC_Exit |
mbedAustin | 11:cada08fc8a70 | 181 | #ifdef IFX_XMC4XXX |
mbedAustin | 11:cada08fc8a70 | 182 | PUSH {LR} |
mbedAustin | 11:cada08fc8a70 | 183 | POP {PC} |
mbedAustin | 11:cada08fc8a70 | 184 | #else |
mbedAustin | 11:cada08fc8a70 | 185 | BX LR |
mbedAustin | 11:cada08fc8a70 | 186 | #endif |
mbedAustin | 11:cada08fc8a70 | 187 | |
mbedAustin | 11:cada08fc8a70 | 188 | /*------------------- User SVC ------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 189 | |
mbedAustin | 11:cada08fc8a70 | 190 | SVC_User |
mbedAustin | 11:cada08fc8a70 | 191 | PUSH {R4,LR} ; Save Registers |
mbedAustin | 11:cada08fc8a70 | 192 | LDR R2,=SVC_Count |
mbedAustin | 11:cada08fc8a70 | 193 | LDR R2,[R2] |
mbedAustin | 11:cada08fc8a70 | 194 | CMP R1,R2 |
mbedAustin | 11:cada08fc8a70 | 195 | BHI SVC_Done ; Overflow |
mbedAustin | 11:cada08fc8a70 | 196 | |
mbedAustin | 11:cada08fc8a70 | 197 | LDR R4,=SVC_Table-4 |
mbedAustin | 11:cada08fc8a70 | 198 | LDR R4,[R4,R1,LSL #2] ; Load SVC Function Address |
mbedAustin | 11:cada08fc8a70 | 199 | |
mbedAustin | 11:cada08fc8a70 | 200 | LDM R0,{R0-R3,R12} ; Read R0-R3,R12 from stack |
mbedAustin | 11:cada08fc8a70 | 201 | BLX R4 ; Call SVC Function |
mbedAustin | 11:cada08fc8a70 | 202 | |
mbedAustin | 11:cada08fc8a70 | 203 | MRS R12,PSP |
mbedAustin | 11:cada08fc8a70 | 204 | STM R12,{R0-R3} ; Function return values |
mbedAustin | 11:cada08fc8a70 | 205 | SVC_Done |
mbedAustin | 11:cada08fc8a70 | 206 | POP {R4,PC} ; RETI |
mbedAustin | 11:cada08fc8a70 | 207 | |
mbedAustin | 11:cada08fc8a70 | 208 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 209 | } |
mbedAustin | 11:cada08fc8a70 | 210 | |
mbedAustin | 11:cada08fc8a70 | 211 | |
mbedAustin | 11:cada08fc8a70 | 212 | /*-------------------------- PendSV_Handler ---------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 213 | |
mbedAustin | 11:cada08fc8a70 | 214 | __asm void PendSV_Handler (void) { |
mbedAustin | 11:cada08fc8a70 | 215 | PRESERVE8 |
mbedAustin | 11:cada08fc8a70 | 216 | |
mbedAustin | 11:cada08fc8a70 | 217 | #ifdef IFX_XMC4XXX |
mbedAustin | 11:cada08fc8a70 | 218 | EXPORT PendSV_Handler_Veneer |
mbedAustin | 11:cada08fc8a70 | 219 | PendSV_Handler_Veneer |
mbedAustin | 11:cada08fc8a70 | 220 | #endif |
mbedAustin | 11:cada08fc8a70 | 221 | |
mbedAustin | 11:cada08fc8a70 | 222 | PUSH {R4,LR} ; Save EXC_RETURN |
mbedAustin | 11:cada08fc8a70 | 223 | BL __cpp(rt_pop_req) |
mbedAustin | 11:cada08fc8a70 | 224 | |
mbedAustin | 11:cada08fc8a70 | 225 | Sys_Switch |
mbedAustin | 11:cada08fc8a70 | 226 | POP {R4,LR} ; Restore EXC_RETURN |
mbedAustin | 11:cada08fc8a70 | 227 | |
mbedAustin | 11:cada08fc8a70 | 228 | LDR R3,=__cpp(&os_tsk) |
mbedAustin | 11:cada08fc8a70 | 229 | LDM R3,{R1,R2} ; os_tsk.run, os_tsk.new |
mbedAustin | 11:cada08fc8a70 | 230 | CMP R1,R2 |
mbedAustin | 11:cada08fc8a70 | 231 | #ifdef IFX_XMC4XXX |
mbedAustin | 11:cada08fc8a70 | 232 | PUSHEQ {LR} |
mbedAustin | 11:cada08fc8a70 | 233 | POPEQ {PC} |
mbedAustin | 11:cada08fc8a70 | 234 | #else |
mbedAustin | 11:cada08fc8a70 | 235 | BXEQ LR ; RETI, no task switch |
mbedAustin | 11:cada08fc8a70 | 236 | #endif |
mbedAustin | 11:cada08fc8a70 | 237 | |
mbedAustin | 11:cada08fc8a70 | 238 | MRS R12,PSP ; Read PSP |
mbedAustin | 11:cada08fc8a70 | 239 | TST LR,#0x10 ; is it extended frame? |
mbedAustin | 11:cada08fc8a70 | 240 | VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs |
mbedAustin | 11:cada08fc8a70 | 241 | MOVEQ R0,#0x01 ; os_tsk->stack_frame val |
mbedAustin | 11:cada08fc8a70 | 242 | MOVNE R0,#0x00 |
mbedAustin | 11:cada08fc8a70 | 243 | STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val |
mbedAustin | 11:cada08fc8a70 | 244 | STMDB R12!,{R4-R11} ; Save Old context |
mbedAustin | 11:cada08fc8a70 | 245 | STR R12,[R1,#TCB_TSTACK] ; Update os_tsk.run->tsk_stack |
mbedAustin | 11:cada08fc8a70 | 246 | |
mbedAustin | 11:cada08fc8a70 | 247 | PUSH {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 248 | BL rt_stk_check ; Check for Stack overflow |
mbedAustin | 11:cada08fc8a70 | 249 | POP {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 250 | |
mbedAustin | 11:cada08fc8a70 | 251 | STR R2,[R3] ; os_tsk.run = os_tsk.new |
mbedAustin | 11:cada08fc8a70 | 252 | |
mbedAustin | 11:cada08fc8a70 | 253 | LDR R12,[R2,#TCB_TSTACK] ; os_tsk.new->tsk_stack |
mbedAustin | 11:cada08fc8a70 | 254 | LDMIA R12!,{R4-R11} ; Restore New Context |
mbedAustin | 11:cada08fc8a70 | 255 | LDRB R0,[R2,#TCB_STACKF] ; Stack Frame |
mbedAustin | 11:cada08fc8a70 | 256 | CMP R0,#0 ; Basic/Extended Stack Frame |
mbedAustin | 11:cada08fc8a70 | 257 | VLDMIANE R12!,{S16-S31} ; restore VFP hi-regs |
mbedAustin | 11:cada08fc8a70 | 258 | MVNNE LR,#:NOT:0xFFFFFFED ; set EXC_RETURN value |
mbedAustin | 11:cada08fc8a70 | 259 | MVNEQ LR,#:NOT:0xFFFFFFFD |
mbedAustin | 11:cada08fc8a70 | 260 | MSR PSP,R12 ; Write PSP |
mbedAustin | 11:cada08fc8a70 | 261 | |
mbedAustin | 11:cada08fc8a70 | 262 | Sys_Exit |
mbedAustin | 11:cada08fc8a70 | 263 | #ifdef IFX_XMC4XXX |
mbedAustin | 11:cada08fc8a70 | 264 | PUSH {LR} |
mbedAustin | 11:cada08fc8a70 | 265 | POP {PC} |
mbedAustin | 11:cada08fc8a70 | 266 | #else |
mbedAustin | 11:cada08fc8a70 | 267 | BX LR ; Return to Thread Mode |
mbedAustin | 11:cada08fc8a70 | 268 | #endif |
mbedAustin | 11:cada08fc8a70 | 269 | |
mbedAustin | 11:cada08fc8a70 | 270 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 271 | } |
mbedAustin | 11:cada08fc8a70 | 272 | |
mbedAustin | 11:cada08fc8a70 | 273 | |
mbedAustin | 11:cada08fc8a70 | 274 | /*-------------------------- SysTick_Handler --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 275 | |
mbedAustin | 11:cada08fc8a70 | 276 | __asm void SysTick_Handler (void) { |
mbedAustin | 11:cada08fc8a70 | 277 | PRESERVE8 |
mbedAustin | 11:cada08fc8a70 | 278 | |
mbedAustin | 11:cada08fc8a70 | 279 | #ifdef IFX_XMC4XXX |
mbedAustin | 11:cada08fc8a70 | 280 | EXPORT SysTick_Handler_Veneer |
mbedAustin | 11:cada08fc8a70 | 281 | SysTick_Handler_Veneer |
mbedAustin | 11:cada08fc8a70 | 282 | #endif |
mbedAustin | 11:cada08fc8a70 | 283 | |
mbedAustin | 11:cada08fc8a70 | 284 | PUSH {R4,LR} ; Save EXC_RETURN |
mbedAustin | 11:cada08fc8a70 | 285 | BL __cpp(rt_systick) |
mbedAustin | 11:cada08fc8a70 | 286 | B Sys_Switch |
mbedAustin | 11:cada08fc8a70 | 287 | |
mbedAustin | 11:cada08fc8a70 | 288 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 289 | } |
mbedAustin | 11:cada08fc8a70 | 290 | |
mbedAustin | 11:cada08fc8a70 | 291 | |
mbedAustin | 11:cada08fc8a70 | 292 | /*-------------------------- OS_Tick_Handler --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 293 | |
mbedAustin | 11:cada08fc8a70 | 294 | __asm void OS_Tick_Handler (void) { |
mbedAustin | 11:cada08fc8a70 | 295 | PRESERVE8 |
mbedAustin | 11:cada08fc8a70 | 296 | |
mbedAustin | 11:cada08fc8a70 | 297 | PUSH {R4,LR} ; Save EXC_RETURN |
mbedAustin | 11:cada08fc8a70 | 298 | BL __cpp(os_tick_irqack) |
mbedAustin | 11:cada08fc8a70 | 299 | BL __cpp(rt_systick) |
mbedAustin | 11:cada08fc8a70 | 300 | B Sys_Switch |
mbedAustin | 11:cada08fc8a70 | 301 | |
mbedAustin | 11:cada08fc8a70 | 302 | ALIGN |
mbedAustin | 11:cada08fc8a70 | 303 | } |
mbedAustin | 11:cada08fc8a70 | 304 | |
mbedAustin | 11:cada08fc8a70 | 305 | |
mbedAustin | 11:cada08fc8a70 | 306 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 307 | * end of file |
mbedAustin | 11:cada08fc8a70 | 308 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 309 |