![](/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_ARM7/ARM7/TOOLCHAIN_GCC/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 | * RL-ARM - RTX |
mbedAustin | 11:cada08fc8a70 | 3 | *---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 4 | * Name: HAL_CM0.S |
mbedAustin | 11:cada08fc8a70 | 5 | * Purpose: Hardware Abstraction Layer for ARM7TDMI |
mbedAustin | 11:cada08fc8a70 | 6 | * Rev.: V1.0 |
mbedAustin | 11:cada08fc8a70 | 7 | *---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 8 | * |
mbedAustin | 11:cada08fc8a70 | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2015 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 | .file "HAL_CM0.S" |
mbedAustin | 11:cada08fc8a70 | 36 | .syntax unified |
mbedAustin | 11:cada08fc8a70 | 37 | |
mbedAustin | 11:cada08fc8a70 | 38 | .equ TCB_TSTACK, 40 |
mbedAustin | 11:cada08fc8a70 | 39 | |
mbedAustin | 11:cada08fc8a70 | 40 | |
mbedAustin | 11:cada08fc8a70 | 41 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 42 | * Functions |
mbedAustin | 11:cada08fc8a70 | 43 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 44 | |
mbedAustin | 11:cada08fc8a70 | 45 | .arm |
mbedAustin | 11:cada08fc8a70 | 46 | |
mbedAustin | 11:cada08fc8a70 | 47 | .section ".text" |
mbedAustin | 11:cada08fc8a70 | 48 | .align 2 |
mbedAustin | 11:cada08fc8a70 | 49 | |
mbedAustin | 11:cada08fc8a70 | 50 | /*-------------------------- Save Context --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 51 | /* MUST be called the first */ |
mbedAustin | 11:cada08fc8a70 | 52 | .macro SaveContext |
mbedAustin | 11:cada08fc8a70 | 53 | |
mbedAustin | 11:cada08fc8a70 | 54 | /* Push R0 as we are going to use the register. */ \ |
mbedAustin | 11:cada08fc8a70 | 55 | STMDB SP!, {R0} |
mbedAustin | 11:cada08fc8a70 | 56 | |
mbedAustin | 11:cada08fc8a70 | 57 | /* Set R0 to SP(user) */ |
mbedAustin | 11:cada08fc8a70 | 58 | STMDB SP,{SP}^ |
mbedAustin | 11:cada08fc8a70 | 59 | NOP |
mbedAustin | 11:cada08fc8a70 | 60 | SUB SP, SP, #4 |
mbedAustin | 11:cada08fc8a70 | 61 | LDMIA SP!,{R0} |
mbedAustin | 11:cada08fc8a70 | 62 | |
mbedAustin | 11:cada08fc8a70 | 63 | /* Push the LR return address onto the user stack. */ |
mbedAustin | 11:cada08fc8a70 | 64 | STMDB R0!, {LR} |
mbedAustin | 11:cada08fc8a70 | 65 | |
mbedAustin | 11:cada08fc8a70 | 66 | /* Now we have saved LR we can use it instead of R0. */ |
mbedAustin | 11:cada08fc8a70 | 67 | MOV LR, R0 |
mbedAustin | 11:cada08fc8a70 | 68 | |
mbedAustin | 11:cada08fc8a70 | 69 | /* Pop R0 so we can save it onto the system mode stack. */ |
mbedAustin | 11:cada08fc8a70 | 70 | LDMIA SP!, {R0} |
mbedAustin | 11:cada08fc8a70 | 71 | |
mbedAustin | 11:cada08fc8a70 | 72 | /* Push all the system mode registers onto the task stack. */ |
mbedAustin | 11:cada08fc8a70 | 73 | STMDB LR,{R0-R12,LR}^ /* LR can not be changed because user's LR is used*/ |
mbedAustin | 11:cada08fc8a70 | 74 | NOP /* pass 1 cycle before changing LR */ |
mbedAustin | 11:cada08fc8a70 | 75 | SUB LR, LR, #14*4 /* change LR now -15 dwords (R0-R14)*/ |
mbedAustin | 11:cada08fc8a70 | 76 | |
mbedAustin | 11:cada08fc8a70 | 77 | /* Push the SPSR onto the task stack. */ |
mbedAustin | 11:cada08fc8a70 | 78 | MRS R0, SPSR |
mbedAustin | 11:cada08fc8a70 | 79 | STMDB LR!, {R0} |
mbedAustin | 11:cada08fc8a70 | 80 | |
mbedAustin | 11:cada08fc8a70 | 81 | /* Store the new top of stack for the task. */ |
mbedAustin | 11:cada08fc8a70 | 82 | LDR R0,=os_tsk |
mbedAustin | 11:cada08fc8a70 | 83 | LDR R0, [R0] /* R0 = (tcb) os_tsk.run */ |
mbedAustin | 11:cada08fc8a70 | 84 | STR LR, [R0, TCB_TSTACK] /* tcb.tsk_stack = SP(user) */ |
mbedAustin | 11:cada08fc8a70 | 85 | .endm |
mbedAustin | 11:cada08fc8a70 | 86 | |
mbedAustin | 11:cada08fc8a70 | 87 | /*-------------------------- Restore Context --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 88 | .type RestoreContext, %function |
mbedAustin | 11:cada08fc8a70 | 89 | .global RestoreContext |
mbedAustin | 11:cada08fc8a70 | 90 | RestoreContext: |
mbedAustin | 11:cada08fc8a70 | 91 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 92 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 93 | /* Set the LR to the task stack. */ |
mbedAustin | 11:cada08fc8a70 | 94 | LDR R0,=os_tsk |
mbedAustin | 11:cada08fc8a70 | 95 | LDR R1, [R0, 4] /* R1 = (tcb) os_tsk.new */ |
mbedAustin | 11:cada08fc8a70 | 96 | STR R1, [R0] /* os_tsk.run = os_tsk_newk */ |
mbedAustin | 11:cada08fc8a70 | 97 | LDR LR, [R1, TCB_TSTACK] /* LR = tcb.tsk_stack */ |
mbedAustin | 11:cada08fc8a70 | 98 | |
mbedAustin | 11:cada08fc8a70 | 99 | /* Get the SPSR from the stack. */ |
mbedAustin | 11:cada08fc8a70 | 100 | LDMFD LR!, {R0} /* SPSR */ |
mbedAustin | 11:cada08fc8a70 | 101 | MSR SPSR, R0 |
mbedAustin | 11:cada08fc8a70 | 102 | |
mbedAustin | 11:cada08fc8a70 | 103 | /* Restore all system mode registers for the task. */ |
mbedAustin | 11:cada08fc8a70 | 104 | LDMFD LR, {R0-R12,LR}^ |
mbedAustin | 11:cada08fc8a70 | 105 | NOP |
mbedAustin | 11:cada08fc8a70 | 106 | |
mbedAustin | 11:cada08fc8a70 | 107 | ADD LR, LR, 15*4 /* increase starck pointer */ |
mbedAustin | 11:cada08fc8a70 | 108 | /* Set SP(user) to LR */ |
mbedAustin | 11:cada08fc8a70 | 109 | STMDB SP!,{LR} |
mbedAustin | 11:cada08fc8a70 | 110 | LDMIA SP,{SP}^ |
mbedAustin | 11:cada08fc8a70 | 111 | NOP |
mbedAustin | 11:cada08fc8a70 | 112 | ADD SP, SP, #4 |
mbedAustin | 11:cada08fc8a70 | 113 | |
mbedAustin | 11:cada08fc8a70 | 114 | /* Restore the return address. */ |
mbedAustin | 11:cada08fc8a70 | 115 | LDR LR, [LR,#-4] /* last dword is task's PC register */ |
mbedAustin | 11:cada08fc8a70 | 116 | |
mbedAustin | 11:cada08fc8a70 | 117 | /* And return - correcting the offset in the LR to obtain the */ |
mbedAustin | 11:cada08fc8a70 | 118 | /* correct address. */ |
mbedAustin | 11:cada08fc8a70 | 119 | SUBS PC, LR, #4 |
mbedAustin | 11:cada08fc8a70 | 120 | |
mbedAustin | 11:cada08fc8a70 | 121 | /*-------------------------- End --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 122 | .fnend |
mbedAustin | 11:cada08fc8a70 | 123 | .size RestoreContext, .-RestoreContext |
mbedAustin | 11:cada08fc8a70 | 124 | |
mbedAustin | 11:cada08fc8a70 | 125 | |
mbedAustin | 11:cada08fc8a70 | 126 | |
mbedAustin | 11:cada08fc8a70 | 127 | /*--------------------------- rt_set_PSP ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 128 | |
mbedAustin | 11:cada08fc8a70 | 129 | # void rt_set_PSP (U32 stack); |
mbedAustin | 11:cada08fc8a70 | 130 | |
mbedAustin | 11:cada08fc8a70 | 131 | .type rt_set_PSP, %function |
mbedAustin | 11:cada08fc8a70 | 132 | .global rt_set_PSP |
mbedAustin | 11:cada08fc8a70 | 133 | rt_set_PSP: |
mbedAustin | 11:cada08fc8a70 | 134 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 135 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 136 | |
mbedAustin | 11:cada08fc8a70 | 137 | MOV SP,R0 |
mbedAustin | 11:cada08fc8a70 | 138 | BX LR |
mbedAustin | 11:cada08fc8a70 | 139 | |
mbedAustin | 11:cada08fc8a70 | 140 | .fnend |
mbedAustin | 11:cada08fc8a70 | 141 | .size rt_set_PSP, .-rt_set_PSP |
mbedAustin | 11:cada08fc8a70 | 142 | |
mbedAustin | 11:cada08fc8a70 | 143 | |
mbedAustin | 11:cada08fc8a70 | 144 | /*--------------------------- rt_get_PSP ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 145 | |
mbedAustin | 11:cada08fc8a70 | 146 | # U32 rt_get_PSP (void); |
mbedAustin | 11:cada08fc8a70 | 147 | |
mbedAustin | 11:cada08fc8a70 | 148 | .type rt_get_PSP, %function |
mbedAustin | 11:cada08fc8a70 | 149 | .global rt_get_PSP |
mbedAustin | 11:cada08fc8a70 | 150 | rt_get_PSP: |
mbedAustin | 11:cada08fc8a70 | 151 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 152 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 153 | |
mbedAustin | 11:cada08fc8a70 | 154 | MOV R0,SP |
mbedAustin | 11:cada08fc8a70 | 155 | BX LR |
mbedAustin | 11:cada08fc8a70 | 156 | |
mbedAustin | 11:cada08fc8a70 | 157 | .fnend |
mbedAustin | 11:cada08fc8a70 | 158 | .size rt_get_PSP, .-rt_get_PSP |
mbedAustin | 11:cada08fc8a70 | 159 | |
mbedAustin | 11:cada08fc8a70 | 160 | |
mbedAustin | 11:cada08fc8a70 | 161 | |
mbedAustin | 11:cada08fc8a70 | 162 | /*--------------------------- _alloc_box ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 163 | |
mbedAustin | 11:cada08fc8a70 | 164 | # void *_alloc_box (void *box_mem); |
mbedAustin | 11:cada08fc8a70 | 165 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbedAustin | 11:cada08fc8a70 | 166 | |
mbedAustin | 11:cada08fc8a70 | 167 | .type _alloc_box, %function |
mbedAustin | 11:cada08fc8a70 | 168 | .global _alloc_box |
mbedAustin | 11:cada08fc8a70 | 169 | _alloc_box: |
mbedAustin | 11:cada08fc8a70 | 170 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 171 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 172 | |
mbedAustin | 11:cada08fc8a70 | 173 | LDR R3,=rt_alloc_box |
mbedAustin | 11:cada08fc8a70 | 174 | MOV R12, R3 |
mbedAustin | 11:cada08fc8a70 | 175 | MRS R3, CPSR |
mbedAustin | 11:cada08fc8a70 | 176 | AND R3, 0x1F |
mbedAustin | 11:cada08fc8a70 | 177 | CMP R3, 0x12 /* IRQ mode*/ |
mbedAustin | 11:cada08fc8a70 | 178 | BNE PrivilegedA |
mbedAustin | 11:cada08fc8a70 | 179 | CMP R3, 0x1F /* System mode*/ |
mbedAustin | 11:cada08fc8a70 | 180 | BNE PrivilegedA |
mbedAustin | 11:cada08fc8a70 | 181 | SVC 0 |
mbedAustin | 11:cada08fc8a70 | 182 | BX LR |
mbedAustin | 11:cada08fc8a70 | 183 | PrivilegedA: |
mbedAustin | 11:cada08fc8a70 | 184 | BX R12 |
mbedAustin | 11:cada08fc8a70 | 185 | |
mbedAustin | 11:cada08fc8a70 | 186 | .fnend |
mbedAustin | 11:cada08fc8a70 | 187 | .size _alloc_box, .-_alloc_box |
mbedAustin | 11:cada08fc8a70 | 188 | |
mbedAustin | 11:cada08fc8a70 | 189 | |
mbedAustin | 11:cada08fc8a70 | 190 | /*--------------------------- _free_box -------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 191 | |
mbedAustin | 11:cada08fc8a70 | 192 | # int _free_box (void *box_mem, void *box); |
mbedAustin | 11:cada08fc8a70 | 193 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbedAustin | 11:cada08fc8a70 | 194 | |
mbedAustin | 11:cada08fc8a70 | 195 | .type _free_box, %function |
mbedAustin | 11:cada08fc8a70 | 196 | .global _free_box |
mbedAustin | 11:cada08fc8a70 | 197 | _free_box: |
mbedAustin | 11:cada08fc8a70 | 198 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 199 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 200 | |
mbedAustin | 11:cada08fc8a70 | 201 | LDR R3,=rt_free_box |
mbedAustin | 11:cada08fc8a70 | 202 | MOV R12, R3 |
mbedAustin | 11:cada08fc8a70 | 203 | MRS R3, CPSR |
mbedAustin | 11:cada08fc8a70 | 204 | AND R3, 0x1F |
mbedAustin | 11:cada08fc8a70 | 205 | CMP R3, 0x12 /* IRQ mode*/ |
mbedAustin | 11:cada08fc8a70 | 206 | BNE PrivilegedA |
mbedAustin | 11:cada08fc8a70 | 207 | CMP R3, 0x1F /* System mode*/ |
mbedAustin | 11:cada08fc8a70 | 208 | BNE PrivilegedA |
mbedAustin | 11:cada08fc8a70 | 209 | SVC 0 |
mbedAustin | 11:cada08fc8a70 | 210 | BX LR |
mbedAustin | 11:cada08fc8a70 | 211 | PrivilegedF: |
mbedAustin | 11:cada08fc8a70 | 212 | BX R12 |
mbedAustin | 11:cada08fc8a70 | 213 | |
mbedAustin | 11:cada08fc8a70 | 214 | .fnend |
mbedAustin | 11:cada08fc8a70 | 215 | .size _free_box, .-_free_box |
mbedAustin | 11:cada08fc8a70 | 216 | |
mbedAustin | 11:cada08fc8a70 | 217 | |
mbedAustin | 11:cada08fc8a70 | 218 | /*-------------------------- SVC_Handler ------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 219 | |
mbedAustin | 11:cada08fc8a70 | 220 | # void SVC_Handler (void); |
mbedAustin | 11:cada08fc8a70 | 221 | |
mbedAustin | 11:cada08fc8a70 | 222 | .type SVC_Handler, %function |
mbedAustin | 11:cada08fc8a70 | 223 | .global SVC_Handler |
mbedAustin | 11:cada08fc8a70 | 224 | SVC_Handler: |
mbedAustin | 11:cada08fc8a70 | 225 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 226 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 227 | /* Within an IRQ ISR the link register has an offset from the true return |
mbedAustin | 11:cada08fc8a70 | 228 | address, but an SWI ISR does not. Add the offset manually so the same |
mbedAustin | 11:cada08fc8a70 | 229 | ISR return code can be used in both cases. */ |
mbedAustin | 11:cada08fc8a70 | 230 | |
mbedAustin | 11:cada08fc8a70 | 231 | STMFD SP!, {R0,LR} /* Store registers. */ |
mbedAustin | 11:cada08fc8a70 | 232 | ADD LR, LR, #4 /* Align LR with IRQ handler */ |
mbedAustin | 11:cada08fc8a70 | 233 | SaveContext |
mbedAustin | 11:cada08fc8a70 | 234 | MOV R11, LR /* Save Task Stack Pointer */ |
mbedAustin | 11:cada08fc8a70 | 235 | LDMFD SP!, {R0,LR} /* Restore registers and return. */ |
mbedAustin | 11:cada08fc8a70 | 236 | STMFD SP!, {R11} /* Save Task Stack Pointer */ |
mbedAustin | 11:cada08fc8a70 | 237 | |
mbedAustin | 11:cada08fc8a70 | 238 | LDR R5, [LR,#-4] /* Calculate address of SWI instruction and load it into r5. */ |
mbedAustin | 11:cada08fc8a70 | 239 | BIC R5, R5,#0xff000000 /* Mask off top 8 bits of instruction to give SWI number. */ |
mbedAustin | 11:cada08fc8a70 | 240 | |
mbedAustin | 11:cada08fc8a70 | 241 | CMP R5, #0 |
mbedAustin | 11:cada08fc8a70 | 242 | BNE SVC_User /* User SVC Number > 0 */ |
mbedAustin | 11:cada08fc8a70 | 243 | MOV LR, PC /* set LR to return address */ |
mbedAustin | 11:cada08fc8a70 | 244 | BX R12 /* Call SVC Function */ |
mbedAustin | 11:cada08fc8a70 | 245 | |
mbedAustin | 11:cada08fc8a70 | 246 | LDMFD SP!, {R11} /* Load Task Stack Pointer */ |
mbedAustin | 11:cada08fc8a70 | 247 | STMIB R11!, {R0-R3} /* Store return values to Task stack */ |
mbedAustin | 11:cada08fc8a70 | 248 | |
mbedAustin | 11:cada08fc8a70 | 249 | SVC_Exit: |
mbedAustin | 11:cada08fc8a70 | 250 | B RestoreContext /* return to the task */ |
mbedAustin | 11:cada08fc8a70 | 251 | |
mbedAustin | 11:cada08fc8a70 | 252 | /*------------------- User SVC ------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 253 | |
mbedAustin | 11:cada08fc8a70 | 254 | SVC_User: |
mbedAustin | 11:cada08fc8a70 | 255 | LDR R6,=SVC_Count |
mbedAustin | 11:cada08fc8a70 | 256 | LDR R6,[R6] |
mbedAustin | 11:cada08fc8a70 | 257 | CMP R5,R6 |
mbedAustin | 11:cada08fc8a70 | 258 | LDMFDHI SP!, {R11} |
mbedAustin | 11:cada08fc8a70 | 259 | BHI SVC_Done /* Overflow */ |
mbedAustin | 11:cada08fc8a70 | 260 | |
mbedAustin | 11:cada08fc8a70 | 261 | LDR R4,=SVC_Table - 4 |
mbedAustin | 11:cada08fc8a70 | 262 | LSLS R5,R5,#2 |
mbedAustin | 11:cada08fc8a70 | 263 | LDR R4,[R4,R5] /* Load SVC Function Address */ |
mbedAustin | 11:cada08fc8a70 | 264 | /* R0-R3,R12 are unchanged */ |
mbedAustin | 11:cada08fc8a70 | 265 | MOV LR, PC /* set LR to return address */ |
mbedAustin | 11:cada08fc8a70 | 266 | BX R4 /* Call SVC Function */ |
mbedAustin | 11:cada08fc8a70 | 267 | |
mbedAustin | 11:cada08fc8a70 | 268 | LDMFD SP!, {R11} /* Load Task Stack Pointer */ |
mbedAustin | 11:cada08fc8a70 | 269 | BEQ SVC_Exit /* no need in return values */ |
mbedAustin | 11:cada08fc8a70 | 270 | |
mbedAustin | 11:cada08fc8a70 | 271 | STMIB R11!, {R0-R3} /* Store return values to Task stack */ |
mbedAustin | 11:cada08fc8a70 | 272 | SVC_Done: |
mbedAustin | 11:cada08fc8a70 | 273 | B RestoreContext /* return to the task */ |
mbedAustin | 11:cada08fc8a70 | 274 | |
mbedAustin | 11:cada08fc8a70 | 275 | .fnend |
mbedAustin | 11:cada08fc8a70 | 276 | .size SVC_Handler, .-SVC_Handler |
mbedAustin | 11:cada08fc8a70 | 277 | |
mbedAustin | 11:cada08fc8a70 | 278 | |
mbedAustin | 11:cada08fc8a70 | 279 | /*-------------------------- IRQ_Handler ---------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 280 | |
mbedAustin | 11:cada08fc8a70 | 281 | # void IRQ_Handler (void); |
mbedAustin | 11:cada08fc8a70 | 282 | |
mbedAustin | 11:cada08fc8a70 | 283 | .type IRQ_Handler, %function |
mbedAustin | 11:cada08fc8a70 | 284 | .global IRQ_Handler |
mbedAustin | 11:cada08fc8a70 | 285 | IRQ_Handler: |
mbedAustin | 11:cada08fc8a70 | 286 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 287 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 288 | |
mbedAustin | 11:cada08fc8a70 | 289 | SaveContext |
mbedAustin | 11:cada08fc8a70 | 290 | |
mbedAustin | 11:cada08fc8a70 | 291 | MOV R0, #0xFFFFFF00 |
mbedAustin | 11:cada08fc8a70 | 292 | LDR R0, [R0] /* Load address of raised IRQ handler*/ |
mbedAustin | 11:cada08fc8a70 | 293 | |
mbedAustin | 11:cada08fc8a70 | 294 | MOV LR, PC |
mbedAustin | 11:cada08fc8a70 | 295 | BX R0 |
mbedAustin | 11:cada08fc8a70 | 296 | |
mbedAustin | 11:cada08fc8a70 | 297 | MOV R0, #0xFFFFFF00 |
mbedAustin | 11:cada08fc8a70 | 298 | STR R0, [R0] /* Clear interrupt */ |
mbedAustin | 11:cada08fc8a70 | 299 | |
mbedAustin | 11:cada08fc8a70 | 300 | B RestoreContext |
mbedAustin | 11:cada08fc8a70 | 301 | |
mbedAustin | 11:cada08fc8a70 | 302 | .fnend |
mbedAustin | 11:cada08fc8a70 | 303 | .size IRQ_Handler, .-IRQ_Handler |
mbedAustin | 11:cada08fc8a70 | 304 | |
mbedAustin | 11:cada08fc8a70 | 305 | /*-------------------------- SysTick_Handler --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 306 | |
mbedAustin | 11:cada08fc8a70 | 307 | # void SysTick_Handler (void); |
mbedAustin | 11:cada08fc8a70 | 308 | |
mbedAustin | 11:cada08fc8a70 | 309 | .type SysTick_Handler, %function |
mbedAustin | 11:cada08fc8a70 | 310 | .global SysTick_Handler |
mbedAustin | 11:cada08fc8a70 | 311 | SysTick_Handler: |
mbedAustin | 11:cada08fc8a70 | 312 | .fnstart |
mbedAustin | 11:cada08fc8a70 | 313 | .cantunwind |
mbedAustin | 11:cada08fc8a70 | 314 | |
mbedAustin | 11:cada08fc8a70 | 315 | PUSH {LR} |
mbedAustin | 11:cada08fc8a70 | 316 | BL rt_systick |
mbedAustin | 11:cada08fc8a70 | 317 | POP {LR} |
mbedAustin | 11:cada08fc8a70 | 318 | BX LR /* return to IRQ handler */ |
mbedAustin | 11:cada08fc8a70 | 319 | |
mbedAustin | 11:cada08fc8a70 | 320 | /*-------------------------- End --------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 321 | .fnend |
mbedAustin | 11:cada08fc8a70 | 322 | .size SysTick_Handler, .-SysTick_Handler |
mbedAustin | 11:cada08fc8a70 | 323 | |
mbedAustin | 11:cada08fc8a70 | 324 | |
mbedAustin | 11:cada08fc8a70 | 325 | /*---------------------------------------------------------------------------- |
mbedAustin | 11:cada08fc8a70 | 326 | * end of file |
mbedAustin | 11:cada08fc8a70 | 327 | *---------------------------------------------------------------------------*/ |
mbedAustin | 11:cada08fc8a70 | 328 | |
mbedAustin | 11:cada08fc8a70 | 329 | .end |