Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.
Dependents: denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more
Deprecated
This is the mbed 2 rtos library. mbed OS 5 integrates the mbed library with mbed-rtos. With this, we have provided thread safety for all mbed APIs. If you'd like to learn about using mbed OS 5, please see the docs.
rtx/TARGET_CORTEX_A/TOOLCHAIN_GCC/HAL_CA9.S@92:bc9729798a19, 2015-09-25 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Sep 25 13:30:34 2015 +0100
- Revision:
- 92:bc9729798a19
- Parent:
- 86:58c3b7759abf
Synchronized with git revision e8c24ba90dd5507bdb7c1b46dd3aba8cfabb762b
Full URL: https://github.com/mbedmicro/mbed/commit/e8c24ba90dd5507bdb7c1b46dd3aba8cfabb762b/
RZ_A1H - Modify to support NEON for RTOS.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 67:63988a2238f7 | 1 | /*---------------------------------------------------------------------------- |
mbed_official | 67:63988a2238f7 | 2 | * RL-ARM - RTX |
mbed_official | 67:63988a2238f7 | 3 | *---------------------------------------------------------------------------- |
mbed_official | 67:63988a2238f7 | 4 | * Name: HAL_CA9.c |
mbed_official | 67:63988a2238f7 | 5 | * Purpose: Hardware Abstraction Layer for Cortex-A9 |
mbed_official | 92:bc9729798a19 | 6 | * Rev.: 8 April 2015 |
mbed_official | 67:63988a2238f7 | 7 | *---------------------------------------------------------------------------- |
mbed_official | 67:63988a2238f7 | 8 | * |
mbed_official | 92:bc9729798a19 | 9 | * Copyright (c) 2012 - 2015 ARM Limited |
mbed_official | 67:63988a2238f7 | 10 | * All rights reserved. |
mbed_official | 67:63988a2238f7 | 11 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 67:63988a2238f7 | 12 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 67:63988a2238f7 | 13 | * - Redistributions of source code must retain the above copyright |
mbed_official | 67:63988a2238f7 | 14 | * notice, this list of conditions and the following disclaimer. |
mbed_official | 67:63988a2238f7 | 15 | * - Redistributions in binary form must reproduce the above copyright |
mbed_official | 67:63988a2238f7 | 16 | * notice, this list of conditions and the following disclaimer in the |
mbed_official | 67:63988a2238f7 | 17 | * documentation and/or other materials provided with the distribution. |
mbed_official | 68:d3d0e710b443 | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
mbed_official | 68:d3d0e710b443 | 19 | * to endorse or promote products derived from this software without |
mbed_official | 67:63988a2238f7 | 20 | * specific prior written permission. |
mbed_official | 67:63988a2238f7 | 21 | * |
mbed_official | 68:d3d0e710b443 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 68:d3d0e710b443 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 67:63988a2238f7 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
mbed_official | 67:63988a2238f7 | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
mbed_official | 67:63988a2238f7 | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
mbed_official | 68:d3d0e710b443 | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
mbed_official | 68:d3d0e710b443 | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
mbed_official | 68:d3d0e710b443 | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
mbed_official | 68:d3d0e710b443 | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
mbed_official | 67:63988a2238f7 | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 67:63988a2238f7 | 32 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 67:63988a2238f7 | 33 | *---------------------------------------------------------------------------*/ |
mbed_official | 67:63988a2238f7 | 34 | |
mbed_official | 67:63988a2238f7 | 35 | .global rt_set_PSP |
mbed_official | 67:63988a2238f7 | 36 | .global rt_get_PSP |
mbed_official | 67:63988a2238f7 | 37 | .global _alloc_box |
mbed_official | 67:63988a2238f7 | 38 | .global _free_box |
mbed_official | 92:bc9729798a19 | 39 | .global SVC_Handler |
mbed_official | 67:63988a2238f7 | 40 | .global PendSV_Handler |
mbed_official | 67:63988a2238f7 | 41 | .global OS_Tick_Handler |
mbed_official | 67:63988a2238f7 | 42 | |
mbed_official | 92:bc9729798a19 | 43 | /* macro defines form rt_HAL_CA.h */ |
mbed_official | 67:63988a2238f7 | 44 | .EQU CPSR_T_BIT, 0x20 |
mbed_official | 67:63988a2238f7 | 45 | .EQU CPSR_I_BIT, 0x80 |
mbed_official | 67:63988a2238f7 | 46 | .EQU CPSR_F_BIT, 0x40 |
mbed_official | 67:63988a2238f7 | 47 | |
mbed_official | 67:63988a2238f7 | 48 | .EQU MODE_USR, 0x10 |
mbed_official | 67:63988a2238f7 | 49 | .EQU MODE_FIQ, 0x11 |
mbed_official | 67:63988a2238f7 | 50 | .EQU MODE_IRQ, 0x12 |
mbed_official | 67:63988a2238f7 | 51 | .EQU MODE_SVC, 0x13 |
mbed_official | 67:63988a2238f7 | 52 | .EQU MODE_ABT, 0x17 |
mbed_official | 67:63988a2238f7 | 53 | .EQU MODE_UND, 0x1B |
mbed_official | 67:63988a2238f7 | 54 | .EQU MODE_SYS, 0x1F |
mbed_official | 67:63988a2238f7 | 55 | |
mbed_official | 92:bc9729798a19 | 56 | /* macro defines form rt_TypeDef.h */ |
mbed_official | 67:63988a2238f7 | 57 | .EQU TCB_TID, 3 /* 'task id' offset */ |
mbed_official | 92:bc9729798a19 | 58 | .EQU TCB_STACKF, 37 /* 'stack_frame' offset */ |
mbed_official | 92:bc9729798a19 | 59 | .EQU TCB_TSTACK, 44 /* 'tsk_stack' offset for LARGE_STACK */ |
mbed_official | 92:bc9729798a19 | 60 | |
mbed_official | 67:63988a2238f7 | 61 | |
mbed_official | 67:63988a2238f7 | 62 | .extern rt_alloc_box |
mbed_official | 67:63988a2238f7 | 63 | .extern os_tsk |
mbed_official | 67:63988a2238f7 | 64 | .extern GICInterface_BASE |
mbed_official | 67:63988a2238f7 | 65 | .extern rt_pop_req |
mbed_official | 67:63988a2238f7 | 66 | .extern os_tick_irqack |
mbed_official | 67:63988a2238f7 | 67 | .extern rt_systick |
mbed_official | 67:63988a2238f7 | 68 | |
mbed_official | 92:bc9729798a19 | 69 | .text |
mbed_official | 92:bc9729798a19 | 70 | |
mbed_official | 67:63988a2238f7 | 71 | /*---------------------------------------------------------------------------- |
mbed_official | 67:63988a2238f7 | 72 | * Functions |
mbed_official | 67:63988a2238f7 | 73 | *---------------------------------------------------------------------------*/ |
mbed_official | 92:bc9729798a19 | 74 | |
mbed_official | 67:63988a2238f7 | 75 | @ For A-class, set USR/SYS stack |
mbed_official | 67:63988a2238f7 | 76 | @ __asm void rt_set_PSP (U32 stack) { |
mbed_official | 67:63988a2238f7 | 77 | rt_set_PSP: |
mbed_official | 92:bc9729798a19 | 78 | .ARM |
mbed_official | 67:63988a2238f7 | 79 | |
mbed_official | 67:63988a2238f7 | 80 | MRS R1, CPSR |
mbed_official | 67:63988a2238f7 | 81 | CPS #MODE_SYS @no effect in USR mode |
mbed_official | 67:63988a2238f7 | 82 | ISB |
mbed_official | 67:63988a2238f7 | 83 | MOV SP, R0 |
mbed_official | 67:63988a2238f7 | 84 | MSR CPSR_c, R1 @no effect in USR mode |
mbed_official | 67:63988a2238f7 | 85 | ISB |
mbed_official | 67:63988a2238f7 | 86 | BX LR |
mbed_official | 67:63988a2238f7 | 87 | |
mbed_official | 67:63988a2238f7 | 88 | @ } |
mbed_official | 67:63988a2238f7 | 89 | |
mbed_official | 67:63988a2238f7 | 90 | @ For A-class, get USR/SYS stack |
mbed_official | 67:63988a2238f7 | 91 | @ __asm U32 rt_get_PSP (void) { |
mbed_official | 67:63988a2238f7 | 92 | rt_get_PSP: |
mbed_official | 92:bc9729798a19 | 93 | .ARM |
mbed_official | 67:63988a2238f7 | 94 | |
mbed_official | 67:63988a2238f7 | 95 | MRS R1, CPSR |
mbed_official | 67:63988a2238f7 | 96 | CPS #MODE_SYS @no effect in USR mode |
mbed_official | 67:63988a2238f7 | 97 | ISB |
mbed_official | 67:63988a2238f7 | 98 | MOV R0, SP |
mbed_official | 67:63988a2238f7 | 99 | MSR CPSR_c, R1 @no effect in USR mode |
mbed_official | 67:63988a2238f7 | 100 | ISB |
mbed_official | 67:63988a2238f7 | 101 | BX LR |
mbed_official | 67:63988a2238f7 | 102 | @ } |
mbed_official | 67:63988a2238f7 | 103 | |
mbed_official | 67:63988a2238f7 | 104 | /*--------------------------- _alloc_box ------------------------------------*/ |
mbed_official | 67:63988a2238f7 | 105 | @ __asm void *_alloc_box (void *box_mem) { |
mbed_official | 67:63988a2238f7 | 106 | _alloc_box: |
mbed_official | 67:63988a2238f7 | 107 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbed_official | 92:bc9729798a19 | 108 | .ARM |
mbed_official | 67:63988a2238f7 | 109 | |
mbed_official | 92:bc9729798a19 | 110 | LDR R12,=rt_alloc_box |
mbed_official | 67:63988a2238f7 | 111 | MRS R2, CPSR |
mbed_official | 67:63988a2238f7 | 112 | LSLS R2, #28 |
mbed_official | 67:63988a2238f7 | 113 | BXNE R12 |
mbed_official | 67:63988a2238f7 | 114 | SVC 0 |
mbed_official | 67:63988a2238f7 | 115 | BX LR |
mbed_official | 67:63988a2238f7 | 116 | @ } |
mbed_official | 67:63988a2238f7 | 117 | |
mbed_official | 67:63988a2238f7 | 118 | |
mbed_official | 67:63988a2238f7 | 119 | /*--------------------------- _free_box -------------------------------------*/ |
mbed_official | 67:63988a2238f7 | 120 | @ __asm int _free_box (void *box_mem, void *box) { |
mbed_official | 67:63988a2238f7 | 121 | _free_box: |
mbed_official | 67:63988a2238f7 | 122 | /* Function wrapper for Unprivileged/Privileged mode. */ |
mbed_official | 92:bc9729798a19 | 123 | .ARM |
mbed_official | 67:63988a2238f7 | 124 | |
mbed_official | 92:bc9729798a19 | 125 | LDR R12,=rt_free_box |
mbed_official | 67:63988a2238f7 | 126 | MRS R2, CPSR |
mbed_official | 67:63988a2238f7 | 127 | LSLS R2, #28 |
mbed_official | 67:63988a2238f7 | 128 | BXNE R12 |
mbed_official | 67:63988a2238f7 | 129 | SVC 0 |
mbed_official | 67:63988a2238f7 | 130 | BX LR |
mbed_official | 67:63988a2238f7 | 131 | |
mbed_official | 67:63988a2238f7 | 132 | @ } |
mbed_official | 67:63988a2238f7 | 133 | |
mbed_official | 67:63988a2238f7 | 134 | /*-------------------------- SVC_Handler -----------------------------------*/ |
mbed_official | 67:63988a2238f7 | 135 | |
mbed_official | 67:63988a2238f7 | 136 | @ #pragma push |
mbed_official | 67:63988a2238f7 | 137 | @ #pragma arm |
mbed_official | 67:63988a2238f7 | 138 | @ __asm void SVC_Handler (void) { |
mbed_official | 92:bc9729798a19 | 139 | SVC_Handler: |
mbed_official | 92:bc9729798a19 | 140 | .eabi_attribute Tag_ABI_align8_preserved,1 |
mbed_official | 92:bc9729798a19 | 141 | .ARM |
mbed_official | 67:63988a2238f7 | 142 | |
mbed_official | 67:63988a2238f7 | 143 | .extern rt_tsk_lock |
mbed_official | 67:63988a2238f7 | 144 | .extern rt_tsk_unlock |
mbed_official | 67:63988a2238f7 | 145 | .extern SVC_Count |
mbed_official | 67:63988a2238f7 | 146 | .extern SVC_Table |
mbed_official | 67:63988a2238f7 | 147 | .extern rt_stk_check |
mbed_official | 67:63988a2238f7 | 148 | .extern FPUEnable |
mbed_official | 92:bc9729798a19 | 149 | .extern scheduler_suspended @ flag set by rt_suspend, cleared by rt_resume, read by SVC_Handler |
mbed_official | 67:63988a2238f7 | 150 | |
mbed_official | 67:63988a2238f7 | 151 | .EQU Mode_SVC, 0x13 |
mbed_official | 67:63988a2238f7 | 152 | |
mbed_official | 92:bc9729798a19 | 153 | SRSDB SP!, #Mode_SVC @ Push LR_SVC and SPRS_SVC onto SVC mode stack @ Use SRSDB because SRSFD isn't supported by GCC-ARM. |
mbed_official | 67:63988a2238f7 | 154 | PUSH {R4} @ Push R4 so we can use it as a temp |
mbed_official | 67:63988a2238f7 | 155 | |
mbed_official | 67:63988a2238f7 | 156 | MRS R4,SPSR @ Get SPSR |
mbed_official | 67:63988a2238f7 | 157 | TST R4,#CPSR_T_BIT @ Check Thumb Bit |
mbed_official | 67:63988a2238f7 | 158 | LDRNEH R4,[LR,#-2] @ Thumb: Load Halfword |
mbed_official | 67:63988a2238f7 | 159 | BICNE R4,R4,#0xFF00 @ Extract SVC Number |
mbed_official | 67:63988a2238f7 | 160 | LDREQ R4,[LR,#-4] @ ARM: Load Word |
mbed_official | 67:63988a2238f7 | 161 | BICEQ R4,R4,#0xFF000000 @ Extract SVC Number |
mbed_official | 67:63988a2238f7 | 162 | |
mbed_official | 67:63988a2238f7 | 163 | /* Lock out systick and re-enable interrupts */ |
mbed_official | 67:63988a2238f7 | 164 | PUSH {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 165 | |
mbed_official | 67:63988a2238f7 | 166 | AND R12, SP, #4 @ Ensure stack is 8-byte aligned |
mbed_official | 67:63988a2238f7 | 167 | SUB SP, SP, R12 @ Adjust stack |
mbed_official | 67:63988a2238f7 | 168 | PUSH {R12, LR} @ Store stack adjustment and dummy LR to SVC stack |
mbed_official | 67:63988a2238f7 | 169 | |
mbed_official | 67:63988a2238f7 | 170 | BLX rt_tsk_lock |
mbed_official | 67:63988a2238f7 | 171 | CPSIE i |
mbed_official | 67:63988a2238f7 | 172 | |
mbed_official | 67:63988a2238f7 | 173 | POP {R12, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 174 | ADD SP, SP, R12 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 175 | |
mbed_official | 67:63988a2238f7 | 176 | POP {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 177 | |
mbed_official | 67:63988a2238f7 | 178 | CMP R4,#0 |
mbed_official | 67:63988a2238f7 | 179 | BNE SVC_User |
mbed_official | 67:63988a2238f7 | 180 | |
mbed_official | 67:63988a2238f7 | 181 | MRS R4,SPSR |
mbed_official | 67:63988a2238f7 | 182 | PUSH {R4} @ Push R4 so we can use it as a temp |
mbed_official | 67:63988a2238f7 | 183 | AND R4, SP, #4 @ Ensure stack is 8-byte aligned |
mbed_official | 67:63988a2238f7 | 184 | SUB SP, SP, R4 @ Adjust stack |
mbed_official | 67:63988a2238f7 | 185 | PUSH {R4, LR} @ Store stack adjustment and dummy LR |
mbed_official | 67:63988a2238f7 | 186 | BLX R12 |
mbed_official | 67:63988a2238f7 | 187 | POP {R4, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 188 | ADD SP, SP, R4 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 189 | POP {R4} @ Restore R4 |
mbed_official | 67:63988a2238f7 | 190 | MSR SPSR_cxsf,R4 |
mbed_official | 67:63988a2238f7 | 191 | |
mbed_official | 67:63988a2238f7 | 192 | /* Here we will be in SVC mode (even if coming in from PendSV_Handler or OS_Tick_Handler) */ |
mbed_official | 67:63988a2238f7 | 193 | Sys_Switch: |
mbed_official | 92:bc9729798a19 | 194 | LDR LR,=os_tsk |
mbed_official | 92:bc9729798a19 | 195 | LDM LR,{R4,LR} @ os_tsk.run, os_tsk.new_tsk |
mbed_official | 67:63988a2238f7 | 196 | CMP R4,LR |
mbed_official | 67:63988a2238f7 | 197 | BNE switching |
mbed_official | 67:63988a2238f7 | 198 | |
mbed_official | 67:63988a2238f7 | 199 | PUSH {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 200 | |
mbed_official | 67:63988a2238f7 | 201 | AND R12, SP, #4 @ Ensure stack is 8-byte aligned |
mbed_official | 67:63988a2238f7 | 202 | SUB SP, SP, R12 @ Adjust stack |
mbed_official | 67:63988a2238f7 | 203 | PUSH {R12, LR} @ Store stack adjustment and dummy LR to SVC stack |
mbed_official | 67:63988a2238f7 | 204 | |
mbed_official | 67:63988a2238f7 | 205 | CPSID i |
mbed_official | 92:bc9729798a19 | 206 | @ Do not unlock scheduler if it has just been suspended by rt_suspend() |
mbed_official | 92:bc9729798a19 | 207 | LDR R1,=scheduler_suspended |
mbed_official | 92:bc9729798a19 | 208 | LDRB R0, [R1] |
mbed_official | 92:bc9729798a19 | 209 | CMP R0, #1 |
mbed_official | 92:bc9729798a19 | 210 | BEQ dont_unlock |
mbed_official | 67:63988a2238f7 | 211 | BLX rt_tsk_unlock |
mbed_official | 92:bc9729798a19 | 212 | dont_unlock: |
mbed_official | 67:63988a2238f7 | 213 | |
mbed_official | 67:63988a2238f7 | 214 | POP {R12, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 215 | ADD SP, SP, R12 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 216 | |
mbed_official | 67:63988a2238f7 | 217 | POP {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 218 | POP {R4} |
mbed_official | 67:63988a2238f7 | 219 | RFEFD SP! @ Return from exception, no task switch |
mbed_official | 67:63988a2238f7 | 220 | |
mbed_official | 67:63988a2238f7 | 221 | switching: |
mbed_official | 67:63988a2238f7 | 222 | CLREX |
mbed_official | 67:63988a2238f7 | 223 | CMP R4,#0 |
mbed_official | 67:63988a2238f7 | 224 | ADDEQ SP,SP,#12 @ Original R4, LR & SPSR do not need to be popped when we are paging in a different task |
mbed_official | 67:63988a2238f7 | 225 | BEQ SVC_Next @ Runtask deleted? |
mbed_official | 67:63988a2238f7 | 226 | |
mbed_official | 67:63988a2238f7 | 227 | |
mbed_official | 67:63988a2238f7 | 228 | PUSH {R8-R11} @ R4 and LR already stacked |
mbed_official | 67:63988a2238f7 | 229 | MOV R10,R4 @ Preserve os_tsk.run |
mbed_official | 92:bc9729798a19 | 230 | MOV R11,LR @ Preserve os_tsk.new_tsk |
mbed_official | 67:63988a2238f7 | 231 | |
mbed_official | 67:63988a2238f7 | 232 | ADD R8,SP,#16 @ Unstack R4,LR |
mbed_official | 67:63988a2238f7 | 233 | LDMIA R8,{R4,LR} |
mbed_official | 67:63988a2238f7 | 234 | |
mbed_official | 67:63988a2238f7 | 235 | SUB SP,SP,#4 @ Make space on the stack for the next instn |
mbed_official | 67:63988a2238f7 | 236 | STMIA SP,{SP}^ @ Put User SP onto stack |
mbed_official | 67:63988a2238f7 | 237 | POP {R8} @ Pop User SP into R8 |
mbed_official | 67:63988a2238f7 | 238 | |
mbed_official | 67:63988a2238f7 | 239 | MRS R9,SPSR |
mbed_official | 67:63988a2238f7 | 240 | STMDB R8!,{R9} @ User CPSR |
mbed_official | 67:63988a2238f7 | 241 | STMDB R8!,{LR} @ User PC |
mbed_official | 67:63988a2238f7 | 242 | STMDB R8,{LR}^ @ User LR |
mbed_official | 67:63988a2238f7 | 243 | SUB R8,R8,#4 @ No writeback for store of User LR |
mbed_official | 67:63988a2238f7 | 244 | STMDB R8!,{R0-R3,R12} @ User R0-R3,R12 |
mbed_official | 67:63988a2238f7 | 245 | MOV R3,R10 @ os_tsk.run |
mbed_official | 92:bc9729798a19 | 246 | MOV LR,R11 @ os_tsk.new_tsk |
mbed_official | 67:63988a2238f7 | 247 | POP {R9-R12} |
mbed_official | 67:63988a2238f7 | 248 | ADD SP,SP,#12 @ Fix up SP for unstack of R4, LR & SPSR |
mbed_official | 67:63988a2238f7 | 249 | STMDB R8!,{R4-R7,R9-R12} @ User R4-R11 |
mbed_official | 67:63988a2238f7 | 250 | |
mbed_official | 92:bc9729798a19 | 251 | @ If applicable, stack VFP/NEON state |
mbed_official | 67:63988a2238f7 | 252 | MRC p15,0,R1,c1,c0,2 @ VFP/NEON access enabled? (CPACR) |
mbed_official | 67:63988a2238f7 | 253 | AND R2,R1,#0x00F00000 |
mbed_official | 67:63988a2238f7 | 254 | CMP R2,#0x00F00000 |
mbed_official | 67:63988a2238f7 | 255 | BNE no_outgoing_vfp |
mbed_official | 67:63988a2238f7 | 256 | VMRS R2,FPSCR |
mbed_official | 67:63988a2238f7 | 257 | STMDB R8!,{R2,R4} @ Push FPSCR, maintain 8-byte alignment |
mbed_official | 92:bc9729798a19 | 258 | VSTMDB R8!,{D0-D15} |
mbed_official | 92:bc9729798a19 | 259 | VSTMDB R8!,{D16-D31} |
mbed_official | 92:bc9729798a19 | 260 | LDRB R2,[R3,#TCB_STACKF] @ Record in TCB that NEON/D32 state is stacked |
mbed_official | 92:bc9729798a19 | 261 | ORR R2,#4 |
mbed_official | 67:63988a2238f7 | 262 | STRB R2,[R3,#TCB_STACKF] |
mbed_official | 67:63988a2238f7 | 263 | |
mbed_official | 67:63988a2238f7 | 264 | no_outgoing_vfp: |
mbed_official | 67:63988a2238f7 | 265 | STR R8,[R3,#TCB_TSTACK] |
mbed_official | 67:63988a2238f7 | 266 | MOV R4,LR |
mbed_official | 67:63988a2238f7 | 267 | |
mbed_official | 67:63988a2238f7 | 268 | PUSH {R4} @ Push R4 so we can use it as a temp |
mbed_official | 67:63988a2238f7 | 269 | AND R4, SP, #4 @ Ensure stack is 8-byte aligned |
mbed_official | 67:63988a2238f7 | 270 | SUB SP, SP, R4 @ Adjust stack |
mbed_official | 67:63988a2238f7 | 271 | PUSH {R4, LR} @ Store stack adjustment and dummy LR to SVC stack |
mbed_official | 67:63988a2238f7 | 272 | |
mbed_official | 67:63988a2238f7 | 273 | BLX rt_stk_check |
mbed_official | 67:63988a2238f7 | 274 | |
mbed_official | 67:63988a2238f7 | 275 | POP {R4, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 276 | ADD SP, SP, R4 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 277 | POP {R4} @ Restore R4 |
mbed_official | 67:63988a2238f7 | 278 | |
mbed_official | 67:63988a2238f7 | 279 | MOV LR,R4 |
mbed_official | 67:63988a2238f7 | 280 | |
mbed_official | 92:bc9729798a19 | 281 | SVC_Next: @ R4 == os_tsk.run, LR == os_tsk.new_tsk, R0-R3, R5-R12 corruptible |
mbed_official | 92:bc9729798a19 | 282 | LDR R1,=os_tsk @ os_tsk.run = os_tsk.new_tsk |
mbed_official | 67:63988a2238f7 | 283 | STR LR,[R1] |
mbed_official | 67:63988a2238f7 | 284 | LDRB R1,[LR,#TCB_TID] @ os_tsk.run->task_id |
mbed_official | 67:63988a2238f7 | 285 | LSL R1,#8 @ Store PROCID |
mbed_official | 67:63988a2238f7 | 286 | MCR p15,0,R1,c13,c0,1 @ Write CONTEXTIDR |
mbed_official | 67:63988a2238f7 | 287 | |
mbed_official | 67:63988a2238f7 | 288 | LDR R0,[LR,#TCB_TSTACK] @ os_tsk.run->tsk_stack |
mbed_official | 67:63988a2238f7 | 289 | |
mbed_official | 92:bc9729798a19 | 290 | @ Does incoming task have VFP/NEON state in stack? |
mbed_official | 67:63988a2238f7 | 291 | LDRB R3,[LR,#TCB_STACKF] |
mbed_official | 92:bc9729798a19 | 292 | ANDS R3, R3, #0x6 |
mbed_official | 67:63988a2238f7 | 293 | MRC p15,0,R1,c1,c0,2 @ Read CPACR |
mbed_official | 92:bc9729798a19 | 294 | ANDEQ R1,R1,#0xFF0FFFFF @ Disable VFP/NEON access if incoming task does not have stacked VFP/NEON state |
mbed_official | 92:bc9729798a19 | 295 | ORRNE R1,R1,#0x00F00000 @ Enable VFP/NEON access if incoming task does have stacked VFP/NEON state |
mbed_official | 67:63988a2238f7 | 296 | MCR p15,0,R1,c1,c0,2 @ Write CPACR |
mbed_official | 67:63988a2238f7 | 297 | BEQ no_incoming_vfp |
mbed_official | 92:bc9729798a19 | 298 | ISB @ We only need the sync if we enabled, otherwise we will context switch before next VFP/NEON instruction anyway |
mbed_official | 92:bc9729798a19 | 299 | VLDMIA R0!,{D16-D31} |
mbed_official | 92:bc9729798a19 | 300 | VLDMIA R0!,{D0-D15} |
mbed_official | 67:63988a2238f7 | 301 | LDR R2,[R0] |
mbed_official | 67:63988a2238f7 | 302 | VMSR FPSCR,R2 |
mbed_official | 67:63988a2238f7 | 303 | ADD R0,R0,#8 |
mbed_official | 67:63988a2238f7 | 304 | |
mbed_official | 67:63988a2238f7 | 305 | no_incoming_vfp: |
mbed_official | 67:63988a2238f7 | 306 | LDR R1,[R0,#60] @ Restore User CPSR |
mbed_official | 67:63988a2238f7 | 307 | MSR SPSR_cxsf,R1 |
mbed_official | 67:63988a2238f7 | 308 | LDMIA R0!,{R4-R11} @ Restore User R4-R11 |
mbed_official | 67:63988a2238f7 | 309 | ADD R0,R0,#4 @ Restore User R1-R3,R12 |
mbed_official | 67:63988a2238f7 | 310 | LDMIA R0!,{R1-R3,R12} |
mbed_official | 67:63988a2238f7 | 311 | LDMIA R0,{LR}^ @ Restore User LR |
mbed_official | 67:63988a2238f7 | 312 | ADD R0,R0,#4 @ No writeback for load to user LR |
mbed_official | 67:63988a2238f7 | 313 | LDMIA R0!,{LR} @ Restore User PC |
mbed_official | 67:63988a2238f7 | 314 | ADD R0,R0,#4 @ Correct User SP for unstacked user CPSR |
mbed_official | 67:63988a2238f7 | 315 | |
mbed_official | 67:63988a2238f7 | 316 | PUSH {R0} @ Push R0 onto stack |
mbed_official | 67:63988a2238f7 | 317 | LDMIA SP,{SP}^ @ Get R0 off stack into User SP |
mbed_official | 67:63988a2238f7 | 318 | ADD SP,SP,#4 @ Put SP back |
mbed_official | 67:63988a2238f7 | 319 | |
mbed_official | 67:63988a2238f7 | 320 | LDR R0,[R0,#-32] @ Restore R0 |
mbed_official | 67:63988a2238f7 | 321 | |
mbed_official | 67:63988a2238f7 | 322 | PUSH {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 323 | |
mbed_official | 67:63988a2238f7 | 324 | AND R12, SP, #4 @ Ensure stack is 8-byte aligned |
mbed_official | 67:63988a2238f7 | 325 | SUB SP, SP, R12 @ Adjust stack |
mbed_official | 67:63988a2238f7 | 326 | PUSH {R12, LR} @ Store stack adjustment and dummy LR to SVC stack |
mbed_official | 67:63988a2238f7 | 327 | |
mbed_official | 67:63988a2238f7 | 328 | CPSID i |
mbed_official | 67:63988a2238f7 | 329 | BLX rt_tsk_unlock |
mbed_official | 67:63988a2238f7 | 330 | |
mbed_official | 67:63988a2238f7 | 331 | POP {R12, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 332 | ADD SP, SP, R12 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 333 | |
mbed_official | 67:63988a2238f7 | 334 | POP {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 335 | |
mbed_official | 67:63988a2238f7 | 336 | MOVS PC,LR @ Return from exception |
mbed_official | 67:63988a2238f7 | 337 | |
mbed_official | 67:63988a2238f7 | 338 | |
mbed_official | 67:63988a2238f7 | 339 | /*------------------- User SVC -------------------------------*/ |
mbed_official | 67:63988a2238f7 | 340 | |
mbed_official | 67:63988a2238f7 | 341 | SVC_User: |
mbed_official | 67:63988a2238f7 | 342 | LDR R12,=SVC_Count |
mbed_official | 67:63988a2238f7 | 343 | LDR R12,[R12] |
mbed_official | 67:63988a2238f7 | 344 | CMP R4,R12 @ Check for overflow |
mbed_official | 67:63988a2238f7 | 345 | BHI SVC_Done |
mbed_official | 67:63988a2238f7 | 346 | |
mbed_official | 67:63988a2238f7 | 347 | LDR R12,=SVC_Table-4 |
mbed_official | 67:63988a2238f7 | 348 | LDR R12,[R12,R4,LSL #2] @ Load SVC Function Address |
mbed_official | 67:63988a2238f7 | 349 | MRS R4,SPSR @ Save SPSR |
mbed_official | 67:63988a2238f7 | 350 | PUSH {R4} @ Push R4 so we can use it as a temp |
mbed_official | 67:63988a2238f7 | 351 | AND R4, SP, #4 @ Ensure stack is 8-byte aligned |
mbed_official | 67:63988a2238f7 | 352 | SUB SP, SP, R4 @ Adjust stack |
mbed_official | 67:63988a2238f7 | 353 | PUSH {R4, LR} @ Store stack adjustment and dummy LR |
mbed_official | 67:63988a2238f7 | 354 | BLX R12 @ Call SVC Function |
mbed_official | 67:63988a2238f7 | 355 | POP {R4, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 356 | ADD SP, SP, R4 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 357 | POP {R4} @ Restore R4 |
mbed_official | 67:63988a2238f7 | 358 | MSR SPSR_cxsf,R4 @ Restore SPSR |
mbed_official | 67:63988a2238f7 | 359 | |
mbed_official | 67:63988a2238f7 | 360 | SVC_Done: |
mbed_official | 67:63988a2238f7 | 361 | PUSH {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 362 | |
mbed_official | 67:63988a2238f7 | 363 | PUSH {R4} @ Push R4 so we can use it as a temp |
mbed_official | 67:63988a2238f7 | 364 | AND R4, SP, #4 @ Ensure stack is 8-byte aligned |
mbed_official | 67:63988a2238f7 | 365 | SUB SP, SP, R4 @ Adjust stack |
mbed_official | 67:63988a2238f7 | 366 | PUSH {R4, LR} @ Store stack adjustment and dummy LR |
mbed_official | 67:63988a2238f7 | 367 | |
mbed_official | 67:63988a2238f7 | 368 | CPSID i |
mbed_official | 67:63988a2238f7 | 369 | BLX rt_tsk_unlock |
mbed_official | 67:63988a2238f7 | 370 | |
mbed_official | 67:63988a2238f7 | 371 | POP {R4, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 372 | ADD SP, SP, R4 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 373 | POP {R4} @ Restore R4 |
mbed_official | 67:63988a2238f7 | 374 | |
mbed_official | 67:63988a2238f7 | 375 | POP {R0-R3,R12,LR} |
mbed_official | 67:63988a2238f7 | 376 | POP {R4} |
mbed_official | 67:63988a2238f7 | 377 | RFEFD SP! @ Return from exception |
mbed_official | 67:63988a2238f7 | 378 | @ } |
mbed_official | 67:63988a2238f7 | 379 | @ #pragma pop |
mbed_official | 67:63988a2238f7 | 380 | |
mbed_official | 67:63988a2238f7 | 381 | @ #pragma push |
mbed_official | 67:63988a2238f7 | 382 | @ #pragma arm |
mbed_official | 67:63988a2238f7 | 383 | @ __asm void PendSV_Handler (U32 IRQn) { |
mbed_official | 67:63988a2238f7 | 384 | PendSV_Handler: |
mbed_official | 92:bc9729798a19 | 385 | .ARM |
mbed_official | 67:63988a2238f7 | 386 | |
mbed_official | 67:63988a2238f7 | 387 | .extern rt_tsk_lock |
mbed_official | 92:bc9729798a19 | 388 | .extern IRQNestLevel @ Flag indicates whether inside an ISR, and the depth of nesting. 0 = not in ISR. |
mbed_official | 92:bc9729798a19 | 389 | .extern seen_id0_active @ Flag used to workaround GIC 390 errata 733075 - set in startup_Renesas_RZ_A1.s |
mbed_official | 67:63988a2238f7 | 390 | |
mbed_official | 67:63988a2238f7 | 391 | ADD SP,SP,#8 @ fix up stack pointer (R0 has been pushed and will never be popped, R1 was pushed for stack alignment) |
mbed_official | 67:63988a2238f7 | 392 | |
mbed_official | 67:63988a2238f7 | 393 | @ Disable systick interrupts, then write EOIR. We want interrupts disabled before we enter the context switcher. |
mbed_official | 67:63988a2238f7 | 394 | PUSH {R0, R1} |
mbed_official | 67:63988a2238f7 | 395 | BLX rt_tsk_lock |
mbed_official | 67:63988a2238f7 | 396 | POP {R0, R1} |
mbed_official | 92:bc9729798a19 | 397 | LDR R1, =GICInterface_BASE |
mbed_official | 67:63988a2238f7 | 398 | LDR R1, [R1, #0] |
mbed_official | 67:63988a2238f7 | 399 | STR R0, [R1, #0x10] |
mbed_official | 67:63988a2238f7 | 400 | |
mbed_official | 92:bc9729798a19 | 401 | @ If it was interrupt ID0, clear the seen flag, otherwise return as normal |
mbed_official | 92:bc9729798a19 | 402 | CMP R0, #0 |
mbed_official | 92:bc9729798a19 | 403 | LDREQ R1, =seen_id0_active |
mbed_official | 92:bc9729798a19 | 404 | STREQB R0, [R1] @ Clear the seen flag, using R0 (which is 0), to save loading another register |
mbed_official | 92:bc9729798a19 | 405 | |
mbed_official | 67:63988a2238f7 | 406 | LDR R0, =IRQNestLevel @ Get address of nesting counter |
mbed_official | 67:63988a2238f7 | 407 | LDR R1, [R0] |
mbed_official | 67:63988a2238f7 | 408 | SUB R1, R1, #1 @ Decrement nesting counter |
mbed_official | 67:63988a2238f7 | 409 | STR R1, [R0] |
mbed_official | 67:63988a2238f7 | 410 | |
mbed_official | 92:bc9729798a19 | 411 | BLX rt_pop_req |
mbed_official | 67:63988a2238f7 | 412 | |
mbed_official | 67:63988a2238f7 | 413 | POP {R1, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 414 | ADD SP, SP, R1 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 415 | |
mbed_official | 67:63988a2238f7 | 416 | LDR R0,[SP,#24] |
mbed_official | 67:63988a2238f7 | 417 | MSR SPSR_cxsf,R0 |
mbed_official | 67:63988a2238f7 | 418 | POP {R0-R3,R12} @ Leave SPSR & LR on the stack |
mbed_official | 67:63988a2238f7 | 419 | PUSH {R4} |
mbed_official | 67:63988a2238f7 | 420 | B Sys_Switch |
mbed_official | 67:63988a2238f7 | 421 | @ } |
mbed_official | 67:63988a2238f7 | 422 | @ #pragma pop |
mbed_official | 67:63988a2238f7 | 423 | |
mbed_official | 92:bc9729798a19 | 424 | |
mbed_official | 67:63988a2238f7 | 425 | @ #pragma push |
mbed_official | 67:63988a2238f7 | 426 | @ #pragma arm |
mbed_official | 67:63988a2238f7 | 427 | @ __asm void OS_Tick_Handler (U32 IRQn) { |
mbed_official | 67:63988a2238f7 | 428 | OS_Tick_Handler: |
mbed_official | 92:bc9729798a19 | 429 | .ARM |
mbed_official | 92:bc9729798a19 | 430 | |
mbed_official | 92:bc9729798a19 | 431 | .extern rt_tsk_lock |
mbed_official | 92:bc9729798a19 | 432 | .extern IRQNestLevel @ Flag indicates whether inside an ISR, and the depth of nesting. 0 = not in ISR. |
mbed_official | 92:bc9729798a19 | 433 | .extern seen_id0_active @ Flag used to workaround GIC 390 errata 733075 - set in startup_Renesas_RZ_A1.s |
mbed_official | 67:63988a2238f7 | 434 | |
mbed_official | 67:63988a2238f7 | 435 | ADD SP,SP,#8 @ fix up stack pointer (R0 has been pushed and will never be popped, R1 was pushed for stack alignment) |
mbed_official | 67:63988a2238f7 | 436 | |
mbed_official | 67:63988a2238f7 | 437 | PUSH {R0, R1} |
mbed_official | 67:63988a2238f7 | 438 | BLX rt_tsk_lock |
mbed_official | 67:63988a2238f7 | 439 | POP {R0, R1} |
mbed_official | 92:bc9729798a19 | 440 | LDR R1, =GICInterface_BASE |
mbed_official | 67:63988a2238f7 | 441 | LDR R1, [R1, #0] |
mbed_official | 67:63988a2238f7 | 442 | STR R0, [R1, #0x10] |
mbed_official | 67:63988a2238f7 | 443 | |
mbed_official | 92:bc9729798a19 | 444 | @ If it was interrupt ID0, clear the seen flag, otherwise return as normal |
mbed_official | 92:bc9729798a19 | 445 | CMP R0, #0 |
mbed_official | 92:bc9729798a19 | 446 | LDREQ R1, =seen_id0_active |
mbed_official | 92:bc9729798a19 | 447 | STREQB R0, [R1] @ Clear the seen flag, using R0 (which is 0), to save loading another register |
mbed_official | 92:bc9729798a19 | 448 | |
mbed_official | 67:63988a2238f7 | 449 | LDR R0, =IRQNestLevel @ Get address of nesting counter |
mbed_official | 67:63988a2238f7 | 450 | LDR R1, [R0] |
mbed_official | 67:63988a2238f7 | 451 | SUB R1, R1, #1 @ Decrement nesting counter |
mbed_official | 67:63988a2238f7 | 452 | STR R1, [R0] |
mbed_official | 67:63988a2238f7 | 453 | |
mbed_official | 92:bc9729798a19 | 454 | BLX os_tick_irqack |
mbed_official | 92:bc9729798a19 | 455 | BLX rt_systick |
mbed_official | 67:63988a2238f7 | 456 | |
mbed_official | 67:63988a2238f7 | 457 | POP {R1, LR} @ Get stack adjustment & discard dummy LR |
mbed_official | 67:63988a2238f7 | 458 | ADD SP, SP, R1 @ Unadjust stack |
mbed_official | 67:63988a2238f7 | 459 | |
mbed_official | 67:63988a2238f7 | 460 | LDR R0,[SP,#24] |
mbed_official | 67:63988a2238f7 | 461 | MSR SPSR_cxsf,R0 |
mbed_official | 67:63988a2238f7 | 462 | POP {R0-R3,R12} @ Leave SPSR & LR on the stack |
mbed_official | 67:63988a2238f7 | 463 | PUSH {R4} |
mbed_official | 67:63988a2238f7 | 464 | B Sys_Switch |
mbed_official | 67:63988a2238f7 | 465 | @ } |
mbed_official | 67:63988a2238f7 | 466 | @ #pragma pop |
mbed_official | 67:63988a2238f7 | 467 | |
mbed_official | 67:63988a2238f7 | 468 | |
mbed_official | 67:63988a2238f7 | 469 | .END |
mbed_official | 67:63988a2238f7 | 470 | /*---------------------------------------------------------------------------- |
mbed_official | 67:63988a2238f7 | 471 | * end of file |
mbed_official | 67:63988a2238f7 | 472 | *---------------------------------------------------------------------------*/ |