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