meh
Fork of mbed by
TARGET_LPC2368/core_caFunc.h@95:7e07b6fb45cf, 2015-03-04 (annotated)
- Committer:
- Kojto
- Date:
- Wed Mar 04 07:31:39 2015 +0100
- Revision:
- 95:7e07b6fb45cf
- Parent:
- 92:4fc01daae5a5
- Child:
- 108:34e6b704fe68
Release 95 of the mbed library
Main changes:
- new platform: APPNEARME_MICRONFCBOARD
- LPC 8xx - us ticker and pwm out fixes
- RZ_A1H - GCC support, fixes in Ticker and Serial
- IAR - stack and heap corrections for few targets
- us ticker - get next timestamp function addition
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 92:4fc01daae5a5 | 1 | /**************************************************************************//** |
bogdanm | 92:4fc01daae5a5 | 2 | * @file core_caFunc.h |
bogdanm | 92:4fc01daae5a5 | 3 | * @brief CMSIS Cortex-A Core Function Access Header File |
bogdanm | 92:4fc01daae5a5 | 4 | * @version V3.10 |
bogdanm | 92:4fc01daae5a5 | 5 | * @date 9 May 2013 |
bogdanm | 92:4fc01daae5a5 | 6 | * |
bogdanm | 92:4fc01daae5a5 | 7 | * @note |
bogdanm | 92:4fc01daae5a5 | 8 | * |
bogdanm | 92:4fc01daae5a5 | 9 | ******************************************************************************/ |
bogdanm | 92:4fc01daae5a5 | 10 | /* Copyright (c) 2009 - 2012 ARM LIMITED |
bogdanm | 92:4fc01daae5a5 | 11 | |
bogdanm | 92:4fc01daae5a5 | 12 | All rights reserved. |
bogdanm | 92:4fc01daae5a5 | 13 | Redistribution and use in source and binary forms, with or without |
bogdanm | 92:4fc01daae5a5 | 14 | modification, are permitted provided that the following conditions are met: |
bogdanm | 92:4fc01daae5a5 | 15 | - Redistributions of source code must retain the above copyright |
bogdanm | 92:4fc01daae5a5 | 16 | notice, this list of conditions and the following disclaimer. |
bogdanm | 92:4fc01daae5a5 | 17 | - Redistributions in binary form must reproduce the above copyright |
bogdanm | 92:4fc01daae5a5 | 18 | notice, this list of conditions and the following disclaimer in the |
bogdanm | 92:4fc01daae5a5 | 19 | documentation and/or other materials provided with the distribution. |
bogdanm | 92:4fc01daae5a5 | 20 | - Neither the name of ARM nor the names of its contributors may be used |
bogdanm | 92:4fc01daae5a5 | 21 | to endorse or promote products derived from this software without |
bogdanm | 92:4fc01daae5a5 | 22 | specific prior written permission. |
bogdanm | 92:4fc01daae5a5 | 23 | * |
bogdanm | 92:4fc01daae5a5 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 92:4fc01daae5a5 | 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 92:4fc01daae5a5 | 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
bogdanm | 92:4fc01daae5a5 | 27 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
bogdanm | 92:4fc01daae5a5 | 28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
bogdanm | 92:4fc01daae5a5 | 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
bogdanm | 92:4fc01daae5a5 | 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
bogdanm | 92:4fc01daae5a5 | 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
bogdanm | 92:4fc01daae5a5 | 32 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
bogdanm | 92:4fc01daae5a5 | 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
bogdanm | 92:4fc01daae5a5 | 34 | POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 92:4fc01daae5a5 | 35 | ---------------------------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 36 | |
bogdanm | 92:4fc01daae5a5 | 37 | |
bogdanm | 92:4fc01daae5a5 | 38 | #ifndef __CORE_CAFUNC_H__ |
bogdanm | 92:4fc01daae5a5 | 39 | #define __CORE_CAFUNC_H__ |
bogdanm | 92:4fc01daae5a5 | 40 | |
bogdanm | 92:4fc01daae5a5 | 41 | |
bogdanm | 92:4fc01daae5a5 | 42 | /* ########################### Core Function Access ########################### */ |
bogdanm | 92:4fc01daae5a5 | 43 | /** \ingroup CMSIS_Core_FunctionInterface |
bogdanm | 92:4fc01daae5a5 | 44 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions |
bogdanm | 92:4fc01daae5a5 | 45 | @{ |
bogdanm | 92:4fc01daae5a5 | 46 | */ |
bogdanm | 92:4fc01daae5a5 | 47 | |
bogdanm | 92:4fc01daae5a5 | 48 | #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ |
bogdanm | 92:4fc01daae5a5 | 49 | /* ARM armcc specific functions */ |
bogdanm | 92:4fc01daae5a5 | 50 | |
bogdanm | 92:4fc01daae5a5 | 51 | #if (__ARMCC_VERSION < 400677) |
bogdanm | 92:4fc01daae5a5 | 52 | #error "Please use ARM Compiler Toolchain V4.0.677 or later!" |
bogdanm | 92:4fc01daae5a5 | 53 | #endif |
bogdanm | 92:4fc01daae5a5 | 54 | |
bogdanm | 92:4fc01daae5a5 | 55 | #define MODE_USR 0x10 |
bogdanm | 92:4fc01daae5a5 | 56 | #define MODE_FIQ 0x11 |
bogdanm | 92:4fc01daae5a5 | 57 | #define MODE_IRQ 0x12 |
bogdanm | 92:4fc01daae5a5 | 58 | #define MODE_SVC 0x13 |
bogdanm | 92:4fc01daae5a5 | 59 | #define MODE_MON 0x16 |
bogdanm | 92:4fc01daae5a5 | 60 | #define MODE_ABT 0x17 |
bogdanm | 92:4fc01daae5a5 | 61 | #define MODE_HYP 0x1A |
bogdanm | 92:4fc01daae5a5 | 62 | #define MODE_UND 0x1B |
bogdanm | 92:4fc01daae5a5 | 63 | #define MODE_SYS 0x1F |
bogdanm | 92:4fc01daae5a5 | 64 | |
bogdanm | 92:4fc01daae5a5 | 65 | /** \brief Get APSR Register |
bogdanm | 92:4fc01daae5a5 | 66 | |
bogdanm | 92:4fc01daae5a5 | 67 | This function returns the content of the APSR Register. |
bogdanm | 92:4fc01daae5a5 | 68 | |
bogdanm | 92:4fc01daae5a5 | 69 | \return APSR Register value |
bogdanm | 92:4fc01daae5a5 | 70 | */ |
bogdanm | 92:4fc01daae5a5 | 71 | __STATIC_INLINE uint32_t __get_APSR(void) |
bogdanm | 92:4fc01daae5a5 | 72 | { |
bogdanm | 92:4fc01daae5a5 | 73 | register uint32_t __regAPSR __ASM("apsr"); |
bogdanm | 92:4fc01daae5a5 | 74 | return(__regAPSR); |
bogdanm | 92:4fc01daae5a5 | 75 | } |
bogdanm | 92:4fc01daae5a5 | 76 | |
bogdanm | 92:4fc01daae5a5 | 77 | |
bogdanm | 92:4fc01daae5a5 | 78 | /** \brief Get CPSR Register |
bogdanm | 92:4fc01daae5a5 | 79 | |
bogdanm | 92:4fc01daae5a5 | 80 | This function returns the content of the CPSR Register. |
bogdanm | 92:4fc01daae5a5 | 81 | |
bogdanm | 92:4fc01daae5a5 | 82 | \return CPSR Register value |
bogdanm | 92:4fc01daae5a5 | 83 | */ |
bogdanm | 92:4fc01daae5a5 | 84 | __STATIC_INLINE uint32_t __get_CPSR(void) |
bogdanm | 92:4fc01daae5a5 | 85 | { |
bogdanm | 92:4fc01daae5a5 | 86 | register uint32_t __regCPSR __ASM("cpsr"); |
bogdanm | 92:4fc01daae5a5 | 87 | return(__regCPSR); |
bogdanm | 92:4fc01daae5a5 | 88 | } |
bogdanm | 92:4fc01daae5a5 | 89 | |
bogdanm | 92:4fc01daae5a5 | 90 | /** \brief Set Stack Pointer |
bogdanm | 92:4fc01daae5a5 | 91 | |
bogdanm | 92:4fc01daae5a5 | 92 | This function assigns the given value to the current stack pointer. |
bogdanm | 92:4fc01daae5a5 | 93 | |
bogdanm | 92:4fc01daae5a5 | 94 | \param [in] topOfStack Stack Pointer value to set |
bogdanm | 92:4fc01daae5a5 | 95 | */ |
bogdanm | 92:4fc01daae5a5 | 96 | register uint32_t __regSP __ASM("sp"); |
bogdanm | 92:4fc01daae5a5 | 97 | __STATIC_INLINE void __set_SP(uint32_t topOfStack) |
bogdanm | 92:4fc01daae5a5 | 98 | { |
bogdanm | 92:4fc01daae5a5 | 99 | __regSP = topOfStack; |
bogdanm | 92:4fc01daae5a5 | 100 | } |
bogdanm | 92:4fc01daae5a5 | 101 | |
bogdanm | 92:4fc01daae5a5 | 102 | |
bogdanm | 92:4fc01daae5a5 | 103 | /** \brief Get link register |
bogdanm | 92:4fc01daae5a5 | 104 | |
bogdanm | 92:4fc01daae5a5 | 105 | This function returns the value of the link register |
bogdanm | 92:4fc01daae5a5 | 106 | |
bogdanm | 92:4fc01daae5a5 | 107 | \return Value of link register |
bogdanm | 92:4fc01daae5a5 | 108 | */ |
bogdanm | 92:4fc01daae5a5 | 109 | register uint32_t __reglr __ASM("lr"); |
bogdanm | 92:4fc01daae5a5 | 110 | __STATIC_INLINE uint32_t __get_LR(void) |
bogdanm | 92:4fc01daae5a5 | 111 | { |
bogdanm | 92:4fc01daae5a5 | 112 | return(__reglr); |
bogdanm | 92:4fc01daae5a5 | 113 | } |
bogdanm | 92:4fc01daae5a5 | 114 | |
bogdanm | 92:4fc01daae5a5 | 115 | /** \brief Set link register |
bogdanm | 92:4fc01daae5a5 | 116 | |
bogdanm | 92:4fc01daae5a5 | 117 | This function sets the value of the link register |
bogdanm | 92:4fc01daae5a5 | 118 | |
bogdanm | 92:4fc01daae5a5 | 119 | \param [in] lr LR value to set |
bogdanm | 92:4fc01daae5a5 | 120 | */ |
bogdanm | 92:4fc01daae5a5 | 121 | __STATIC_INLINE void __set_LR(uint32_t lr) |
bogdanm | 92:4fc01daae5a5 | 122 | { |
bogdanm | 92:4fc01daae5a5 | 123 | __reglr = lr; |
bogdanm | 92:4fc01daae5a5 | 124 | } |
bogdanm | 92:4fc01daae5a5 | 125 | |
bogdanm | 92:4fc01daae5a5 | 126 | /** \brief Set Process Stack Pointer |
bogdanm | 92:4fc01daae5a5 | 127 | |
bogdanm | 92:4fc01daae5a5 | 128 | This function assigns the given value to the USR/SYS Stack Pointer (PSP). |
bogdanm | 92:4fc01daae5a5 | 129 | |
bogdanm | 92:4fc01daae5a5 | 130 | \param [in] topOfProcStack USR/SYS Stack Pointer value to set |
bogdanm | 92:4fc01daae5a5 | 131 | */ |
bogdanm | 92:4fc01daae5a5 | 132 | __STATIC_ASM void __set_PSP(uint32_t topOfProcStack) |
bogdanm | 92:4fc01daae5a5 | 133 | { |
bogdanm | 92:4fc01daae5a5 | 134 | ARM |
bogdanm | 92:4fc01daae5a5 | 135 | PRESERVE8 |
bogdanm | 92:4fc01daae5a5 | 136 | |
bogdanm | 92:4fc01daae5a5 | 137 | BIC R0, R0, #7 ;ensure stack is 8-byte aligned |
bogdanm | 92:4fc01daae5a5 | 138 | MRS R1, CPSR |
bogdanm | 92:4fc01daae5a5 | 139 | CPS #MODE_SYS ;no effect in USR mode |
bogdanm | 92:4fc01daae5a5 | 140 | MOV SP, R0 |
bogdanm | 92:4fc01daae5a5 | 141 | MSR CPSR_c, R1 ;no effect in USR mode |
bogdanm | 92:4fc01daae5a5 | 142 | ISB |
bogdanm | 92:4fc01daae5a5 | 143 | BX LR |
bogdanm | 92:4fc01daae5a5 | 144 | |
bogdanm | 92:4fc01daae5a5 | 145 | } |
bogdanm | 92:4fc01daae5a5 | 146 | |
bogdanm | 92:4fc01daae5a5 | 147 | /** \brief Set User Mode |
bogdanm | 92:4fc01daae5a5 | 148 | |
bogdanm | 92:4fc01daae5a5 | 149 | This function changes the processor state to User Mode |
bogdanm | 92:4fc01daae5a5 | 150 | |
bogdanm | 92:4fc01daae5a5 | 151 | \param [in] topOfProcStack USR/SYS Stack Pointer value to set |
bogdanm | 92:4fc01daae5a5 | 152 | */ |
bogdanm | 92:4fc01daae5a5 | 153 | __STATIC_ASM void __set_CPS_USR(void) |
bogdanm | 92:4fc01daae5a5 | 154 | { |
bogdanm | 92:4fc01daae5a5 | 155 | ARM |
bogdanm | 92:4fc01daae5a5 | 156 | |
bogdanm | 92:4fc01daae5a5 | 157 | CPS #MODE_USR |
bogdanm | 92:4fc01daae5a5 | 158 | BX LR |
bogdanm | 92:4fc01daae5a5 | 159 | } |
bogdanm | 92:4fc01daae5a5 | 160 | |
bogdanm | 92:4fc01daae5a5 | 161 | |
bogdanm | 92:4fc01daae5a5 | 162 | /** \brief Enable FIQ |
bogdanm | 92:4fc01daae5a5 | 163 | |
bogdanm | 92:4fc01daae5a5 | 164 | This function enables FIQ interrupts by clearing the F-bit in the CPSR. |
bogdanm | 92:4fc01daae5a5 | 165 | Can only be executed in Privileged modes. |
bogdanm | 92:4fc01daae5a5 | 166 | */ |
bogdanm | 92:4fc01daae5a5 | 167 | #define __enable_fault_irq __enable_fiq |
bogdanm | 92:4fc01daae5a5 | 168 | |
bogdanm | 92:4fc01daae5a5 | 169 | |
bogdanm | 92:4fc01daae5a5 | 170 | /** \brief Disable FIQ |
bogdanm | 92:4fc01daae5a5 | 171 | |
bogdanm | 92:4fc01daae5a5 | 172 | This function disables FIQ interrupts by setting the F-bit in the CPSR. |
bogdanm | 92:4fc01daae5a5 | 173 | Can only be executed in Privileged modes. |
bogdanm | 92:4fc01daae5a5 | 174 | */ |
bogdanm | 92:4fc01daae5a5 | 175 | #define __disable_fault_irq __disable_fiq |
bogdanm | 92:4fc01daae5a5 | 176 | |
bogdanm | 92:4fc01daae5a5 | 177 | |
bogdanm | 92:4fc01daae5a5 | 178 | /** \brief Get FPSCR |
bogdanm | 92:4fc01daae5a5 | 179 | |
bogdanm | 92:4fc01daae5a5 | 180 | This function returns the current value of the Floating Point Status/Control register. |
bogdanm | 92:4fc01daae5a5 | 181 | |
bogdanm | 92:4fc01daae5a5 | 182 | \return Floating Point Status/Control register value |
bogdanm | 92:4fc01daae5a5 | 183 | */ |
bogdanm | 92:4fc01daae5a5 | 184 | __STATIC_INLINE uint32_t __get_FPSCR(void) |
bogdanm | 92:4fc01daae5a5 | 185 | { |
bogdanm | 92:4fc01daae5a5 | 186 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
bogdanm | 92:4fc01daae5a5 | 187 | register uint32_t __regfpscr __ASM("fpscr"); |
bogdanm | 92:4fc01daae5a5 | 188 | return(__regfpscr); |
bogdanm | 92:4fc01daae5a5 | 189 | #else |
bogdanm | 92:4fc01daae5a5 | 190 | return(0); |
bogdanm | 92:4fc01daae5a5 | 191 | #endif |
bogdanm | 92:4fc01daae5a5 | 192 | } |
bogdanm | 92:4fc01daae5a5 | 193 | |
bogdanm | 92:4fc01daae5a5 | 194 | |
bogdanm | 92:4fc01daae5a5 | 195 | /** \brief Set FPSCR |
bogdanm | 92:4fc01daae5a5 | 196 | |
bogdanm | 92:4fc01daae5a5 | 197 | This function assigns the given value to the Floating Point Status/Control register. |
bogdanm | 92:4fc01daae5a5 | 198 | |
bogdanm | 92:4fc01daae5a5 | 199 | \param [in] fpscr Floating Point Status/Control value to set |
bogdanm | 92:4fc01daae5a5 | 200 | */ |
bogdanm | 92:4fc01daae5a5 | 201 | __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) |
bogdanm | 92:4fc01daae5a5 | 202 | { |
bogdanm | 92:4fc01daae5a5 | 203 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
bogdanm | 92:4fc01daae5a5 | 204 | register uint32_t __regfpscr __ASM("fpscr"); |
bogdanm | 92:4fc01daae5a5 | 205 | __regfpscr = (fpscr); |
bogdanm | 92:4fc01daae5a5 | 206 | #endif |
bogdanm | 92:4fc01daae5a5 | 207 | } |
bogdanm | 92:4fc01daae5a5 | 208 | |
bogdanm | 92:4fc01daae5a5 | 209 | /** \brief Get FPEXC |
bogdanm | 92:4fc01daae5a5 | 210 | |
bogdanm | 92:4fc01daae5a5 | 211 | This function returns the current value of the Floating Point Exception Control register. |
bogdanm | 92:4fc01daae5a5 | 212 | |
bogdanm | 92:4fc01daae5a5 | 213 | \return Floating Point Exception Control register value |
bogdanm | 92:4fc01daae5a5 | 214 | */ |
bogdanm | 92:4fc01daae5a5 | 215 | __STATIC_INLINE uint32_t __get_FPEXC(void) |
bogdanm | 92:4fc01daae5a5 | 216 | { |
bogdanm | 92:4fc01daae5a5 | 217 | #if (__FPU_PRESENT == 1) |
bogdanm | 92:4fc01daae5a5 | 218 | register uint32_t __regfpexc __ASM("fpexc"); |
bogdanm | 92:4fc01daae5a5 | 219 | return(__regfpexc); |
bogdanm | 92:4fc01daae5a5 | 220 | #else |
bogdanm | 92:4fc01daae5a5 | 221 | return(0); |
bogdanm | 92:4fc01daae5a5 | 222 | #endif |
bogdanm | 92:4fc01daae5a5 | 223 | } |
bogdanm | 92:4fc01daae5a5 | 224 | |
bogdanm | 92:4fc01daae5a5 | 225 | |
bogdanm | 92:4fc01daae5a5 | 226 | /** \brief Set FPEXC |
bogdanm | 92:4fc01daae5a5 | 227 | |
bogdanm | 92:4fc01daae5a5 | 228 | This function assigns the given value to the Floating Point Exception Control register. |
bogdanm | 92:4fc01daae5a5 | 229 | |
bogdanm | 92:4fc01daae5a5 | 230 | \param [in] fpscr Floating Point Exception Control value to set |
bogdanm | 92:4fc01daae5a5 | 231 | */ |
bogdanm | 92:4fc01daae5a5 | 232 | __STATIC_INLINE void __set_FPEXC(uint32_t fpexc) |
bogdanm | 92:4fc01daae5a5 | 233 | { |
bogdanm | 92:4fc01daae5a5 | 234 | #if (__FPU_PRESENT == 1) |
bogdanm | 92:4fc01daae5a5 | 235 | register uint32_t __regfpexc __ASM("fpexc"); |
bogdanm | 92:4fc01daae5a5 | 236 | __regfpexc = (fpexc); |
bogdanm | 92:4fc01daae5a5 | 237 | #endif |
bogdanm | 92:4fc01daae5a5 | 238 | } |
bogdanm | 92:4fc01daae5a5 | 239 | |
bogdanm | 92:4fc01daae5a5 | 240 | /** \brief Get CPACR |
bogdanm | 92:4fc01daae5a5 | 241 | |
bogdanm | 92:4fc01daae5a5 | 242 | This function returns the current value of the Coprocessor Access Control register. |
bogdanm | 92:4fc01daae5a5 | 243 | |
bogdanm | 92:4fc01daae5a5 | 244 | \return Coprocessor Access Control register value |
bogdanm | 92:4fc01daae5a5 | 245 | */ |
bogdanm | 92:4fc01daae5a5 | 246 | __STATIC_INLINE uint32_t __get_CPACR(void) |
bogdanm | 92:4fc01daae5a5 | 247 | { |
bogdanm | 92:4fc01daae5a5 | 248 | register uint32_t __regCPACR __ASM("cp15:0:c1:c0:2"); |
bogdanm | 92:4fc01daae5a5 | 249 | return __regCPACR; |
bogdanm | 92:4fc01daae5a5 | 250 | } |
bogdanm | 92:4fc01daae5a5 | 251 | |
bogdanm | 92:4fc01daae5a5 | 252 | /** \brief Set CPACR |
bogdanm | 92:4fc01daae5a5 | 253 | |
bogdanm | 92:4fc01daae5a5 | 254 | This function assigns the given value to the Coprocessor Access Control register. |
bogdanm | 92:4fc01daae5a5 | 255 | |
bogdanm | 92:4fc01daae5a5 | 256 | \param [in] cpacr Coporcessor Acccess Control value to set |
bogdanm | 92:4fc01daae5a5 | 257 | */ |
bogdanm | 92:4fc01daae5a5 | 258 | __STATIC_INLINE void __set_CPACR(uint32_t cpacr) |
bogdanm | 92:4fc01daae5a5 | 259 | { |
bogdanm | 92:4fc01daae5a5 | 260 | register uint32_t __regCPACR __ASM("cp15:0:c1:c0:2"); |
bogdanm | 92:4fc01daae5a5 | 261 | __regCPACR = cpacr; |
bogdanm | 92:4fc01daae5a5 | 262 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 263 | } |
bogdanm | 92:4fc01daae5a5 | 264 | |
bogdanm | 92:4fc01daae5a5 | 265 | /** \brief Get CBAR |
bogdanm | 92:4fc01daae5a5 | 266 | |
bogdanm | 92:4fc01daae5a5 | 267 | This function returns the value of the Configuration Base Address register. |
bogdanm | 92:4fc01daae5a5 | 268 | |
bogdanm | 92:4fc01daae5a5 | 269 | \return Configuration Base Address register value |
bogdanm | 92:4fc01daae5a5 | 270 | */ |
bogdanm | 92:4fc01daae5a5 | 271 | __STATIC_INLINE uint32_t __get_CBAR() { |
bogdanm | 92:4fc01daae5a5 | 272 | register uint32_t __regCBAR __ASM("cp15:4:c15:c0:0"); |
bogdanm | 92:4fc01daae5a5 | 273 | return(__regCBAR); |
bogdanm | 92:4fc01daae5a5 | 274 | } |
bogdanm | 92:4fc01daae5a5 | 275 | |
bogdanm | 92:4fc01daae5a5 | 276 | /** \brief Get TTBR0 |
bogdanm | 92:4fc01daae5a5 | 277 | |
bogdanm | 92:4fc01daae5a5 | 278 | This function returns the value of the Configuration Base Address register. |
bogdanm | 92:4fc01daae5a5 | 279 | |
bogdanm | 92:4fc01daae5a5 | 280 | \return Translation Table Base Register 0 value |
bogdanm | 92:4fc01daae5a5 | 281 | */ |
bogdanm | 92:4fc01daae5a5 | 282 | __STATIC_INLINE uint32_t __get_TTBR0() { |
bogdanm | 92:4fc01daae5a5 | 283 | register uint32_t __regTTBR0 __ASM("cp15:0:c2:c0:0"); |
bogdanm | 92:4fc01daae5a5 | 284 | return(__regTTBR0); |
bogdanm | 92:4fc01daae5a5 | 285 | } |
bogdanm | 92:4fc01daae5a5 | 286 | |
bogdanm | 92:4fc01daae5a5 | 287 | /** \brief Set TTBR0 |
bogdanm | 92:4fc01daae5a5 | 288 | |
bogdanm | 92:4fc01daae5a5 | 289 | This function assigns the given value to the Coprocessor Access Control register. |
bogdanm | 92:4fc01daae5a5 | 290 | |
bogdanm | 92:4fc01daae5a5 | 291 | \param [in] ttbr0 Translation Table Base Register 0 value to set |
bogdanm | 92:4fc01daae5a5 | 292 | */ |
bogdanm | 92:4fc01daae5a5 | 293 | __STATIC_INLINE void __set_TTBR0(uint32_t ttbr0) { |
bogdanm | 92:4fc01daae5a5 | 294 | register uint32_t __regTTBR0 __ASM("cp15:0:c2:c0:0"); |
bogdanm | 92:4fc01daae5a5 | 295 | __regTTBR0 = ttbr0; |
bogdanm | 92:4fc01daae5a5 | 296 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 297 | } |
bogdanm | 92:4fc01daae5a5 | 298 | |
bogdanm | 92:4fc01daae5a5 | 299 | /** \brief Get DACR |
bogdanm | 92:4fc01daae5a5 | 300 | |
bogdanm | 92:4fc01daae5a5 | 301 | This function returns the value of the Domain Access Control Register. |
bogdanm | 92:4fc01daae5a5 | 302 | |
bogdanm | 92:4fc01daae5a5 | 303 | \return Domain Access Control Register value |
bogdanm | 92:4fc01daae5a5 | 304 | */ |
bogdanm | 92:4fc01daae5a5 | 305 | __STATIC_INLINE uint32_t __get_DACR() { |
bogdanm | 92:4fc01daae5a5 | 306 | register uint32_t __regDACR __ASM("cp15:0:c3:c0:0"); |
bogdanm | 92:4fc01daae5a5 | 307 | return(__regDACR); |
bogdanm | 92:4fc01daae5a5 | 308 | } |
bogdanm | 92:4fc01daae5a5 | 309 | |
bogdanm | 92:4fc01daae5a5 | 310 | /** \brief Set DACR |
bogdanm | 92:4fc01daae5a5 | 311 | |
bogdanm | 92:4fc01daae5a5 | 312 | This function assigns the given value to the Coprocessor Access Control register. |
bogdanm | 92:4fc01daae5a5 | 313 | |
bogdanm | 92:4fc01daae5a5 | 314 | \param [in] dacr Domain Access Control Register value to set |
bogdanm | 92:4fc01daae5a5 | 315 | */ |
bogdanm | 92:4fc01daae5a5 | 316 | __STATIC_INLINE void __set_DACR(uint32_t dacr) { |
bogdanm | 92:4fc01daae5a5 | 317 | register uint32_t __regDACR __ASM("cp15:0:c3:c0:0"); |
bogdanm | 92:4fc01daae5a5 | 318 | __regDACR = dacr; |
bogdanm | 92:4fc01daae5a5 | 319 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 320 | } |
bogdanm | 92:4fc01daae5a5 | 321 | |
bogdanm | 92:4fc01daae5a5 | 322 | /******************************** Cache and BTAC enable ****************************************************/ |
bogdanm | 92:4fc01daae5a5 | 323 | |
bogdanm | 92:4fc01daae5a5 | 324 | /** \brief Set SCTLR |
bogdanm | 92:4fc01daae5a5 | 325 | |
bogdanm | 92:4fc01daae5a5 | 326 | This function assigns the given value to the System Control Register. |
bogdanm | 92:4fc01daae5a5 | 327 | |
bogdanm | 92:4fc01daae5a5 | 328 | \param [in] sctlr System Control Register, value to set |
bogdanm | 92:4fc01daae5a5 | 329 | */ |
bogdanm | 92:4fc01daae5a5 | 330 | __STATIC_INLINE void __set_SCTLR(uint32_t sctlr) |
bogdanm | 92:4fc01daae5a5 | 331 | { |
bogdanm | 92:4fc01daae5a5 | 332 | register uint32_t __regSCTLR __ASM("cp15:0:c1:c0:0"); |
bogdanm | 92:4fc01daae5a5 | 333 | __regSCTLR = sctlr; |
bogdanm | 92:4fc01daae5a5 | 334 | } |
bogdanm | 92:4fc01daae5a5 | 335 | |
bogdanm | 92:4fc01daae5a5 | 336 | /** \brief Get SCTLR |
bogdanm | 92:4fc01daae5a5 | 337 | |
bogdanm | 92:4fc01daae5a5 | 338 | This function returns the value of the System Control Register. |
bogdanm | 92:4fc01daae5a5 | 339 | |
bogdanm | 92:4fc01daae5a5 | 340 | \return System Control Register value |
bogdanm | 92:4fc01daae5a5 | 341 | */ |
bogdanm | 92:4fc01daae5a5 | 342 | __STATIC_INLINE uint32_t __get_SCTLR() { |
bogdanm | 92:4fc01daae5a5 | 343 | register uint32_t __regSCTLR __ASM("cp15:0:c1:c0:0"); |
bogdanm | 92:4fc01daae5a5 | 344 | return(__regSCTLR); |
bogdanm | 92:4fc01daae5a5 | 345 | } |
bogdanm | 92:4fc01daae5a5 | 346 | |
bogdanm | 92:4fc01daae5a5 | 347 | /** \brief Enable Caches |
bogdanm | 92:4fc01daae5a5 | 348 | |
bogdanm | 92:4fc01daae5a5 | 349 | Enable Caches |
bogdanm | 92:4fc01daae5a5 | 350 | */ |
bogdanm | 92:4fc01daae5a5 | 351 | __STATIC_INLINE void __enable_caches(void) { |
bogdanm | 92:4fc01daae5a5 | 352 | // Set I bit 12 to enable I Cache |
bogdanm | 92:4fc01daae5a5 | 353 | // Set C bit 2 to enable D Cache |
bogdanm | 92:4fc01daae5a5 | 354 | __set_SCTLR( __get_SCTLR() | (1 << 12) | (1 << 2)); |
bogdanm | 92:4fc01daae5a5 | 355 | } |
bogdanm | 92:4fc01daae5a5 | 356 | |
bogdanm | 92:4fc01daae5a5 | 357 | /** \brief Disable Caches |
bogdanm | 92:4fc01daae5a5 | 358 | |
bogdanm | 92:4fc01daae5a5 | 359 | Disable Caches |
bogdanm | 92:4fc01daae5a5 | 360 | */ |
bogdanm | 92:4fc01daae5a5 | 361 | __STATIC_INLINE void __disable_caches(void) { |
bogdanm | 92:4fc01daae5a5 | 362 | // Clear I bit 12 to disable I Cache |
bogdanm | 92:4fc01daae5a5 | 363 | // Clear C bit 2 to disable D Cache |
bogdanm | 92:4fc01daae5a5 | 364 | __set_SCTLR( __get_SCTLR() & ~(1 << 12) & ~(1 << 2)); |
bogdanm | 92:4fc01daae5a5 | 365 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 366 | } |
bogdanm | 92:4fc01daae5a5 | 367 | |
bogdanm | 92:4fc01daae5a5 | 368 | /** \brief Enable BTAC |
bogdanm | 92:4fc01daae5a5 | 369 | |
bogdanm | 92:4fc01daae5a5 | 370 | Enable BTAC |
bogdanm | 92:4fc01daae5a5 | 371 | */ |
bogdanm | 92:4fc01daae5a5 | 372 | __STATIC_INLINE void __enable_btac(void) { |
bogdanm | 92:4fc01daae5a5 | 373 | // Set Z bit 11 to enable branch prediction |
bogdanm | 92:4fc01daae5a5 | 374 | __set_SCTLR( __get_SCTLR() | (1 << 11)); |
bogdanm | 92:4fc01daae5a5 | 375 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 376 | } |
bogdanm | 92:4fc01daae5a5 | 377 | |
bogdanm | 92:4fc01daae5a5 | 378 | /** \brief Disable BTAC |
bogdanm | 92:4fc01daae5a5 | 379 | |
bogdanm | 92:4fc01daae5a5 | 380 | Disable BTAC |
bogdanm | 92:4fc01daae5a5 | 381 | */ |
bogdanm | 92:4fc01daae5a5 | 382 | __STATIC_INLINE void __disable_btac(void) { |
bogdanm | 92:4fc01daae5a5 | 383 | // Clear Z bit 11 to disable branch prediction |
bogdanm | 92:4fc01daae5a5 | 384 | __set_SCTLR( __get_SCTLR() & ~(1 << 11)); |
bogdanm | 92:4fc01daae5a5 | 385 | } |
bogdanm | 92:4fc01daae5a5 | 386 | |
bogdanm | 92:4fc01daae5a5 | 387 | |
bogdanm | 92:4fc01daae5a5 | 388 | /** \brief Enable MMU |
bogdanm | 92:4fc01daae5a5 | 389 | |
bogdanm | 92:4fc01daae5a5 | 390 | Enable MMU |
bogdanm | 92:4fc01daae5a5 | 391 | */ |
bogdanm | 92:4fc01daae5a5 | 392 | __STATIC_INLINE void __enable_mmu(void) { |
bogdanm | 92:4fc01daae5a5 | 393 | // Set M bit 0 to enable the MMU |
bogdanm | 92:4fc01daae5a5 | 394 | // Set AFE bit to enable simplified access permissions model |
bogdanm | 92:4fc01daae5a5 | 395 | // Clear TRE bit to disable TEX remap and A bit to disable strict alignment fault checking |
bogdanm | 92:4fc01daae5a5 | 396 | __set_SCTLR( (__get_SCTLR() & ~(1 << 28) & ~(1 << 1)) | 1 | (1 << 29)); |
bogdanm | 92:4fc01daae5a5 | 397 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 398 | } |
bogdanm | 92:4fc01daae5a5 | 399 | |
bogdanm | 92:4fc01daae5a5 | 400 | /** \brief Enable MMU |
bogdanm | 92:4fc01daae5a5 | 401 | |
bogdanm | 92:4fc01daae5a5 | 402 | Enable MMU |
bogdanm | 92:4fc01daae5a5 | 403 | */ |
bogdanm | 92:4fc01daae5a5 | 404 | __STATIC_INLINE void __disable_mmu(void) { |
bogdanm | 92:4fc01daae5a5 | 405 | // Clear M bit 0 to disable the MMU |
bogdanm | 92:4fc01daae5a5 | 406 | __set_SCTLR( __get_SCTLR() & ~1); |
bogdanm | 92:4fc01daae5a5 | 407 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 408 | } |
bogdanm | 92:4fc01daae5a5 | 409 | |
bogdanm | 92:4fc01daae5a5 | 410 | /******************************** TLB maintenance operations ************************************************/ |
bogdanm | 92:4fc01daae5a5 | 411 | /** \brief Invalidate the whole tlb |
bogdanm | 92:4fc01daae5a5 | 412 | |
bogdanm | 92:4fc01daae5a5 | 413 | TLBIALL. Invalidate the whole tlb |
bogdanm | 92:4fc01daae5a5 | 414 | */ |
bogdanm | 92:4fc01daae5a5 | 415 | |
bogdanm | 92:4fc01daae5a5 | 416 | __STATIC_INLINE void __ca9u_inv_tlb_all(void) { |
bogdanm | 92:4fc01daae5a5 | 417 | register uint32_t __TLBIALL __ASM("cp15:0:c8:c7:0"); |
bogdanm | 92:4fc01daae5a5 | 418 | __TLBIALL = 0; |
bogdanm | 92:4fc01daae5a5 | 419 | __DSB(); |
bogdanm | 92:4fc01daae5a5 | 420 | __ISB(); |
bogdanm | 92:4fc01daae5a5 | 421 | } |
bogdanm | 92:4fc01daae5a5 | 422 | |
bogdanm | 92:4fc01daae5a5 | 423 | /******************************** BTB maintenance operations ************************************************/ |
bogdanm | 92:4fc01daae5a5 | 424 | /** \brief Invalidate entire branch predictor array |
bogdanm | 92:4fc01daae5a5 | 425 | |
bogdanm | 92:4fc01daae5a5 | 426 | BPIALL. Branch Predictor Invalidate All. |
bogdanm | 92:4fc01daae5a5 | 427 | */ |
bogdanm | 92:4fc01daae5a5 | 428 | |
bogdanm | 92:4fc01daae5a5 | 429 | __STATIC_INLINE void __v7_inv_btac(void) { |
bogdanm | 92:4fc01daae5a5 | 430 | register uint32_t __BPIALL __ASM("cp15:0:c7:c5:6"); |
bogdanm | 92:4fc01daae5a5 | 431 | __BPIALL = 0; |
bogdanm | 92:4fc01daae5a5 | 432 | __DSB(); //ensure completion of the invalidation |
bogdanm | 92:4fc01daae5a5 | 433 | __ISB(); //ensure instruction fetch path sees new state |
bogdanm | 92:4fc01daae5a5 | 434 | } |
bogdanm | 92:4fc01daae5a5 | 435 | |
bogdanm | 92:4fc01daae5a5 | 436 | |
bogdanm | 92:4fc01daae5a5 | 437 | /******************************** L1 cache operations ******************************************************/ |
bogdanm | 92:4fc01daae5a5 | 438 | |
bogdanm | 92:4fc01daae5a5 | 439 | /** \brief Invalidate the whole I$ |
bogdanm | 92:4fc01daae5a5 | 440 | |
bogdanm | 92:4fc01daae5a5 | 441 | ICIALLU. Instruction Cache Invalidate All to PoU |
bogdanm | 92:4fc01daae5a5 | 442 | */ |
bogdanm | 92:4fc01daae5a5 | 443 | __STATIC_INLINE void __v7_inv_icache_all(void) { |
bogdanm | 92:4fc01daae5a5 | 444 | register uint32_t __ICIALLU __ASM("cp15:0:c7:c5:0"); |
bogdanm | 92:4fc01daae5a5 | 445 | __ICIALLU = 0; |
bogdanm | 92:4fc01daae5a5 | 446 | __DSB(); //ensure completion of the invalidation |
bogdanm | 92:4fc01daae5a5 | 447 | __ISB(); //ensure instruction fetch path sees new I cache state |
bogdanm | 92:4fc01daae5a5 | 448 | } |
bogdanm | 92:4fc01daae5a5 | 449 | |
bogdanm | 92:4fc01daae5a5 | 450 | /** \brief Clean D$ by MVA |
bogdanm | 92:4fc01daae5a5 | 451 | |
bogdanm | 92:4fc01daae5a5 | 452 | DCCMVAC. Data cache clean by MVA to PoC |
bogdanm | 92:4fc01daae5a5 | 453 | */ |
bogdanm | 92:4fc01daae5a5 | 454 | __STATIC_INLINE void __v7_clean_dcache_mva(void *va) { |
bogdanm | 92:4fc01daae5a5 | 455 | register uint32_t __DCCMVAC __ASM("cp15:0:c7:c10:1"); |
bogdanm | 92:4fc01daae5a5 | 456 | __DCCMVAC = (uint32_t)va; |
bogdanm | 92:4fc01daae5a5 | 457 | __DMB(); //ensure the ordering of data cache maintenance operations and their effects |
bogdanm | 92:4fc01daae5a5 | 458 | } |
bogdanm | 92:4fc01daae5a5 | 459 | |
bogdanm | 92:4fc01daae5a5 | 460 | /** \brief Invalidate D$ by MVA |
bogdanm | 92:4fc01daae5a5 | 461 | |
bogdanm | 92:4fc01daae5a5 | 462 | DCIMVAC. Data cache invalidate by MVA to PoC |
bogdanm | 92:4fc01daae5a5 | 463 | */ |
bogdanm | 92:4fc01daae5a5 | 464 | __STATIC_INLINE void __v7_inv_dcache_mva(void *va) { |
bogdanm | 92:4fc01daae5a5 | 465 | register uint32_t __DCIMVAC __ASM("cp15:0:c7:c6:1"); |
bogdanm | 92:4fc01daae5a5 | 466 | __DCIMVAC = (uint32_t)va; |
bogdanm | 92:4fc01daae5a5 | 467 | __DMB(); //ensure the ordering of data cache maintenance operations and their effects |
bogdanm | 92:4fc01daae5a5 | 468 | } |
bogdanm | 92:4fc01daae5a5 | 469 | |
bogdanm | 92:4fc01daae5a5 | 470 | /** \brief Clean and Invalidate D$ by MVA |
bogdanm | 92:4fc01daae5a5 | 471 | |
bogdanm | 92:4fc01daae5a5 | 472 | DCCIMVAC. Data cache clean and invalidate by MVA to PoC |
bogdanm | 92:4fc01daae5a5 | 473 | */ |
bogdanm | 92:4fc01daae5a5 | 474 | __STATIC_INLINE void __v7_clean_inv_dcache_mva(void *va) { |
bogdanm | 92:4fc01daae5a5 | 475 | register uint32_t __DCCIMVAC __ASM("cp15:0:c7:c14:1"); |
bogdanm | 92:4fc01daae5a5 | 476 | __DCCIMVAC = (uint32_t)va; |
bogdanm | 92:4fc01daae5a5 | 477 | __DMB(); //ensure the ordering of data cache maintenance operations and their effects |
bogdanm | 92:4fc01daae5a5 | 478 | } |
bogdanm | 92:4fc01daae5a5 | 479 | |
bogdanm | 92:4fc01daae5a5 | 480 | /** \brief |
bogdanm | 92:4fc01daae5a5 | 481 | * Generic mechanism for cleaning/invalidating the entire data or unified cache to the point of coherency. |
bogdanm | 92:4fc01daae5a5 | 482 | */ |
bogdanm | 92:4fc01daae5a5 | 483 | #pragma push |
bogdanm | 92:4fc01daae5a5 | 484 | #pragma arm |
bogdanm | 92:4fc01daae5a5 | 485 | __STATIC_ASM void __v7_all_cache(uint32_t op) { |
bogdanm | 92:4fc01daae5a5 | 486 | ARM |
bogdanm | 92:4fc01daae5a5 | 487 | |
bogdanm | 92:4fc01daae5a5 | 488 | PUSH {R4-R11} |
bogdanm | 92:4fc01daae5a5 | 489 | |
bogdanm | 92:4fc01daae5a5 | 490 | MRC p15, 1, R6, c0, c0, 1 // Read CLIDR |
bogdanm | 92:4fc01daae5a5 | 491 | ANDS R3, R6, #0x07000000 // Extract coherency level |
bogdanm | 92:4fc01daae5a5 | 492 | MOV R3, R3, LSR #23 // Total cache levels << 1 |
bogdanm | 92:4fc01daae5a5 | 493 | BEQ Finished // If 0, no need to clean |
bogdanm | 92:4fc01daae5a5 | 494 | |
bogdanm | 92:4fc01daae5a5 | 495 | MOV R10, #0 // R10 holds current cache level << 1 |
bogdanm | 92:4fc01daae5a5 | 496 | Loop1 ADD R2, R10, R10, LSR #1 // R2 holds cache "Set" position |
bogdanm | 92:4fc01daae5a5 | 497 | MOV R1, R6, LSR R2 // Bottom 3 bits are the Cache-type for this level |
bogdanm | 92:4fc01daae5a5 | 498 | AND R1, R1, #7 // Isolate those lower 3 bits |
bogdanm | 92:4fc01daae5a5 | 499 | CMP R1, #2 |
bogdanm | 92:4fc01daae5a5 | 500 | BLT Skip // No cache or only instruction cache at this level |
bogdanm | 92:4fc01daae5a5 | 501 | |
bogdanm | 92:4fc01daae5a5 | 502 | MCR p15, 2, R10, c0, c0, 0 // Write the Cache Size selection register |
bogdanm | 92:4fc01daae5a5 | 503 | ISB // ISB to sync the change to the CacheSizeID reg |
bogdanm | 92:4fc01daae5a5 | 504 | MRC p15, 1, R1, c0, c0, 0 // Reads current Cache Size ID register |
bogdanm | 92:4fc01daae5a5 | 505 | AND R2, R1, #7 // Extract the line length field |
bogdanm | 92:4fc01daae5a5 | 506 | ADD R2, R2, #4 // Add 4 for the line length offset (log2 16 bytes) |
bogdanm | 92:4fc01daae5a5 | 507 | LDR R4, =0x3FF |
bogdanm | 92:4fc01daae5a5 | 508 | ANDS R4, R4, R1, LSR #3 // R4 is the max number on the way size (right aligned) |
bogdanm | 92:4fc01daae5a5 | 509 | CLZ R5, R4 // R5 is the bit position of the way size increment |
bogdanm | 92:4fc01daae5a5 | 510 | LDR R7, =0x7FFF |
bogdanm | 92:4fc01daae5a5 | 511 | ANDS R7, R7, R1, LSR #13 // R7 is the max number of the index size (right aligned) |
bogdanm | 92:4fc01daae5a5 | 512 | |
bogdanm | 92:4fc01daae5a5 | 513 | Loop2 MOV R9, R4 // R9 working copy of the max way size (right aligned) |
bogdanm | 92:4fc01daae5a5 | 514 | |
bogdanm | 92:4fc01daae5a5 | 515 | Loop3 ORR R11, R10, R9, LSL R5 // Factor in the Way number and cache number into R11 |
bogdanm | 92:4fc01daae5a5 | 516 | ORR R11, R11, R7, LSL R2 // Factor in the Set number |
bogdanm | 92:4fc01daae5a5 | 517 | CMP R0, #0 |
bogdanm | 92:4fc01daae5a5 | 518 | BNE Dccsw |
bogdanm | 92:4fc01daae5a5 | 519 | MCR p15, 0, R11, c7, c6, 2 // DCISW. Invalidate by Set/Way |
bogdanm | 92:4fc01daae5a5 | 520 | B cont |
bogdanm | 92:4fc01daae5a5 | 521 | Dccsw CMP R0, #1 |
bogdanm | 92:4fc01daae5a5 | 522 | BNE Dccisw |
bogdanm | 92:4fc01daae5a5 | 523 | MCR p15, 0, R11, c7, c10, 2 // DCCSW. Clean by Set/Way |
bogdanm | 92:4fc01daae5a5 | 524 | B cont |
bogdanm | 92:4fc01daae5a5 | 525 | Dccisw MCR p15, 0, R11, c7, c14, 2 // DCCISW, Clean and Invalidate by Set/Way |
bogdanm | 92:4fc01daae5a5 | 526 | cont SUBS R9, R9, #1 // Decrement the Way number |
bogdanm | 92:4fc01daae5a5 | 527 | BGE Loop3 |
bogdanm | 92:4fc01daae5a5 | 528 | SUBS R7, R7, #1 // Decrement the Set number |
bogdanm | 92:4fc01daae5a5 | 529 | BGE Loop2 |
bogdanm | 92:4fc01daae5a5 | 530 | Skip ADD R10, R10, #2 // increment the cache number |
bogdanm | 92:4fc01daae5a5 | 531 | CMP R3, R10 |
bogdanm | 92:4fc01daae5a5 | 532 | BGT Loop1 |
bogdanm | 92:4fc01daae5a5 | 533 | |
bogdanm | 92:4fc01daae5a5 | 534 | Finished |
bogdanm | 92:4fc01daae5a5 | 535 | DSB |
bogdanm | 92:4fc01daae5a5 | 536 | POP {R4-R11} |
bogdanm | 92:4fc01daae5a5 | 537 | BX lr |
bogdanm | 92:4fc01daae5a5 | 538 | |
bogdanm | 92:4fc01daae5a5 | 539 | } |
bogdanm | 92:4fc01daae5a5 | 540 | #pragma pop |
bogdanm | 92:4fc01daae5a5 | 541 | |
bogdanm | 92:4fc01daae5a5 | 542 | /** \brief __v7_all_cache - helper function |
bogdanm | 92:4fc01daae5a5 | 543 | |
bogdanm | 92:4fc01daae5a5 | 544 | */ |
bogdanm | 92:4fc01daae5a5 | 545 | |
bogdanm | 92:4fc01daae5a5 | 546 | /** \brief Invalidate the whole D$ |
bogdanm | 92:4fc01daae5a5 | 547 | |
bogdanm | 92:4fc01daae5a5 | 548 | DCISW. Invalidate by Set/Way |
bogdanm | 92:4fc01daae5a5 | 549 | */ |
bogdanm | 92:4fc01daae5a5 | 550 | |
bogdanm | 92:4fc01daae5a5 | 551 | __STATIC_INLINE void __v7_inv_dcache_all(void) { |
bogdanm | 92:4fc01daae5a5 | 552 | __v7_all_cache(0); |
bogdanm | 92:4fc01daae5a5 | 553 | } |
bogdanm | 92:4fc01daae5a5 | 554 | |
bogdanm | 92:4fc01daae5a5 | 555 | /** \brief Clean the whole D$ |
bogdanm | 92:4fc01daae5a5 | 556 | |
bogdanm | 92:4fc01daae5a5 | 557 | DCCSW. Clean by Set/Way |
bogdanm | 92:4fc01daae5a5 | 558 | */ |
bogdanm | 92:4fc01daae5a5 | 559 | |
bogdanm | 92:4fc01daae5a5 | 560 | __STATIC_INLINE void __v7_clean_dcache_all(void) { |
bogdanm | 92:4fc01daae5a5 | 561 | __v7_all_cache(1); |
bogdanm | 92:4fc01daae5a5 | 562 | } |
bogdanm | 92:4fc01daae5a5 | 563 | |
bogdanm | 92:4fc01daae5a5 | 564 | /** \brief Clean and invalidate the whole D$ |
bogdanm | 92:4fc01daae5a5 | 565 | |
bogdanm | 92:4fc01daae5a5 | 566 | DCCISW. Clean and Invalidate by Set/Way |
bogdanm | 92:4fc01daae5a5 | 567 | */ |
bogdanm | 92:4fc01daae5a5 | 568 | |
bogdanm | 92:4fc01daae5a5 | 569 | __STATIC_INLINE void __v7_clean_inv_dcache_all(void) { |
bogdanm | 92:4fc01daae5a5 | 570 | __v7_all_cache(2); |
bogdanm | 92:4fc01daae5a5 | 571 | } |
bogdanm | 92:4fc01daae5a5 | 572 | |
bogdanm | 92:4fc01daae5a5 | 573 | #include "core_ca_mmu.h" |
bogdanm | 92:4fc01daae5a5 | 574 | |
bogdanm | 92:4fc01daae5a5 | 575 | #elif (defined (__ICCARM__)) /*---------------- ICC Compiler ---------------------*/ |
bogdanm | 92:4fc01daae5a5 | 576 | |
bogdanm | 92:4fc01daae5a5 | 577 | #error IAR Compiler support not implemented for Cortex-A |
bogdanm | 92:4fc01daae5a5 | 578 | |
bogdanm | 92:4fc01daae5a5 | 579 | #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/ |
bogdanm | 92:4fc01daae5a5 | 580 | |
Kojto | 95:7e07b6fb45cf | 581 | /* GNU gcc specific functions */ |
Kojto | 95:7e07b6fb45cf | 582 | |
Kojto | 95:7e07b6fb45cf | 583 | #define MODE_USR 0x10 |
Kojto | 95:7e07b6fb45cf | 584 | #define MODE_FIQ 0x11 |
Kojto | 95:7e07b6fb45cf | 585 | #define MODE_IRQ 0x12 |
Kojto | 95:7e07b6fb45cf | 586 | #define MODE_SVC 0x13 |
Kojto | 95:7e07b6fb45cf | 587 | #define MODE_MON 0x16 |
Kojto | 95:7e07b6fb45cf | 588 | #define MODE_ABT 0x17 |
Kojto | 95:7e07b6fb45cf | 589 | #define MODE_HYP 0x1A |
Kojto | 95:7e07b6fb45cf | 590 | #define MODE_UND 0x1B |
Kojto | 95:7e07b6fb45cf | 591 | #define MODE_SYS 0x1F |
Kojto | 95:7e07b6fb45cf | 592 | |
Kojto | 95:7e07b6fb45cf | 593 | |
Kojto | 95:7e07b6fb45cf | 594 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) |
Kojto | 95:7e07b6fb45cf | 595 | { |
Kojto | 95:7e07b6fb45cf | 596 | __ASM volatile ("cpsie i"); |
Kojto | 95:7e07b6fb45cf | 597 | } |
Kojto | 95:7e07b6fb45cf | 598 | |
Kojto | 95:7e07b6fb45cf | 599 | /** \brief Disable IRQ Interrupts |
Kojto | 95:7e07b6fb45cf | 600 | |
Kojto | 95:7e07b6fb45cf | 601 | This function disables IRQ interrupts by setting the I-bit in the CPSR. |
Kojto | 95:7e07b6fb45cf | 602 | Can only be executed in Privileged modes. |
Kojto | 95:7e07b6fb45cf | 603 | */ |
Kojto | 95:7e07b6fb45cf | 604 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __disable_irq(void) |
Kojto | 95:7e07b6fb45cf | 605 | { |
Kojto | 95:7e07b6fb45cf | 606 | uint32_t result; |
Kojto | 95:7e07b6fb45cf | 607 | |
Kojto | 95:7e07b6fb45cf | 608 | __ASM volatile ("mrs %0, cpsr" : "=r" (result)); |
Kojto | 95:7e07b6fb45cf | 609 | __ASM volatile ("cpsid i"); |
Kojto | 95:7e07b6fb45cf | 610 | return(result & 0x80); |
Kojto | 95:7e07b6fb45cf | 611 | } |
Kojto | 95:7e07b6fb45cf | 612 | |
Kojto | 95:7e07b6fb45cf | 613 | |
Kojto | 95:7e07b6fb45cf | 614 | /** \brief Get APSR Register |
Kojto | 95:7e07b6fb45cf | 615 | |
Kojto | 95:7e07b6fb45cf | 616 | This function returns the content of the APSR Register. |
Kojto | 95:7e07b6fb45cf | 617 | |
Kojto | 95:7e07b6fb45cf | 618 | \return APSR Register value |
Kojto | 95:7e07b6fb45cf | 619 | */ |
Kojto | 95:7e07b6fb45cf | 620 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) |
Kojto | 95:7e07b6fb45cf | 621 | { |
Kojto | 95:7e07b6fb45cf | 622 | #if 1 |
Kojto | 95:7e07b6fb45cf | 623 | uint32_t result; |
Kojto | 95:7e07b6fb45cf | 624 | |
Kojto | 95:7e07b6fb45cf | 625 | __ASM volatile ("mrs %0, apsr" : "=r" (result) ); |
Kojto | 95:7e07b6fb45cf | 626 | return (result); |
Kojto | 95:7e07b6fb45cf | 627 | #else |
Kojto | 95:7e07b6fb45cf | 628 | register uint32_t __regAPSR __ASM("apsr"); |
Kojto | 95:7e07b6fb45cf | 629 | return(__regAPSR); |
Kojto | 95:7e07b6fb45cf | 630 | #endif |
Kojto | 95:7e07b6fb45cf | 631 | } |
Kojto | 95:7e07b6fb45cf | 632 | |
Kojto | 95:7e07b6fb45cf | 633 | |
Kojto | 95:7e07b6fb45cf | 634 | /** \brief Get CPSR Register |
Kojto | 95:7e07b6fb45cf | 635 | |
Kojto | 95:7e07b6fb45cf | 636 | This function returns the content of the CPSR Register. |
Kojto | 95:7e07b6fb45cf | 637 | |
Kojto | 95:7e07b6fb45cf | 638 | \return CPSR Register value |
Kojto | 95:7e07b6fb45cf | 639 | */ |
Kojto | 95:7e07b6fb45cf | 640 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CPSR(void) |
Kojto | 95:7e07b6fb45cf | 641 | { |
Kojto | 95:7e07b6fb45cf | 642 | #if 1 |
Kojto | 95:7e07b6fb45cf | 643 | register uint32_t __regCPSR; |
Kojto | 95:7e07b6fb45cf | 644 | __ASM volatile ("mrs %0, cpsr" : "=r" (__regCPSR)); |
Kojto | 95:7e07b6fb45cf | 645 | #else |
Kojto | 95:7e07b6fb45cf | 646 | register uint32_t __regCPSR __ASM("cpsr"); |
Kojto | 95:7e07b6fb45cf | 647 | #endif |
Kojto | 95:7e07b6fb45cf | 648 | return(__regCPSR); |
Kojto | 95:7e07b6fb45cf | 649 | } |
Kojto | 95:7e07b6fb45cf | 650 | |
Kojto | 95:7e07b6fb45cf | 651 | #if 0 |
Kojto | 95:7e07b6fb45cf | 652 | /** \brief Set Stack Pointer |
Kojto | 95:7e07b6fb45cf | 653 | |
Kojto | 95:7e07b6fb45cf | 654 | This function assigns the given value to the current stack pointer. |
Kojto | 95:7e07b6fb45cf | 655 | |
Kojto | 95:7e07b6fb45cf | 656 | \param [in] topOfStack Stack Pointer value to set |
Kojto | 95:7e07b6fb45cf | 657 | */ |
Kojto | 95:7e07b6fb45cf | 658 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_SP(uint32_t topOfStack) |
Kojto | 95:7e07b6fb45cf | 659 | { |
Kojto | 95:7e07b6fb45cf | 660 | register uint32_t __regSP __ASM("sp"); |
Kojto | 95:7e07b6fb45cf | 661 | __regSP = topOfStack; |
Kojto | 95:7e07b6fb45cf | 662 | } |
Kojto | 95:7e07b6fb45cf | 663 | #endif |
Kojto | 95:7e07b6fb45cf | 664 | |
Kojto | 95:7e07b6fb45cf | 665 | /** \brief Get link register |
Kojto | 95:7e07b6fb45cf | 666 | |
Kojto | 95:7e07b6fb45cf | 667 | This function returns the value of the link register |
Kojto | 95:7e07b6fb45cf | 668 | |
Kojto | 95:7e07b6fb45cf | 669 | \return Value of link register |
Kojto | 95:7e07b6fb45cf | 670 | */ |
Kojto | 95:7e07b6fb45cf | 671 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_LR(void) |
Kojto | 95:7e07b6fb45cf | 672 | { |
Kojto | 95:7e07b6fb45cf | 673 | register uint32_t __reglr __ASM("lr"); |
Kojto | 95:7e07b6fb45cf | 674 | return(__reglr); |
Kojto | 95:7e07b6fb45cf | 675 | } |
Kojto | 95:7e07b6fb45cf | 676 | |
Kojto | 95:7e07b6fb45cf | 677 | #if 0 |
Kojto | 95:7e07b6fb45cf | 678 | /** \brief Set link register |
Kojto | 95:7e07b6fb45cf | 679 | |
Kojto | 95:7e07b6fb45cf | 680 | This function sets the value of the link register |
Kojto | 95:7e07b6fb45cf | 681 | |
Kojto | 95:7e07b6fb45cf | 682 | \param [in] lr LR value to set |
Kojto | 95:7e07b6fb45cf | 683 | */ |
Kojto | 95:7e07b6fb45cf | 684 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_LR(uint32_t lr) |
Kojto | 95:7e07b6fb45cf | 685 | { |
Kojto | 95:7e07b6fb45cf | 686 | register uint32_t __reglr __ASM("lr"); |
Kojto | 95:7e07b6fb45cf | 687 | __reglr = lr; |
Kojto | 95:7e07b6fb45cf | 688 | } |
Kojto | 95:7e07b6fb45cf | 689 | #endif |
Kojto | 95:7e07b6fb45cf | 690 | |
Kojto | 95:7e07b6fb45cf | 691 | /** \brief Set Process Stack Pointer |
Kojto | 95:7e07b6fb45cf | 692 | |
Kojto | 95:7e07b6fb45cf | 693 | This function assigns the given value to the USR/SYS Stack Pointer (PSP). |
Kojto | 95:7e07b6fb45cf | 694 | |
Kojto | 95:7e07b6fb45cf | 695 | \param [in] topOfProcStack USR/SYS Stack Pointer value to set |
Kojto | 95:7e07b6fb45cf | 696 | */ |
Kojto | 95:7e07b6fb45cf | 697 | extern void __set_PSP(uint32_t topOfProcStack); |
Kojto | 95:7e07b6fb45cf | 698 | |
Kojto | 95:7e07b6fb45cf | 699 | /** \brief Set User Mode |
Kojto | 95:7e07b6fb45cf | 700 | |
Kojto | 95:7e07b6fb45cf | 701 | This function changes the processor state to User Mode |
Kojto | 95:7e07b6fb45cf | 702 | |
Kojto | 95:7e07b6fb45cf | 703 | \param [in] topOfProcStack USR/SYS Stack Pointer value to set |
Kojto | 95:7e07b6fb45cf | 704 | */ |
Kojto | 95:7e07b6fb45cf | 705 | extern void __set_CPS_USR(void); |
Kojto | 95:7e07b6fb45cf | 706 | |
Kojto | 95:7e07b6fb45cf | 707 | /** \brief Enable FIQ |
Kojto | 95:7e07b6fb45cf | 708 | |
Kojto | 95:7e07b6fb45cf | 709 | This function enables FIQ interrupts by clearing the F-bit in the CPSR. |
Kojto | 95:7e07b6fb45cf | 710 | Can only be executed in Privileged modes. |
Kojto | 95:7e07b6fb45cf | 711 | */ |
Kojto | 95:7e07b6fb45cf | 712 | #define __enable_fault_irq __enable_fiq |
Kojto | 95:7e07b6fb45cf | 713 | |
Kojto | 95:7e07b6fb45cf | 714 | |
Kojto | 95:7e07b6fb45cf | 715 | /** \brief Disable FIQ |
Kojto | 95:7e07b6fb45cf | 716 | |
Kojto | 95:7e07b6fb45cf | 717 | This function disables FIQ interrupts by setting the F-bit in the CPSR. |
Kojto | 95:7e07b6fb45cf | 718 | Can only be executed in Privileged modes. |
Kojto | 95:7e07b6fb45cf | 719 | */ |
Kojto | 95:7e07b6fb45cf | 720 | #define __disable_fault_irq __disable_fiq |
Kojto | 95:7e07b6fb45cf | 721 | |
Kojto | 95:7e07b6fb45cf | 722 | |
Kojto | 95:7e07b6fb45cf | 723 | /** \brief Get FPSCR |
Kojto | 95:7e07b6fb45cf | 724 | |
Kojto | 95:7e07b6fb45cf | 725 | This function returns the current value of the Floating Point Status/Control register. |
Kojto | 95:7e07b6fb45cf | 726 | |
Kojto | 95:7e07b6fb45cf | 727 | \return Floating Point Status/Control register value |
Kojto | 95:7e07b6fb45cf | 728 | */ |
Kojto | 95:7e07b6fb45cf | 729 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) |
Kojto | 95:7e07b6fb45cf | 730 | { |
Kojto | 95:7e07b6fb45cf | 731 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
Kojto | 95:7e07b6fb45cf | 732 | #if 1 |
Kojto | 95:7e07b6fb45cf | 733 | uint32_t result; |
Kojto | 95:7e07b6fb45cf | 734 | |
Kojto | 95:7e07b6fb45cf | 735 | __ASM volatile ("vmrs %0, fpscr" : "=r" (result) ); |
Kojto | 95:7e07b6fb45cf | 736 | return (result); |
Kojto | 95:7e07b6fb45cf | 737 | #else |
Kojto | 95:7e07b6fb45cf | 738 | register uint32_t __regfpscr __ASM("fpscr"); |
Kojto | 95:7e07b6fb45cf | 739 | return(__regfpscr); |
Kojto | 95:7e07b6fb45cf | 740 | #endif |
Kojto | 95:7e07b6fb45cf | 741 | #else |
Kojto | 95:7e07b6fb45cf | 742 | return(0); |
Kojto | 95:7e07b6fb45cf | 743 | #endif |
Kojto | 95:7e07b6fb45cf | 744 | } |
Kojto | 95:7e07b6fb45cf | 745 | |
Kojto | 95:7e07b6fb45cf | 746 | |
Kojto | 95:7e07b6fb45cf | 747 | /** \brief Set FPSCR |
Kojto | 95:7e07b6fb45cf | 748 | |
Kojto | 95:7e07b6fb45cf | 749 | This function assigns the given value to the Floating Point Status/Control register. |
Kojto | 95:7e07b6fb45cf | 750 | |
Kojto | 95:7e07b6fb45cf | 751 | \param [in] fpscr Floating Point Status/Control value to set |
Kojto | 95:7e07b6fb45cf | 752 | */ |
Kojto | 95:7e07b6fb45cf | 753 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) |
Kojto | 95:7e07b6fb45cf | 754 | { |
Kojto | 95:7e07b6fb45cf | 755 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
Kojto | 95:7e07b6fb45cf | 756 | #if 1 |
Kojto | 95:7e07b6fb45cf | 757 | __ASM volatile ("vmsr fpscr, %0" : : "r" (fpscr) ); |
Kojto | 95:7e07b6fb45cf | 758 | #else |
Kojto | 95:7e07b6fb45cf | 759 | register uint32_t __regfpscr __ASM("fpscr"); |
Kojto | 95:7e07b6fb45cf | 760 | __regfpscr = (fpscr); |
Kojto | 95:7e07b6fb45cf | 761 | #endif |
Kojto | 95:7e07b6fb45cf | 762 | #endif |
Kojto | 95:7e07b6fb45cf | 763 | } |
Kojto | 95:7e07b6fb45cf | 764 | |
Kojto | 95:7e07b6fb45cf | 765 | /** \brief Get FPEXC |
Kojto | 95:7e07b6fb45cf | 766 | |
Kojto | 95:7e07b6fb45cf | 767 | This function returns the current value of the Floating Point Exception Control register. |
Kojto | 95:7e07b6fb45cf | 768 | |
Kojto | 95:7e07b6fb45cf | 769 | \return Floating Point Exception Control register value |
Kojto | 95:7e07b6fb45cf | 770 | */ |
Kojto | 95:7e07b6fb45cf | 771 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPEXC(void) |
Kojto | 95:7e07b6fb45cf | 772 | { |
Kojto | 95:7e07b6fb45cf | 773 | #if (__FPU_PRESENT == 1) |
Kojto | 95:7e07b6fb45cf | 774 | #if 1 |
Kojto | 95:7e07b6fb45cf | 775 | uint32_t result; |
Kojto | 95:7e07b6fb45cf | 776 | |
Kojto | 95:7e07b6fb45cf | 777 | __ASM volatile ("vmrs %0, fpexc" : "=r" (result)); |
Kojto | 95:7e07b6fb45cf | 778 | return (result); |
Kojto | 95:7e07b6fb45cf | 779 | #else |
Kojto | 95:7e07b6fb45cf | 780 | register uint32_t __regfpexc __ASM("fpexc"); |
Kojto | 95:7e07b6fb45cf | 781 | return(__regfpexc); |
Kojto | 95:7e07b6fb45cf | 782 | #endif |
Kojto | 95:7e07b6fb45cf | 783 | #else |
Kojto | 95:7e07b6fb45cf | 784 | return(0); |
Kojto | 95:7e07b6fb45cf | 785 | #endif |
Kojto | 95:7e07b6fb45cf | 786 | } |
Kojto | 95:7e07b6fb45cf | 787 | |
Kojto | 95:7e07b6fb45cf | 788 | |
Kojto | 95:7e07b6fb45cf | 789 | /** \brief Set FPEXC |
Kojto | 95:7e07b6fb45cf | 790 | |
Kojto | 95:7e07b6fb45cf | 791 | This function assigns the given value to the Floating Point Exception Control register. |
Kojto | 95:7e07b6fb45cf | 792 | |
Kojto | 95:7e07b6fb45cf | 793 | \param [in] fpscr Floating Point Exception Control value to set |
Kojto | 95:7e07b6fb45cf | 794 | */ |
Kojto | 95:7e07b6fb45cf | 795 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPEXC(uint32_t fpexc) |
Kojto | 95:7e07b6fb45cf | 796 | { |
Kojto | 95:7e07b6fb45cf | 797 | #if (__FPU_PRESENT == 1) |
Kojto | 95:7e07b6fb45cf | 798 | #if 1 |
Kojto | 95:7e07b6fb45cf | 799 | __ASM volatile ("vmsr fpexc, %0" : : "r" (fpexc)); |
Kojto | 95:7e07b6fb45cf | 800 | #else |
Kojto | 95:7e07b6fb45cf | 801 | register uint32_t __regfpexc __ASM("fpexc"); |
Kojto | 95:7e07b6fb45cf | 802 | __regfpexc = (fpexc); |
Kojto | 95:7e07b6fb45cf | 803 | #endif |
Kojto | 95:7e07b6fb45cf | 804 | #endif |
Kojto | 95:7e07b6fb45cf | 805 | } |
Kojto | 95:7e07b6fb45cf | 806 | |
Kojto | 95:7e07b6fb45cf | 807 | /** \brief Get CPACR |
Kojto | 95:7e07b6fb45cf | 808 | |
Kojto | 95:7e07b6fb45cf | 809 | This function returns the current value of the Coprocessor Access Control register. |
Kojto | 95:7e07b6fb45cf | 810 | |
Kojto | 95:7e07b6fb45cf | 811 | \return Coprocessor Access Control register value |
Kojto | 95:7e07b6fb45cf | 812 | */ |
Kojto | 95:7e07b6fb45cf | 813 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CPACR(void) |
Kojto | 95:7e07b6fb45cf | 814 | { |
Kojto | 95:7e07b6fb45cf | 815 | #if 1 |
Kojto | 95:7e07b6fb45cf | 816 | register uint32_t __regCPACR; |
Kojto | 95:7e07b6fb45cf | 817 | __ASM volatile ("mrc p15, 0, %0, c1, c0, 2" : "=r" (__regCPACR)); |
Kojto | 95:7e07b6fb45cf | 818 | #else |
Kojto | 95:7e07b6fb45cf | 819 | register uint32_t __regCPACR __ASM("cp15:0:c1:c0:2"); |
Kojto | 95:7e07b6fb45cf | 820 | #endif |
Kojto | 95:7e07b6fb45cf | 821 | return __regCPACR; |
Kojto | 95:7e07b6fb45cf | 822 | } |
Kojto | 95:7e07b6fb45cf | 823 | |
Kojto | 95:7e07b6fb45cf | 824 | /** \brief Set CPACR |
Kojto | 95:7e07b6fb45cf | 825 | |
Kojto | 95:7e07b6fb45cf | 826 | This function assigns the given value to the Coprocessor Access Control register. |
Kojto | 95:7e07b6fb45cf | 827 | |
Kojto | 95:7e07b6fb45cf | 828 | \param [in] cpacr Coporcessor Acccess Control value to set |
Kojto | 95:7e07b6fb45cf | 829 | */ |
Kojto | 95:7e07b6fb45cf | 830 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CPACR(uint32_t cpacr) |
Kojto | 95:7e07b6fb45cf | 831 | { |
Kojto | 95:7e07b6fb45cf | 832 | #if 1 |
Kojto | 95:7e07b6fb45cf | 833 | __ASM volatile ("mcr p15, 0, %0, c1, c0, 2" : : "r" (cpacr)); |
Kojto | 95:7e07b6fb45cf | 834 | #else |
Kojto | 95:7e07b6fb45cf | 835 | register uint32_t __regCPACR __ASM("cp15:0:c1:c0:2"); |
Kojto | 95:7e07b6fb45cf | 836 | __regCPACR = cpacr; |
Kojto | 95:7e07b6fb45cf | 837 | #endif |
Kojto | 95:7e07b6fb45cf | 838 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 839 | } |
Kojto | 95:7e07b6fb45cf | 840 | |
Kojto | 95:7e07b6fb45cf | 841 | /** \brief Get CBAR |
Kojto | 95:7e07b6fb45cf | 842 | |
Kojto | 95:7e07b6fb45cf | 843 | This function returns the value of the Configuration Base Address register. |
Kojto | 95:7e07b6fb45cf | 844 | |
Kojto | 95:7e07b6fb45cf | 845 | \return Configuration Base Address register value |
Kojto | 95:7e07b6fb45cf | 846 | */ |
Kojto | 95:7e07b6fb45cf | 847 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CBAR() { |
Kojto | 95:7e07b6fb45cf | 848 | #if 1 |
Kojto | 95:7e07b6fb45cf | 849 | register uint32_t __regCBAR; |
Kojto | 95:7e07b6fb45cf | 850 | __ASM volatile ("mrc p15, 4, %0, c15, c0, 0" : "=r" (__regCBAR)); |
Kojto | 95:7e07b6fb45cf | 851 | #else |
Kojto | 95:7e07b6fb45cf | 852 | register uint32_t __regCBAR __ASM("cp15:4:c15:c0:0"); |
Kojto | 95:7e07b6fb45cf | 853 | #endif |
Kojto | 95:7e07b6fb45cf | 854 | return(__regCBAR); |
Kojto | 95:7e07b6fb45cf | 855 | } |
Kojto | 95:7e07b6fb45cf | 856 | |
Kojto | 95:7e07b6fb45cf | 857 | /** \brief Get TTBR0 |
Kojto | 95:7e07b6fb45cf | 858 | |
Kojto | 95:7e07b6fb45cf | 859 | This function returns the value of the Configuration Base Address register. |
Kojto | 95:7e07b6fb45cf | 860 | |
Kojto | 95:7e07b6fb45cf | 861 | \return Translation Table Base Register 0 value |
Kojto | 95:7e07b6fb45cf | 862 | */ |
Kojto | 95:7e07b6fb45cf | 863 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_TTBR0() { |
Kojto | 95:7e07b6fb45cf | 864 | #if 1 |
Kojto | 95:7e07b6fb45cf | 865 | register uint32_t __regTTBR0; |
Kojto | 95:7e07b6fb45cf | 866 | __ASM volatile ("mrc p15, 0, %0, c2, c0, 0" : "=r" (__regTTBR0)); |
Kojto | 95:7e07b6fb45cf | 867 | #else |
Kojto | 95:7e07b6fb45cf | 868 | register uint32_t __regTTBR0 __ASM("cp15:0:c2:c0:0"); |
Kojto | 95:7e07b6fb45cf | 869 | #endif |
Kojto | 95:7e07b6fb45cf | 870 | return(__regTTBR0); |
Kojto | 95:7e07b6fb45cf | 871 | } |
Kojto | 95:7e07b6fb45cf | 872 | |
Kojto | 95:7e07b6fb45cf | 873 | /** \brief Set TTBR0 |
Kojto | 95:7e07b6fb45cf | 874 | |
Kojto | 95:7e07b6fb45cf | 875 | This function assigns the given value to the Coprocessor Access Control register. |
Kojto | 95:7e07b6fb45cf | 876 | |
Kojto | 95:7e07b6fb45cf | 877 | \param [in] ttbr0 Translation Table Base Register 0 value to set |
Kojto | 95:7e07b6fb45cf | 878 | */ |
Kojto | 95:7e07b6fb45cf | 879 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_TTBR0(uint32_t ttbr0) { |
Kojto | 95:7e07b6fb45cf | 880 | #if 1 |
Kojto | 95:7e07b6fb45cf | 881 | __ASM volatile ("mcr p15, 0, %0, c2, c0, 0" : : "r" (ttbr0)); |
Kojto | 95:7e07b6fb45cf | 882 | #else |
Kojto | 95:7e07b6fb45cf | 883 | register uint32_t __regTTBR0 __ASM("cp15:0:c2:c0:0"); |
Kojto | 95:7e07b6fb45cf | 884 | __regTTBR0 = ttbr0; |
Kojto | 95:7e07b6fb45cf | 885 | #endif |
Kojto | 95:7e07b6fb45cf | 886 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 887 | } |
Kojto | 95:7e07b6fb45cf | 888 | |
Kojto | 95:7e07b6fb45cf | 889 | /** \brief Get DACR |
Kojto | 95:7e07b6fb45cf | 890 | |
Kojto | 95:7e07b6fb45cf | 891 | This function returns the value of the Domain Access Control Register. |
Kojto | 95:7e07b6fb45cf | 892 | |
Kojto | 95:7e07b6fb45cf | 893 | \return Domain Access Control Register value |
Kojto | 95:7e07b6fb45cf | 894 | */ |
Kojto | 95:7e07b6fb45cf | 895 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_DACR() { |
Kojto | 95:7e07b6fb45cf | 896 | #if 1 |
Kojto | 95:7e07b6fb45cf | 897 | register uint32_t __regDACR; |
Kojto | 95:7e07b6fb45cf | 898 | __ASM volatile ("mrc p15, 0, %0, c3, c0, 0" : "=r" (__regDACR)); |
Kojto | 95:7e07b6fb45cf | 899 | #else |
Kojto | 95:7e07b6fb45cf | 900 | register uint32_t __regDACR __ASM("cp15:0:c3:c0:0"); |
Kojto | 95:7e07b6fb45cf | 901 | #endif |
Kojto | 95:7e07b6fb45cf | 902 | return(__regDACR); |
Kojto | 95:7e07b6fb45cf | 903 | } |
Kojto | 95:7e07b6fb45cf | 904 | |
Kojto | 95:7e07b6fb45cf | 905 | /** \brief Set DACR |
Kojto | 95:7e07b6fb45cf | 906 | |
Kojto | 95:7e07b6fb45cf | 907 | This function assigns the given value to the Coprocessor Access Control register. |
Kojto | 95:7e07b6fb45cf | 908 | |
Kojto | 95:7e07b6fb45cf | 909 | \param [in] dacr Domain Access Control Register value to set |
Kojto | 95:7e07b6fb45cf | 910 | */ |
Kojto | 95:7e07b6fb45cf | 911 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_DACR(uint32_t dacr) { |
Kojto | 95:7e07b6fb45cf | 912 | #if 1 |
Kojto | 95:7e07b6fb45cf | 913 | __ASM volatile ("mcr p15, 0, %0, c3, c0, 0" : : "r" (dacr)); |
Kojto | 95:7e07b6fb45cf | 914 | #else |
Kojto | 95:7e07b6fb45cf | 915 | register uint32_t __regDACR __ASM("cp15:0:c3:c0:0"); |
Kojto | 95:7e07b6fb45cf | 916 | __regDACR = dacr; |
Kojto | 95:7e07b6fb45cf | 917 | #endif |
Kojto | 95:7e07b6fb45cf | 918 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 919 | } |
Kojto | 95:7e07b6fb45cf | 920 | |
Kojto | 95:7e07b6fb45cf | 921 | /******************************** Cache and BTAC enable ****************************************************/ |
Kojto | 95:7e07b6fb45cf | 922 | |
Kojto | 95:7e07b6fb45cf | 923 | /** \brief Set SCTLR |
Kojto | 95:7e07b6fb45cf | 924 | |
Kojto | 95:7e07b6fb45cf | 925 | This function assigns the given value to the System Control Register. |
Kojto | 95:7e07b6fb45cf | 926 | |
Kojto | 95:7e07b6fb45cf | 927 | \param [in] sctlr System Control Register, value to set |
Kojto | 95:7e07b6fb45cf | 928 | */ |
Kojto | 95:7e07b6fb45cf | 929 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_SCTLR(uint32_t sctlr) |
Kojto | 95:7e07b6fb45cf | 930 | { |
Kojto | 95:7e07b6fb45cf | 931 | #if 1 |
Kojto | 95:7e07b6fb45cf | 932 | __ASM volatile ("mcr p15, 0, %0, c1, c0, 0" : : "r" (sctlr)); |
Kojto | 95:7e07b6fb45cf | 933 | #else |
Kojto | 95:7e07b6fb45cf | 934 | register uint32_t __regSCTLR __ASM("cp15:0:c1:c0:0"); |
Kojto | 95:7e07b6fb45cf | 935 | __regSCTLR = sctlr; |
Kojto | 95:7e07b6fb45cf | 936 | #endif |
Kojto | 95:7e07b6fb45cf | 937 | } |
Kojto | 95:7e07b6fb45cf | 938 | |
Kojto | 95:7e07b6fb45cf | 939 | /** \brief Get SCTLR |
Kojto | 95:7e07b6fb45cf | 940 | |
Kojto | 95:7e07b6fb45cf | 941 | This function returns the value of the System Control Register. |
Kojto | 95:7e07b6fb45cf | 942 | |
Kojto | 95:7e07b6fb45cf | 943 | \return System Control Register value |
Kojto | 95:7e07b6fb45cf | 944 | */ |
Kojto | 95:7e07b6fb45cf | 945 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_SCTLR() { |
Kojto | 95:7e07b6fb45cf | 946 | #if 1 |
Kojto | 95:7e07b6fb45cf | 947 | register uint32_t __regSCTLR; |
Kojto | 95:7e07b6fb45cf | 948 | __ASM volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r" (__regSCTLR)); |
Kojto | 95:7e07b6fb45cf | 949 | #else |
Kojto | 95:7e07b6fb45cf | 950 | register uint32_t __regSCTLR __ASM("cp15:0:c1:c0:0"); |
Kojto | 95:7e07b6fb45cf | 951 | #endif |
Kojto | 95:7e07b6fb45cf | 952 | return(__regSCTLR); |
Kojto | 95:7e07b6fb45cf | 953 | } |
Kojto | 95:7e07b6fb45cf | 954 | |
Kojto | 95:7e07b6fb45cf | 955 | /** \brief Enable Caches |
Kojto | 95:7e07b6fb45cf | 956 | |
Kojto | 95:7e07b6fb45cf | 957 | Enable Caches |
Kojto | 95:7e07b6fb45cf | 958 | */ |
Kojto | 95:7e07b6fb45cf | 959 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_caches(void) { |
Kojto | 95:7e07b6fb45cf | 960 | // Set I bit 12 to enable I Cache |
Kojto | 95:7e07b6fb45cf | 961 | // Set C bit 2 to enable D Cache |
Kojto | 95:7e07b6fb45cf | 962 | __set_SCTLR( __get_SCTLR() | (1 << 12) | (1 << 2)); |
Kojto | 95:7e07b6fb45cf | 963 | } |
Kojto | 95:7e07b6fb45cf | 964 | |
Kojto | 95:7e07b6fb45cf | 965 | /** \brief Disable Caches |
Kojto | 95:7e07b6fb45cf | 966 | |
Kojto | 95:7e07b6fb45cf | 967 | Disable Caches |
Kojto | 95:7e07b6fb45cf | 968 | */ |
Kojto | 95:7e07b6fb45cf | 969 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_caches(void) { |
Kojto | 95:7e07b6fb45cf | 970 | // Clear I bit 12 to disable I Cache |
Kojto | 95:7e07b6fb45cf | 971 | // Clear C bit 2 to disable D Cache |
Kojto | 95:7e07b6fb45cf | 972 | __set_SCTLR( __get_SCTLR() & ~(1 << 12) & ~(1 << 2)); |
Kojto | 95:7e07b6fb45cf | 973 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 974 | } |
Kojto | 95:7e07b6fb45cf | 975 | |
Kojto | 95:7e07b6fb45cf | 976 | /** \brief Enable BTAC |
Kojto | 95:7e07b6fb45cf | 977 | |
Kojto | 95:7e07b6fb45cf | 978 | Enable BTAC |
Kojto | 95:7e07b6fb45cf | 979 | */ |
Kojto | 95:7e07b6fb45cf | 980 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_btac(void) { |
Kojto | 95:7e07b6fb45cf | 981 | // Set Z bit 11 to enable branch prediction |
Kojto | 95:7e07b6fb45cf | 982 | __set_SCTLR( __get_SCTLR() | (1 << 11)); |
Kojto | 95:7e07b6fb45cf | 983 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 984 | } |
Kojto | 95:7e07b6fb45cf | 985 | |
Kojto | 95:7e07b6fb45cf | 986 | /** \brief Disable BTAC |
Kojto | 95:7e07b6fb45cf | 987 | |
Kojto | 95:7e07b6fb45cf | 988 | Disable BTAC |
Kojto | 95:7e07b6fb45cf | 989 | */ |
Kojto | 95:7e07b6fb45cf | 990 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_btac(void) { |
Kojto | 95:7e07b6fb45cf | 991 | // Clear Z bit 11 to disable branch prediction |
Kojto | 95:7e07b6fb45cf | 992 | __set_SCTLR( __get_SCTLR() & ~(1 << 11)); |
Kojto | 95:7e07b6fb45cf | 993 | } |
Kojto | 95:7e07b6fb45cf | 994 | |
Kojto | 95:7e07b6fb45cf | 995 | |
Kojto | 95:7e07b6fb45cf | 996 | /** \brief Enable MMU |
Kojto | 95:7e07b6fb45cf | 997 | |
Kojto | 95:7e07b6fb45cf | 998 | Enable MMU |
Kojto | 95:7e07b6fb45cf | 999 | */ |
Kojto | 95:7e07b6fb45cf | 1000 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_mmu(void) { |
Kojto | 95:7e07b6fb45cf | 1001 | // Set M bit 0 to enable the MMU |
Kojto | 95:7e07b6fb45cf | 1002 | // Set AFE bit to enable simplified access permissions model |
Kojto | 95:7e07b6fb45cf | 1003 | // Clear TRE bit to disable TEX remap and A bit to disable strict alignment fault checking |
Kojto | 95:7e07b6fb45cf | 1004 | __set_SCTLR( (__get_SCTLR() & ~(1 << 28) & ~(1 << 1)) | 1 | (1 << 29)); |
Kojto | 95:7e07b6fb45cf | 1005 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 1006 | } |
Kojto | 95:7e07b6fb45cf | 1007 | |
Kojto | 95:7e07b6fb45cf | 1008 | /** \brief Enable MMU |
Kojto | 95:7e07b6fb45cf | 1009 | |
Kojto | 95:7e07b6fb45cf | 1010 | Enable MMU |
Kojto | 95:7e07b6fb45cf | 1011 | */ |
Kojto | 95:7e07b6fb45cf | 1012 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_mmu(void) { |
Kojto | 95:7e07b6fb45cf | 1013 | // Clear M bit 0 to disable the MMU |
Kojto | 95:7e07b6fb45cf | 1014 | __set_SCTLR( __get_SCTLR() & ~1); |
Kojto | 95:7e07b6fb45cf | 1015 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 1016 | } |
Kojto | 95:7e07b6fb45cf | 1017 | |
Kojto | 95:7e07b6fb45cf | 1018 | /******************************** TLB maintenance operations ************************************************/ |
Kojto | 95:7e07b6fb45cf | 1019 | /** \brief Invalidate the whole tlb |
Kojto | 95:7e07b6fb45cf | 1020 | |
Kojto | 95:7e07b6fb45cf | 1021 | TLBIALL. Invalidate the whole tlb |
Kojto | 95:7e07b6fb45cf | 1022 | */ |
Kojto | 95:7e07b6fb45cf | 1023 | |
Kojto | 95:7e07b6fb45cf | 1024 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __ca9u_inv_tlb_all(void) { |
Kojto | 95:7e07b6fb45cf | 1025 | #if 1 |
Kojto | 95:7e07b6fb45cf | 1026 | __ASM volatile ("mcr p15, 0, %0, c8, c7, 0" : : "r" (0)); |
Kojto | 95:7e07b6fb45cf | 1027 | #else |
Kojto | 95:7e07b6fb45cf | 1028 | register uint32_t __TLBIALL __ASM("cp15:0:c8:c7:0"); |
Kojto | 95:7e07b6fb45cf | 1029 | __TLBIALL = 0; |
Kojto | 95:7e07b6fb45cf | 1030 | #endif |
Kojto | 95:7e07b6fb45cf | 1031 | __DSB(); |
Kojto | 95:7e07b6fb45cf | 1032 | __ISB(); |
Kojto | 95:7e07b6fb45cf | 1033 | } |
Kojto | 95:7e07b6fb45cf | 1034 | |
Kojto | 95:7e07b6fb45cf | 1035 | /******************************** BTB maintenance operations ************************************************/ |
Kojto | 95:7e07b6fb45cf | 1036 | /** \brief Invalidate entire branch predictor array |
Kojto | 95:7e07b6fb45cf | 1037 | |
Kojto | 95:7e07b6fb45cf | 1038 | BPIALL. Branch Predictor Invalidate All. |
Kojto | 95:7e07b6fb45cf | 1039 | */ |
Kojto | 95:7e07b6fb45cf | 1040 | |
Kojto | 95:7e07b6fb45cf | 1041 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_inv_btac(void) { |
Kojto | 95:7e07b6fb45cf | 1042 | #if 1 |
Kojto | 95:7e07b6fb45cf | 1043 | __ASM volatile ("mcr p15, 0, %0, c7, c5, 6" : : "r" (0)); |
Kojto | 95:7e07b6fb45cf | 1044 | #else |
Kojto | 95:7e07b6fb45cf | 1045 | register uint32_t __BPIALL __ASM("cp15:0:c7:c5:6"); |
Kojto | 95:7e07b6fb45cf | 1046 | __BPIALL = 0; |
Kojto | 95:7e07b6fb45cf | 1047 | #endif |
Kojto | 95:7e07b6fb45cf | 1048 | __DSB(); //ensure completion of the invalidation |
Kojto | 95:7e07b6fb45cf | 1049 | __ISB(); //ensure instruction fetch path sees new state |
Kojto | 95:7e07b6fb45cf | 1050 | } |
Kojto | 95:7e07b6fb45cf | 1051 | |
Kojto | 95:7e07b6fb45cf | 1052 | |
Kojto | 95:7e07b6fb45cf | 1053 | /******************************** L1 cache operations ******************************************************/ |
Kojto | 95:7e07b6fb45cf | 1054 | |
Kojto | 95:7e07b6fb45cf | 1055 | /** \brief Invalidate the whole I$ |
Kojto | 95:7e07b6fb45cf | 1056 | |
Kojto | 95:7e07b6fb45cf | 1057 | ICIALLU. Instruction Cache Invalidate All to PoU |
Kojto | 95:7e07b6fb45cf | 1058 | */ |
Kojto | 95:7e07b6fb45cf | 1059 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_inv_icache_all(void) { |
Kojto | 95:7e07b6fb45cf | 1060 | #if 1 |
Kojto | 95:7e07b6fb45cf | 1061 | __ASM volatile ("mcr p15, 0, %0, c7, c5, 0" : : "r" (0)); |
Kojto | 95:7e07b6fb45cf | 1062 | #else |
Kojto | 95:7e07b6fb45cf | 1063 | register uint32_t __ICIALLU __ASM("cp15:0:c7:c5:0"); |
Kojto | 95:7e07b6fb45cf | 1064 | __ICIALLU = 0; |
Kojto | 95:7e07b6fb45cf | 1065 | #endif |
Kojto | 95:7e07b6fb45cf | 1066 | __DSB(); //ensure completion of the invalidation |
Kojto | 95:7e07b6fb45cf | 1067 | __ISB(); //ensure instruction fetch path sees new I cache state |
Kojto | 95:7e07b6fb45cf | 1068 | } |
Kojto | 95:7e07b6fb45cf | 1069 | |
Kojto | 95:7e07b6fb45cf | 1070 | /** \brief Clean D$ by MVA |
Kojto | 95:7e07b6fb45cf | 1071 | |
Kojto | 95:7e07b6fb45cf | 1072 | DCCMVAC. Data cache clean by MVA to PoC |
Kojto | 95:7e07b6fb45cf | 1073 | */ |
Kojto | 95:7e07b6fb45cf | 1074 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_clean_dcache_mva(void *va) { |
Kojto | 95:7e07b6fb45cf | 1075 | #if 1 |
Kojto | 95:7e07b6fb45cf | 1076 | __ASM volatile ("mcr p15, 0, %0, c7, c10, 1" : : "r" ((uint32_t)va)); |
Kojto | 95:7e07b6fb45cf | 1077 | #else |
Kojto | 95:7e07b6fb45cf | 1078 | register uint32_t __DCCMVAC __ASM("cp15:0:c7:c10:1"); |
Kojto | 95:7e07b6fb45cf | 1079 | __DCCMVAC = (uint32_t)va; |
Kojto | 95:7e07b6fb45cf | 1080 | #endif |
Kojto | 95:7e07b6fb45cf | 1081 | __DMB(); //ensure the ordering of data cache maintenance operations and their effects |
Kojto | 95:7e07b6fb45cf | 1082 | } |
Kojto | 95:7e07b6fb45cf | 1083 | |
Kojto | 95:7e07b6fb45cf | 1084 | /** \brief Invalidate D$ by MVA |
Kojto | 95:7e07b6fb45cf | 1085 | |
Kojto | 95:7e07b6fb45cf | 1086 | DCIMVAC. Data cache invalidate by MVA to PoC |
Kojto | 95:7e07b6fb45cf | 1087 | */ |
Kojto | 95:7e07b6fb45cf | 1088 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_inv_dcache_mva(void *va) { |
Kojto | 95:7e07b6fb45cf | 1089 | #if 1 |
Kojto | 95:7e07b6fb45cf | 1090 | __ASM volatile ("mcr p15, 0, %0, c7, c6, 1" : : "r" ((uint32_t)va)); |
Kojto | 95:7e07b6fb45cf | 1091 | #else |
Kojto | 95:7e07b6fb45cf | 1092 | register uint32_t __DCIMVAC __ASM("cp15:0:c7:c6:1"); |
Kojto | 95:7e07b6fb45cf | 1093 | __DCIMVAC = (uint32_t)va; |
Kojto | 95:7e07b6fb45cf | 1094 | #endif |
Kojto | 95:7e07b6fb45cf | 1095 | __DMB(); //ensure the ordering of data cache maintenance operations and their effects |
Kojto | 95:7e07b6fb45cf | 1096 | } |
Kojto | 95:7e07b6fb45cf | 1097 | |
Kojto | 95:7e07b6fb45cf | 1098 | /** \brief Clean and Invalidate D$ by MVA |
Kojto | 95:7e07b6fb45cf | 1099 | |
Kojto | 95:7e07b6fb45cf | 1100 | DCCIMVAC. Data cache clean and invalidate by MVA to PoC |
Kojto | 95:7e07b6fb45cf | 1101 | */ |
Kojto | 95:7e07b6fb45cf | 1102 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_clean_inv_dcache_mva(void *va) { |
Kojto | 95:7e07b6fb45cf | 1103 | #if 1 |
Kojto | 95:7e07b6fb45cf | 1104 | __ASM volatile ("mcr p15, 0, %0, c7, c14, 1" : : "r" ((uint32_t)va)); |
Kojto | 95:7e07b6fb45cf | 1105 | #else |
Kojto | 95:7e07b6fb45cf | 1106 | register uint32_t __DCCIMVAC __ASM("cp15:0:c7:c14:1"); |
Kojto | 95:7e07b6fb45cf | 1107 | __DCCIMVAC = (uint32_t)va; |
Kojto | 95:7e07b6fb45cf | 1108 | #endif |
Kojto | 95:7e07b6fb45cf | 1109 | __DMB(); //ensure the ordering of data cache maintenance operations and their effects |
Kojto | 95:7e07b6fb45cf | 1110 | } |
Kojto | 95:7e07b6fb45cf | 1111 | |
Kojto | 95:7e07b6fb45cf | 1112 | /** \brief |
Kojto | 95:7e07b6fb45cf | 1113 | * Generic mechanism for cleaning/invalidating the entire data or unified cache to the point of coherency. |
Kojto | 95:7e07b6fb45cf | 1114 | */ |
Kojto | 95:7e07b6fb45cf | 1115 | |
Kojto | 95:7e07b6fb45cf | 1116 | /** \brief __v7_all_cache - helper function |
Kojto | 95:7e07b6fb45cf | 1117 | |
Kojto | 95:7e07b6fb45cf | 1118 | */ |
Kojto | 95:7e07b6fb45cf | 1119 | |
Kojto | 95:7e07b6fb45cf | 1120 | extern void __v7_all_cache(uint32_t op); |
Kojto | 95:7e07b6fb45cf | 1121 | |
Kojto | 95:7e07b6fb45cf | 1122 | |
Kojto | 95:7e07b6fb45cf | 1123 | /** \brief Invalidate the whole D$ |
Kojto | 95:7e07b6fb45cf | 1124 | |
Kojto | 95:7e07b6fb45cf | 1125 | DCISW. Invalidate by Set/Way |
Kojto | 95:7e07b6fb45cf | 1126 | */ |
Kojto | 95:7e07b6fb45cf | 1127 | |
Kojto | 95:7e07b6fb45cf | 1128 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_inv_dcache_all(void) { |
Kojto | 95:7e07b6fb45cf | 1129 | __v7_all_cache(0); |
Kojto | 95:7e07b6fb45cf | 1130 | } |
Kojto | 95:7e07b6fb45cf | 1131 | |
Kojto | 95:7e07b6fb45cf | 1132 | /** \brief Clean the whole D$ |
Kojto | 95:7e07b6fb45cf | 1133 | |
Kojto | 95:7e07b6fb45cf | 1134 | DCCSW. Clean by Set/Way |
Kojto | 95:7e07b6fb45cf | 1135 | */ |
Kojto | 95:7e07b6fb45cf | 1136 | |
Kojto | 95:7e07b6fb45cf | 1137 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_clean_dcache_all(void) { |
Kojto | 95:7e07b6fb45cf | 1138 | __v7_all_cache(1); |
Kojto | 95:7e07b6fb45cf | 1139 | } |
Kojto | 95:7e07b6fb45cf | 1140 | |
Kojto | 95:7e07b6fb45cf | 1141 | /** \brief Clean and invalidate the whole D$ |
Kojto | 95:7e07b6fb45cf | 1142 | |
Kojto | 95:7e07b6fb45cf | 1143 | DCCISW. Clean and Invalidate by Set/Way |
Kojto | 95:7e07b6fb45cf | 1144 | */ |
Kojto | 95:7e07b6fb45cf | 1145 | |
Kojto | 95:7e07b6fb45cf | 1146 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __v7_clean_inv_dcache_all(void) { |
Kojto | 95:7e07b6fb45cf | 1147 | __v7_all_cache(2); |
Kojto | 95:7e07b6fb45cf | 1148 | } |
Kojto | 95:7e07b6fb45cf | 1149 | |
Kojto | 95:7e07b6fb45cf | 1150 | #include "core_ca_mmu.h" |
bogdanm | 92:4fc01daae5a5 | 1151 | |
bogdanm | 92:4fc01daae5a5 | 1152 | #elif (defined (__TASKING__)) /*--------------- TASKING Compiler -----------------*/ |
bogdanm | 92:4fc01daae5a5 | 1153 | |
bogdanm | 92:4fc01daae5a5 | 1154 | #error TASKING Compiler support not implemented for Cortex-A |
bogdanm | 92:4fc01daae5a5 | 1155 | |
bogdanm | 92:4fc01daae5a5 | 1156 | #endif |
bogdanm | 92:4fc01daae5a5 | 1157 | |
bogdanm | 92:4fc01daae5a5 | 1158 | /*@} end of CMSIS_Core_RegAccFunctions */ |
bogdanm | 92:4fc01daae5a5 | 1159 | |
bogdanm | 92:4fc01daae5a5 | 1160 | |
bogdanm | 92:4fc01daae5a5 | 1161 | #endif /* __CORE_CAFUNC_H__ */ |