![](/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_M0P/TOOLCHAIN_IAR/HAL_CM0.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_CM0.S |
mbedAustin | 11:cada08fc8a70 | 5 | * Purpose: Hardware Abstraction Layer for Cortex-M0 |
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_CM0.S |
mbedAustin | 11:cada08fc8a70 | 36 | |
mbedAustin | 11:cada08fc8a70 | 37 | #define TCB_TSTACK 40 |
mbedAustin | 11:cada08fc8a70 | 38 | |
mbedAustin | 11:cada08fc8a70 | 39 | EXTERN os_flags |
mbedAustin | 11:cada08fc8a70 | 40 | EXTERN os_tsk |
mbedAustin | 11:cada08fc8a70 | 41 | EXTERN rt_alloc_box |
mbedAustin | 11:cada08fc8a70 | 42 | EXTERN rt_free_box |
mbedAustin | 11:cada08fc8a70 | 43 | EXTERN rt_stk_check |
mbedAustin | 11:cada08fc8a70 | 44 | EXTERN rt_pop_req |
mbedAustin | 11:cada08fc8a70 | 45 | EXTERN rt_systick |
mbedAustin | 11:cada08fc8a70 | 46 | EXTERN os_tick_irqack |
mbedAustin | 11:cada08fc8a70 | 47 | EXTERN SVC_Table |
mbedAustin | 11:cada08fc8a70 | 48 | EXTERN SVC_Count |
mbedAustin | 11:cada08fc8a70 | 49 | |
mbedAustin | 11:cada08fc8a70 | 50 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 51 | * Functions |
mbedAustin | 11:cada08fc8a70 | 52 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 53 | |
mbedAustin | 11:cada08fc8a70 | 54 | SECTION .text:CODE:NOROOT(2) |
mbedAustin | 11:cada08fc8a70 | 55 | THUMB |
mbedAustin | 11:cada08fc8a70 | 56 | |
mbedAustin | 11:cada08fc8a70 | 57 | /*--------------------------- rt_set_PSP ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 58 | |
mbedAustin | 11:cada08fc8a70 | 59 | ; void rt_set_PSP (U32 stack); |
mbedAustin | 11:cada08fc8a70 | 60 | |
mbedAustin | 11:cada08fc8a70 | 61 | PUBLIC rt_set_PSP |
mbedAustin | 11:cada08fc8a70 | 62 | rt_set_PSP: |
mbedAustin | 11:cada08fc8a70 | 63 | |
mbedAustin | 11:cada08fc8a70 | 64 | MSR PSP,R0 |
mbedAustin | 11:cada08fc8a70 | 65 | BX LR |
mbedAustin | 11:cada08fc8a70 | 66 | |
mbedAustin | 11:cada08fc8a70 | 67 | |
mbedAustin | 11:cada08fc8a70 | 68 | /*--------------------------- rt_get_PSP ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 69 | |
mbedAustin | 11:cada08fc8a70 | 70 | ; U32 rt_get_PSP (void); |
mbedAustin | 11:cada08fc8a70 | 71 | |
mbedAustin | 11:cada08fc8a70 | 72 | PUBLIC rt_get_PSP |
mbedAustin | 11:cada08fc8a70 | 73 | rt_get_PSP: |
mbedAustin | 11:cada08fc8a70 | 74 | |
mbedAustin | 11:cada08fc8a70 | 75 | MRS R0,PSP |
mbedAustin | 11:cada08fc8a70 | 76 | BX LR |
mbedAustin | 11:cada08fc8a70 | 77 | |
mbedAustin | 11:cada08fc8a70 | 78 | |
mbedAustin | 11:cada08fc8a70 | 79 | /*--------------------------- os_set_env ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 80 | |
mbedAustin | 11:cada08fc8a70 | 81 | ; void os_set_env (void); |
mbedAustin | 11:cada08fc8a70 | 82 | /* Switch to Unprivileged/Privileged Thread mode, use PSP. */ |
mbedAustin | 11:cada08fc8a70 | 83 | |
mbedAustin | 11:cada08fc8a70 | 84 | PUBLIC os_set_env |
mbedAustin | 11:cada08fc8a70 | 85 | os_set_env: |
mbedAustin | 11:cada08fc8a70 | 86 | |
mbedAustin | 11:cada08fc8a70 | 87 | MOV R0,SP /* PSP = MSP */ |
mbedAustin | 11:cada08fc8a70 | 88 | MSR PSP,R0 |
mbedAustin | 11:cada08fc8a70 | 89 | LDR R0,=os_flags |
mbedAustin | 11:cada08fc8a70 | 90 | LDRB R0,[R0] |
mbedAustin | 11:cada08fc8a70 | 91 | LSLS R0,#31 |
mbedAustin | 11:cada08fc8a70 | 92 | BNE PrivilegedE |
mbedAustin | 11:cada08fc8a70 | 93 | MOVS R0,#0x03 /* Unprivileged Thread mode, use PSP */ |
mbedAustin | 11:cada08fc8a70 | 94 | MSR CONTROL,R0 |
mbedAustin | 11:cada08fc8a70 | 95 | BX LR |
mbedAustin | 11:cada08fc8a70 | 96 | PrivilegedE: |
mbedAustin | 11:cada08fc8a70 | 97 | MOVS R0,#0x02 /* Privileged Thread mode, use PSP */ |
mbedAustin | 11:cada08fc8a70 | 98 | MSR CONTROL,R0 |
mbedAustin | 11:cada08fc8a70 | 99 | BX LR |
mbedAustin | 11:cada08fc8a70 | 100 | |
mbedAustin | 11:cada08fc8a70 | 101 | |
mbedAustin | 11:cada08fc8a70 | 102 | /*--------------------------- _alloc_box ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 103 | |
mbedAustin | 11:cada08fc8a70 | 104 | ; void *_alloc_box (void *box_mem); |
mbedAustin | 11:cada08fc8a70 | 105 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbedAustin | 11:cada08fc8a70 | 106 | |
mbedAustin | 11:cada08fc8a70 | 107 | PUBLIC _alloc_box |
mbedAustin | 11:cada08fc8a70 | 108 | _alloc_box: |
mbedAustin | 11:cada08fc8a70 | 109 | |
mbedAustin | 11:cada08fc8a70 | 110 | LDR R3,=rt_alloc_box |
mbedAustin | 11:cada08fc8a70 | 111 | MOV R12,R3 |
mbedAustin | 11:cada08fc8a70 | 112 | MRS R3,IPSR |
mbedAustin | 11:cada08fc8a70 | 113 | LSLS R3,#24 |
mbedAustin | 11:cada08fc8a70 | 114 | BNE PrivilegedA |
mbedAustin | 11:cada08fc8a70 | 115 | MRS R3,CONTROL |
mbedAustin | 11:cada08fc8a70 | 116 | LSLS R3,#31 |
mbedAustin | 11:cada08fc8a70 | 117 | BEQ PrivilegedA |
mbedAustin | 11:cada08fc8a70 | 118 | SVC 0 |
mbedAustin | 11:cada08fc8a70 | 119 | BX LR |
mbedAustin | 11:cada08fc8a70 | 120 | PrivilegedA: |
mbedAustin | 11:cada08fc8a70 | 121 | BX R12 |
mbedAustin | 11:cada08fc8a70 | 122 | |
mbedAustin | 11:cada08fc8a70 | 123 | |
mbedAustin | 11:cada08fc8a70 | 124 | /*--------------------------- _free_box -------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 125 | |
mbedAustin | 11:cada08fc8a70 | 126 | ; int _free_box (void *box_mem, void *box); |
mbedAustin | 11:cada08fc8a70 | 127 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbedAustin | 11:cada08fc8a70 | 128 | |
mbedAustin | 11:cada08fc8a70 | 129 | PUBLIC _free_box |
mbedAustin | 11:cada08fc8a70 | 130 | _free_box: |
mbedAustin | 11:cada08fc8a70 | 131 | |
mbedAustin | 11:cada08fc8a70 | 132 | LDR R3,=rt_free_box |
mbedAustin | 11:cada08fc8a70 | 133 | MOV R12,R3 |
mbedAustin | 11:cada08fc8a70 | 134 | MRS R3,IPSR |
mbedAustin | 11:cada08fc8a70 | 135 | LSLS R3,#24 |
mbedAustin | 11:cada08fc8a70 | 136 | BNE PrivilegedF |
mbedAustin | 11:cada08fc8a70 | 137 | MRS R3,CONTROL |
mbedAustin | 11:cada08fc8a70 | 138 | LSLS R3,#31 |
mbedAustin | 11:cada08fc8a70 | 139 | BEQ PrivilegedF |
mbedAustin | 11:cada08fc8a70 | 140 | SVC 0 |
mbedAustin | 11:cada08fc8a70 | 141 | BX LR |
mbedAustin | 11:cada08fc8a70 | 142 | PrivilegedF: |
mbedAustin | 11:cada08fc8a70 | 143 | BX R12 |
mbedAustin | 11:cada08fc8a70 | 144 | |
mbedAustin | 11:cada08fc8a70 | 145 | |
mbedAustin | 11:cada08fc8a70 | 146 | /*-------------------------- SVC_Handler ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 147 | |
mbedAustin | 11:cada08fc8a70 | 148 | ; void SVC_Handler (void); |
mbedAustin | 11:cada08fc8a70 | 149 | |
mbedAustin | 11:cada08fc8a70 | 150 | PUBLIC SVC_Handler |
mbedAustin | 11:cada08fc8a70 | 151 | SVC_Handler: |
mbedAustin | 11:cada08fc8a70 | 152 | |
mbedAustin | 11:cada08fc8a70 | 153 | MRS R0,PSP /* Read PSP */ |
mbedAustin | 11:cada08fc8a70 | 154 | LDR R1,[R0,#24] /* Read Saved PC from Stack */ |
mbedAustin | 11:cada08fc8a70 | 155 | SUBS R1,R1,#2 /* Point to SVC Instruction */ |
mbedAustin | 11:cada08fc8a70 | 156 | LDRB R1,[R1] /* Load SVC Number */ |
mbedAustin | 11:cada08fc8a70 | 157 | CMP R1,#0 |
mbedAustin | 11:cada08fc8a70 | 158 | BNE SVC_User /* User SVC Number > 0 */ |
mbedAustin | 11:cada08fc8a70 | 159 | |
mbedAustin | 11:cada08fc8a70 | 160 | MOV LR,R4 |
mbedAustin | 11:cada08fc8a70 | 161 | LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */ |
mbedAustin | 11:cada08fc8a70 | 162 | MOV R12,R4 |
mbedAustin | 11:cada08fc8a70 | 163 | MOV R4,LR |
mbedAustin | 11:cada08fc8a70 | 164 | BLX R12 /* Call SVC Function */ |
mbedAustin | 11:cada08fc8a70 | 165 | |
mbedAustin | 11:cada08fc8a70 | 166 | MRS R3,PSP /* Read PSP */ |
mbedAustin | 11:cada08fc8a70 | 167 | STMIA R3!,{R0-R2} /* Store return values */ |
mbedAustin | 11:cada08fc8a70 | 168 | |
mbedAustin | 11:cada08fc8a70 | 169 | LDR R3,=os_tsk |
mbedAustin | 11:cada08fc8a70 | 170 | LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.new */ |
mbedAustin | 11:cada08fc8a70 | 171 | CMP R1,R2 |
mbedAustin | 11:cada08fc8a70 | 172 | BEQ SVC_Exit /* no task switch */ |
mbedAustin | 11:cada08fc8a70 | 173 | |
mbedAustin | 11:cada08fc8a70 | 174 | SUBS R3,#8 |
mbedAustin | 11:cada08fc8a70 | 175 | CMP R1,#0 /* Runtask deleted? */ |
mbedAustin | 11:cada08fc8a70 | 176 | BEQ SVC_Next |
mbedAustin | 11:cada08fc8a70 | 177 | |
mbedAustin | 11:cada08fc8a70 | 178 | MRS R0,PSP /* Read PSP */ |
mbedAustin | 11:cada08fc8a70 | 179 | SUBS R0,R0,#32 /* Adjust Start Address */ |
mbedAustin | 11:cada08fc8a70 | 180 | STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
mbedAustin | 11:cada08fc8a70 | 181 | STMIA R0!,{R4-R7} /* Save old context (R4-R7) */ |
mbedAustin | 11:cada08fc8a70 | 182 | MOV R4,R8 |
mbedAustin | 11:cada08fc8a70 | 183 | MOV R5,R9 |
mbedAustin | 11:cada08fc8a70 | 184 | MOV R6,R10 |
mbedAustin | 11:cada08fc8a70 | 185 | MOV R7,R11 |
mbedAustin | 11:cada08fc8a70 | 186 | STMIA R0!,{R4-R7} /* Save old context (R8-R11) */ |
mbedAustin | 11:cada08fc8a70 | 187 | |
mbedAustin | 11:cada08fc8a70 | 188 | PUSH {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 189 | BL rt_stk_check /* Check for Stack overflow */ |
mbedAustin | 11:cada08fc8a70 | 190 | POP {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 191 | |
mbedAustin | 11:cada08fc8a70 | 192 | SVC_Next: |
mbedAustin | 11:cada08fc8a70 | 193 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
mbedAustin | 11:cada08fc8a70 | 194 | |
mbedAustin | 11:cada08fc8a70 | 195 | LDR R0,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
mbedAustin | 11:cada08fc8a70 | 196 | ADDS R0,R0,#16 /* Adjust Start Address */ |
mbedAustin | 11:cada08fc8a70 | 197 | LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */ |
mbedAustin | 11:cada08fc8a70 | 198 | MOV R8,R4 |
mbedAustin | 11:cada08fc8a70 | 199 | MOV R9,R5 |
mbedAustin | 11:cada08fc8a70 | 200 | MOV R10,R6 |
mbedAustin | 11:cada08fc8a70 | 201 | MOV R11,R7 |
mbedAustin | 11:cada08fc8a70 | 202 | MSR PSP,R0 /* Write PSP */ |
mbedAustin | 11:cada08fc8a70 | 203 | SUBS R0,R0,#32 /* Adjust Start Address */ |
mbedAustin | 11:cada08fc8a70 | 204 | LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */ |
mbedAustin | 11:cada08fc8a70 | 205 | |
mbedAustin | 11:cada08fc8a70 | 206 | SVC_Exit: |
mbedAustin | 11:cada08fc8a70 | 207 | MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */ |
mbedAustin | 11:cada08fc8a70 | 208 | MVNS R0,R0 |
mbedAustin | 11:cada08fc8a70 | 209 | BX R0 /* RETI to Thread Mode, use PSP */ |
mbedAustin | 11:cada08fc8a70 | 210 | |
mbedAustin | 11:cada08fc8a70 | 211 | /*------------------- User SVC ------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 212 | |
mbedAustin | 11:cada08fc8a70 | 213 | SVC_User: |
mbedAustin | 11:cada08fc8a70 | 214 | PUSH {R4,LR} /* Save Registers */ |
mbedAustin | 11:cada08fc8a70 | 215 | LDR R2,=SVC_Count |
mbedAustin | 11:cada08fc8a70 | 216 | LDR R2,[R2] |
mbedAustin | 11:cada08fc8a70 | 217 | CMP R1,R2 |
mbedAustin | 11:cada08fc8a70 | 218 | BHI SVC_Done /* Overflow */ |
mbedAustin | 11:cada08fc8a70 | 219 | |
mbedAustin | 11:cada08fc8a70 | 220 | LDR R4,=SVC_Table-4 |
mbedAustin | 11:cada08fc8a70 | 221 | LSLS R1,R1,#2 |
mbedAustin | 11:cada08fc8a70 | 222 | LDR R4,[R4,R1] /* Load SVC Function Address */ |
mbedAustin | 11:cada08fc8a70 | 223 | MOV LR,R4 |
mbedAustin | 11:cada08fc8a70 | 224 | |
mbedAustin | 11:cada08fc8a70 | 225 | LDMIA R0,{R0-R3,R4} /* Read R0-R3,R12 from stack */ |
mbedAustin | 11:cada08fc8a70 | 226 | MOV R12,R4 |
mbedAustin | 11:cada08fc8a70 | 227 | BLX LR /* Call SVC Function */ |
mbedAustin | 11:cada08fc8a70 | 228 | |
mbedAustin | 11:cada08fc8a70 | 229 | MRS R4,PSP /* Read PSP */ |
mbedAustin | 11:cada08fc8a70 | 230 | STMIA R4!,{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 | BL rt_pop_req |
mbedAustin | 11:cada08fc8a70 | 243 | |
mbedAustin | 11:cada08fc8a70 | 244 | Sys_Switch: |
mbedAustin | 11:cada08fc8a70 | 245 | LDR R3,=os_tsk |
mbedAustin | 11:cada08fc8a70 | 246 | LDMIA R3!,{R1,R2} /* os_tsk.run, os_tsk.new */ |
mbedAustin | 11:cada08fc8a70 | 247 | CMP R1,R2 |
mbedAustin | 11:cada08fc8a70 | 248 | BEQ Sys_Exit /* no task switch */ |
mbedAustin | 11:cada08fc8a70 | 249 | |
mbedAustin | 11:cada08fc8a70 | 250 | SUBS R3,#8 |
mbedAustin | 11:cada08fc8a70 | 251 | |
mbedAustin | 11:cada08fc8a70 | 252 | MRS R0,PSP /* Read PSP */ |
mbedAustin | 11:cada08fc8a70 | 253 | SUBS R0,R0,#32 /* Adjust Start Address */ |
mbedAustin | 11:cada08fc8a70 | 254 | STR R0,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */ |
mbedAustin | 11:cada08fc8a70 | 255 | STMIA R0!,{R4-R7} /* Save old context (R4-R7) */ |
mbedAustin | 11:cada08fc8a70 | 256 | MOV R4,R8 |
mbedAustin | 11:cada08fc8a70 | 257 | MOV R5,R9 |
mbedAustin | 11:cada08fc8a70 | 258 | MOV R6,R10 |
mbedAustin | 11:cada08fc8a70 | 259 | MOV R7,R11 |
mbedAustin | 11:cada08fc8a70 | 260 | STMIA R0!,{R4-R7} /* Save old context (R8-R11) */ |
mbedAustin | 11:cada08fc8a70 | 261 | |
mbedAustin | 11:cada08fc8a70 | 262 | PUSH {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 263 | BL rt_stk_check /* Check for Stack overflow */ |
mbedAustin | 11:cada08fc8a70 | 264 | POP {R2,R3} |
mbedAustin | 11:cada08fc8a70 | 265 | |
mbedAustin | 11:cada08fc8a70 | 266 | STR R2,[R3] /* os_tsk.run = os_tsk.new */ |
mbedAustin | 11:cada08fc8a70 | 267 | |
mbedAustin | 11:cada08fc8a70 | 268 | LDR R0,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */ |
mbedAustin | 11:cada08fc8a70 | 269 | ADDS R0,R0,#16 /* Adjust Start Address */ |
mbedAustin | 11:cada08fc8a70 | 270 | LDMIA R0!,{R4-R7} /* Restore new Context (R8-R11) */ |
mbedAustin | 11:cada08fc8a70 | 271 | MOV R8,R4 |
mbedAustin | 11:cada08fc8a70 | 272 | MOV R9,R5 |
mbedAustin | 11:cada08fc8a70 | 273 | MOV R10,R6 |
mbedAustin | 11:cada08fc8a70 | 274 | MOV R11,R7 |
mbedAustin | 11:cada08fc8a70 | 275 | MSR PSP,R0 /* Write PSP */ |
mbedAustin | 11:cada08fc8a70 | 276 | SUBS R0,R0,#32 /* Adjust Start Address */ |
mbedAustin | 11:cada08fc8a70 | 277 | LDMIA R0!,{R4-R7} /* Restore new Context (R4-R7) */ |
mbedAustin | 11:cada08fc8a70 | 278 | |
mbedAustin | 11:cada08fc8a70 | 279 | Sys_Exit: |
mbedAustin | 11:cada08fc8a70 | 280 | MOVS R0,#~0xFFFFFFFD /* Set EXC_RETURN value */ |
mbedAustin | 11:cada08fc8a70 | 281 | MVNS R0,R0 |
mbedAustin | 11:cada08fc8a70 | 282 | BX R0 /* RETI to Thread Mode, use PSP */ |
mbedAustin | 11:cada08fc8a70 | 283 | |
mbedAustin | 11:cada08fc8a70 | 284 | |
mbedAustin | 11:cada08fc8a70 | 285 | /*-------------------------- SysTick_Handler --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 286 | |
mbedAustin | 11:cada08fc8a70 | 287 | ; void SysTick_Handler (void); |
mbedAustin | 11:cada08fc8a70 | 288 | |
mbedAustin | 11:cada08fc8a70 | 289 | PUBLIC SysTick_Handler |
mbedAustin | 11:cada08fc8a70 | 290 | SysTick_Handler: |
mbedAustin | 11:cada08fc8a70 | 291 | |
mbedAustin | 11:cada08fc8a70 | 292 | BL rt_systick |
mbedAustin | 11:cada08fc8a70 | 293 | B Sys_Switch |
mbedAustin | 11:cada08fc8a70 | 294 | |
mbedAustin | 11:cada08fc8a70 | 295 | |
mbedAustin | 11:cada08fc8a70 | 296 | /*-------------------------- OS_Tick_Handler --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 297 | |
mbedAustin | 11:cada08fc8a70 | 298 | ; void OS_Tick_Handler (void); |
mbedAustin | 11:cada08fc8a70 | 299 | |
mbedAustin | 11:cada08fc8a70 | 300 | PUBLIC OS_Tick_Handler |
mbedAustin | 11:cada08fc8a70 | 301 | OS_Tick_Handler: |
mbedAustin | 11:cada08fc8a70 | 302 | |
mbedAustin | 11:cada08fc8a70 | 303 | BL os_tick_irqack |
mbedAustin | 11:cada08fc8a70 | 304 | BL rt_systick |
mbedAustin | 11:cada08fc8a70 | 305 | B Sys_Switch |
mbedAustin | 11:cada08fc8a70 | 306 | |
mbedAustin | 11:cada08fc8a70 | 307 | |
mbedAustin | 11:cada08fc8a70 | 308 | END |
mbedAustin | 11:cada08fc8a70 | 309 | |
mbedAustin | 11:cada08fc8a70 | 310 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 311 | * end of file |
mbedAustin | 11:cada08fc8a70 | 312 | *---------------------------------------------------------------------------*/ |