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