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.

Committer:
AnnaBridge
Date:
Thu Sep 06 13:39:34 2018 +0100
Revision:
170:e95d10626187
Parent:
169:a7c7b631e539
mbed library. Release version 163

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 145:64910690c574 1 /**************************************************************************//**
AnnaBridge 145:64910690c574 2 * @file core_ca.h
AnnaBridge 145:64910690c574 3 * @brief CMSIS Cortex-A Core Peripheral Access Layer Header File
AnnaBridge 145:64910690c574 4 * @version V1.00
AnnaBridge 145:64910690c574 5 * @date 22. Feb 2017
AnnaBridge 145:64910690c574 6 ******************************************************************************/
AnnaBridge 145:64910690c574 7 /*
AnnaBridge 145:64910690c574 8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
AnnaBridge 145:64910690c574 9 *
AnnaBridge 145:64910690c574 10 * SPDX-License-Identifier: Apache-2.0
AnnaBridge 145:64910690c574 11 *
AnnaBridge 145:64910690c574 12 * Licensed under the Apache License, Version 2.0 (the License); you may
AnnaBridge 145:64910690c574 13 * not use this file except in compliance with the License.
AnnaBridge 145:64910690c574 14 * You may obtain a copy of the License at
AnnaBridge 145:64910690c574 15 *
AnnaBridge 145:64910690c574 16 * www.apache.org/licenses/LICENSE-2.0
AnnaBridge 145:64910690c574 17 *
AnnaBridge 145:64910690c574 18 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 145:64910690c574 19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
AnnaBridge 145:64910690c574 20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 145:64910690c574 21 * See the License for the specific language governing permissions and
AnnaBridge 145:64910690c574 22 * limitations under the License.
AnnaBridge 145:64910690c574 23 */
AnnaBridge 145:64910690c574 24
Anna Bridge 160:5571c4ff569f 25 #if defined ( __ICCARM__ )
Anna Bridge 160:5571c4ff569f 26 #pragma system_include /* treat file as system include file for MISRA check */
Anna Bridge 160:5571c4ff569f 27 #elif defined (__clang__)
Anna Bridge 160:5571c4ff569f 28 #pragma clang system_header /* treat file as system include file */
AnnaBridge 145:64910690c574 29 #endif
AnnaBridge 145:64910690c574 30
AnnaBridge 145:64910690c574 31 #ifdef __cplusplus
AnnaBridge 145:64910690c574 32 extern "C" {
AnnaBridge 145:64910690c574 33 #endif
AnnaBridge 145:64910690c574 34
AnnaBridge 145:64910690c574 35 #ifndef __CORE_CA_H_GENERIC
AnnaBridge 145:64910690c574 36 #define __CORE_CA_H_GENERIC
AnnaBridge 145:64910690c574 37
AnnaBridge 145:64910690c574 38
AnnaBridge 145:64910690c574 39 /*******************************************************************************
AnnaBridge 145:64910690c574 40 * CMSIS definitions
AnnaBridge 145:64910690c574 41 ******************************************************************************/
AnnaBridge 145:64910690c574 42
AnnaBridge 145:64910690c574 43 /* CMSIS CA definitions */
Anna Bridge 160:5571c4ff569f 44 #define __CA_CMSIS_VERSION_MAIN (1U) /*!< \brief [31:16] CMSIS-Core(A) main version */
Anna Bridge 160:5571c4ff569f 45 #define __CA_CMSIS_VERSION_SUB (1U) /*!< \brief [15:0] CMSIS-Core(A) sub version */
AnnaBridge 145:64910690c574 46 #define __CA_CMSIS_VERSION ((__CA_CMSIS_VERSION_MAIN << 16U) | \
Anna Bridge 160:5571c4ff569f 47 __CA_CMSIS_VERSION_SUB ) /*!< \brief CMSIS-Core(A) version number */
AnnaBridge 145:64910690c574 48
AnnaBridge 145:64910690c574 49 #if defined ( __CC_ARM )
AnnaBridge 145:64910690c574 50 #if defined __TARGET_FPU_VFP
AnnaBridge 145:64910690c574 51 #if (__FPU_PRESENT == 1)
AnnaBridge 145:64910690c574 52 #define __FPU_USED 1U
AnnaBridge 145:64910690c574 53 #else
AnnaBridge 145:64910690c574 54 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
AnnaBridge 145:64910690c574 55 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 56 #endif
AnnaBridge 145:64910690c574 57 #else
AnnaBridge 145:64910690c574 58 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 59 #endif
AnnaBridge 145:64910690c574 60
Anna Bridge 160:5571c4ff569f 61 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
Anna Bridge 160:5571c4ff569f 62 #if defined __ARM_PCS_VFP
Anna Bridge 160:5571c4ff569f 63 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
Anna Bridge 160:5571c4ff569f 64 #define __FPU_USED 1U
Anna Bridge 160:5571c4ff569f 65 #else
Anna Bridge 160:5571c4ff569f 66 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
Anna Bridge 160:5571c4ff569f 67 #define __FPU_USED 0U
Anna Bridge 160:5571c4ff569f 68 #endif
Anna Bridge 160:5571c4ff569f 69 #else
Anna Bridge 160:5571c4ff569f 70 #define __FPU_USED 0U
Anna Bridge 160:5571c4ff569f 71 #endif
Anna Bridge 160:5571c4ff569f 72
AnnaBridge 145:64910690c574 73 #elif defined ( __ICCARM__ )
AnnaBridge 145:64910690c574 74 #if defined __ARMVFP__
AnnaBridge 145:64910690c574 75 #if (__FPU_PRESENT == 1)
AnnaBridge 145:64910690c574 76 #define __FPU_USED 1U
AnnaBridge 145:64910690c574 77 #else
AnnaBridge 145:64910690c574 78 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
AnnaBridge 145:64910690c574 79 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 80 #endif
AnnaBridge 145:64910690c574 81 #else
AnnaBridge 145:64910690c574 82 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 83 #endif
AnnaBridge 145:64910690c574 84
AnnaBridge 145:64910690c574 85 #elif defined ( __TMS470__ )
AnnaBridge 145:64910690c574 86 #if defined __TI_VFP_SUPPORT__
AnnaBridge 145:64910690c574 87 #if (__FPU_PRESENT == 1)
AnnaBridge 145:64910690c574 88 #define __FPU_USED 1U
AnnaBridge 145:64910690c574 89 #else
AnnaBridge 145:64910690c574 90 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
AnnaBridge 145:64910690c574 91 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 92 #endif
AnnaBridge 145:64910690c574 93 #else
AnnaBridge 145:64910690c574 94 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 95 #endif
AnnaBridge 145:64910690c574 96
AnnaBridge 145:64910690c574 97 #elif defined ( __GNUC__ )
AnnaBridge 145:64910690c574 98 #if defined (__VFP_FP__) && !defined(__SOFTFP__)
AnnaBridge 145:64910690c574 99 #if (__FPU_PRESENT == 1)
AnnaBridge 145:64910690c574 100 #define __FPU_USED 1U
AnnaBridge 145:64910690c574 101 #else
AnnaBridge 145:64910690c574 102 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
AnnaBridge 145:64910690c574 103 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 104 #endif
AnnaBridge 145:64910690c574 105 #else
AnnaBridge 145:64910690c574 106 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 107 #endif
AnnaBridge 145:64910690c574 108
AnnaBridge 145:64910690c574 109 #elif defined ( __TASKING__ )
AnnaBridge 145:64910690c574 110 #if defined __FPU_VFP__
AnnaBridge 145:64910690c574 111 #if (__FPU_PRESENT == 1)
AnnaBridge 145:64910690c574 112 #define __FPU_USED 1U
AnnaBridge 145:64910690c574 113 #else
AnnaBridge 145:64910690c574 114 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
AnnaBridge 145:64910690c574 115 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 116 #endif
AnnaBridge 145:64910690c574 117 #else
AnnaBridge 145:64910690c574 118 #define __FPU_USED 0U
AnnaBridge 145:64910690c574 119 #endif
AnnaBridge 145:64910690c574 120 #endif
AnnaBridge 145:64910690c574 121
AnnaBridge 145:64910690c574 122 #include "cmsis_compiler.h" /* CMSIS compiler specific defines */
AnnaBridge 145:64910690c574 123
AnnaBridge 145:64910690c574 124 #ifdef __cplusplus
AnnaBridge 145:64910690c574 125 }
AnnaBridge 145:64910690c574 126 #endif
AnnaBridge 145:64910690c574 127
AnnaBridge 145:64910690c574 128 #endif /* __CORE_CA_H_GENERIC */
AnnaBridge 145:64910690c574 129
AnnaBridge 145:64910690c574 130 #ifndef __CMSIS_GENERIC
AnnaBridge 145:64910690c574 131
AnnaBridge 145:64910690c574 132 #ifndef __CORE_CA_H_DEPENDANT
AnnaBridge 145:64910690c574 133 #define __CORE_CA_H_DEPENDANT
AnnaBridge 145:64910690c574 134
AnnaBridge 145:64910690c574 135 #ifdef __cplusplus
AnnaBridge 145:64910690c574 136 extern "C" {
AnnaBridge 145:64910690c574 137 #endif
AnnaBridge 145:64910690c574 138
AnnaBridge 145:64910690c574 139 /* check device defines and use defaults */
AnnaBridge 145:64910690c574 140 #if defined __CHECK_DEVICE_DEFINES
AnnaBridge 145:64910690c574 141 #ifndef __CA_REV
AnnaBridge 145:64910690c574 142 #define __CA_REV 0x0000U
AnnaBridge 145:64910690c574 143 #warning "__CA_REV not defined in device header file; using default!"
AnnaBridge 145:64910690c574 144 #endif
AnnaBridge 145:64910690c574 145
AnnaBridge 145:64910690c574 146 #ifndef __FPU_PRESENT
AnnaBridge 145:64910690c574 147 #define __FPU_PRESENT 0U
AnnaBridge 145:64910690c574 148 #warning "__FPU_PRESENT not defined in device header file; using default!"
AnnaBridge 145:64910690c574 149 #endif
Anna Bridge 160:5571c4ff569f 150
AnnaBridge 145:64910690c574 151 #ifndef __GIC_PRESENT
AnnaBridge 145:64910690c574 152 #define __GIC_PRESENT 1U
AnnaBridge 145:64910690c574 153 #warning "__GIC_PRESENT not defined in device header file; using default!"
AnnaBridge 145:64910690c574 154 #endif
AnnaBridge 145:64910690c574 155
AnnaBridge 145:64910690c574 156 #ifndef __TIM_PRESENT
AnnaBridge 145:64910690c574 157 #define __TIM_PRESENT 1U
AnnaBridge 145:64910690c574 158 #warning "__TIM_PRESENT not defined in device header file; using default!"
AnnaBridge 145:64910690c574 159 #endif
AnnaBridge 145:64910690c574 160
AnnaBridge 145:64910690c574 161 #ifndef __L2C_PRESENT
AnnaBridge 145:64910690c574 162 #define __L2C_PRESENT 0U
AnnaBridge 145:64910690c574 163 #warning "__L2C_PRESENT not defined in device header file; using default!"
AnnaBridge 145:64910690c574 164 #endif
AnnaBridge 145:64910690c574 165 #endif
AnnaBridge 145:64910690c574 166
AnnaBridge 145:64910690c574 167 /* IO definitions (access restrictions to peripheral registers) */
AnnaBridge 145:64910690c574 168 #ifdef __cplusplus
AnnaBridge 145:64910690c574 169 #define __I volatile /*!< \brief Defines 'read only' permissions */
AnnaBridge 145:64910690c574 170 #else
AnnaBridge 145:64910690c574 171 #define __I volatile const /*!< \brief Defines 'read only' permissions */
AnnaBridge 145:64910690c574 172 #endif
AnnaBridge 145:64910690c574 173 #define __O volatile /*!< \brief Defines 'write only' permissions */
AnnaBridge 145:64910690c574 174 #define __IO volatile /*!< \brief Defines 'read / write' permissions */
AnnaBridge 145:64910690c574 175
AnnaBridge 145:64910690c574 176 /* following defines should be used for structure members */
AnnaBridge 145:64910690c574 177 #define __IM volatile const /*!< \brief Defines 'read only' structure member permissions */
AnnaBridge 145:64910690c574 178 #define __OM volatile /*!< \brief Defines 'write only' structure member permissions */
AnnaBridge 145:64910690c574 179 #define __IOM volatile /*!< \brief Defines 'read / write' structure member permissions */
Anna Bridge 160:5571c4ff569f 180 #define RESERVED(N, T) T RESERVED##N; // placeholder struct members used for "reserved" areas
AnnaBridge 145:64910690c574 181
AnnaBridge 145:64910690c574 182 /*******************************************************************************
AnnaBridge 145:64910690c574 183 * Register Abstraction
AnnaBridge 145:64910690c574 184 Core Register contain:
AnnaBridge 145:64910690c574 185 - CPSR
AnnaBridge 145:64910690c574 186 - CP15 Registers
AnnaBridge 145:64910690c574 187 - L2C-310 Cache Controller
AnnaBridge 145:64910690c574 188 - Generic Interrupt Controller Distributor
AnnaBridge 145:64910690c574 189 - Generic Interrupt Controller Interface
AnnaBridge 145:64910690c574 190 ******************************************************************************/
AnnaBridge 145:64910690c574 191
AnnaBridge 145:64910690c574 192 /* Core Register CPSR */
AnnaBridge 145:64910690c574 193 typedef union
AnnaBridge 145:64910690c574 194 {
AnnaBridge 145:64910690c574 195 struct
AnnaBridge 145:64910690c574 196 {
AnnaBridge 145:64910690c574 197 uint32_t M:5; /*!< \brief bit: 0.. 4 Mode field */
AnnaBridge 145:64910690c574 198 uint32_t T:1; /*!< \brief bit: 5 Thumb execution state bit */
AnnaBridge 145:64910690c574 199 uint32_t F:1; /*!< \brief bit: 6 FIQ mask bit */
AnnaBridge 145:64910690c574 200 uint32_t I:1; /*!< \brief bit: 7 IRQ mask bit */
AnnaBridge 145:64910690c574 201 uint32_t A:1; /*!< \brief bit: 8 Asynchronous abort mask bit */
AnnaBridge 145:64910690c574 202 uint32_t E:1; /*!< \brief bit: 9 Endianness execution state bit */
AnnaBridge 145:64910690c574 203 uint32_t IT1:6; /*!< \brief bit: 10..15 If-Then execution state bits 2-7 */
AnnaBridge 145:64910690c574 204 uint32_t GE:4; /*!< \brief bit: 16..19 Greater than or Equal flags */
Anna Bridge 160:5571c4ff569f 205 RESERVED(0:4, uint32_t)
AnnaBridge 145:64910690c574 206 uint32_t J:1; /*!< \brief bit: 24 Jazelle bit */
AnnaBridge 145:64910690c574 207 uint32_t IT0:2; /*!< \brief bit: 25..26 If-Then execution state bits 0-1 */
AnnaBridge 145:64910690c574 208 uint32_t Q:1; /*!< \brief bit: 27 Saturation condition flag */
AnnaBridge 145:64910690c574 209 uint32_t V:1; /*!< \brief bit: 28 Overflow condition code flag */
AnnaBridge 145:64910690c574 210 uint32_t C:1; /*!< \brief bit: 29 Carry condition code flag */
AnnaBridge 145:64910690c574 211 uint32_t Z:1; /*!< \brief bit: 30 Zero condition code flag */
AnnaBridge 145:64910690c574 212 uint32_t N:1; /*!< \brief bit: 31 Negative condition code flag */
AnnaBridge 145:64910690c574 213 } b; /*!< \brief Structure used for bit access */
AnnaBridge 145:64910690c574 214 uint32_t w; /*!< \brief Type used for word access */
AnnaBridge 145:64910690c574 215 } CPSR_Type;
AnnaBridge 145:64910690c574 216
Anna Bridge 160:5571c4ff569f 217
Anna Bridge 160:5571c4ff569f 218
AnnaBridge 145:64910690c574 219 /* CPSR Register Definitions */
AnnaBridge 145:64910690c574 220 #define CPSR_N_Pos 31U /*!< \brief CPSR: N Position */
AnnaBridge 145:64910690c574 221 #define CPSR_N_Msk (1UL << CPSR_N_Pos) /*!< \brief CPSR: N Mask */
AnnaBridge 145:64910690c574 222
AnnaBridge 145:64910690c574 223 #define CPSR_Z_Pos 30U /*!< \brief CPSR: Z Position */
AnnaBridge 145:64910690c574 224 #define CPSR_Z_Msk (1UL << CPSR_Z_Pos) /*!< \brief CPSR: Z Mask */
AnnaBridge 145:64910690c574 225
AnnaBridge 145:64910690c574 226 #define CPSR_C_Pos 29U /*!< \brief CPSR: C Position */
AnnaBridge 145:64910690c574 227 #define CPSR_C_Msk (1UL << CPSR_C_Pos) /*!< \brief CPSR: C Mask */
AnnaBridge 145:64910690c574 228
AnnaBridge 145:64910690c574 229 #define CPSR_V_Pos 28U /*!< \brief CPSR: V Position */
AnnaBridge 145:64910690c574 230 #define CPSR_V_Msk (1UL << CPSR_V_Pos) /*!< \brief CPSR: V Mask */
AnnaBridge 145:64910690c574 231
AnnaBridge 145:64910690c574 232 #define CPSR_Q_Pos 27U /*!< \brief CPSR: Q Position */
AnnaBridge 145:64910690c574 233 #define CPSR_Q_Msk (1UL << CPSR_Q_Pos) /*!< \brief CPSR: Q Mask */
AnnaBridge 145:64910690c574 234
AnnaBridge 145:64910690c574 235 #define CPSR_IT0_Pos 25U /*!< \brief CPSR: IT0 Position */
AnnaBridge 145:64910690c574 236 #define CPSR_IT0_Msk (3UL << CPSR_IT0_Pos) /*!< \brief CPSR: IT0 Mask */
AnnaBridge 145:64910690c574 237
AnnaBridge 145:64910690c574 238 #define CPSR_J_Pos 24U /*!< \brief CPSR: J Position */
AnnaBridge 145:64910690c574 239 #define CPSR_J_Msk (1UL << CPSR_J_Pos) /*!< \brief CPSR: J Mask */
AnnaBridge 145:64910690c574 240
AnnaBridge 145:64910690c574 241 #define CPSR_GE_Pos 16U /*!< \brief CPSR: GE Position */
AnnaBridge 145:64910690c574 242 #define CPSR_GE_Msk (0xFUL << CPSR_GE_Pos) /*!< \brief CPSR: GE Mask */
AnnaBridge 145:64910690c574 243
AnnaBridge 145:64910690c574 244 #define CPSR_IT1_Pos 10U /*!< \brief CPSR: IT1 Position */
AnnaBridge 145:64910690c574 245 #define CPSR_IT1_Msk (0x3FUL << CPSR_IT1_Pos) /*!< \brief CPSR: IT1 Mask */
AnnaBridge 145:64910690c574 246
AnnaBridge 145:64910690c574 247 #define CPSR_E_Pos 9U /*!< \brief CPSR: E Position */
AnnaBridge 145:64910690c574 248 #define CPSR_E_Msk (1UL << CPSR_E_Pos) /*!< \brief CPSR: E Mask */
AnnaBridge 145:64910690c574 249
AnnaBridge 145:64910690c574 250 #define CPSR_A_Pos 8U /*!< \brief CPSR: A Position */
AnnaBridge 145:64910690c574 251 #define CPSR_A_Msk (1UL << CPSR_A_Pos) /*!< \brief CPSR: A Mask */
AnnaBridge 145:64910690c574 252
AnnaBridge 145:64910690c574 253 #define CPSR_I_Pos 7U /*!< \brief CPSR: I Position */
AnnaBridge 145:64910690c574 254 #define CPSR_I_Msk (1UL << CPSR_I_Pos) /*!< \brief CPSR: I Mask */
AnnaBridge 145:64910690c574 255
AnnaBridge 145:64910690c574 256 #define CPSR_F_Pos 6U /*!< \brief CPSR: F Position */
AnnaBridge 145:64910690c574 257 #define CPSR_F_Msk (1UL << CPSR_F_Pos) /*!< \brief CPSR: F Mask */
AnnaBridge 145:64910690c574 258
AnnaBridge 145:64910690c574 259 #define CPSR_T_Pos 5U /*!< \brief CPSR: T Position */
AnnaBridge 145:64910690c574 260 #define CPSR_T_Msk (1UL << CPSR_T_Pos) /*!< \brief CPSR: T Mask */
AnnaBridge 145:64910690c574 261
AnnaBridge 145:64910690c574 262 #define CPSR_M_Pos 0U /*!< \brief CPSR: M Position */
AnnaBridge 145:64910690c574 263 #define CPSR_M_Msk (0x1FUL << CPSR_M_Pos) /*!< \brief CPSR: M Mask */
AnnaBridge 145:64910690c574 264
Anna Bridge 160:5571c4ff569f 265 #define CPSR_M_USR 0x10U /*!< \brief CPSR: M User mode (PL0) */
Anna Bridge 160:5571c4ff569f 266 #define CPSR_M_FIQ 0x11U /*!< \brief CPSR: M Fast Interrupt mode (PL1) */
Anna Bridge 160:5571c4ff569f 267 #define CPSR_M_IRQ 0x12U /*!< \brief CPSR: M Interrupt mode (PL1) */
Anna Bridge 160:5571c4ff569f 268 #define CPSR_M_SVC 0x13U /*!< \brief CPSR: M Supervisor mode (PL1) */
Anna Bridge 160:5571c4ff569f 269 #define CPSR_M_MON 0x16U /*!< \brief CPSR: M Monitor mode (PL1) */
Anna Bridge 160:5571c4ff569f 270 #define CPSR_M_ABT 0x17U /*!< \brief CPSR: M Abort mode (PL1) */
Anna Bridge 160:5571c4ff569f 271 #define CPSR_M_HYP 0x1AU /*!< \brief CPSR: M Hypervisor mode (PL2) */
Anna Bridge 160:5571c4ff569f 272 #define CPSR_M_UND 0x1BU /*!< \brief CPSR: M Undefined mode (PL1) */
Anna Bridge 160:5571c4ff569f 273 #define CPSR_M_SYS 0x1FU /*!< \brief CPSR: M System mode (PL1) */
Anna Bridge 160:5571c4ff569f 274
AnnaBridge 145:64910690c574 275 /* CP15 Register SCTLR */
AnnaBridge 145:64910690c574 276 typedef union
AnnaBridge 145:64910690c574 277 {
AnnaBridge 145:64910690c574 278 struct
AnnaBridge 145:64910690c574 279 {
AnnaBridge 145:64910690c574 280 uint32_t M:1; /*!< \brief bit: 0 MMU enable */
AnnaBridge 145:64910690c574 281 uint32_t A:1; /*!< \brief bit: 1 Alignment check enable */
AnnaBridge 145:64910690c574 282 uint32_t C:1; /*!< \brief bit: 2 Cache enable */
Anna Bridge 160:5571c4ff569f 283 RESERVED(0:2, uint32_t)
AnnaBridge 145:64910690c574 284 uint32_t CP15BEN:1; /*!< \brief bit: 5 CP15 barrier enable */
Anna Bridge 160:5571c4ff569f 285 RESERVED(1:1, uint32_t)
AnnaBridge 145:64910690c574 286 uint32_t B:1; /*!< \brief bit: 7 Endianness model */
Anna Bridge 160:5571c4ff569f 287 RESERVED(2:2, uint32_t)
AnnaBridge 145:64910690c574 288 uint32_t SW:1; /*!< \brief bit: 10 SWP and SWPB enable */
AnnaBridge 145:64910690c574 289 uint32_t Z:1; /*!< \brief bit: 11 Branch prediction enable */
AnnaBridge 145:64910690c574 290 uint32_t I:1; /*!< \brief bit: 12 Instruction cache enable */
AnnaBridge 145:64910690c574 291 uint32_t V:1; /*!< \brief bit: 13 Vectors bit */
AnnaBridge 145:64910690c574 292 uint32_t RR:1; /*!< \brief bit: 14 Round Robin select */
Anna Bridge 160:5571c4ff569f 293 RESERVED(3:2, uint32_t)
AnnaBridge 145:64910690c574 294 uint32_t HA:1; /*!< \brief bit: 17 Hardware Access flag enable */
Anna Bridge 160:5571c4ff569f 295 RESERVED(4:1, uint32_t)
AnnaBridge 145:64910690c574 296 uint32_t WXN:1; /*!< \brief bit: 19 Write permission implies XN */
AnnaBridge 145:64910690c574 297 uint32_t UWXN:1; /*!< \brief bit: 20 Unprivileged write permission implies PL1 XN */
AnnaBridge 145:64910690c574 298 uint32_t FI:1; /*!< \brief bit: 21 Fast interrupts configuration enable */
AnnaBridge 145:64910690c574 299 uint32_t U:1; /*!< \brief bit: 22 Alignment model */
Anna Bridge 160:5571c4ff569f 300 RESERVED(5:1, uint32_t)
AnnaBridge 145:64910690c574 301 uint32_t VE:1; /*!< \brief bit: 24 Interrupt Vectors Enable */
AnnaBridge 145:64910690c574 302 uint32_t EE:1; /*!< \brief bit: 25 Exception Endianness */
Anna Bridge 160:5571c4ff569f 303 RESERVED(6:1, uint32_t)
AnnaBridge 145:64910690c574 304 uint32_t NMFI:1; /*!< \brief bit: 27 Non-maskable FIQ (NMFI) support */
AnnaBridge 145:64910690c574 305 uint32_t TRE:1; /*!< \brief bit: 28 TEX remap enable. */
AnnaBridge 145:64910690c574 306 uint32_t AFE:1; /*!< \brief bit: 29 Access flag enable */
AnnaBridge 145:64910690c574 307 uint32_t TE:1; /*!< \brief bit: 30 Thumb Exception enable */
Anna Bridge 160:5571c4ff569f 308 RESERVED(7:1, uint32_t)
AnnaBridge 145:64910690c574 309 } b; /*!< \brief Structure used for bit access */
AnnaBridge 145:64910690c574 310 uint32_t w; /*!< \brief Type used for word access */
AnnaBridge 145:64910690c574 311 } SCTLR_Type;
AnnaBridge 145:64910690c574 312
AnnaBridge 145:64910690c574 313 #define SCTLR_TE_Pos 30U /*!< \brief SCTLR: TE Position */
AnnaBridge 145:64910690c574 314 #define SCTLR_TE_Msk (1UL << SCTLR_TE_Pos) /*!< \brief SCTLR: TE Mask */
AnnaBridge 145:64910690c574 315
AnnaBridge 145:64910690c574 316 #define SCTLR_AFE_Pos 29U /*!< \brief SCTLR: AFE Position */
AnnaBridge 145:64910690c574 317 #define SCTLR_AFE_Msk (1UL << SCTLR_AFE_Pos) /*!< \brief SCTLR: AFE Mask */
AnnaBridge 145:64910690c574 318
AnnaBridge 145:64910690c574 319 #define SCTLR_TRE_Pos 28U /*!< \brief SCTLR: TRE Position */
AnnaBridge 145:64910690c574 320 #define SCTLR_TRE_Msk (1UL << SCTLR_TRE_Pos) /*!< \brief SCTLR: TRE Mask */
AnnaBridge 145:64910690c574 321
AnnaBridge 145:64910690c574 322 #define SCTLR_NMFI_Pos 27U /*!< \brief SCTLR: NMFI Position */
AnnaBridge 145:64910690c574 323 #define SCTLR_NMFI_Msk (1UL << SCTLR_NMFI_Pos) /*!< \brief SCTLR: NMFI Mask */
AnnaBridge 145:64910690c574 324
AnnaBridge 145:64910690c574 325 #define SCTLR_EE_Pos 25U /*!< \brief SCTLR: EE Position */
AnnaBridge 145:64910690c574 326 #define SCTLR_EE_Msk (1UL << SCTLR_EE_Pos) /*!< \brief SCTLR: EE Mask */
AnnaBridge 145:64910690c574 327
AnnaBridge 145:64910690c574 328 #define SCTLR_VE_Pos 24U /*!< \brief SCTLR: VE Position */
AnnaBridge 145:64910690c574 329 #define SCTLR_VE_Msk (1UL << SCTLR_VE_Pos) /*!< \brief SCTLR: VE Mask */
AnnaBridge 145:64910690c574 330
AnnaBridge 145:64910690c574 331 #define SCTLR_U_Pos 22U /*!< \brief SCTLR: U Position */
AnnaBridge 145:64910690c574 332 #define SCTLR_U_Msk (1UL << SCTLR_U_Pos) /*!< \brief SCTLR: U Mask */
AnnaBridge 145:64910690c574 333
AnnaBridge 145:64910690c574 334 #define SCTLR_FI_Pos 21U /*!< \brief SCTLR: FI Position */
AnnaBridge 145:64910690c574 335 #define SCTLR_FI_Msk (1UL << SCTLR_FI_Pos) /*!< \brief SCTLR: FI Mask */
AnnaBridge 145:64910690c574 336
AnnaBridge 145:64910690c574 337 #define SCTLR_UWXN_Pos 20U /*!< \brief SCTLR: UWXN Position */
AnnaBridge 145:64910690c574 338 #define SCTLR_UWXN_Msk (1UL << SCTLR_UWXN_Pos) /*!< \brief SCTLR: UWXN Mask */
AnnaBridge 145:64910690c574 339
AnnaBridge 145:64910690c574 340 #define SCTLR_WXN_Pos 19U /*!< \brief SCTLR: WXN Position */
AnnaBridge 145:64910690c574 341 #define SCTLR_WXN_Msk (1UL << SCTLR_WXN_Pos) /*!< \brief SCTLR: WXN Mask */
AnnaBridge 145:64910690c574 342
AnnaBridge 145:64910690c574 343 #define SCTLR_HA_Pos 17U /*!< \brief SCTLR: HA Position */
AnnaBridge 145:64910690c574 344 #define SCTLR_HA_Msk (1UL << SCTLR_HA_Pos) /*!< \brief SCTLR: HA Mask */
AnnaBridge 145:64910690c574 345
AnnaBridge 145:64910690c574 346 #define SCTLR_RR_Pos 14U /*!< \brief SCTLR: RR Position */
AnnaBridge 145:64910690c574 347 #define SCTLR_RR_Msk (1UL << SCTLR_RR_Pos) /*!< \brief SCTLR: RR Mask */
AnnaBridge 145:64910690c574 348
AnnaBridge 145:64910690c574 349 #define SCTLR_V_Pos 13U /*!< \brief SCTLR: V Position */
AnnaBridge 145:64910690c574 350 #define SCTLR_V_Msk (1UL << SCTLR_V_Pos) /*!< \brief SCTLR: V Mask */
AnnaBridge 145:64910690c574 351
AnnaBridge 145:64910690c574 352 #define SCTLR_I_Pos 12U /*!< \brief SCTLR: I Position */
AnnaBridge 145:64910690c574 353 #define SCTLR_I_Msk (1UL << SCTLR_I_Pos) /*!< \brief SCTLR: I Mask */
AnnaBridge 145:64910690c574 354
AnnaBridge 145:64910690c574 355 #define SCTLR_Z_Pos 11U /*!< \brief SCTLR: Z Position */
AnnaBridge 145:64910690c574 356 #define SCTLR_Z_Msk (1UL << SCTLR_Z_Pos) /*!< \brief SCTLR: Z Mask */
AnnaBridge 145:64910690c574 357
AnnaBridge 145:64910690c574 358 #define SCTLR_SW_Pos 10U /*!< \brief SCTLR: SW Position */
AnnaBridge 145:64910690c574 359 #define SCTLR_SW_Msk (1UL << SCTLR_SW_Pos) /*!< \brief SCTLR: SW Mask */
AnnaBridge 145:64910690c574 360
AnnaBridge 145:64910690c574 361 #define SCTLR_B_Pos 7U /*!< \brief SCTLR: B Position */
AnnaBridge 145:64910690c574 362 #define SCTLR_B_Msk (1UL << SCTLR_B_Pos) /*!< \brief SCTLR: B Mask */
AnnaBridge 145:64910690c574 363
AnnaBridge 145:64910690c574 364 #define SCTLR_CP15BEN_Pos 5U /*!< \brief SCTLR: CP15BEN Position */
AnnaBridge 145:64910690c574 365 #define SCTLR_CP15BEN_Msk (1UL << SCTLR_CP15BEN_Pos) /*!< \brief SCTLR: CP15BEN Mask */
AnnaBridge 145:64910690c574 366
AnnaBridge 145:64910690c574 367 #define SCTLR_C_Pos 2U /*!< \brief SCTLR: C Position */
AnnaBridge 145:64910690c574 368 #define SCTLR_C_Msk (1UL << SCTLR_C_Pos) /*!< \brief SCTLR: C Mask */
AnnaBridge 145:64910690c574 369
AnnaBridge 145:64910690c574 370 #define SCTLR_A_Pos 1U /*!< \brief SCTLR: A Position */
AnnaBridge 145:64910690c574 371 #define SCTLR_A_Msk (1UL << SCTLR_A_Pos) /*!< \brief SCTLR: A Mask */
AnnaBridge 145:64910690c574 372
AnnaBridge 145:64910690c574 373 #define SCTLR_M_Pos 0U /*!< \brief SCTLR: M Position */
AnnaBridge 145:64910690c574 374 #define SCTLR_M_Msk (1UL << SCTLR_M_Pos) /*!< \brief SCTLR: M Mask */
AnnaBridge 145:64910690c574 375
Anna Bridge 160:5571c4ff569f 376 /* CP15 Register ACTLR */
Anna Bridge 160:5571c4ff569f 377 typedef union
Anna Bridge 160:5571c4ff569f 378 {
Anna Bridge 160:5571c4ff569f 379 #if __CORTEX_A == 5 || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 380 /** \brief Structure used for bit access on Cortex-A5 */
Anna Bridge 160:5571c4ff569f 381 struct
Anna Bridge 160:5571c4ff569f 382 {
Anna Bridge 160:5571c4ff569f 383 uint32_t FW:1; /*!< \brief bit: 0 Cache and TLB maintenance broadcast */
Anna Bridge 160:5571c4ff569f 384 RESERVED(0:5, uint32_t)
Anna Bridge 160:5571c4ff569f 385 uint32_t SMP:1; /*!< \brief bit: 6 Enables coherent requests to the processor */
Anna Bridge 160:5571c4ff569f 386 uint32_t EXCL:1; /*!< \brief bit: 7 Exclusive L1/L2 cache control */
Anna Bridge 160:5571c4ff569f 387 RESERVED(1:2, uint32_t)
Anna Bridge 160:5571c4ff569f 388 uint32_t DODMBS:1; /*!< \brief bit: 10 Disable optimized data memory barrier behavior */
Anna Bridge 160:5571c4ff569f 389 uint32_t DWBST:1; /*!< \brief bit: 11 AXI data write bursts to Normal memory */
Anna Bridge 160:5571c4ff569f 390 uint32_t RADIS:1; /*!< \brief bit: 12 L1 Data Cache read-allocate mode disable */
Anna Bridge 160:5571c4ff569f 391 uint32_t L1PCTL:2; /*!< \brief bit:13..14 L1 Data prefetch control */
Anna Bridge 160:5571c4ff569f 392 uint32_t BP:2; /*!< \brief bit:16..15 Branch prediction policy */
Anna Bridge 160:5571c4ff569f 393 uint32_t RSDIS:1; /*!< \brief bit: 17 Disable return stack operation */
Anna Bridge 160:5571c4ff569f 394 uint32_t BTDIS:1; /*!< \brief bit: 18 Disable indirect Branch Target Address Cache (BTAC) */
Anna Bridge 160:5571c4ff569f 395 RESERVED(3:9, uint32_t)
Anna Bridge 160:5571c4ff569f 396 uint32_t DBDI:1; /*!< \brief bit: 28 Disable branch dual issue */
Anna Bridge 160:5571c4ff569f 397 RESERVED(7:3, uint32_t)
Anna Bridge 160:5571c4ff569f 398 } b;
Anna Bridge 160:5571c4ff569f 399 #endif
Anna Bridge 160:5571c4ff569f 400 #if __CORTEX_A == 7 || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 401 /** \brief Structure used for bit access on Cortex-A7 */
Anna Bridge 160:5571c4ff569f 402 struct
Anna Bridge 160:5571c4ff569f 403 {
Anna Bridge 160:5571c4ff569f 404 RESERVED(0:6, uint32_t)
Anna Bridge 160:5571c4ff569f 405 uint32_t SMP:1; /*!< \brief bit: 6 Enables coherent requests to the processor */
Anna Bridge 160:5571c4ff569f 406 RESERVED(1:3, uint32_t)
Anna Bridge 160:5571c4ff569f 407 uint32_t DODMBS:1; /*!< \brief bit: 10 Disable optimized data memory barrier behavior */
Anna Bridge 160:5571c4ff569f 408 uint32_t L2RADIS:1; /*!< \brief bit: 11 L2 Data Cache read-allocate mode disable */
Anna Bridge 160:5571c4ff569f 409 uint32_t L1RADIS:1; /*!< \brief bit: 12 L1 Data Cache read-allocate mode disable */
Anna Bridge 160:5571c4ff569f 410 uint32_t L1PCTL:2; /*!< \brief bit:13..14 L1 Data prefetch control */
Anna Bridge 160:5571c4ff569f 411 uint32_t DDVM:1; /*!< \brief bit: 15 Disable Distributed Virtual Memory (DVM) transactions */
Anna Bridge 160:5571c4ff569f 412 RESERVED(3:12, uint32_t)
Anna Bridge 160:5571c4ff569f 413 uint32_t DDI:1; /*!< \brief bit: 28 Disable dual issue */
Anna Bridge 160:5571c4ff569f 414 RESERVED(7:3, uint32_t)
Anna Bridge 160:5571c4ff569f 415 } b;
Anna Bridge 160:5571c4ff569f 416 #endif
Anna Bridge 160:5571c4ff569f 417 #if __CORTEX_A == 9 || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 418 /** \brief Structure used for bit access on Cortex-A9 */
Anna Bridge 160:5571c4ff569f 419 struct
Anna Bridge 160:5571c4ff569f 420 {
Anna Bridge 160:5571c4ff569f 421 uint32_t FW:1; /*!< \brief bit: 0 Cache and TLB maintenance broadcast */
Anna Bridge 160:5571c4ff569f 422 RESERVED(0:1, uint32_t)
Anna Bridge 160:5571c4ff569f 423 uint32_t L1PE:1; /*!< \brief bit: 2 Dside prefetch */
Anna Bridge 160:5571c4ff569f 424 uint32_t WFLZM:1; /*!< \brief bit: 3 Cache and TLB maintenance broadcast */
Anna Bridge 160:5571c4ff569f 425 RESERVED(1:2, uint32_t)
Anna Bridge 160:5571c4ff569f 426 uint32_t SMP:1; /*!< \brief bit: 6 Enables coherent requests to the processor */
Anna Bridge 160:5571c4ff569f 427 uint32_t EXCL:1; /*!< \brief bit: 7 Exclusive L1/L2 cache control */
Anna Bridge 160:5571c4ff569f 428 uint32_t AOW:1; /*!< \brief bit: 8 Enable allocation in one cache way only */
Anna Bridge 160:5571c4ff569f 429 uint32_t PARITY:1; /*!< \brief bit: 9 Support for parity checking, if implemented */
Anna Bridge 160:5571c4ff569f 430 RESERVED(7:22, uint32_t)
Anna Bridge 160:5571c4ff569f 431 } b;
Anna Bridge 160:5571c4ff569f 432 #endif
Anna Bridge 160:5571c4ff569f 433 uint32_t w; /*!< \brief Type used for word access */
Anna Bridge 160:5571c4ff569f 434 } ACTLR_Type;
Anna Bridge 160:5571c4ff569f 435
Anna Bridge 160:5571c4ff569f 436 #define ACTLR_DDI_Pos 28U /*!< \brief ACTLR: DDI Position */
Anna Bridge 160:5571c4ff569f 437 #define ACTLR_DDI_Msk (1UL << ACTLR_DDI_Pos) /*!< \brief ACTLR: DDI Mask */
Anna Bridge 160:5571c4ff569f 438
Anna Bridge 160:5571c4ff569f 439 #define ACTLR_DBDI_Pos 28U /*!< \brief ACTLR: DBDI Position */
Anna Bridge 160:5571c4ff569f 440 #define ACTLR_DBDI_Msk (1UL << ACTLR_DBDI_Pos) /*!< \brief ACTLR: DBDI Mask */
Anna Bridge 160:5571c4ff569f 441
Anna Bridge 160:5571c4ff569f 442 #define ACTLR_BTDIS_Pos 18U /*!< \brief ACTLR: BTDIS Position */
Anna Bridge 160:5571c4ff569f 443 #define ACTLR_BTDIS_Msk (1UL << ACTLR_BTDIS_Pos) /*!< \brief ACTLR: BTDIS Mask */
Anna Bridge 160:5571c4ff569f 444
Anna Bridge 160:5571c4ff569f 445 #define ACTLR_RSDIS_Pos 17U /*!< \brief ACTLR: RSDIS Position */
Anna Bridge 160:5571c4ff569f 446 #define ACTLR_RSDIS_Msk (1UL << ACTLR_RSDIS_Pos) /*!< \brief ACTLR: RSDIS Mask */
Anna Bridge 160:5571c4ff569f 447
Anna Bridge 160:5571c4ff569f 448 #define ACTLR_BP_Pos 15U /*!< \brief ACTLR: BP Position */
Anna Bridge 160:5571c4ff569f 449 #define ACTLR_BP_Msk (3UL << ACTLR_BP_Pos) /*!< \brief ACTLR: BP Mask */
Anna Bridge 160:5571c4ff569f 450
Anna Bridge 160:5571c4ff569f 451 #define ACTLR_DDVM_Pos 15U /*!< \brief ACTLR: DDVM Position */
Anna Bridge 160:5571c4ff569f 452 #define ACTLR_DDVM_Msk (1UL << ACTLR_DDVM_Pos) /*!< \brief ACTLR: DDVM Mask */
Anna Bridge 160:5571c4ff569f 453
Anna Bridge 160:5571c4ff569f 454 #define ACTLR_L1PCTL_Pos 13U /*!< \brief ACTLR: L1PCTL Position */
Anna Bridge 160:5571c4ff569f 455 #define ACTLR_L1PCTL_Msk (3UL << ACTLR_L1PCTL_Pos) /*!< \brief ACTLR: L1PCTL Mask */
Anna Bridge 160:5571c4ff569f 456
Anna Bridge 160:5571c4ff569f 457 #define ACTLR_RADIS_Pos 12U /*!< \brief ACTLR: RADIS Position */
Anna Bridge 160:5571c4ff569f 458 #define ACTLR_RADIS_Msk (1UL << ACTLR_RADIS_Pos) /*!< \brief ACTLR: RADIS Mask */
Anna Bridge 160:5571c4ff569f 459
Anna Bridge 160:5571c4ff569f 460 #define ACTLR_L1RADIS_Pos 12U /*!< \brief ACTLR: L1RADIS Position */
Anna Bridge 160:5571c4ff569f 461 #define ACTLR_L1RADIS_Msk (1UL << ACTLR_L1RADIS_Pos) /*!< \brief ACTLR: L1RADIS Mask */
Anna Bridge 160:5571c4ff569f 462
Anna Bridge 160:5571c4ff569f 463 #define ACTLR_DWBST_Pos 11U /*!< \brief ACTLR: DWBST Position */
Anna Bridge 160:5571c4ff569f 464 #define ACTLR_DWBST_Msk (1UL << ACTLR_DWBST_Pos) /*!< \brief ACTLR: DWBST Mask */
Anna Bridge 160:5571c4ff569f 465
Anna Bridge 160:5571c4ff569f 466 #define ACTLR_L2RADIS_Pos 11U /*!< \brief ACTLR: L2RADIS Position */
Anna Bridge 160:5571c4ff569f 467 #define ACTLR_L2RADIS_Msk (1UL << ACTLR_L2RADIS_Pos) /*!< \brief ACTLR: L2RADIS Mask */
Anna Bridge 160:5571c4ff569f 468
Anna Bridge 160:5571c4ff569f 469 #define ACTLR_DODMBS_Pos 10U /*!< \brief ACTLR: DODMBS Position */
Anna Bridge 160:5571c4ff569f 470 #define ACTLR_DODMBS_Msk (1UL << ACTLR_DODMBS_Pos) /*!< \brief ACTLR: DODMBS Mask */
Anna Bridge 160:5571c4ff569f 471
Anna Bridge 160:5571c4ff569f 472 #define ACTLR_PARITY_Pos 9U /*!< \brief ACTLR: PARITY Position */
Anna Bridge 160:5571c4ff569f 473 #define ACTLR_PARITY_Msk (1UL << ACTLR_PARITY_Pos) /*!< \brief ACTLR: PARITY Mask */
Anna Bridge 160:5571c4ff569f 474
Anna Bridge 160:5571c4ff569f 475 #define ACTLR_AOW_Pos 8U /*!< \brief ACTLR: AOW Position */
Anna Bridge 160:5571c4ff569f 476 #define ACTLR_AOW_Msk (1UL << ACTLR_AOW_Pos) /*!< \brief ACTLR: AOW Mask */
Anna Bridge 160:5571c4ff569f 477
Anna Bridge 160:5571c4ff569f 478 #define ACTLR_EXCL_Pos 7U /*!< \brief ACTLR: EXCL Position */
Anna Bridge 160:5571c4ff569f 479 #define ACTLR_EXCL_Msk (1UL << ACTLR_EXCL_Pos) /*!< \brief ACTLR: EXCL Mask */
Anna Bridge 160:5571c4ff569f 480
Anna Bridge 160:5571c4ff569f 481 #define ACTLR_SMP_Pos 6U /*!< \brief ACTLR: SMP Position */
Anna Bridge 160:5571c4ff569f 482 #define ACTLR_SMP_Msk (1UL << ACTLR_SMP_Pos) /*!< \brief ACTLR: SMP Mask */
Anna Bridge 160:5571c4ff569f 483
Anna Bridge 160:5571c4ff569f 484 #define ACTLR_WFLZM_Pos 3U /*!< \brief ACTLR: WFLZM Position */
Anna Bridge 160:5571c4ff569f 485 #define ACTLR_WFLZM_Msk (1UL << ACTLR_WFLZM_Pos) /*!< \brief ACTLR: WFLZM Mask */
Anna Bridge 160:5571c4ff569f 486
Anna Bridge 160:5571c4ff569f 487 #define ACTLR_L1PE_Pos 2U /*!< \brief ACTLR: L1PE Position */
Anna Bridge 160:5571c4ff569f 488 #define ACTLR_L1PE_Msk (1UL << ACTLR_L1PE_Pos) /*!< \brief ACTLR: L1PE Mask */
Anna Bridge 160:5571c4ff569f 489
Anna Bridge 160:5571c4ff569f 490 #define ACTLR_FW_Pos 0U /*!< \brief ACTLR: FW Position */
Anna Bridge 160:5571c4ff569f 491 #define ACTLR_FW_Msk (1UL << ACTLR_FW_Pos) /*!< \brief ACTLR: FW Mask */
Anna Bridge 160:5571c4ff569f 492
AnnaBridge 145:64910690c574 493 /* CP15 Register CPACR */
AnnaBridge 145:64910690c574 494 typedef union
AnnaBridge 145:64910690c574 495 {
AnnaBridge 145:64910690c574 496 struct
AnnaBridge 145:64910690c574 497 {
Anna Bridge 160:5571c4ff569f 498 uint32_t CP0:2; /*!< \brief bit: 0..1 Access rights for coprocessor 0 */
Anna Bridge 160:5571c4ff569f 499 uint32_t CP1:2; /*!< \brief bit: 2..3 Access rights for coprocessor 1 */
Anna Bridge 160:5571c4ff569f 500 uint32_t CP2:2; /*!< \brief bit: 4..5 Access rights for coprocessor 2 */
Anna Bridge 160:5571c4ff569f 501 uint32_t CP3:2; /*!< \brief bit: 6..7 Access rights for coprocessor 3 */
Anna Bridge 160:5571c4ff569f 502 uint32_t CP4:2; /*!< \brief bit: 8..9 Access rights for coprocessor 4 */
Anna Bridge 160:5571c4ff569f 503 uint32_t CP5:2; /*!< \brief bit:10..11 Access rights for coprocessor 5 */
Anna Bridge 160:5571c4ff569f 504 uint32_t CP6:2; /*!< \brief bit:12..13 Access rights for coprocessor 6 */
Anna Bridge 160:5571c4ff569f 505 uint32_t CP7:2; /*!< \brief bit:14..15 Access rights for coprocessor 7 */
Anna Bridge 160:5571c4ff569f 506 uint32_t CP8:2; /*!< \brief bit:16..17 Access rights for coprocessor 8 */
Anna Bridge 160:5571c4ff569f 507 uint32_t CP9:2; /*!< \brief bit:18..19 Access rights for coprocessor 9 */
Anna Bridge 160:5571c4ff569f 508 uint32_t CP10:2; /*!< \brief bit:20..21 Access rights for coprocessor 10 */
Anna Bridge 160:5571c4ff569f 509 uint32_t CP11:2; /*!< \brief bit:22..23 Access rights for coprocessor 11 */
Anna Bridge 160:5571c4ff569f 510 uint32_t CP12:2; /*!< \brief bit:24..25 Access rights for coprocessor 11 */
Anna Bridge 160:5571c4ff569f 511 uint32_t CP13:2; /*!< \brief bit:26..27 Access rights for coprocessor 11 */
Anna Bridge 160:5571c4ff569f 512 uint32_t TRCDIS:1; /*!< \brief bit: 28 Disable CP14 access to trace registers */
Anna Bridge 160:5571c4ff569f 513 RESERVED(0:1, uint32_t)
AnnaBridge 145:64910690c574 514 uint32_t D32DIS:1; /*!< \brief bit: 30 Disable use of registers D16-D31 of the VFP register file */
AnnaBridge 145:64910690c574 515 uint32_t ASEDIS:1; /*!< \brief bit: 31 Disable Advanced SIMD Functionality */
AnnaBridge 145:64910690c574 516 } b; /*!< \brief Structure used for bit access */
AnnaBridge 145:64910690c574 517 uint32_t w; /*!< \brief Type used for word access */
AnnaBridge 145:64910690c574 518 } CPACR_Type;
AnnaBridge 145:64910690c574 519
AnnaBridge 145:64910690c574 520 #define CPACR_ASEDIS_Pos 31U /*!< \brief CPACR: ASEDIS Position */
AnnaBridge 145:64910690c574 521 #define CPACR_ASEDIS_Msk (1UL << CPACR_ASEDIS_Pos) /*!< \brief CPACR: ASEDIS Mask */
AnnaBridge 145:64910690c574 522
AnnaBridge 145:64910690c574 523 #define CPACR_D32DIS_Pos 30U /*!< \brief CPACR: D32DIS Position */
AnnaBridge 145:64910690c574 524 #define CPACR_D32DIS_Msk (1UL << CPACR_D32DIS_Pos) /*!< \brief CPACR: D32DIS Mask */
AnnaBridge 145:64910690c574 525
Anna Bridge 160:5571c4ff569f 526 #define CPACR_TRCDIS_Pos 28U /*!< \brief CPACR: D32DIS Position */
Anna Bridge 160:5571c4ff569f 527 #define CPACR_TRCDIS_Msk (1UL << CPACR_D32DIS_Pos) /*!< \brief CPACR: D32DIS Mask */
AnnaBridge 145:64910690c574 528
Anna Bridge 160:5571c4ff569f 529 #define CPACR_CP_Pos_(n) (n*2U) /*!< \brief CPACR: CPn Position */
Anna Bridge 160:5571c4ff569f 530 #define CPACR_CP_Msk_(n) (3UL << CPACR_CP_Pos_(n)) /*!< \brief CPACR: CPn Mask */
Anna Bridge 160:5571c4ff569f 531
Anna Bridge 160:5571c4ff569f 532 #define CPACR_CP_NA 0U /*!< \brief CPACR CPn field: Access denied. */
Anna Bridge 160:5571c4ff569f 533 #define CPACR_CP_PL1 1U /*!< \brief CPACR CPn field: Accessible from PL1 only. */
Anna Bridge 160:5571c4ff569f 534 #define CPACR_CP_FA 3U /*!< \brief CPACR CPn field: Full access. */
AnnaBridge 145:64910690c574 535
AnnaBridge 145:64910690c574 536 /* CP15 Register DFSR */
AnnaBridge 145:64910690c574 537 typedef union
AnnaBridge 145:64910690c574 538 {
AnnaBridge 145:64910690c574 539 struct
AnnaBridge 145:64910690c574 540 {
AnnaBridge 145:64910690c574 541 uint32_t FS0:4; /*!< \brief bit: 0.. 3 Fault Status bits bit 0-3 */
AnnaBridge 145:64910690c574 542 uint32_t Domain:4; /*!< \brief bit: 4.. 7 Fault on which domain */
Anna Bridge 160:5571c4ff569f 543 RESERVED(0:1, uint32_t)
Anna Bridge 160:5571c4ff569f 544 uint32_t LPAE:1; /*!< \brief bit: 9 Large Physical Address Extension */
AnnaBridge 145:64910690c574 545 uint32_t FS1:1; /*!< \brief bit: 10 Fault Status bits bit 4 */
AnnaBridge 145:64910690c574 546 uint32_t WnR:1; /*!< \brief bit: 11 Write not Read bit */
AnnaBridge 145:64910690c574 547 uint32_t ExT:1; /*!< \brief bit: 12 External abort type */
AnnaBridge 145:64910690c574 548 uint32_t CM:1; /*!< \brief bit: 13 Cache maintenance fault */
Anna Bridge 160:5571c4ff569f 549 RESERVED(1:18, uint32_t)
Anna Bridge 160:5571c4ff569f 550 } s; /*!< \brief Structure used for bit access in short format */
Anna Bridge 160:5571c4ff569f 551 struct
Anna Bridge 160:5571c4ff569f 552 {
Anna Bridge 160:5571c4ff569f 553 uint32_t STATUS:5; /*!< \brief bit: 0.. 5 Fault Status bits */
Anna Bridge 160:5571c4ff569f 554 RESERVED(0:3, uint32_t)
Anna Bridge 160:5571c4ff569f 555 uint32_t LPAE:1; /*!< \brief bit: 9 Large Physical Address Extension */
Anna Bridge 160:5571c4ff569f 556 RESERVED(1:1, uint32_t)
Anna Bridge 160:5571c4ff569f 557 uint32_t WnR:1; /*!< \brief bit: 11 Write not Read bit */
Anna Bridge 160:5571c4ff569f 558 uint32_t ExT:1; /*!< \brief bit: 12 External abort type */
Anna Bridge 160:5571c4ff569f 559 uint32_t CM:1; /*!< \brief bit: 13 Cache maintenance fault */
Anna Bridge 160:5571c4ff569f 560 RESERVED(2:18, uint32_t)
Anna Bridge 160:5571c4ff569f 561 } l; /*!< \brief Structure used for bit access in long format */
AnnaBridge 145:64910690c574 562 uint32_t w; /*!< \brief Type used for word access */
AnnaBridge 145:64910690c574 563 } DFSR_Type;
AnnaBridge 145:64910690c574 564
AnnaBridge 145:64910690c574 565 #define DFSR_CM_Pos 13U /*!< \brief DFSR: CM Position */
AnnaBridge 145:64910690c574 566 #define DFSR_CM_Msk (1UL << DFSR_CM_Pos) /*!< \brief DFSR: CM Mask */
AnnaBridge 145:64910690c574 567
AnnaBridge 145:64910690c574 568 #define DFSR_Ext_Pos 12U /*!< \brief DFSR: Ext Position */
AnnaBridge 145:64910690c574 569 #define DFSR_Ext_Msk (1UL << DFSR_Ext_Pos) /*!< \brief DFSR: Ext Mask */
AnnaBridge 145:64910690c574 570
AnnaBridge 145:64910690c574 571 #define DFSR_WnR_Pos 11U /*!< \brief DFSR: WnR Position */
AnnaBridge 145:64910690c574 572 #define DFSR_WnR_Msk (1UL << DFSR_WnR_Pos) /*!< \brief DFSR: WnR Mask */
AnnaBridge 145:64910690c574 573
AnnaBridge 145:64910690c574 574 #define DFSR_FS1_Pos 10U /*!< \brief DFSR: FS1 Position */
AnnaBridge 145:64910690c574 575 #define DFSR_FS1_Msk (1UL << DFSR_FS1_Pos) /*!< \brief DFSR: FS1 Mask */
AnnaBridge 145:64910690c574 576
Anna Bridge 160:5571c4ff569f 577 #define DFSR_LPAE_Pos 9U /*!< \brief DFSR: LPAE Position */
Anna Bridge 160:5571c4ff569f 578 #define DFSR_LPAE_Msk (1UL << DFSR_LPAE_Pos) /*!< \brief DFSR: LPAE Mask */
Anna Bridge 160:5571c4ff569f 579
AnnaBridge 145:64910690c574 580 #define DFSR_Domain_Pos 4U /*!< \brief DFSR: Domain Position */
AnnaBridge 145:64910690c574 581 #define DFSR_Domain_Msk (0xFUL << DFSR_Domain_Pos) /*!< \brief DFSR: Domain Mask */
AnnaBridge 145:64910690c574 582
AnnaBridge 145:64910690c574 583 #define DFSR_FS0_Pos 0U /*!< \brief DFSR: FS0 Position */
AnnaBridge 145:64910690c574 584 #define DFSR_FS0_Msk (0xFUL << DFSR_FS0_Pos) /*!< \brief DFSR: FS0 Mask */
AnnaBridge 145:64910690c574 585
Anna Bridge 160:5571c4ff569f 586 #define DFSR_STATUS_Pos 0U /*!< \brief DFSR: STATUS Position */
Anna Bridge 160:5571c4ff569f 587 #define DFSR_STATUS_Msk (0x3FUL << DFSR_STATUS_Pos) /*!< \brief DFSR: STATUS Mask */
Anna Bridge 160:5571c4ff569f 588
AnnaBridge 145:64910690c574 589 /* CP15 Register IFSR */
AnnaBridge 145:64910690c574 590 typedef union
AnnaBridge 145:64910690c574 591 {
AnnaBridge 145:64910690c574 592 struct
AnnaBridge 145:64910690c574 593 {
AnnaBridge 145:64910690c574 594 uint32_t FS0:4; /*!< \brief bit: 0.. 3 Fault Status bits bit 0-3 */
Anna Bridge 160:5571c4ff569f 595 RESERVED(0:5, uint32_t)
Anna Bridge 160:5571c4ff569f 596 uint32_t LPAE:1; /*!< \brief bit: 9 Large Physical Address Extension */
AnnaBridge 145:64910690c574 597 uint32_t FS1:1; /*!< \brief bit: 10 Fault Status bits bit 4 */
Anna Bridge 160:5571c4ff569f 598 RESERVED(1:1, uint32_t)
AnnaBridge 145:64910690c574 599 uint32_t ExT:1; /*!< \brief bit: 12 External abort type */
Anna Bridge 160:5571c4ff569f 600 RESERVED(2:19, uint32_t)
Anna Bridge 160:5571c4ff569f 601 } s; /*!< \brief Structure used for bit access in short format */
Anna Bridge 160:5571c4ff569f 602 struct
Anna Bridge 160:5571c4ff569f 603 {
Anna Bridge 160:5571c4ff569f 604 uint32_t STATUS:6; /*!< \brief bit: 0.. 5 Fault Status bits */
Anna Bridge 160:5571c4ff569f 605 RESERVED(0:3, uint32_t)
Anna Bridge 160:5571c4ff569f 606 uint32_t LPAE:1; /*!< \brief bit: 9 Large Physical Address Extension */
Anna Bridge 160:5571c4ff569f 607 RESERVED(1:2, uint32_t)
Anna Bridge 160:5571c4ff569f 608 uint32_t ExT:1; /*!< \brief bit: 12 External abort type */
Anna Bridge 160:5571c4ff569f 609 RESERVED(2:19, uint32_t)
Anna Bridge 160:5571c4ff569f 610 } l; /*!< \brief Structure used for bit access in long format */
AnnaBridge 145:64910690c574 611 uint32_t w; /*!< \brief Type used for word access */
AnnaBridge 145:64910690c574 612 } IFSR_Type;
AnnaBridge 145:64910690c574 613
AnnaBridge 145:64910690c574 614 #define IFSR_ExT_Pos 12U /*!< \brief IFSR: ExT Position */
AnnaBridge 145:64910690c574 615 #define IFSR_ExT_Msk (1UL << IFSR_ExT_Pos) /*!< \brief IFSR: ExT Mask */
AnnaBridge 145:64910690c574 616
AnnaBridge 145:64910690c574 617 #define IFSR_FS1_Pos 10U /*!< \brief IFSR: FS1 Position */
AnnaBridge 145:64910690c574 618 #define IFSR_FS1_Msk (1UL << IFSR_FS1_Pos) /*!< \brief IFSR: FS1 Mask */
AnnaBridge 145:64910690c574 619
Anna Bridge 160:5571c4ff569f 620 #define IFSR_LPAE_Pos 9U /*!< \brief IFSR: LPAE Position */
Anna Bridge 160:5571c4ff569f 621 #define IFSR_LPAE_Msk (0x1UL << IFSR_LPAE_Pos) /*!< \brief IFSR: LPAE Mask */
Anna Bridge 160:5571c4ff569f 622
AnnaBridge 145:64910690c574 623 #define IFSR_FS0_Pos 0U /*!< \brief IFSR: FS0 Position */
AnnaBridge 145:64910690c574 624 #define IFSR_FS0_Msk (0xFUL << IFSR_FS0_Pos) /*!< \brief IFSR: FS0 Mask */
AnnaBridge 145:64910690c574 625
Anna Bridge 160:5571c4ff569f 626 #define IFSR_STATUS_Pos 0U /*!< \brief IFSR: STATUS Position */
Anna Bridge 160:5571c4ff569f 627 #define IFSR_STATUS_Msk (0x3FUL << IFSR_STATUS_Pos) /*!< \brief IFSR: STATUS Mask */
Anna Bridge 160:5571c4ff569f 628
AnnaBridge 145:64910690c574 629 /* CP15 Register ISR */
AnnaBridge 145:64910690c574 630 typedef union
AnnaBridge 145:64910690c574 631 {
AnnaBridge 145:64910690c574 632 struct
AnnaBridge 145:64910690c574 633 {
Anna Bridge 160:5571c4ff569f 634 RESERVED(0:6, uint32_t)
AnnaBridge 145:64910690c574 635 uint32_t F:1; /*!< \brief bit: 6 FIQ pending bit */
AnnaBridge 145:64910690c574 636 uint32_t I:1; /*!< \brief bit: 7 IRQ pending bit */
AnnaBridge 145:64910690c574 637 uint32_t A:1; /*!< \brief bit: 8 External abort pending bit */
Anna Bridge 160:5571c4ff569f 638 RESERVED(1:23, uint32_t)
AnnaBridge 145:64910690c574 639 } b; /*!< \brief Structure used for bit access */
AnnaBridge 145:64910690c574 640 uint32_t w; /*!< \brief Type used for word access */
AnnaBridge 145:64910690c574 641 } ISR_Type;
AnnaBridge 145:64910690c574 642
AnnaBridge 145:64910690c574 643 #define ISR_A_Pos 13U /*!< \brief ISR: A Position */
AnnaBridge 145:64910690c574 644 #define ISR_A_Msk (1UL << ISR_A_Pos) /*!< \brief ISR: A Mask */
AnnaBridge 145:64910690c574 645
AnnaBridge 145:64910690c574 646 #define ISR_I_Pos 12U /*!< \brief ISR: I Position */
AnnaBridge 145:64910690c574 647 #define ISR_I_Msk (1UL << ISR_I_Pos) /*!< \brief ISR: I Mask */
AnnaBridge 145:64910690c574 648
AnnaBridge 145:64910690c574 649 #define ISR_F_Pos 11U /*!< \brief ISR: F Position */
AnnaBridge 145:64910690c574 650 #define ISR_F_Msk (1UL << ISR_F_Pos) /*!< \brief ISR: F Mask */
AnnaBridge 145:64910690c574 651
Anna Bridge 160:5571c4ff569f 652 /* DACR Register */
Anna Bridge 160:5571c4ff569f 653 #define DACR_D_Pos_(n) (2U*n) /*!< \brief DACR: Dn Position */
Anna Bridge 160:5571c4ff569f 654 #define DACR_D_Msk_(n) (3UL << DACR_D_Pos_(n)) /*!< \brief DACR: Dn Mask */
Anna Bridge 160:5571c4ff569f 655 #define DACR_Dn_NOACCESS 0U /*!< \brief DACR Dn field: No access */
Anna Bridge 160:5571c4ff569f 656 #define DACR_Dn_CLIENT 1U /*!< \brief DACR Dn field: Client */
Anna Bridge 160:5571c4ff569f 657 #define DACR_Dn_MANAGER 3U /*!< \brief DACR Dn field: Manager */
Anna Bridge 160:5571c4ff569f 658
Anna Bridge 160:5571c4ff569f 659 /**
Anna Bridge 160:5571c4ff569f 660 \brief Mask and shift a bit field value for use in a register bit range.
Anna Bridge 160:5571c4ff569f 661 \param [in] field Name of the register bit field.
Anna Bridge 160:5571c4ff569f 662 \param [in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
Anna Bridge 160:5571c4ff569f 663 \return Masked and shifted value.
Anna Bridge 160:5571c4ff569f 664 */
Anna Bridge 160:5571c4ff569f 665 #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
Anna Bridge 160:5571c4ff569f 666
Anna Bridge 160:5571c4ff569f 667 /**
Anna Bridge 160:5571c4ff569f 668 \brief Mask and shift a register value to extract a bit filed value.
Anna Bridge 160:5571c4ff569f 669 \param [in] field Name of the register bit field.
Anna Bridge 160:5571c4ff569f 670 \param [in] value Value of register. This parameter is interpreted as an uint32_t type.
Anna Bridge 160:5571c4ff569f 671 \return Masked and shifted bit field value.
Anna Bridge 160:5571c4ff569f 672 */
Anna Bridge 160:5571c4ff569f 673 #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
Anna Bridge 160:5571c4ff569f 674
AnnaBridge 145:64910690c574 675
AnnaBridge 145:64910690c574 676 /**
AnnaBridge 145:64910690c574 677 \brief Union type to access the L2C_310 Cache Controller.
AnnaBridge 145:64910690c574 678 */
Anna Bridge 160:5571c4ff569f 679 #if (__L2C_PRESENT == 1U) || defined(DOXYGEN)
AnnaBridge 145:64910690c574 680 typedef struct
AnnaBridge 145:64910690c574 681 {
Anna Bridge 160:5571c4ff569f 682 __IM uint32_t CACHE_ID; /*!< \brief Offset: 0x0000 (R/ ) Cache ID Register */
Anna Bridge 160:5571c4ff569f 683 __IM uint32_t CACHE_TYPE; /*!< \brief Offset: 0x0004 (R/ ) Cache Type Register */
Anna Bridge 160:5571c4ff569f 684 RESERVED(0[0x3e], uint32_t)
Anna Bridge 160:5571c4ff569f 685 __IOM uint32_t CONTROL; /*!< \brief Offset: 0x0100 (R/W) Control Register */
Anna Bridge 160:5571c4ff569f 686 __IOM uint32_t AUX_CNT; /*!< \brief Offset: 0x0104 (R/W) Auxiliary Control */
Anna Bridge 160:5571c4ff569f 687 RESERVED(1[0x3e], uint32_t)
Anna Bridge 160:5571c4ff569f 688 __IOM uint32_t EVENT_CONTROL; /*!< \brief Offset: 0x0200 (R/W) Event Counter Control */
Anna Bridge 160:5571c4ff569f 689 __IOM uint32_t EVENT_COUNTER1_CONF; /*!< \brief Offset: 0x0204 (R/W) Event Counter 1 Configuration */
Anna Bridge 160:5571c4ff569f 690 __IOM uint32_t EVENT_COUNTER0_CONF; /*!< \brief Offset: 0x0208 (R/W) Event Counter 1 Configuration */
Anna Bridge 160:5571c4ff569f 691 RESERVED(2[0x2], uint32_t)
Anna Bridge 160:5571c4ff569f 692 __IOM uint32_t INTERRUPT_MASK; /*!< \brief Offset: 0x0214 (R/W) Interrupt Mask */
Anna Bridge 160:5571c4ff569f 693 __IM uint32_t MASKED_INT_STATUS; /*!< \brief Offset: 0x0218 (R/ ) Masked Interrupt Status */
Anna Bridge 160:5571c4ff569f 694 __IM uint32_t RAW_INT_STATUS; /*!< \brief Offset: 0x021c (R/ ) Raw Interrupt Status */
Anna Bridge 160:5571c4ff569f 695 __OM uint32_t INTERRUPT_CLEAR; /*!< \brief Offset: 0x0220 ( /W) Interrupt Clear */
Anna Bridge 160:5571c4ff569f 696 RESERVED(3[0x143], uint32_t)
Anna Bridge 160:5571c4ff569f 697 __IOM uint32_t CACHE_SYNC; /*!< \brief Offset: 0x0730 (R/W) Cache Sync */
Anna Bridge 160:5571c4ff569f 698 RESERVED(4[0xf], uint32_t)
Anna Bridge 160:5571c4ff569f 699 __IOM uint32_t INV_LINE_PA; /*!< \brief Offset: 0x0770 (R/W) Invalidate Line By PA */
Anna Bridge 160:5571c4ff569f 700 RESERVED(6[2], uint32_t)
Anna Bridge 160:5571c4ff569f 701 __IOM uint32_t INV_WAY; /*!< \brief Offset: 0x077c (R/W) Invalidate by Way */
Anna Bridge 160:5571c4ff569f 702 RESERVED(5[0xc], uint32_t)
Anna Bridge 160:5571c4ff569f 703 __IOM uint32_t CLEAN_LINE_PA; /*!< \brief Offset: 0x07b0 (R/W) Clean Line by PA */
Anna Bridge 160:5571c4ff569f 704 RESERVED(7[1], uint32_t)
Anna Bridge 160:5571c4ff569f 705 __IOM uint32_t CLEAN_LINE_INDEX_WAY; /*!< \brief Offset: 0x07b8 (R/W) Clean Line by Index/Way */
Anna Bridge 160:5571c4ff569f 706 __IOM uint32_t CLEAN_WAY; /*!< \brief Offset: 0x07bc (R/W) Clean by Way */
Anna Bridge 160:5571c4ff569f 707 RESERVED(8[0xc], uint32_t)
Anna Bridge 160:5571c4ff569f 708 __IOM uint32_t CLEAN_INV_LINE_PA; /*!< \brief Offset: 0x07f0 (R/W) Clean and Invalidate Line by PA */
Anna Bridge 160:5571c4ff569f 709 RESERVED(9[1], uint32_t)
Anna Bridge 160:5571c4ff569f 710 __IOM uint32_t CLEAN_INV_LINE_INDEX_WAY; /*!< \brief Offset: 0x07f8 (R/W) Clean and Invalidate Line by Index/Way */
Anna Bridge 160:5571c4ff569f 711 __IOM uint32_t CLEAN_INV_WAY; /*!< \brief Offset: 0x07fc (R/W) Clean and Invalidate by Way */
Anna Bridge 160:5571c4ff569f 712 RESERVED(10[0x40], uint32_t)
Anna Bridge 160:5571c4ff569f 713 __IOM uint32_t DATA_LOCK_0_WAY; /*!< \brief Offset: 0x0900 (R/W) Data Lockdown 0 by Way */
Anna Bridge 160:5571c4ff569f 714 __IOM uint32_t INST_LOCK_0_WAY; /*!< \brief Offset: 0x0904 (R/W) Instruction Lockdown 0 by Way */
Anna Bridge 160:5571c4ff569f 715 __IOM uint32_t DATA_LOCK_1_WAY; /*!< \brief Offset: 0x0908 (R/W) Data Lockdown 1 by Way */
Anna Bridge 160:5571c4ff569f 716 __IOM uint32_t INST_LOCK_1_WAY; /*!< \brief Offset: 0x090c (R/W) Instruction Lockdown 1 by Way */
Anna Bridge 160:5571c4ff569f 717 __IOM uint32_t DATA_LOCK_2_WAY; /*!< \brief Offset: 0x0910 (R/W) Data Lockdown 2 by Way */
Anna Bridge 160:5571c4ff569f 718 __IOM uint32_t INST_LOCK_2_WAY; /*!< \brief Offset: 0x0914 (R/W) Instruction Lockdown 2 by Way */
Anna Bridge 160:5571c4ff569f 719 __IOM uint32_t DATA_LOCK_3_WAY; /*!< \brief Offset: 0x0918 (R/W) Data Lockdown 3 by Way */
Anna Bridge 160:5571c4ff569f 720 __IOM uint32_t INST_LOCK_3_WAY; /*!< \brief Offset: 0x091c (R/W) Instruction Lockdown 3 by Way */
Anna Bridge 160:5571c4ff569f 721 __IOM uint32_t DATA_LOCK_4_WAY; /*!< \brief Offset: 0x0920 (R/W) Data Lockdown 4 by Way */
Anna Bridge 160:5571c4ff569f 722 __IOM uint32_t INST_LOCK_4_WAY; /*!< \brief Offset: 0x0924 (R/W) Instruction Lockdown 4 by Way */
Anna Bridge 160:5571c4ff569f 723 __IOM uint32_t DATA_LOCK_5_WAY; /*!< \brief Offset: 0x0928 (R/W) Data Lockdown 5 by Way */
Anna Bridge 160:5571c4ff569f 724 __IOM uint32_t INST_LOCK_5_WAY; /*!< \brief Offset: 0x092c (R/W) Instruction Lockdown 5 by Way */
Anna Bridge 160:5571c4ff569f 725 __IOM uint32_t DATA_LOCK_6_WAY; /*!< \brief Offset: 0x0930 (R/W) Data Lockdown 5 by Way */
Anna Bridge 160:5571c4ff569f 726 __IOM uint32_t INST_LOCK_6_WAY; /*!< \brief Offset: 0x0934 (R/W) Instruction Lockdown 5 by Way */
Anna Bridge 160:5571c4ff569f 727 __IOM uint32_t DATA_LOCK_7_WAY; /*!< \brief Offset: 0x0938 (R/W) Data Lockdown 6 by Way */
Anna Bridge 160:5571c4ff569f 728 __IOM uint32_t INST_LOCK_7_WAY; /*!< \brief Offset: 0x093c (R/W) Instruction Lockdown 6 by Way */
Anna Bridge 160:5571c4ff569f 729 RESERVED(11[0x4], uint32_t)
Anna Bridge 160:5571c4ff569f 730 __IOM uint32_t LOCK_LINE_EN; /*!< \brief Offset: 0x0950 (R/W) Lockdown by Line Enable */
Anna Bridge 160:5571c4ff569f 731 __IOM uint32_t UNLOCK_ALL_BY_WAY; /*!< \brief Offset: 0x0954 (R/W) Unlock All Lines by Way */
Anna Bridge 160:5571c4ff569f 732 RESERVED(12[0xaa], uint32_t)
Anna Bridge 160:5571c4ff569f 733 __IOM uint32_t ADDRESS_FILTER_START; /*!< \brief Offset: 0x0c00 (R/W) Address Filtering Start */
Anna Bridge 160:5571c4ff569f 734 __IOM uint32_t ADDRESS_FILTER_END; /*!< \brief Offset: 0x0c04 (R/W) Address Filtering End */
Anna Bridge 160:5571c4ff569f 735 RESERVED(13[0xce], uint32_t)
Anna Bridge 160:5571c4ff569f 736 __IOM uint32_t DEBUG_CONTROL; /*!< \brief Offset: 0x0f40 (R/W) Debug Control Register */
AnnaBridge 145:64910690c574 737 } L2C_310_TypeDef;
AnnaBridge 145:64910690c574 738
Anna Bridge 160:5571c4ff569f 739 #define L2C_310 ((L2C_310_TypeDef *)L2C_310_BASE) /*!< \brief L2C_310 register set access pointer */
AnnaBridge 145:64910690c574 740 #endif
AnnaBridge 145:64910690c574 741
Anna Bridge 160:5571c4ff569f 742 #if (__GIC_PRESENT == 1U) || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 743
AnnaBridge 145:64910690c574 744 /** \brief Structure type to access the Generic Interrupt Controller Distributor (GICD)
AnnaBridge 145:64910690c574 745 */
AnnaBridge 145:64910690c574 746 typedef struct
AnnaBridge 145:64910690c574 747 {
Anna Bridge 160:5571c4ff569f 748 __IOM uint32_t CTLR; /*!< \brief Offset: 0x000 (R/W) Distributor Control Register */
Anna Bridge 160:5571c4ff569f 749 __IM uint32_t TYPER; /*!< \brief Offset: 0x004 (R/ ) Interrupt Controller Type Register */
Anna Bridge 160:5571c4ff569f 750 __IM uint32_t IIDR; /*!< \brief Offset: 0x008 (R/ ) Distributor Implementer Identification Register */
Anna Bridge 160:5571c4ff569f 751 RESERVED(0, uint32_t)
Anna Bridge 160:5571c4ff569f 752 __IOM uint32_t STATUSR; /*!< \brief Offset: 0x010 (R/W) Error Reporting Status Register, optional */
Anna Bridge 160:5571c4ff569f 753 RESERVED(1[11], uint32_t)
Anna Bridge 160:5571c4ff569f 754 __OM uint32_t SETSPI_NSR; /*!< \brief Offset: 0x040 ( /W) Set SPI Register */
Anna Bridge 160:5571c4ff569f 755 RESERVED(2, uint32_t)
Anna Bridge 160:5571c4ff569f 756 __OM uint32_t CLRSPI_NSR; /*!< \brief Offset: 0x048 ( /W) Clear SPI Register */
Anna Bridge 160:5571c4ff569f 757 RESERVED(3, uint32_t)
Anna Bridge 160:5571c4ff569f 758 __OM uint32_t SETSPI_SR; /*!< \brief Offset: 0x050 ( /W) Set SPI, Secure Register */
Anna Bridge 160:5571c4ff569f 759 RESERVED(4, uint32_t)
Anna Bridge 160:5571c4ff569f 760 __OM uint32_t CLRSPI_SR; /*!< \brief Offset: 0x058 ( /W) Clear SPI, Secure Register */
Anna Bridge 160:5571c4ff569f 761 RESERVED(5[9], uint32_t)
Anna Bridge 160:5571c4ff569f 762 __IOM uint32_t IGROUPR[32]; /*!< \brief Offset: 0x080 (R/W) Interrupt Group Registers */
Anna Bridge 160:5571c4ff569f 763 __IOM uint32_t ISENABLER[32]; /*!< \brief Offset: 0x100 (R/W) Interrupt Set-Enable Registers */
Anna Bridge 160:5571c4ff569f 764 __IOM uint32_t ICENABLER[32]; /*!< \brief Offset: 0x180 (R/W) Interrupt Clear-Enable Registers */
Anna Bridge 160:5571c4ff569f 765 __IOM uint32_t ISPENDR[32]; /*!< \brief Offset: 0x200 (R/W) Interrupt Set-Pending Registers */
Anna Bridge 160:5571c4ff569f 766 __IOM uint32_t ICPENDR[32]; /*!< \brief Offset: 0x280 (R/W) Interrupt Clear-Pending Registers */
Anna Bridge 160:5571c4ff569f 767 __IOM uint32_t ISACTIVER[32]; /*!< \brief Offset: 0x300 (R/W) Interrupt Set-Active Registers */
Anna Bridge 160:5571c4ff569f 768 __IOM uint32_t ICACTIVER[32]; /*!< \brief Offset: 0x380 (R/W) Interrupt Clear-Active Registers */
Anna Bridge 160:5571c4ff569f 769 __IOM uint32_t IPRIORITYR[255]; /*!< \brief Offset: 0x400 (R/W) Interrupt Priority Registers */
Anna Bridge 160:5571c4ff569f 770 RESERVED(6, uint32_t)
Anna Bridge 160:5571c4ff569f 771 __IOM uint32_t ITARGETSR[255]; /*!< \brief Offset: 0x800 (R/W) Interrupt Targets Registers */
Anna Bridge 160:5571c4ff569f 772 RESERVED(7, uint32_t)
Anna Bridge 160:5571c4ff569f 773 __IOM uint32_t ICFGR[64]; /*!< \brief Offset: 0xC00 (R/W) Interrupt Configuration Registers */
Anna Bridge 160:5571c4ff569f 774 __IOM uint32_t IGRPMODR[32]; /*!< \brief Offset: 0xD00 (R/W) Interrupt Group Modifier Registers */
Anna Bridge 160:5571c4ff569f 775 RESERVED(8[32], uint32_t)
Anna Bridge 160:5571c4ff569f 776 __IOM uint32_t NSACR[64]; /*!< \brief Offset: 0xE00 (R/W) Non-secure Access Control Registers */
Anna Bridge 160:5571c4ff569f 777 __OM uint32_t SGIR; /*!< \brief Offset: 0xF00 ( /W) Software Generated Interrupt Register */
Anna Bridge 160:5571c4ff569f 778 RESERVED(9[3], uint32_t)
Anna Bridge 160:5571c4ff569f 779 __IOM uint32_t CPENDSGIR[4]; /*!< \brief Offset: 0xF10 (R/W) SGI Clear-Pending Registers */
Anna Bridge 160:5571c4ff569f 780 __IOM uint32_t SPENDSGIR[4]; /*!< \brief Offset: 0xF20 (R/W) SGI Set-Pending Registers */
Anna Bridge 160:5571c4ff569f 781 RESERVED(10[5236], uint32_t)
Anna Bridge 160:5571c4ff569f 782 __IOM uint64_t IROUTER[988]; /*!< \brief Offset: 0x6100(R/W) Interrupt Routing Registers */
AnnaBridge 145:64910690c574 783 } GICDistributor_Type;
AnnaBridge 145:64910690c574 784
Anna Bridge 160:5571c4ff569f 785 #define GICDistributor ((GICDistributor_Type *) GIC_DISTRIBUTOR_BASE ) /*!< \brief GIC Distributor register set access pointer */
AnnaBridge 145:64910690c574 786
AnnaBridge 145:64910690c574 787 /** \brief Structure type to access the Generic Interrupt Controller Interface (GICC)
AnnaBridge 145:64910690c574 788 */
AnnaBridge 145:64910690c574 789 typedef struct
AnnaBridge 145:64910690c574 790 {
Anna Bridge 160:5571c4ff569f 791 __IOM uint32_t CTLR; /*!< \brief Offset: 0x000 (R/W) CPU Interface Control Register */
Anna Bridge 160:5571c4ff569f 792 __IOM uint32_t PMR; /*!< \brief Offset: 0x004 (R/W) Interrupt Priority Mask Register */
Anna Bridge 160:5571c4ff569f 793 __IOM uint32_t BPR; /*!< \brief Offset: 0x008 (R/W) Binary Point Register */
Anna Bridge 160:5571c4ff569f 794 __IM uint32_t IAR; /*!< \brief Offset: 0x00C (R/ ) Interrupt Acknowledge Register */
Anna Bridge 160:5571c4ff569f 795 __OM uint32_t EOIR; /*!< \brief Offset: 0x010 ( /W) End Of Interrupt Register */
Anna Bridge 160:5571c4ff569f 796 __IM uint32_t RPR; /*!< \brief Offset: 0x014 (R/ ) Running Priority Register */
Anna Bridge 160:5571c4ff569f 797 __IM uint32_t HPPIR; /*!< \brief Offset: 0x018 (R/ ) Highest Priority Pending Interrupt Register */
Anna Bridge 160:5571c4ff569f 798 __IOM uint32_t ABPR; /*!< \brief Offset: 0x01C (R/W) Aliased Binary Point Register */
Anna Bridge 160:5571c4ff569f 799 __IM uint32_t AIAR; /*!< \brief Offset: 0x020 (R/ ) Aliased Interrupt Acknowledge Register */
Anna Bridge 160:5571c4ff569f 800 __OM uint32_t AEOIR; /*!< \brief Offset: 0x024 ( /W) Aliased End Of Interrupt Register */
Anna Bridge 160:5571c4ff569f 801 __IM uint32_t AHPPIR; /*!< \brief Offset: 0x028 (R/ ) Aliased Highest Priority Pending Interrupt Register */
Anna Bridge 160:5571c4ff569f 802 __IOM uint32_t STATUSR; /*!< \brief Offset: 0x02C (R/W) Error Reporting Status Register, optional */
Anna Bridge 160:5571c4ff569f 803 RESERVED(1[40], uint32_t)
Anna Bridge 160:5571c4ff569f 804 __IOM uint32_t APR[4]; /*!< \brief Offset: 0x0D0 (R/W) Active Priority Register */
Anna Bridge 160:5571c4ff569f 805 __IOM uint32_t NSAPR[4]; /*!< \brief Offset: 0x0E0 (R/W) Non-secure Active Priority Register */
Anna Bridge 160:5571c4ff569f 806 RESERVED(2[3], uint32_t)
Anna Bridge 160:5571c4ff569f 807 __IM uint32_t IIDR; /*!< \brief Offset: 0x0FC (R/ ) CPU Interface Identification Register */
Anna Bridge 160:5571c4ff569f 808 RESERVED(3[960], uint32_t)
Anna Bridge 160:5571c4ff569f 809 __OM uint32_t DIR; /*!< \brief Offset: 0x1000( /W) Deactivate Interrupt Register */
AnnaBridge 145:64910690c574 810 } GICInterface_Type;
AnnaBridge 145:64910690c574 811
Anna Bridge 160:5571c4ff569f 812 #define GICInterface ((GICInterface_Type *) GIC_INTERFACE_BASE ) /*!< \brief GIC Interface register set access pointer */
AnnaBridge 145:64910690c574 813 #endif
AnnaBridge 145:64910690c574 814
Anna Bridge 160:5571c4ff569f 815 #if (__TIM_PRESENT == 1U) || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 816 #if ((__CORTEX_A == 5U) || (__CORTEX_A == 9U)) || defined(DOXYGEN)
AnnaBridge 145:64910690c574 817 /** \brief Structure type to access the Private Timer
AnnaBridge 145:64910690c574 818 */
AnnaBridge 145:64910690c574 819 typedef struct
AnnaBridge 145:64910690c574 820 {
Anna Bridge 160:5571c4ff569f 821 __IOM uint32_t LOAD; //!< \brief Offset: 0x000 (R/W) Private Timer Load Register
Anna Bridge 160:5571c4ff569f 822 __IOM uint32_t COUNTER; //!< \brief Offset: 0x004 (R/W) Private Timer Counter Register
Anna Bridge 160:5571c4ff569f 823 __IOM uint32_t CONTROL; //!< \brief Offset: 0x008 (R/W) Private Timer Control Register
Anna Bridge 160:5571c4ff569f 824 __IOM uint32_t ISR; //!< \brief Offset: 0x00C (R/W) Private Timer Interrupt Status Register
Anna Bridge 160:5571c4ff569f 825 RESERVED(0[4], uint32_t)
Anna Bridge 160:5571c4ff569f 826 __IOM uint32_t WLOAD; //!< \brief Offset: 0x020 (R/W) Watchdog Load Register
Anna Bridge 160:5571c4ff569f 827 __IOM uint32_t WCOUNTER; //!< \brief Offset: 0x024 (R/W) Watchdog Counter Register
Anna Bridge 160:5571c4ff569f 828 __IOM uint32_t WCONTROL; //!< \brief Offset: 0x028 (R/W) Watchdog Control Register
Anna Bridge 160:5571c4ff569f 829 __IOM uint32_t WISR; //!< \brief Offset: 0x02C (R/W) Watchdog Interrupt Status Register
Anna Bridge 160:5571c4ff569f 830 __IOM uint32_t WRESET; //!< \brief Offset: 0x030 (R/W) Watchdog Reset Status Register
Anna Bridge 160:5571c4ff569f 831 __OM uint32_t WDISABLE; //!< \brief Offset: 0x034 ( /W) Watchdog Disable Register
AnnaBridge 145:64910690c574 832 } Timer_Type;
Anna Bridge 160:5571c4ff569f 833 #define PTIM ((Timer_Type *) TIMER_BASE ) /*!< \brief Timer register struct */
AnnaBridge 145:64910690c574 834 #endif
AnnaBridge 145:64910690c574 835 #endif
AnnaBridge 145:64910690c574 836
AnnaBridge 145:64910690c574 837 /*******************************************************************************
AnnaBridge 145:64910690c574 838 * Hardware Abstraction Layer
AnnaBridge 145:64910690c574 839 Core Function Interface contains:
AnnaBridge 145:64910690c574 840 - L1 Cache Functions
AnnaBridge 145:64910690c574 841 - L2C-310 Cache Controller Functions
AnnaBridge 145:64910690c574 842 - PL1 Timer Functions
AnnaBridge 145:64910690c574 843 - GIC Functions
AnnaBridge 145:64910690c574 844 - MMU Functions
AnnaBridge 145:64910690c574 845 ******************************************************************************/
AnnaBridge 145:64910690c574 846
AnnaBridge 145:64910690c574 847 /* ########################## L1 Cache functions ################################# */
AnnaBridge 145:64910690c574 848
Anna Bridge 160:5571c4ff569f 849 /** \brief Enable Caches by setting I and C bits in SCTLR register.
Anna Bridge 160:5571c4ff569f 850 */
Anna Bridge 160:5571c4ff569f 851 __STATIC_FORCEINLINE void L1C_EnableCaches(void) {
Anna Bridge 160:5571c4ff569f 852 __set_SCTLR( __get_SCTLR() | SCTLR_I_Msk | SCTLR_C_Msk);
Anna Bridge 160:5571c4ff569f 853 __ISB();
AnnaBridge 145:64910690c574 854 }
AnnaBridge 145:64910690c574 855
Anna Bridge 160:5571c4ff569f 856 /** \brief Disable Caches by clearing I and C bits in SCTLR register.
Anna Bridge 160:5571c4ff569f 857 */
Anna Bridge 160:5571c4ff569f 858 __STATIC_FORCEINLINE void L1C_DisableCaches(void) {
Anna Bridge 160:5571c4ff569f 859 __set_SCTLR( __get_SCTLR() & (~SCTLR_I_Msk) & (~SCTLR_C_Msk));
AnnaBridge 145:64910690c574 860 __ISB();
AnnaBridge 145:64910690c574 861 }
AnnaBridge 145:64910690c574 862
Anna Bridge 160:5571c4ff569f 863 /** \brief Enable Branch Prediction by setting Z bit in SCTLR register.
Anna Bridge 160:5571c4ff569f 864 */
Anna Bridge 160:5571c4ff569f 865 __STATIC_FORCEINLINE void L1C_EnableBTAC(void) {
Anna Bridge 160:5571c4ff569f 866 __set_SCTLR( __get_SCTLR() | SCTLR_Z_Msk);
AnnaBridge 145:64910690c574 867 __ISB();
AnnaBridge 145:64910690c574 868 }
AnnaBridge 145:64910690c574 869
Anna Bridge 160:5571c4ff569f 870 /** \brief Disable Branch Prediction by clearing Z bit in SCTLR register.
Anna Bridge 160:5571c4ff569f 871 */
Anna Bridge 160:5571c4ff569f 872 __STATIC_FORCEINLINE void L1C_DisableBTAC(void) {
Anna Bridge 160:5571c4ff569f 873 __set_SCTLR( __get_SCTLR() & (~SCTLR_Z_Msk));
Anna Bridge 160:5571c4ff569f 874 __ISB();
AnnaBridge 145:64910690c574 875 }
AnnaBridge 145:64910690c574 876
AnnaBridge 145:64910690c574 877 /** \brief Invalidate entire branch predictor array
Anna Bridge 160:5571c4ff569f 878 */
Anna Bridge 160:5571c4ff569f 879 __STATIC_FORCEINLINE void L1C_InvalidateBTAC(void) {
AnnaBridge 145:64910690c574 880 __set_BPIALL(0);
AnnaBridge 145:64910690c574 881 __DSB(); //ensure completion of the invalidation
AnnaBridge 145:64910690c574 882 __ISB(); //ensure instruction fetch path sees new state
AnnaBridge 145:64910690c574 883 }
AnnaBridge 145:64910690c574 884
Anna Bridge 160:5571c4ff569f 885 /** \brief Invalidate the whole instruction cache
AnnaBridge 145:64910690c574 886 */
Anna Bridge 160:5571c4ff569f 887 __STATIC_FORCEINLINE void L1C_InvalidateICacheAll(void) {
AnnaBridge 145:64910690c574 888 __set_ICIALLU(0);
AnnaBridge 145:64910690c574 889 __DSB(); //ensure completion of the invalidation
AnnaBridge 145:64910690c574 890 __ISB(); //ensure instruction fetch path sees new I cache state
AnnaBridge 145:64910690c574 891 }
AnnaBridge 145:64910690c574 892
Anna Bridge 160:5571c4ff569f 893 /** \brief Clean data cache line by address.
Anna Bridge 160:5571c4ff569f 894 * \param [in] va Pointer to data to clear the cache for.
AnnaBridge 145:64910690c574 895 */
Anna Bridge 160:5571c4ff569f 896 __STATIC_FORCEINLINE void L1C_CleanDCacheMVA(void *va) {
AnnaBridge 145:64910690c574 897 __set_DCCMVAC((uint32_t)va);
AnnaBridge 145:64910690c574 898 __DMB(); //ensure the ordering of data cache maintenance operations and their effects
AnnaBridge 145:64910690c574 899 }
AnnaBridge 145:64910690c574 900
Anna Bridge 160:5571c4ff569f 901 /** \brief Invalidate data cache line by address.
Anna Bridge 160:5571c4ff569f 902 * \param [in] va Pointer to data to invalidate the cache for.
AnnaBridge 145:64910690c574 903 */
Anna Bridge 160:5571c4ff569f 904 __STATIC_FORCEINLINE void L1C_InvalidateDCacheMVA(void *va) {
AnnaBridge 145:64910690c574 905 __set_DCIMVAC((uint32_t)va);
AnnaBridge 145:64910690c574 906 __DMB(); //ensure the ordering of data cache maintenance operations and their effects
AnnaBridge 145:64910690c574 907 }
AnnaBridge 145:64910690c574 908
Anna Bridge 160:5571c4ff569f 909 /** \brief Clean and Invalidate data cache by address.
Anna Bridge 160:5571c4ff569f 910 * \param [in] va Pointer to data to invalidate the cache for.
AnnaBridge 145:64910690c574 911 */
Anna Bridge 160:5571c4ff569f 912 __STATIC_FORCEINLINE void L1C_CleanInvalidateDCacheMVA(void *va) {
AnnaBridge 145:64910690c574 913 __set_DCCIMVAC((uint32_t)va);
AnnaBridge 145:64910690c574 914 __DMB(); //ensure the ordering of data cache maintenance operations and their effects
AnnaBridge 145:64910690c574 915 }
AnnaBridge 145:64910690c574 916
Anna Bridge 160:5571c4ff569f 917 /** \brief Calculate log2 rounded up
Anna Bridge 160:5571c4ff569f 918 * - log(0) => 0
Anna Bridge 160:5571c4ff569f 919 * - log(1) => 0
Anna Bridge 160:5571c4ff569f 920 * - log(2) => 1
Anna Bridge 160:5571c4ff569f 921 * - log(3) => 2
Anna Bridge 160:5571c4ff569f 922 * - log(4) => 2
Anna Bridge 160:5571c4ff569f 923 * - log(5) => 3
Anna Bridge 160:5571c4ff569f 924 * : :
Anna Bridge 160:5571c4ff569f 925 * - log(16) => 4
Anna Bridge 160:5571c4ff569f 926 * - log(32) => 5
Anna Bridge 160:5571c4ff569f 927 * : :
Anna Bridge 160:5571c4ff569f 928 * \param [in] n input value parameter
Anna Bridge 160:5571c4ff569f 929 * \return log2(n)
AnnaBridge 145:64910690c574 930 */
Anna Bridge 160:5571c4ff569f 931 __STATIC_FORCEINLINE uint8_t __log2_up(uint32_t n)
Anna Bridge 160:5571c4ff569f 932 {
Anna Bridge 160:5571c4ff569f 933 if (n < 2U) {
Anna Bridge 160:5571c4ff569f 934 return 0U;
Anna Bridge 160:5571c4ff569f 935 }
Anna Bridge 160:5571c4ff569f 936 uint8_t log = 0U;
Anna Bridge 160:5571c4ff569f 937 uint32_t t = n;
Anna Bridge 160:5571c4ff569f 938 while(t > 1U)
Anna Bridge 160:5571c4ff569f 939 {
Anna Bridge 160:5571c4ff569f 940 log++;
Anna Bridge 160:5571c4ff569f 941 t >>= 1U;
Anna Bridge 160:5571c4ff569f 942 }
Anna Bridge 160:5571c4ff569f 943 if (n & 1U) { log++; }
Anna Bridge 160:5571c4ff569f 944 return log;
AnnaBridge 145:64910690c574 945 }
AnnaBridge 145:64910690c574 946
Anna Bridge 160:5571c4ff569f 947 /** \brief Apply cache maintenance to given cache level.
Anna Bridge 160:5571c4ff569f 948 * \param [in] level cache level to be maintained
Anna Bridge 160:5571c4ff569f 949 * \param [in] maint 0 - invalidate, 1 - clean, otherwise - invalidate and clean
Anna Bridge 160:5571c4ff569f 950 */
Anna Bridge 160:5571c4ff569f 951 __STATIC_FORCEINLINE void __L1C_MaintainDCacheSetWay(uint32_t level, uint32_t maint)
Anna Bridge 160:5571c4ff569f 952 {
Anna Bridge 169:a7c7b631e539 953 uint32_t Dummy;
Anna Bridge 169:a7c7b631e539 954 uint32_t ccsidr;
Anna Bridge 160:5571c4ff569f 955 uint32_t num_sets;
Anna Bridge 160:5571c4ff569f 956 uint32_t num_ways;
Anna Bridge 160:5571c4ff569f 957 uint32_t shift_way;
Anna Bridge 160:5571c4ff569f 958 uint32_t log2_linesize;
Anna Bridge 160:5571c4ff569f 959 int32_t log2_num_ways;
AnnaBridge 145:64910690c574 960
Anna Bridge 160:5571c4ff569f 961 Dummy = level << 1U;
Anna Bridge 160:5571c4ff569f 962 /* set csselr, select ccsidr register */
Anna Bridge 169:a7c7b631e539 963 __set_CSSELR(Dummy);
Anna Bridge 160:5571c4ff569f 964 /* get current ccsidr register */
Anna Bridge 160:5571c4ff569f 965 ccsidr = __get_CCSIDR();
Anna Bridge 160:5571c4ff569f 966 num_sets = ((ccsidr & 0x0FFFE000U) >> 13U) + 1U;
Anna Bridge 160:5571c4ff569f 967 num_ways = ((ccsidr & 0x00001FF8U) >> 3U) + 1U;
Anna Bridge 160:5571c4ff569f 968 log2_linesize = (ccsidr & 0x00000007U) + 2U + 2U;
Anna Bridge 160:5571c4ff569f 969 log2_num_ways = __log2_up(num_ways);
Anna Bridge 160:5571c4ff569f 970 if ((log2_num_ways < 0) || (log2_num_ways > 32)) {
Anna Bridge 160:5571c4ff569f 971 return; // FATAL ERROR
Anna Bridge 160:5571c4ff569f 972 }
Anna Bridge 160:5571c4ff569f 973 shift_way = 32U - (uint32_t)log2_num_ways;
Anna Bridge 160:5571c4ff569f 974 for(int32_t way = num_ways-1; way >= 0; way--)
Anna Bridge 160:5571c4ff569f 975 {
Anna Bridge 160:5571c4ff569f 976 for(int32_t set = num_sets-1; set >= 0; set--)
Anna Bridge 160:5571c4ff569f 977 {
Anna Bridge 160:5571c4ff569f 978 Dummy = (level << 1U) | (((uint32_t)set) << log2_linesize) | (((uint32_t)way) << shift_way);
Anna Bridge 160:5571c4ff569f 979 switch (maint)
Anna Bridge 160:5571c4ff569f 980 {
Anna Bridge 160:5571c4ff569f 981 case 0U: __set_DCISW(Dummy); break;
Anna Bridge 160:5571c4ff569f 982 case 1U: __set_DCCSW(Dummy); break;
Anna Bridge 160:5571c4ff569f 983 default: __set_DCCISW(Dummy); break;
Anna Bridge 160:5571c4ff569f 984 }
Anna Bridge 160:5571c4ff569f 985 }
Anna Bridge 160:5571c4ff569f 986 }
Anna Bridge 160:5571c4ff569f 987 __DMB();
Anna Bridge 160:5571c4ff569f 988 }
Anna Bridge 160:5571c4ff569f 989
Anna Bridge 160:5571c4ff569f 990 /** \brief Clean and Invalidate the entire data or unified cache
Anna Bridge 160:5571c4ff569f 991 * Generic mechanism for cleaning/invalidating the entire data or unified cache to the point of coherency
Anna Bridge 160:5571c4ff569f 992 * \param [in] op 0 - invalidate, 1 - clean, otherwise - invalidate and clean
AnnaBridge 145:64910690c574 993 */
Anna Bridge 160:5571c4ff569f 994 __STATIC_FORCEINLINE void L1C_CleanInvalidateCache(uint32_t op) {
Anna Bridge 169:a7c7b631e539 995 uint32_t clidr;
Anna Bridge 160:5571c4ff569f 996 uint32_t cache_type;
Anna Bridge 160:5571c4ff569f 997 clidr = __get_CLIDR();
Anna Bridge 160:5571c4ff569f 998 for(uint32_t i = 0U; i<7U; i++)
Anna Bridge 160:5571c4ff569f 999 {
Anna Bridge 160:5571c4ff569f 1000 cache_type = (clidr >> i*3U) & 0x7UL;
Anna Bridge 160:5571c4ff569f 1001 if ((cache_type >= 2U) && (cache_type <= 4U))
Anna Bridge 160:5571c4ff569f 1002 {
Anna Bridge 160:5571c4ff569f 1003 __L1C_MaintainDCacheSetWay(i, op);
Anna Bridge 160:5571c4ff569f 1004 }
Anna Bridge 160:5571c4ff569f 1005 }
Anna Bridge 160:5571c4ff569f 1006 }
AnnaBridge 145:64910690c574 1007
Anna Bridge 160:5571c4ff569f 1008 /** \brief Clean and Invalidate the entire data or unified cache
Anna Bridge 160:5571c4ff569f 1009 * Generic mechanism for cleaning/invalidating the entire data or unified cache to the point of coherency
Anna Bridge 160:5571c4ff569f 1010 * \param [in] op 0 - invalidate, 1 - clean, otherwise - invalidate and clean
Anna Bridge 160:5571c4ff569f 1011 * \deprecated Use generic L1C_CleanInvalidateCache instead.
Anna Bridge 160:5571c4ff569f 1012 */
Anna Bridge 160:5571c4ff569f 1013 CMSIS_DEPRECATED
Anna Bridge 160:5571c4ff569f 1014 __STATIC_FORCEINLINE void __L1C_CleanInvalidateCache(uint32_t op) {
Anna Bridge 160:5571c4ff569f 1015 L1C_CleanInvalidateCache(op);
Anna Bridge 160:5571c4ff569f 1016 }
Anna Bridge 160:5571c4ff569f 1017
Anna Bridge 160:5571c4ff569f 1018 /** \brief Invalidate the whole data cache.
Anna Bridge 160:5571c4ff569f 1019 */
Anna Bridge 160:5571c4ff569f 1020 __STATIC_FORCEINLINE void L1C_InvalidateDCacheAll(void) {
AnnaBridge 145:64910690c574 1021 L1C_CleanInvalidateCache(0);
AnnaBridge 145:64910690c574 1022 }
AnnaBridge 145:64910690c574 1023
Anna Bridge 160:5571c4ff569f 1024 /** \brief Clean the whole data cache.
AnnaBridge 145:64910690c574 1025 */
Anna Bridge 160:5571c4ff569f 1026 __STATIC_FORCEINLINE void L1C_CleanDCacheAll(void) {
AnnaBridge 145:64910690c574 1027 L1C_CleanInvalidateCache(1);
AnnaBridge 145:64910690c574 1028 }
AnnaBridge 145:64910690c574 1029
Anna Bridge 160:5571c4ff569f 1030 /** \brief Clean and invalidate the whole data cache.
AnnaBridge 145:64910690c574 1031 */
Anna Bridge 160:5571c4ff569f 1032 __STATIC_FORCEINLINE void L1C_CleanInvalidateDCacheAll(void) {
AnnaBridge 145:64910690c574 1033 L1C_CleanInvalidateCache(2);
AnnaBridge 145:64910690c574 1034 }
AnnaBridge 145:64910690c574 1035
AnnaBridge 145:64910690c574 1036 /* ########################## L2 Cache functions ################################# */
Anna Bridge 160:5571c4ff569f 1037 #if (__L2C_PRESENT == 1U) || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 1038 /** \brief Cache Sync operation by writing CACHE_SYNC register.
Anna Bridge 160:5571c4ff569f 1039 */
AnnaBridge 145:64910690c574 1040 __STATIC_INLINE void L2C_Sync(void)
AnnaBridge 145:64910690c574 1041 {
AnnaBridge 145:64910690c574 1042 L2C_310->CACHE_SYNC = 0x0;
AnnaBridge 145:64910690c574 1043 }
AnnaBridge 145:64910690c574 1044
Anna Bridge 160:5571c4ff569f 1045 /** \brief Read cache controller cache ID from CACHE_ID register.
Anna Bridge 160:5571c4ff569f 1046 * \return L2C_310_TypeDef::CACHE_ID
Anna Bridge 160:5571c4ff569f 1047 */
AnnaBridge 145:64910690c574 1048 __STATIC_INLINE int L2C_GetID (void)
AnnaBridge 145:64910690c574 1049 {
AnnaBridge 145:64910690c574 1050 return L2C_310->CACHE_ID;
AnnaBridge 145:64910690c574 1051 }
AnnaBridge 145:64910690c574 1052
Anna Bridge 160:5571c4ff569f 1053 /** \brief Read cache controller cache type from CACHE_TYPE register.
Anna Bridge 160:5571c4ff569f 1054 * \return L2C_310_TypeDef::CACHE_TYPE
Anna Bridge 160:5571c4ff569f 1055 */
AnnaBridge 145:64910690c574 1056 __STATIC_INLINE int L2C_GetType (void)
AnnaBridge 145:64910690c574 1057 {
AnnaBridge 145:64910690c574 1058 return L2C_310->CACHE_TYPE;
AnnaBridge 145:64910690c574 1059 }
AnnaBridge 145:64910690c574 1060
Anna Bridge 160:5571c4ff569f 1061 /** \brief Invalidate all cache by way
Anna Bridge 160:5571c4ff569f 1062 */
AnnaBridge 145:64910690c574 1063 __STATIC_INLINE void L2C_InvAllByWay (void)
AnnaBridge 145:64910690c574 1064 {
AnnaBridge 145:64910690c574 1065 unsigned int assoc;
AnnaBridge 145:64910690c574 1066
Anna Bridge 160:5571c4ff569f 1067 if (L2C_310->AUX_CNT & (1U << 16U)) {
Anna Bridge 160:5571c4ff569f 1068 assoc = 16U;
Anna Bridge 160:5571c4ff569f 1069 } else {
Anna Bridge 160:5571c4ff569f 1070 assoc = 8U;
Anna Bridge 160:5571c4ff569f 1071 }
Anna Bridge 160:5571c4ff569f 1072
Anna Bridge 160:5571c4ff569f 1073 L2C_310->INV_WAY = (1U << assoc) - 1U;
Anna Bridge 160:5571c4ff569f 1074 while(L2C_310->INV_WAY & ((1U << assoc) - 1U)); //poll invalidate
AnnaBridge 145:64910690c574 1075
AnnaBridge 145:64910690c574 1076 L2C_Sync();
AnnaBridge 145:64910690c574 1077 }
AnnaBridge 145:64910690c574 1078
Anna Bridge 160:5571c4ff569f 1079 /** \brief Clean and Invalidate all cache by way
Anna Bridge 160:5571c4ff569f 1080 */
AnnaBridge 145:64910690c574 1081 __STATIC_INLINE void L2C_CleanInvAllByWay (void)
AnnaBridge 145:64910690c574 1082 {
AnnaBridge 145:64910690c574 1083 unsigned int assoc;
AnnaBridge 145:64910690c574 1084
Anna Bridge 160:5571c4ff569f 1085 if (L2C_310->AUX_CNT & (1U << 16U)) {
Anna Bridge 160:5571c4ff569f 1086 assoc = 16U;
Anna Bridge 160:5571c4ff569f 1087 } else {
Anna Bridge 160:5571c4ff569f 1088 assoc = 8U;
Anna Bridge 160:5571c4ff569f 1089 }
AnnaBridge 145:64910690c574 1090
Anna Bridge 160:5571c4ff569f 1091 L2C_310->CLEAN_INV_WAY = (1U << assoc) - 1U;
Anna Bridge 160:5571c4ff569f 1092 while(L2C_310->CLEAN_INV_WAY & ((1U << assoc) - 1U)); //poll invalidate
AnnaBridge 145:64910690c574 1093
AnnaBridge 145:64910690c574 1094 L2C_Sync();
AnnaBridge 145:64910690c574 1095 }
AnnaBridge 145:64910690c574 1096
Anna Bridge 160:5571c4ff569f 1097 /** \brief Enable Level 2 Cache
Anna Bridge 160:5571c4ff569f 1098 */
AnnaBridge 145:64910690c574 1099 __STATIC_INLINE void L2C_Enable(void)
AnnaBridge 145:64910690c574 1100 {
AnnaBridge 145:64910690c574 1101 L2C_310->CONTROL = 0;
AnnaBridge 145:64910690c574 1102 L2C_310->INTERRUPT_CLEAR = 0x000001FFuL;
AnnaBridge 145:64910690c574 1103 L2C_310->DEBUG_CONTROL = 0;
AnnaBridge 145:64910690c574 1104 L2C_310->DATA_LOCK_0_WAY = 0;
AnnaBridge 145:64910690c574 1105 L2C_310->CACHE_SYNC = 0;
AnnaBridge 145:64910690c574 1106 L2C_310->CONTROL = 0x01;
AnnaBridge 145:64910690c574 1107 L2C_Sync();
AnnaBridge 145:64910690c574 1108 }
Anna Bridge 160:5571c4ff569f 1109
Anna Bridge 160:5571c4ff569f 1110 /** \brief Disable Level 2 Cache
Anna Bridge 160:5571c4ff569f 1111 */
AnnaBridge 145:64910690c574 1112 __STATIC_INLINE void L2C_Disable(void)
AnnaBridge 145:64910690c574 1113 {
AnnaBridge 145:64910690c574 1114 L2C_310->CONTROL = 0x00;
AnnaBridge 145:64910690c574 1115 L2C_Sync();
AnnaBridge 145:64910690c574 1116 }
AnnaBridge 145:64910690c574 1117
Anna Bridge 160:5571c4ff569f 1118 /** \brief Invalidate cache by physical address
Anna Bridge 160:5571c4ff569f 1119 * \param [in] pa Pointer to data to invalidate cache for.
Anna Bridge 160:5571c4ff569f 1120 */
AnnaBridge 145:64910690c574 1121 __STATIC_INLINE void L2C_InvPa (void *pa)
AnnaBridge 145:64910690c574 1122 {
AnnaBridge 145:64910690c574 1123 L2C_310->INV_LINE_PA = (unsigned int)pa;
AnnaBridge 145:64910690c574 1124 L2C_Sync();
AnnaBridge 145:64910690c574 1125 }
AnnaBridge 145:64910690c574 1126
Anna Bridge 160:5571c4ff569f 1127 /** \brief Clean cache by physical address
Anna Bridge 160:5571c4ff569f 1128 * \param [in] pa Pointer to data to invalidate cache for.
Anna Bridge 160:5571c4ff569f 1129 */
AnnaBridge 145:64910690c574 1130 __STATIC_INLINE void L2C_CleanPa (void *pa)
AnnaBridge 145:64910690c574 1131 {
AnnaBridge 145:64910690c574 1132 L2C_310->CLEAN_LINE_PA = (unsigned int)pa;
AnnaBridge 145:64910690c574 1133 L2C_Sync();
AnnaBridge 145:64910690c574 1134 }
AnnaBridge 145:64910690c574 1135
Anna Bridge 160:5571c4ff569f 1136 /** \brief Clean and invalidate cache by physical address
Anna Bridge 160:5571c4ff569f 1137 * \param [in] pa Pointer to data to invalidate cache for.
Anna Bridge 160:5571c4ff569f 1138 */
AnnaBridge 145:64910690c574 1139 __STATIC_INLINE void L2C_CleanInvPa (void *pa)
AnnaBridge 145:64910690c574 1140 {
AnnaBridge 145:64910690c574 1141 L2C_310->CLEAN_INV_LINE_PA = (unsigned int)pa;
AnnaBridge 145:64910690c574 1142 L2C_Sync();
AnnaBridge 145:64910690c574 1143 }
AnnaBridge 145:64910690c574 1144 #endif
AnnaBridge 145:64910690c574 1145
AnnaBridge 145:64910690c574 1146 /* ########################## GIC functions ###################################### */
Anna Bridge 160:5571c4ff569f 1147 #if (__GIC_PRESENT == 1U) || defined(DOXYGEN)
AnnaBridge 145:64910690c574 1148
Anna Bridge 160:5571c4ff569f 1149 /** \brief Enable the interrupt distributor using the GIC's CTLR register.
Anna Bridge 160:5571c4ff569f 1150 */
AnnaBridge 145:64910690c574 1151 __STATIC_INLINE void GIC_EnableDistributor(void)
AnnaBridge 145:64910690c574 1152 {
Anna Bridge 160:5571c4ff569f 1153 GICDistributor->CTLR |= 1U;
AnnaBridge 145:64910690c574 1154 }
AnnaBridge 145:64910690c574 1155
Anna Bridge 160:5571c4ff569f 1156 /** \brief Disable the interrupt distributor using the GIC's CTLR register.
Anna Bridge 160:5571c4ff569f 1157 */
AnnaBridge 145:64910690c574 1158 __STATIC_INLINE void GIC_DisableDistributor(void)
AnnaBridge 145:64910690c574 1159 {
Anna Bridge 160:5571c4ff569f 1160 GICDistributor->CTLR &=~1U;
AnnaBridge 145:64910690c574 1161 }
AnnaBridge 145:64910690c574 1162
Anna Bridge 160:5571c4ff569f 1163 /** \brief Read the GIC's TYPER register.
Anna Bridge 160:5571c4ff569f 1164 * \return GICDistributor_Type::TYPER
Anna Bridge 160:5571c4ff569f 1165 */
AnnaBridge 145:64910690c574 1166 __STATIC_INLINE uint32_t GIC_DistributorInfo(void)
AnnaBridge 145:64910690c574 1167 {
Anna Bridge 160:5571c4ff569f 1168 return (GICDistributor->TYPER);
AnnaBridge 145:64910690c574 1169 }
AnnaBridge 145:64910690c574 1170
Anna Bridge 160:5571c4ff569f 1171 /** \brief Reads the GIC's IIDR register.
Anna Bridge 160:5571c4ff569f 1172 * \return GICDistributor_Type::IIDR
Anna Bridge 160:5571c4ff569f 1173 */
AnnaBridge 145:64910690c574 1174 __STATIC_INLINE uint32_t GIC_DistributorImplementer(void)
AnnaBridge 145:64910690c574 1175 {
Anna Bridge 160:5571c4ff569f 1176 return (GICDistributor->IIDR);
Anna Bridge 160:5571c4ff569f 1177 }
Anna Bridge 160:5571c4ff569f 1178
Anna Bridge 160:5571c4ff569f 1179 /** \brief Sets the GIC's ITARGETSR register for the given interrupt.
Anna Bridge 160:5571c4ff569f 1180 * \param [in] IRQn Interrupt to be configured.
Anna Bridge 160:5571c4ff569f 1181 * \param [in] cpu_target CPU interfaces to assign this interrupt to.
Anna Bridge 160:5571c4ff569f 1182 */
Anna Bridge 160:5571c4ff569f 1183 __STATIC_INLINE void GIC_SetTarget(IRQn_Type IRQn, uint32_t cpu_target)
Anna Bridge 160:5571c4ff569f 1184 {
Anna Bridge 160:5571c4ff569f 1185 uint32_t mask = GICDistributor->ITARGETSR[IRQn / 4U] & ~(0xFFUL << ((IRQn % 4U) * 8U));
Anna Bridge 160:5571c4ff569f 1186 GICDistributor->ITARGETSR[IRQn / 4U] = mask | ((cpu_target & 0xFFUL) << ((IRQn % 4U) * 8U));
Anna Bridge 160:5571c4ff569f 1187 }
Anna Bridge 160:5571c4ff569f 1188
Anna Bridge 160:5571c4ff569f 1189 /** \brief Read the GIC's ITARGETSR register.
Anna Bridge 160:5571c4ff569f 1190 * \param [in] IRQn Interrupt to acquire the configuration for.
Anna Bridge 160:5571c4ff569f 1191 * \return GICDistributor_Type::ITARGETSR
Anna Bridge 160:5571c4ff569f 1192 */
Anna Bridge 160:5571c4ff569f 1193 __STATIC_INLINE uint32_t GIC_GetTarget(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1194 {
Anna Bridge 160:5571c4ff569f 1195 return (GICDistributor->ITARGETSR[IRQn / 4U] >> ((IRQn % 4U) * 8U)) & 0xFFUL;
AnnaBridge 145:64910690c574 1196 }
AnnaBridge 145:64910690c574 1197
Anna Bridge 160:5571c4ff569f 1198 /** \brief Enable the CPU's interrupt interface.
Anna Bridge 160:5571c4ff569f 1199 */
Anna Bridge 160:5571c4ff569f 1200 __STATIC_INLINE void GIC_EnableInterface(void)
Anna Bridge 160:5571c4ff569f 1201 {
Anna Bridge 160:5571c4ff569f 1202 GICInterface->CTLR |= 1U; //enable interface
Anna Bridge 160:5571c4ff569f 1203 }
Anna Bridge 160:5571c4ff569f 1204
Anna Bridge 160:5571c4ff569f 1205 /** \brief Disable the CPU's interrupt interface.
Anna Bridge 160:5571c4ff569f 1206 */
Anna Bridge 160:5571c4ff569f 1207 __STATIC_INLINE void GIC_DisableInterface(void)
AnnaBridge 145:64910690c574 1208 {
Anna Bridge 160:5571c4ff569f 1209 GICInterface->CTLR &=~1U; //disable distributor
Anna Bridge 160:5571c4ff569f 1210 }
Anna Bridge 160:5571c4ff569f 1211
Anna Bridge 160:5571c4ff569f 1212 /** \brief Read the CPU's IAR register.
Anna Bridge 160:5571c4ff569f 1213 * \return GICInterface_Type::IAR
Anna Bridge 160:5571c4ff569f 1214 */
Anna Bridge 160:5571c4ff569f 1215 __STATIC_INLINE IRQn_Type GIC_AcknowledgePending(void)
Anna Bridge 160:5571c4ff569f 1216 {
Anna Bridge 160:5571c4ff569f 1217 return (IRQn_Type)(GICInterface->IAR);
Anna Bridge 160:5571c4ff569f 1218 }
Anna Bridge 160:5571c4ff569f 1219
Anna Bridge 160:5571c4ff569f 1220 /** \brief Writes the given interrupt number to the CPU's EOIR register.
Anna Bridge 160:5571c4ff569f 1221 * \param [in] IRQn The interrupt to be signaled as finished.
Anna Bridge 160:5571c4ff569f 1222 */
Anna Bridge 160:5571c4ff569f 1223 __STATIC_INLINE void GIC_EndInterrupt(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1224 {
Anna Bridge 160:5571c4ff569f 1225 GICInterface->EOIR = IRQn;
AnnaBridge 145:64910690c574 1226 }
AnnaBridge 145:64910690c574 1227
Anna Bridge 160:5571c4ff569f 1228 /** \brief Enables the given interrupt using GIC's ISENABLER register.
Anna Bridge 160:5571c4ff569f 1229 * \param [in] IRQn The interrupt to be enabled.
Anna Bridge 160:5571c4ff569f 1230 */
Anna Bridge 160:5571c4ff569f 1231 __STATIC_INLINE void GIC_EnableIRQ(IRQn_Type IRQn)
AnnaBridge 145:64910690c574 1232 {
Anna Bridge 160:5571c4ff569f 1233 GICDistributor->ISENABLER[IRQn / 32U] = 1U << (IRQn % 32U);
Anna Bridge 160:5571c4ff569f 1234 }
Anna Bridge 160:5571c4ff569f 1235
Anna Bridge 160:5571c4ff569f 1236 /** \brief Get interrupt enable status using GIC's ISENABLER register.
Anna Bridge 160:5571c4ff569f 1237 * \param [in] IRQn The interrupt to be queried.
Anna Bridge 160:5571c4ff569f 1238 * \return 0 - interrupt is not enabled, 1 - interrupt is enabled.
Anna Bridge 160:5571c4ff569f 1239 */
Anna Bridge 160:5571c4ff569f 1240 __STATIC_INLINE uint32_t GIC_GetEnableIRQ(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1241 {
Anna Bridge 160:5571c4ff569f 1242 return (GICDistributor->ISENABLER[IRQn / 32U] >> (IRQn % 32U)) & 1UL;
Anna Bridge 160:5571c4ff569f 1243 }
Anna Bridge 160:5571c4ff569f 1244
Anna Bridge 160:5571c4ff569f 1245 /** \brief Disables the given interrupt using GIC's ICENABLER register.
Anna Bridge 160:5571c4ff569f 1246 * \param [in] IRQn The interrupt to be disabled.
Anna Bridge 160:5571c4ff569f 1247 */
Anna Bridge 160:5571c4ff569f 1248 __STATIC_INLINE void GIC_DisableIRQ(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1249 {
Anna Bridge 160:5571c4ff569f 1250 GICDistributor->ICENABLER[IRQn / 32U] = 1U << (IRQn % 32U);
Anna Bridge 160:5571c4ff569f 1251 }
AnnaBridge 145:64910690c574 1252
Anna Bridge 160:5571c4ff569f 1253 /** \brief Get interrupt pending status from GIC's ISPENDR register.
Anna Bridge 160:5571c4ff569f 1254 * \param [in] IRQn The interrupt to be queried.
Anna Bridge 160:5571c4ff569f 1255 * \return 0 - interrupt is not pending, 1 - interrupt is pendig.
Anna Bridge 160:5571c4ff569f 1256 */
Anna Bridge 160:5571c4ff569f 1257 __STATIC_INLINE uint32_t GIC_GetPendingIRQ(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1258 {
Anna Bridge 160:5571c4ff569f 1259 uint32_t pend;
AnnaBridge 145:64910690c574 1260
Anna Bridge 160:5571c4ff569f 1261 if (IRQn >= 16U) {
Anna Bridge 160:5571c4ff569f 1262 pend = (GICDistributor->ISPENDR[IRQn / 32U] >> (IRQn % 32U)) & 1UL;
Anna Bridge 160:5571c4ff569f 1263 } else {
Anna Bridge 160:5571c4ff569f 1264 // INTID 0-15 Software Generated Interrupt
Anna Bridge 160:5571c4ff569f 1265 pend = (GICDistributor->SPENDSGIR[IRQn / 4U] >> ((IRQn % 4U) * 8U)) & 0xFFUL;
Anna Bridge 160:5571c4ff569f 1266 // No CPU identification offered
Anna Bridge 160:5571c4ff569f 1267 if (pend != 0U) {
Anna Bridge 160:5571c4ff569f 1268 pend = 1U;
Anna Bridge 160:5571c4ff569f 1269 } else {
Anna Bridge 160:5571c4ff569f 1270 pend = 0U;
Anna Bridge 160:5571c4ff569f 1271 }
Anna Bridge 160:5571c4ff569f 1272 }
Anna Bridge 160:5571c4ff569f 1273
Anna Bridge 160:5571c4ff569f 1274 return (pend);
Anna Bridge 160:5571c4ff569f 1275 }
Anna Bridge 160:5571c4ff569f 1276
Anna Bridge 160:5571c4ff569f 1277 /** \brief Sets the given interrupt as pending using GIC's ISPENDR register.
Anna Bridge 160:5571c4ff569f 1278 * \param [in] IRQn The interrupt to be enabled.
Anna Bridge 160:5571c4ff569f 1279 */
Anna Bridge 160:5571c4ff569f 1280 __STATIC_INLINE void GIC_SetPendingIRQ(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1281 {
Anna Bridge 160:5571c4ff569f 1282 if (IRQn >= 16U) {
Anna Bridge 160:5571c4ff569f 1283 GICDistributor->ISPENDR[IRQn / 32U] = 1U << (IRQn % 32U);
Anna Bridge 160:5571c4ff569f 1284 } else {
Anna Bridge 160:5571c4ff569f 1285 // INTID 0-15 Software Generated Interrupt
Anna Bridge 160:5571c4ff569f 1286 GICDistributor->SPENDSGIR[IRQn / 4U] = 1U << ((IRQn % 4U) * 8U);
Anna Bridge 160:5571c4ff569f 1287 // Forward the interrupt to the CPU interface that requested it
Anna Bridge 160:5571c4ff569f 1288 GICDistributor->SGIR = (IRQn | 0x02000000U);
AnnaBridge 145:64910690c574 1289 }
AnnaBridge 145:64910690c574 1290 }
AnnaBridge 145:64910690c574 1291
Anna Bridge 160:5571c4ff569f 1292 /** \brief Clears the given interrupt from being pending using GIC's ICPENDR register.
Anna Bridge 160:5571c4ff569f 1293 * \param [in] IRQn The interrupt to be enabled.
Anna Bridge 160:5571c4ff569f 1294 */
AnnaBridge 145:64910690c574 1295 __STATIC_INLINE void GIC_ClearPendingIRQ(IRQn_Type IRQn)
AnnaBridge 145:64910690c574 1296 {
Anna Bridge 160:5571c4ff569f 1297 if (IRQn >= 16U) {
Anna Bridge 160:5571c4ff569f 1298 GICDistributor->ICPENDR[IRQn / 32U] = 1U << (IRQn % 32U);
Anna Bridge 160:5571c4ff569f 1299 } else {
Anna Bridge 160:5571c4ff569f 1300 // INTID 0-15 Software Generated Interrupt
Anna Bridge 160:5571c4ff569f 1301 GICDistributor->CPENDSGIR[IRQn / 4U] = 1U << ((IRQn % 4U) * 8U);
Anna Bridge 160:5571c4ff569f 1302 }
AnnaBridge 145:64910690c574 1303 }
AnnaBridge 145:64910690c574 1304
Anna Bridge 160:5571c4ff569f 1305 /** \brief Sets the interrupt configuration using GIC's ICFGR register.
Anna Bridge 160:5571c4ff569f 1306 * \param [in] IRQn The interrupt to be configured.
Anna Bridge 160:5571c4ff569f 1307 * \param [in] int_config Int_config field value. Bit 0: Reserved (0 - N-N model, 1 - 1-N model for some GIC before v1)
Anna Bridge 160:5571c4ff569f 1308 * Bit 1: 0 - level sensitive, 1 - edge triggered
Anna Bridge 160:5571c4ff569f 1309 */
Anna Bridge 160:5571c4ff569f 1310 __STATIC_INLINE void GIC_SetConfiguration(IRQn_Type IRQn, uint32_t int_config)
Anna Bridge 160:5571c4ff569f 1311 {
Anna Bridge 160:5571c4ff569f 1312 uint32_t icfgr = GICDistributor->ICFGR[IRQn / 16U];
Anna Bridge 160:5571c4ff569f 1313 uint32_t shift = (IRQn % 16U) << 1U;
AnnaBridge 145:64910690c574 1314
Anna Bridge 160:5571c4ff569f 1315 icfgr &= (~(3U << shift));
Anna Bridge 160:5571c4ff569f 1316 icfgr |= ( int_config << shift);
AnnaBridge 145:64910690c574 1317
Anna Bridge 160:5571c4ff569f 1318 GICDistributor->ICFGR[IRQn / 16U] = icfgr;
AnnaBridge 145:64910690c574 1319 }
AnnaBridge 145:64910690c574 1320
Anna Bridge 160:5571c4ff569f 1321 /** \brief Get the interrupt configuration from the GIC's ICFGR register.
Anna Bridge 160:5571c4ff569f 1322 * \param [in] IRQn Interrupt to acquire the configuration for.
Anna Bridge 160:5571c4ff569f 1323 * \return Int_config field value. Bit 0: Reserved (0 - N-N model, 1 - 1-N model for some GIC before v1)
Anna Bridge 160:5571c4ff569f 1324 * Bit 1: 0 - level sensitive, 1 - edge triggered
Anna Bridge 160:5571c4ff569f 1325 */
Anna Bridge 160:5571c4ff569f 1326 __STATIC_INLINE uint32_t GIC_GetConfiguration(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1327 {
Anna Bridge 160:5571c4ff569f 1328 return (GICDistributor->ICFGR[IRQn / 16U] >> ((IRQn % 16U) >> 1U));
Anna Bridge 160:5571c4ff569f 1329 }
Anna Bridge 160:5571c4ff569f 1330
Anna Bridge 160:5571c4ff569f 1331 /** \brief Set the priority for the given interrupt in the GIC's IPRIORITYR register.
Anna Bridge 160:5571c4ff569f 1332 * \param [in] IRQn The interrupt to be configured.
Anna Bridge 160:5571c4ff569f 1333 * \param [in] priority The priority for the interrupt, lower values denote higher priorities.
Anna Bridge 160:5571c4ff569f 1334 */
AnnaBridge 145:64910690c574 1335 __STATIC_INLINE void GIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
AnnaBridge 145:64910690c574 1336 {
Anna Bridge 160:5571c4ff569f 1337 uint32_t mask = GICDistributor->IPRIORITYR[IRQn / 4U] & ~(0xFFUL << ((IRQn % 4U) * 8U));
Anna Bridge 160:5571c4ff569f 1338 GICDistributor->IPRIORITYR[IRQn / 4U] = mask | ((priority & 0xFFUL) << ((IRQn % 4U) * 8U));
AnnaBridge 145:64910690c574 1339 }
AnnaBridge 145:64910690c574 1340
Anna Bridge 160:5571c4ff569f 1341 /** \brief Read the current interrupt priority from GIC's IPRIORITYR register.
Anna Bridge 160:5571c4ff569f 1342 * \param [in] IRQn The interrupt to be queried.
Anna Bridge 160:5571c4ff569f 1343 */
AnnaBridge 145:64910690c574 1344 __STATIC_INLINE uint32_t GIC_GetPriority(IRQn_Type IRQn)
AnnaBridge 145:64910690c574 1345 {
Anna Bridge 160:5571c4ff569f 1346 return (GICDistributor->IPRIORITYR[IRQn / 4U] >> ((IRQn % 4U) * 8U)) & 0xFFUL;
Anna Bridge 160:5571c4ff569f 1347 }
Anna Bridge 160:5571c4ff569f 1348
Anna Bridge 160:5571c4ff569f 1349 /** \brief Set the interrupt priority mask using CPU's PMR register.
Anna Bridge 160:5571c4ff569f 1350 * \param [in] priority Priority mask to be set.
Anna Bridge 160:5571c4ff569f 1351 */
Anna Bridge 160:5571c4ff569f 1352 __STATIC_INLINE void GIC_SetInterfacePriorityMask(uint32_t priority)
Anna Bridge 160:5571c4ff569f 1353 {
Anna Bridge 160:5571c4ff569f 1354 GICInterface->PMR = priority & 0xFFUL; //set priority mask
AnnaBridge 145:64910690c574 1355 }
AnnaBridge 145:64910690c574 1356
Anna Bridge 160:5571c4ff569f 1357 /** \brief Read the current interrupt priority mask from CPU's PMR register.
Anna Bridge 160:5571c4ff569f 1358 * \result GICInterface_Type::PMR
Anna Bridge 160:5571c4ff569f 1359 */
Anna Bridge 160:5571c4ff569f 1360 __STATIC_INLINE uint32_t GIC_GetInterfacePriorityMask(void)
AnnaBridge 145:64910690c574 1361 {
Anna Bridge 160:5571c4ff569f 1362 return GICInterface->PMR;
AnnaBridge 145:64910690c574 1363 }
AnnaBridge 145:64910690c574 1364
Anna Bridge 160:5571c4ff569f 1365 /** \brief Configures the group priority and subpriority split point using CPU's BPR register.
Anna Bridge 160:5571c4ff569f 1366 * \param [in] binary_point Amount of bits used as subpriority.
Anna Bridge 160:5571c4ff569f 1367 */
AnnaBridge 145:64910690c574 1368 __STATIC_INLINE void GIC_SetBinaryPoint(uint32_t binary_point)
AnnaBridge 145:64910690c574 1369 {
Anna Bridge 160:5571c4ff569f 1370 GICInterface->BPR = binary_point & 7U; //set binary point
AnnaBridge 145:64910690c574 1371 }
AnnaBridge 145:64910690c574 1372
Anna Bridge 160:5571c4ff569f 1373 /** \brief Read the current group priority and subpriority split point from CPU's BPR register.
Anna Bridge 160:5571c4ff569f 1374 * \return GICInterface_Type::BPR
Anna Bridge 160:5571c4ff569f 1375 */
Anna Bridge 160:5571c4ff569f 1376 __STATIC_INLINE uint32_t GIC_GetBinaryPoint(void)
AnnaBridge 145:64910690c574 1377 {
Anna Bridge 160:5571c4ff569f 1378 return GICInterface->BPR;
AnnaBridge 145:64910690c574 1379 }
AnnaBridge 145:64910690c574 1380
Anna Bridge 160:5571c4ff569f 1381 /** \brief Get the status for a given interrupt.
Anna Bridge 160:5571c4ff569f 1382 * \param [in] IRQn The interrupt to get status for.
Anna Bridge 160:5571c4ff569f 1383 * \return 0 - not pending/active, 1 - pending, 2 - active, 3 - pending and active
Anna Bridge 160:5571c4ff569f 1384 */
AnnaBridge 145:64910690c574 1385 __STATIC_INLINE uint32_t GIC_GetIRQStatus(IRQn_Type IRQn)
AnnaBridge 145:64910690c574 1386 {
AnnaBridge 145:64910690c574 1387 uint32_t pending, active;
AnnaBridge 145:64910690c574 1388
Anna Bridge 160:5571c4ff569f 1389 active = ((GICDistributor->ISACTIVER[IRQn / 32U]) >> (IRQn % 32U)) & 1UL;
Anna Bridge 160:5571c4ff569f 1390 pending = ((GICDistributor->ISPENDR[IRQn / 32U]) >> (IRQn % 32U)) & 1UL;
AnnaBridge 145:64910690c574 1391
Anna Bridge 160:5571c4ff569f 1392 return ((active<<1U) | pending);
AnnaBridge 145:64910690c574 1393 }
AnnaBridge 145:64910690c574 1394
Anna Bridge 160:5571c4ff569f 1395 /** \brief Generate a software interrupt using GIC's SGIR register.
Anna Bridge 160:5571c4ff569f 1396 * \param [in] IRQn Software interrupt to be generated.
Anna Bridge 160:5571c4ff569f 1397 * \param [in] target_list List of CPUs the software interrupt should be forwarded to.
Anna Bridge 160:5571c4ff569f 1398 * \param [in] filter_list Filter to be applied to determine interrupt receivers.
Anna Bridge 160:5571c4ff569f 1399 */
AnnaBridge 145:64910690c574 1400 __STATIC_INLINE void GIC_SendSGI(IRQn_Type IRQn, uint32_t target_list, uint32_t filter_list)
AnnaBridge 145:64910690c574 1401 {
Anna Bridge 160:5571c4ff569f 1402 GICDistributor->SGIR = ((filter_list & 3U) << 24U) | ((target_list & 0xFFUL) << 16U) | (IRQn & 0x0FUL);
Anna Bridge 160:5571c4ff569f 1403 }
Anna Bridge 160:5571c4ff569f 1404
Anna Bridge 160:5571c4ff569f 1405 /** \brief Get the interrupt number of the highest interrupt pending from CPU's HPPIR register.
Anna Bridge 160:5571c4ff569f 1406 * \return GICInterface_Type::HPPIR
Anna Bridge 160:5571c4ff569f 1407 */
Anna Bridge 160:5571c4ff569f 1408 __STATIC_INLINE uint32_t GIC_GetHighPendingIRQ(void)
Anna Bridge 160:5571c4ff569f 1409 {
Anna Bridge 160:5571c4ff569f 1410 return GICInterface->HPPIR;
Anna Bridge 160:5571c4ff569f 1411 }
Anna Bridge 160:5571c4ff569f 1412
Anna Bridge 160:5571c4ff569f 1413 /** \brief Provides information about the implementer and revision of the CPU interface.
Anna Bridge 160:5571c4ff569f 1414 * \return GICInterface_Type::IIDR
Anna Bridge 160:5571c4ff569f 1415 */
Anna Bridge 160:5571c4ff569f 1416 __STATIC_INLINE uint32_t GIC_GetInterfaceId(void)
Anna Bridge 160:5571c4ff569f 1417 {
Anna Bridge 160:5571c4ff569f 1418 return GICInterface->IIDR;
AnnaBridge 145:64910690c574 1419 }
AnnaBridge 145:64910690c574 1420
Anna Bridge 160:5571c4ff569f 1421 /** \brief Set the interrupt group from the GIC's IGROUPR register.
Anna Bridge 160:5571c4ff569f 1422 * \param [in] IRQn The interrupt to be queried.
Anna Bridge 160:5571c4ff569f 1423 * \param [in] group Interrupt group number: 0 - Group 0, 1 - Group 1
Anna Bridge 160:5571c4ff569f 1424 */
Anna Bridge 160:5571c4ff569f 1425 __STATIC_INLINE void GIC_SetGroup(IRQn_Type IRQn, uint32_t group)
Anna Bridge 160:5571c4ff569f 1426 {
Anna Bridge 160:5571c4ff569f 1427 uint32_t igroupr = GICDistributor->IGROUPR[IRQn / 32U];
Anna Bridge 160:5571c4ff569f 1428 uint32_t shift = (IRQn % 32U);
Anna Bridge 160:5571c4ff569f 1429
Anna Bridge 160:5571c4ff569f 1430 igroupr &= (~(1U << shift));
Anna Bridge 160:5571c4ff569f 1431 igroupr |= ( (group & 1U) << shift);
Anna Bridge 160:5571c4ff569f 1432
Anna Bridge 160:5571c4ff569f 1433 GICDistributor->IGROUPR[IRQn / 32U] = igroupr;
Anna Bridge 160:5571c4ff569f 1434 }
Anna Bridge 160:5571c4ff569f 1435 #define GIC_SetSecurity GIC_SetGroup
Anna Bridge 160:5571c4ff569f 1436
Anna Bridge 160:5571c4ff569f 1437 /** \brief Get the interrupt group from the GIC's IGROUPR register.
Anna Bridge 160:5571c4ff569f 1438 * \param [in] IRQn The interrupt to be queried.
Anna Bridge 160:5571c4ff569f 1439 * \return 0 - Group 0, 1 - Group 1
Anna Bridge 160:5571c4ff569f 1440 */
Anna Bridge 160:5571c4ff569f 1441 __STATIC_INLINE uint32_t GIC_GetGroup(IRQn_Type IRQn)
Anna Bridge 160:5571c4ff569f 1442 {
Anna Bridge 160:5571c4ff569f 1443 return (GICDistributor->IGROUPR[IRQn / 32U] >> (IRQn % 32U)) & 1UL;
Anna Bridge 160:5571c4ff569f 1444 }
Anna Bridge 160:5571c4ff569f 1445 #define GIC_GetSecurity GIC_GetGroup
Anna Bridge 160:5571c4ff569f 1446
Anna Bridge 160:5571c4ff569f 1447 /** \brief Initialize the interrupt distributor.
Anna Bridge 160:5571c4ff569f 1448 */
AnnaBridge 145:64910690c574 1449 __STATIC_INLINE void GIC_DistInit(void)
AnnaBridge 145:64910690c574 1450 {
Anna Bridge 160:5571c4ff569f 1451 uint32_t i;
Anna Bridge 160:5571c4ff569f 1452 uint32_t num_irq = 0U;
AnnaBridge 145:64910690c574 1453 uint32_t priority_field;
AnnaBridge 145:64910690c574 1454
Anna Bridge 160:5571c4ff569f 1455 //A reset sets all bits in the IGROUPRs corresponding to the SPIs to 0,
AnnaBridge 145:64910690c574 1456 //configuring all of the interrupts as Secure.
AnnaBridge 145:64910690c574 1457
AnnaBridge 145:64910690c574 1458 //Disable interrupt forwarding
AnnaBridge 145:64910690c574 1459 GIC_DisableDistributor();
AnnaBridge 145:64910690c574 1460 //Get the maximum number of interrupts that the GIC supports
Anna Bridge 160:5571c4ff569f 1461 num_irq = 32U * ((GIC_DistributorInfo() & 0x1FU) + 1U);
AnnaBridge 145:64910690c574 1462
AnnaBridge 145:64910690c574 1463 /* Priority level is implementation defined.
Anna Bridge 160:5571c4ff569f 1464 To determine the number of priority bits implemented write 0xFF to an IPRIORITYR
AnnaBridge 145:64910690c574 1465 priority field and read back the value stored.*/
Anna Bridge 160:5571c4ff569f 1466 GIC_SetPriority((IRQn_Type)0U, 0xFFU);
Anna Bridge 160:5571c4ff569f 1467 priority_field = GIC_GetPriority((IRQn_Type)0U);
AnnaBridge 145:64910690c574 1468
Anna Bridge 160:5571c4ff569f 1469 for (i = 32U; i < num_irq; i++)
AnnaBridge 145:64910690c574 1470 {
AnnaBridge 145:64910690c574 1471 //Disable the SPI interrupt
Anna Bridge 160:5571c4ff569f 1472 GIC_DisableIRQ((IRQn_Type)i);
Anna Bridge 160:5571c4ff569f 1473 //Set level-sensitive (and N-N model)
Anna Bridge 160:5571c4ff569f 1474 GIC_SetConfiguration((IRQn_Type)i, 0U);
AnnaBridge 145:64910690c574 1475 //Set priority
Anna Bridge 160:5571c4ff569f 1476 GIC_SetPriority((IRQn_Type)i, priority_field/2U);
AnnaBridge 145:64910690c574 1477 //Set target list to CPU0
Anna Bridge 160:5571c4ff569f 1478 GIC_SetTarget((IRQn_Type)i, 1U);
AnnaBridge 145:64910690c574 1479 }
AnnaBridge 145:64910690c574 1480 //Enable distributor
AnnaBridge 145:64910690c574 1481 GIC_EnableDistributor();
AnnaBridge 145:64910690c574 1482 }
AnnaBridge 145:64910690c574 1483
Anna Bridge 160:5571c4ff569f 1484 /** \brief Initialize the CPU's interrupt interface
Anna Bridge 160:5571c4ff569f 1485 */
AnnaBridge 145:64910690c574 1486 __STATIC_INLINE void GIC_CPUInterfaceInit(void)
AnnaBridge 145:64910690c574 1487 {
Anna Bridge 160:5571c4ff569f 1488 uint32_t i;
AnnaBridge 145:64910690c574 1489 uint32_t priority_field;
AnnaBridge 145:64910690c574 1490
Anna Bridge 160:5571c4ff569f 1491 //A reset sets all bits in the IGROUPRs corresponding to the SPIs to 0,
AnnaBridge 145:64910690c574 1492 //configuring all of the interrupts as Secure.
AnnaBridge 145:64910690c574 1493
AnnaBridge 145:64910690c574 1494 //Disable interrupt forwarding
AnnaBridge 145:64910690c574 1495 GIC_DisableInterface();
AnnaBridge 145:64910690c574 1496
AnnaBridge 145:64910690c574 1497 /* Priority level is implementation defined.
Anna Bridge 160:5571c4ff569f 1498 To determine the number of priority bits implemented write 0xFF to an IPRIORITYR
AnnaBridge 145:64910690c574 1499 priority field and read back the value stored.*/
Anna Bridge 160:5571c4ff569f 1500 GIC_SetPriority((IRQn_Type)0U, 0xFFU);
Anna Bridge 160:5571c4ff569f 1501 priority_field = GIC_GetPriority((IRQn_Type)0U);
AnnaBridge 145:64910690c574 1502
AnnaBridge 145:64910690c574 1503 //SGI and PPI
Anna Bridge 160:5571c4ff569f 1504 for (i = 0U; i < 32U; i++)
AnnaBridge 145:64910690c574 1505 {
Anna Bridge 160:5571c4ff569f 1506 if(i > 15U) {
Anna Bridge 160:5571c4ff569f 1507 //Set level-sensitive (and N-N model) for PPI
Anna Bridge 160:5571c4ff569f 1508 GIC_SetConfiguration((IRQn_Type)i, 0U);
Anna Bridge 160:5571c4ff569f 1509 }
Anna Bridge 160:5571c4ff569f 1510 //Disable SGI and PPI interrupts
Anna Bridge 160:5571c4ff569f 1511 GIC_DisableIRQ((IRQn_Type)i);
Anna Bridge 160:5571c4ff569f 1512 //Set priority
Anna Bridge 160:5571c4ff569f 1513 GIC_SetPriority((IRQn_Type)i, priority_field/2U);
AnnaBridge 145:64910690c574 1514 }
AnnaBridge 145:64910690c574 1515 //Enable interface
AnnaBridge 145:64910690c574 1516 GIC_EnableInterface();
AnnaBridge 145:64910690c574 1517 //Set binary point to 0
Anna Bridge 160:5571c4ff569f 1518 GIC_SetBinaryPoint(0U);
AnnaBridge 145:64910690c574 1519 //Set priority mask
Anna Bridge 160:5571c4ff569f 1520 GIC_SetInterfacePriorityMask(0xFFU);
AnnaBridge 145:64910690c574 1521 }
AnnaBridge 145:64910690c574 1522
Anna Bridge 160:5571c4ff569f 1523 /** \brief Initialize and enable the GIC
Anna Bridge 160:5571c4ff569f 1524 */
AnnaBridge 145:64910690c574 1525 __STATIC_INLINE void GIC_Enable(void)
AnnaBridge 145:64910690c574 1526 {
AnnaBridge 145:64910690c574 1527 GIC_DistInit();
AnnaBridge 145:64910690c574 1528 GIC_CPUInterfaceInit(); //per CPU
AnnaBridge 145:64910690c574 1529 }
AnnaBridge 145:64910690c574 1530 #endif
AnnaBridge 145:64910690c574 1531
AnnaBridge 145:64910690c574 1532 /* ########################## Generic Timer functions ############################ */
Anna Bridge 160:5571c4ff569f 1533 #if (__TIM_PRESENT == 1U) || defined(DOXYGEN)
AnnaBridge 145:64910690c574 1534
AnnaBridge 145:64910690c574 1535 /* PL1 Physical Timer */
Anna Bridge 160:5571c4ff569f 1536 #if (__CORTEX_A == 7U) || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 1537
Anna Bridge 160:5571c4ff569f 1538 /** \brief Physical Timer Control register */
Anna Bridge 160:5571c4ff569f 1539 typedef union
Anna Bridge 160:5571c4ff569f 1540 {
Anna Bridge 160:5571c4ff569f 1541 struct
Anna Bridge 160:5571c4ff569f 1542 {
Anna Bridge 160:5571c4ff569f 1543 uint32_t ENABLE:1; /*!< \brief bit: 0 Enables the timer. */
Anna Bridge 160:5571c4ff569f 1544 uint32_t IMASK:1; /*!< \brief bit: 1 Timer output signal mask bit. */
Anna Bridge 160:5571c4ff569f 1545 uint32_t ISTATUS:1; /*!< \brief bit: 2 The status of the timer. */
Anna Bridge 160:5571c4ff569f 1546 RESERVED(0:29, uint32_t)
Anna Bridge 160:5571c4ff569f 1547 } b; /*!< \brief Structure used for bit access */
Anna Bridge 160:5571c4ff569f 1548 uint32_t w; /*!< \brief Type used for word access */
Anna Bridge 160:5571c4ff569f 1549 } CNTP_CTL_Type;
Anna Bridge 160:5571c4ff569f 1550
Anna Bridge 160:5571c4ff569f 1551 /** \brief Configures the frequency the timer shall run at.
Anna Bridge 160:5571c4ff569f 1552 * \param [in] value The timer frequency in Hz.
Anna Bridge 160:5571c4ff569f 1553 */
Anna Bridge 160:5571c4ff569f 1554 __STATIC_INLINE void PL1_SetCounterFrequency(uint32_t value)
Anna Bridge 160:5571c4ff569f 1555 {
Anna Bridge 160:5571c4ff569f 1556 __set_CNTFRQ(value);
Anna Bridge 160:5571c4ff569f 1557 __ISB();
Anna Bridge 160:5571c4ff569f 1558 }
Anna Bridge 160:5571c4ff569f 1559
Anna Bridge 160:5571c4ff569f 1560 /** \brief Sets the reset value of the timer.
Anna Bridge 160:5571c4ff569f 1561 * \param [in] value The value the timer is loaded with.
Anna Bridge 160:5571c4ff569f 1562 */
Anna Bridge 160:5571c4ff569f 1563 __STATIC_INLINE void PL1_SetLoadValue(uint32_t value)
Anna Bridge 160:5571c4ff569f 1564 {
AnnaBridge 145:64910690c574 1565 __set_CNTP_TVAL(value);
AnnaBridge 145:64910690c574 1566 __ISB();
AnnaBridge 145:64910690c574 1567 }
AnnaBridge 145:64910690c574 1568
Anna Bridge 160:5571c4ff569f 1569 /** \brief Get the current counter value.
Anna Bridge 160:5571c4ff569f 1570 * \return Current counter value.
Anna Bridge 160:5571c4ff569f 1571 */
Anna Bridge 160:5571c4ff569f 1572 __STATIC_INLINE uint32_t PL1_GetCurrentValue(void)
Anna Bridge 160:5571c4ff569f 1573 {
AnnaBridge 145:64910690c574 1574 return(__get_CNTP_TVAL());
AnnaBridge 145:64910690c574 1575 }
AnnaBridge 145:64910690c574 1576
Anna Bridge 160:5571c4ff569f 1577 /** \brief Get the current physical counter value.
Anna Bridge 160:5571c4ff569f 1578 * \return Current physical counter value.
Anna Bridge 160:5571c4ff569f 1579 */
Anna Bridge 160:5571c4ff569f 1580 __STATIC_INLINE uint64_t PL1_GetCurrentPhysicalValue(void)
Anna Bridge 160:5571c4ff569f 1581 {
Anna Bridge 160:5571c4ff569f 1582 return(__get_CNTPCT());
Anna Bridge 160:5571c4ff569f 1583 }
Anna Bridge 160:5571c4ff569f 1584
Anna Bridge 160:5571c4ff569f 1585 /** \brief Set the physical compare value.
Anna Bridge 160:5571c4ff569f 1586 * \param [in] value New physical timer compare value.
Anna Bridge 160:5571c4ff569f 1587 */
Anna Bridge 160:5571c4ff569f 1588 __STATIC_INLINE void PL1_SetPhysicalCompareValue(uint64_t value)
Anna Bridge 160:5571c4ff569f 1589 {
Anna Bridge 160:5571c4ff569f 1590 __set_CNTP_CVAL(value);
Anna Bridge 160:5571c4ff569f 1591 __ISB();
Anna Bridge 160:5571c4ff569f 1592 }
Anna Bridge 160:5571c4ff569f 1593
Anna Bridge 160:5571c4ff569f 1594 /** \brief Get the physical compare value.
Anna Bridge 160:5571c4ff569f 1595 * \return Physical compare value.
Anna Bridge 160:5571c4ff569f 1596 */
Anna Bridge 160:5571c4ff569f 1597 __STATIC_INLINE uint64_t PL1_GetPhysicalCompareValue(void)
Anna Bridge 160:5571c4ff569f 1598 {
Anna Bridge 160:5571c4ff569f 1599 return(__get_CNTP_CVAL());
Anna Bridge 160:5571c4ff569f 1600 }
Anna Bridge 160:5571c4ff569f 1601
Anna Bridge 160:5571c4ff569f 1602 /** \brief Configure the timer by setting the control value.
Anna Bridge 160:5571c4ff569f 1603 * \param [in] value New timer control value.
Anna Bridge 160:5571c4ff569f 1604 */
Anna Bridge 160:5571c4ff569f 1605 __STATIC_INLINE void PL1_SetControl(uint32_t value)
Anna Bridge 160:5571c4ff569f 1606 {
AnnaBridge 145:64910690c574 1607 __set_CNTP_CTL(value);
AnnaBridge 145:64910690c574 1608 __ISB();
AnnaBridge 145:64910690c574 1609 }
AnnaBridge 145:64910690c574 1610
Anna Bridge 160:5571c4ff569f 1611 /** \brief Get the control value.
Anna Bridge 160:5571c4ff569f 1612 * \return Control value.
Anna Bridge 160:5571c4ff569f 1613 */
Anna Bridge 160:5571c4ff569f 1614 __STATIC_INLINE uint32_t PL1_GetControl(void)
Anna Bridge 160:5571c4ff569f 1615 {
Anna Bridge 160:5571c4ff569f 1616 return(__get_CNTP_CTL());
Anna Bridge 160:5571c4ff569f 1617 }
Anna Bridge 160:5571c4ff569f 1618 #endif
Anna Bridge 160:5571c4ff569f 1619
AnnaBridge 145:64910690c574 1620 /* Private Timer */
Anna Bridge 160:5571c4ff569f 1621 #if ((__CORTEX_A == 5U) || (__CORTEX_A == 9U)) || defined(DOXYGEN)
Anna Bridge 160:5571c4ff569f 1622 /** \brief Set the load value to timers LOAD register.
Anna Bridge 160:5571c4ff569f 1623 * \param [in] value The load value to be set.
Anna Bridge 160:5571c4ff569f 1624 */
Anna Bridge 160:5571c4ff569f 1625 __STATIC_INLINE void PTIM_SetLoadValue(uint32_t value)
Anna Bridge 160:5571c4ff569f 1626 {
AnnaBridge 145:64910690c574 1627 PTIM->LOAD = value;
AnnaBridge 145:64910690c574 1628 }
AnnaBridge 145:64910690c574 1629
Anna Bridge 160:5571c4ff569f 1630 /** \brief Get the load value from timers LOAD register.
Anna Bridge 160:5571c4ff569f 1631 * \return Timer_Type::LOAD
Anna Bridge 160:5571c4ff569f 1632 */
Anna Bridge 160:5571c4ff569f 1633 __STATIC_INLINE uint32_t PTIM_GetLoadValue(void)
Anna Bridge 160:5571c4ff569f 1634 {
AnnaBridge 145:64910690c574 1635 return(PTIM->LOAD);
AnnaBridge 145:64910690c574 1636 }
AnnaBridge 145:64910690c574 1637
Anna Bridge 160:5571c4ff569f 1638 /** \brief Set current counter value from its COUNTER register.
Anna Bridge 160:5571c4ff569f 1639 */
Anna Bridge 160:5571c4ff569f 1640 __STATIC_INLINE void PTIM_SetCurrentValue(uint32_t value)
Anna Bridge 160:5571c4ff569f 1641 {
Anna Bridge 160:5571c4ff569f 1642 PTIM->COUNTER = value;
Anna Bridge 160:5571c4ff569f 1643 }
Anna Bridge 160:5571c4ff569f 1644
Anna Bridge 160:5571c4ff569f 1645 /** \brief Get current counter value from timers COUNTER register.
Anna Bridge 160:5571c4ff569f 1646 * \result Timer_Type::COUNTER
Anna Bridge 160:5571c4ff569f 1647 */
Anna Bridge 160:5571c4ff569f 1648 __STATIC_INLINE uint32_t PTIM_GetCurrentValue(void)
Anna Bridge 160:5571c4ff569f 1649 {
AnnaBridge 145:64910690c574 1650 return(PTIM->COUNTER);
AnnaBridge 145:64910690c574 1651 }
AnnaBridge 145:64910690c574 1652
Anna Bridge 160:5571c4ff569f 1653 /** \brief Configure the timer using its CONTROL register.
Anna Bridge 160:5571c4ff569f 1654 * \param [in] value The new configuration value to be set.
Anna Bridge 160:5571c4ff569f 1655 */
Anna Bridge 160:5571c4ff569f 1656 __STATIC_INLINE void PTIM_SetControl(uint32_t value)
Anna Bridge 160:5571c4ff569f 1657 {
AnnaBridge 145:64910690c574 1658 PTIM->CONTROL = value;
AnnaBridge 145:64910690c574 1659 }
AnnaBridge 145:64910690c574 1660
Anna Bridge 160:5571c4ff569f 1661 /** ref Timer_Type::CONTROL Get the current timer configuration from its CONTROL register.
Anna Bridge 160:5571c4ff569f 1662 * \return Timer_Type::CONTROL
Anna Bridge 160:5571c4ff569f 1663 */
Anna Bridge 160:5571c4ff569f 1664 __STATIC_INLINE uint32_t PTIM_GetControl(void)
Anna Bridge 160:5571c4ff569f 1665 {
AnnaBridge 145:64910690c574 1666 return(PTIM->CONTROL);
AnnaBridge 145:64910690c574 1667 }
AnnaBridge 145:64910690c574 1668
Anna Bridge 160:5571c4ff569f 1669 /** ref Timer_Type::CONTROL Get the event flag in timers ISR register.
Anna Bridge 160:5571c4ff569f 1670 * \return 0 - flag is not set, 1- flag is set
Anna Bridge 160:5571c4ff569f 1671 */
Anna Bridge 160:5571c4ff569f 1672 __STATIC_INLINE uint32_t PTIM_GetEventFlag(void)
Anna Bridge 160:5571c4ff569f 1673 {
Anna Bridge 160:5571c4ff569f 1674 return (PTIM->ISR & 1UL);
Anna Bridge 160:5571c4ff569f 1675 }
Anna Bridge 160:5571c4ff569f 1676
Anna Bridge 160:5571c4ff569f 1677 /** ref Timer_Type::CONTROL Clears the event flag in timers ISR register.
Anna Bridge 160:5571c4ff569f 1678 */
Anna Bridge 160:5571c4ff569f 1679 __STATIC_INLINE void PTIM_ClearEventFlag(void)
Anna Bridge 160:5571c4ff569f 1680 {
AnnaBridge 145:64910690c574 1681 PTIM->ISR = 1;
AnnaBridge 145:64910690c574 1682 }
AnnaBridge 145:64910690c574 1683 #endif
AnnaBridge 145:64910690c574 1684 #endif
AnnaBridge 145:64910690c574 1685
AnnaBridge 145:64910690c574 1686 /* ########################## MMU functions ###################################### */
AnnaBridge 145:64910690c574 1687
AnnaBridge 145:64910690c574 1688 #define SECTION_DESCRIPTOR (0x2)
AnnaBridge 145:64910690c574 1689 #define SECTION_MASK (0xFFFFFFFC)
AnnaBridge 145:64910690c574 1690
AnnaBridge 145:64910690c574 1691 #define SECTION_TEXCB_MASK (0xFFFF8FF3)
AnnaBridge 145:64910690c574 1692 #define SECTION_B_SHIFT (2)
AnnaBridge 145:64910690c574 1693 #define SECTION_C_SHIFT (3)
AnnaBridge 145:64910690c574 1694 #define SECTION_TEX0_SHIFT (12)
AnnaBridge 145:64910690c574 1695 #define SECTION_TEX1_SHIFT (13)
AnnaBridge 145:64910690c574 1696 #define SECTION_TEX2_SHIFT (14)
AnnaBridge 145:64910690c574 1697
AnnaBridge 145:64910690c574 1698 #define SECTION_XN_MASK (0xFFFFFFEF)
AnnaBridge 145:64910690c574 1699 #define SECTION_XN_SHIFT (4)
AnnaBridge 145:64910690c574 1700
AnnaBridge 145:64910690c574 1701 #define SECTION_DOMAIN_MASK (0xFFFFFE1F)
AnnaBridge 145:64910690c574 1702 #define SECTION_DOMAIN_SHIFT (5)
AnnaBridge 145:64910690c574 1703
AnnaBridge 145:64910690c574 1704 #define SECTION_P_MASK (0xFFFFFDFF)
AnnaBridge 145:64910690c574 1705 #define SECTION_P_SHIFT (9)
AnnaBridge 145:64910690c574 1706
AnnaBridge 145:64910690c574 1707 #define SECTION_AP_MASK (0xFFFF73FF)
AnnaBridge 145:64910690c574 1708 #define SECTION_AP_SHIFT (10)
AnnaBridge 145:64910690c574 1709 #define SECTION_AP2_SHIFT (15)
AnnaBridge 145:64910690c574 1710
AnnaBridge 145:64910690c574 1711 #define SECTION_S_MASK (0xFFFEFFFF)
AnnaBridge 145:64910690c574 1712 #define SECTION_S_SHIFT (16)
AnnaBridge 145:64910690c574 1713
AnnaBridge 145:64910690c574 1714 #define SECTION_NG_MASK (0xFFFDFFFF)
AnnaBridge 145:64910690c574 1715 #define SECTION_NG_SHIFT (17)
AnnaBridge 145:64910690c574 1716
AnnaBridge 145:64910690c574 1717 #define SECTION_NS_MASK (0xFFF7FFFF)
AnnaBridge 145:64910690c574 1718 #define SECTION_NS_SHIFT (19)
AnnaBridge 145:64910690c574 1719
AnnaBridge 145:64910690c574 1720 #define PAGE_L1_DESCRIPTOR (0x1)
AnnaBridge 145:64910690c574 1721 #define PAGE_L1_MASK (0xFFFFFFFC)
AnnaBridge 145:64910690c574 1722
AnnaBridge 145:64910690c574 1723 #define PAGE_L2_4K_DESC (0x2)
AnnaBridge 145:64910690c574 1724 #define PAGE_L2_4K_MASK (0xFFFFFFFD)
AnnaBridge 145:64910690c574 1725
AnnaBridge 145:64910690c574 1726 #define PAGE_L2_64K_DESC (0x1)
AnnaBridge 145:64910690c574 1727 #define PAGE_L2_64K_MASK (0xFFFFFFFC)
AnnaBridge 145:64910690c574 1728
AnnaBridge 145:64910690c574 1729 #define PAGE_4K_TEXCB_MASK (0xFFFFFE33)
AnnaBridge 145:64910690c574 1730 #define PAGE_4K_B_SHIFT (2)
AnnaBridge 145:64910690c574 1731 #define PAGE_4K_C_SHIFT (3)
AnnaBridge 145:64910690c574 1732 #define PAGE_4K_TEX0_SHIFT (6)
AnnaBridge 145:64910690c574 1733 #define PAGE_4K_TEX1_SHIFT (7)
AnnaBridge 145:64910690c574 1734 #define PAGE_4K_TEX2_SHIFT (8)
AnnaBridge 145:64910690c574 1735
AnnaBridge 145:64910690c574 1736 #define PAGE_64K_TEXCB_MASK (0xFFFF8FF3)
AnnaBridge 145:64910690c574 1737 #define PAGE_64K_B_SHIFT (2)
AnnaBridge 145:64910690c574 1738 #define PAGE_64K_C_SHIFT (3)
AnnaBridge 145:64910690c574 1739 #define PAGE_64K_TEX0_SHIFT (12)
AnnaBridge 145:64910690c574 1740 #define PAGE_64K_TEX1_SHIFT (13)
AnnaBridge 145:64910690c574 1741 #define PAGE_64K_TEX2_SHIFT (14)
AnnaBridge 145:64910690c574 1742
AnnaBridge 145:64910690c574 1743 #define PAGE_TEXCB_MASK (0xFFFF8FF3)
AnnaBridge 145:64910690c574 1744 #define PAGE_B_SHIFT (2)
AnnaBridge 145:64910690c574 1745 #define PAGE_C_SHIFT (3)
AnnaBridge 145:64910690c574 1746 #define PAGE_TEX_SHIFT (12)
AnnaBridge 145:64910690c574 1747
AnnaBridge 145:64910690c574 1748 #define PAGE_XN_4K_MASK (0xFFFFFFFE)
AnnaBridge 145:64910690c574 1749 #define PAGE_XN_4K_SHIFT (0)
AnnaBridge 145:64910690c574 1750 #define PAGE_XN_64K_MASK (0xFFFF7FFF)
AnnaBridge 145:64910690c574 1751 #define PAGE_XN_64K_SHIFT (15)
AnnaBridge 145:64910690c574 1752
AnnaBridge 145:64910690c574 1753 #define PAGE_DOMAIN_MASK (0xFFFFFE1F)
AnnaBridge 145:64910690c574 1754 #define PAGE_DOMAIN_SHIFT (5)
AnnaBridge 145:64910690c574 1755
AnnaBridge 145:64910690c574 1756 #define PAGE_P_MASK (0xFFFFFDFF)
AnnaBridge 145:64910690c574 1757 #define PAGE_P_SHIFT (9)
AnnaBridge 145:64910690c574 1758
AnnaBridge 145:64910690c574 1759 #define PAGE_AP_MASK (0xFFFFFDCF)
AnnaBridge 145:64910690c574 1760 #define PAGE_AP_SHIFT (4)
AnnaBridge 145:64910690c574 1761 #define PAGE_AP2_SHIFT (9)
AnnaBridge 145:64910690c574 1762
AnnaBridge 145:64910690c574 1763 #define PAGE_S_MASK (0xFFFFFBFF)
AnnaBridge 145:64910690c574 1764 #define PAGE_S_SHIFT (10)
AnnaBridge 145:64910690c574 1765
AnnaBridge 145:64910690c574 1766 #define PAGE_NG_MASK (0xFFFFF7FF)
AnnaBridge 145:64910690c574 1767 #define PAGE_NG_SHIFT (11)
AnnaBridge 145:64910690c574 1768
AnnaBridge 145:64910690c574 1769 #define PAGE_NS_MASK (0xFFFFFFF7)
AnnaBridge 145:64910690c574 1770 #define PAGE_NS_SHIFT (3)
AnnaBridge 145:64910690c574 1771
AnnaBridge 145:64910690c574 1772 #define OFFSET_1M (0x00100000)
AnnaBridge 145:64910690c574 1773 #define OFFSET_64K (0x00010000)
AnnaBridge 145:64910690c574 1774 #define OFFSET_4K (0x00001000)
AnnaBridge 145:64910690c574 1775
AnnaBridge 145:64910690c574 1776 #define DESCRIPTOR_FAULT (0x00000000)
AnnaBridge 145:64910690c574 1777
AnnaBridge 145:64910690c574 1778 /* Attributes enumerations */
AnnaBridge 145:64910690c574 1779
AnnaBridge 145:64910690c574 1780 /* Region size attributes */
AnnaBridge 145:64910690c574 1781 typedef enum
AnnaBridge 145:64910690c574 1782 {
AnnaBridge 145:64910690c574 1783 SECTION,
AnnaBridge 145:64910690c574 1784 PAGE_4k,
AnnaBridge 145:64910690c574 1785 PAGE_64k,
AnnaBridge 145:64910690c574 1786 } mmu_region_size_Type;
AnnaBridge 145:64910690c574 1787
AnnaBridge 145:64910690c574 1788 /* Region type attributes */
AnnaBridge 145:64910690c574 1789 typedef enum
AnnaBridge 145:64910690c574 1790 {
AnnaBridge 145:64910690c574 1791 NORMAL,
AnnaBridge 145:64910690c574 1792 DEVICE,
AnnaBridge 145:64910690c574 1793 SHARED_DEVICE,
AnnaBridge 145:64910690c574 1794 NON_SHARED_DEVICE,
AnnaBridge 145:64910690c574 1795 STRONGLY_ORDERED
AnnaBridge 145:64910690c574 1796 } mmu_memory_Type;
AnnaBridge 145:64910690c574 1797
AnnaBridge 145:64910690c574 1798 /* Region cacheability attributes */
AnnaBridge 145:64910690c574 1799 typedef enum
AnnaBridge 145:64910690c574 1800 {
AnnaBridge 145:64910690c574 1801 NON_CACHEABLE,
AnnaBridge 145:64910690c574 1802 WB_WA,
AnnaBridge 145:64910690c574 1803 WT,
AnnaBridge 145:64910690c574 1804 WB_NO_WA,
AnnaBridge 145:64910690c574 1805 } mmu_cacheability_Type;
AnnaBridge 145:64910690c574 1806
AnnaBridge 145:64910690c574 1807 /* Region parity check attributes */
AnnaBridge 145:64910690c574 1808 typedef enum
AnnaBridge 145:64910690c574 1809 {
AnnaBridge 145:64910690c574 1810 ECC_DISABLED,
AnnaBridge 145:64910690c574 1811 ECC_ENABLED,
AnnaBridge 145:64910690c574 1812 } mmu_ecc_check_Type;
AnnaBridge 145:64910690c574 1813
AnnaBridge 145:64910690c574 1814 /* Region execution attributes */
AnnaBridge 145:64910690c574 1815 typedef enum
AnnaBridge 145:64910690c574 1816 {
AnnaBridge 145:64910690c574 1817 EXECUTE,
AnnaBridge 145:64910690c574 1818 NON_EXECUTE,
AnnaBridge 145:64910690c574 1819 } mmu_execute_Type;
AnnaBridge 145:64910690c574 1820
AnnaBridge 145:64910690c574 1821 /* Region global attributes */
AnnaBridge 145:64910690c574 1822 typedef enum
AnnaBridge 145:64910690c574 1823 {
AnnaBridge 145:64910690c574 1824 GLOBAL,
AnnaBridge 145:64910690c574 1825 NON_GLOBAL,
AnnaBridge 145:64910690c574 1826 } mmu_global_Type;
AnnaBridge 145:64910690c574 1827
AnnaBridge 145:64910690c574 1828 /* Region shareability attributes */
AnnaBridge 145:64910690c574 1829 typedef enum
AnnaBridge 145:64910690c574 1830 {
AnnaBridge 145:64910690c574 1831 NON_SHARED,
AnnaBridge 145:64910690c574 1832 SHARED,
AnnaBridge 145:64910690c574 1833 } mmu_shared_Type;
AnnaBridge 145:64910690c574 1834
AnnaBridge 145:64910690c574 1835 /* Region security attributes */
AnnaBridge 145:64910690c574 1836 typedef enum
AnnaBridge 145:64910690c574 1837 {
AnnaBridge 145:64910690c574 1838 SECURE,
AnnaBridge 145:64910690c574 1839 NON_SECURE,
AnnaBridge 145:64910690c574 1840 } mmu_secure_Type;
AnnaBridge 145:64910690c574 1841
AnnaBridge 145:64910690c574 1842 /* Region access attributes */
AnnaBridge 145:64910690c574 1843 typedef enum
AnnaBridge 145:64910690c574 1844 {
AnnaBridge 145:64910690c574 1845 NO_ACCESS,
AnnaBridge 145:64910690c574 1846 RW,
AnnaBridge 145:64910690c574 1847 READ,
AnnaBridge 145:64910690c574 1848 } mmu_access_Type;
AnnaBridge 145:64910690c574 1849
AnnaBridge 145:64910690c574 1850 /* Memory Region definition */
AnnaBridge 145:64910690c574 1851 typedef struct RegionStruct {
AnnaBridge 145:64910690c574 1852 mmu_region_size_Type rg_t;
AnnaBridge 145:64910690c574 1853 mmu_memory_Type mem_t;
AnnaBridge 145:64910690c574 1854 uint8_t domain;
AnnaBridge 145:64910690c574 1855 mmu_cacheability_Type inner_norm_t;
AnnaBridge 145:64910690c574 1856 mmu_cacheability_Type outer_norm_t;
AnnaBridge 145:64910690c574 1857 mmu_ecc_check_Type e_t;
AnnaBridge 145:64910690c574 1858 mmu_execute_Type xn_t;
AnnaBridge 145:64910690c574 1859 mmu_global_Type g_t;
AnnaBridge 145:64910690c574 1860 mmu_secure_Type sec_t;
AnnaBridge 145:64910690c574 1861 mmu_access_Type priv_t;
AnnaBridge 145:64910690c574 1862 mmu_access_Type user_t;
AnnaBridge 145:64910690c574 1863 mmu_shared_Type sh_t;
AnnaBridge 145:64910690c574 1864
AnnaBridge 145:64910690c574 1865 } mmu_region_attributes_Type;
AnnaBridge 145:64910690c574 1866
AnnaBridge 145:64910690c574 1867 //Following macros define the descriptors and attributes
AnnaBridge 145:64910690c574 1868 //Sect_Normal. Outer & inner wb/wa, non-shareable, executable, rw, domain 0
AnnaBridge 145:64910690c574 1869 #define section_normal(descriptor_l1, region) region.rg_t = SECTION; \
AnnaBridge 145:64910690c574 1870 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1871 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1872 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1873 region.inner_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1874 region.outer_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1875 region.mem_t = NORMAL; \
AnnaBridge 145:64910690c574 1876 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1877 region.xn_t = EXECUTE; \
AnnaBridge 145:64910690c574 1878 region.priv_t = RW; \
AnnaBridge 145:64910690c574 1879 region.user_t = RW; \
AnnaBridge 145:64910690c574 1880 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1881 MMU_GetSectionDescriptor(&descriptor_l1, region);
AnnaBridge 145:64910690c574 1882
Anna Bridge 160:5571c4ff569f 1883 //Sect_Normal_NC. Outer & inner non-cacheable, non-shareable, executable, rw, domain 0
Anna Bridge 160:5571c4ff569f 1884 #define section_normal_nc(descriptor_l1, region) region.rg_t = SECTION; \
Anna Bridge 160:5571c4ff569f 1885 region.domain = 0x0; \
Anna Bridge 160:5571c4ff569f 1886 region.e_t = ECC_DISABLED; \
Anna Bridge 160:5571c4ff569f 1887 region.g_t = GLOBAL; \
Anna Bridge 160:5571c4ff569f 1888 region.inner_norm_t = NON_CACHEABLE; \
Anna Bridge 160:5571c4ff569f 1889 region.outer_norm_t = NON_CACHEABLE; \
Anna Bridge 160:5571c4ff569f 1890 region.mem_t = NORMAL; \
Anna Bridge 160:5571c4ff569f 1891 region.sec_t = SECURE; \
Anna Bridge 160:5571c4ff569f 1892 region.xn_t = EXECUTE; \
Anna Bridge 160:5571c4ff569f 1893 region.priv_t = RW; \
Anna Bridge 160:5571c4ff569f 1894 region.user_t = RW; \
Anna Bridge 160:5571c4ff569f 1895 region.sh_t = NON_SHARED; \
Anna Bridge 160:5571c4ff569f 1896 MMU_GetSectionDescriptor(&descriptor_l1, region);
Anna Bridge 160:5571c4ff569f 1897
AnnaBridge 145:64910690c574 1898 //Sect_Normal_Cod. Outer & inner wb/wa, non-shareable, executable, ro, domain 0
AnnaBridge 145:64910690c574 1899 #define section_normal_cod(descriptor_l1, region) region.rg_t = SECTION; \
AnnaBridge 145:64910690c574 1900 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1901 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1902 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1903 region.inner_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1904 region.outer_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1905 region.mem_t = NORMAL; \
AnnaBridge 145:64910690c574 1906 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1907 region.xn_t = EXECUTE; \
AnnaBridge 145:64910690c574 1908 region.priv_t = READ; \
AnnaBridge 145:64910690c574 1909 region.user_t = READ; \
AnnaBridge 145:64910690c574 1910 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1911 MMU_GetSectionDescriptor(&descriptor_l1, region);
AnnaBridge 145:64910690c574 1912
AnnaBridge 145:64910690c574 1913 //Sect_Normal_RO. Sect_Normal_Cod, but not executable
AnnaBridge 145:64910690c574 1914 #define section_normal_ro(descriptor_l1, region) region.rg_t = SECTION; \
AnnaBridge 145:64910690c574 1915 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1916 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1917 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1918 region.inner_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1919 region.outer_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1920 region.mem_t = NORMAL; \
AnnaBridge 145:64910690c574 1921 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1922 region.xn_t = NON_EXECUTE; \
AnnaBridge 145:64910690c574 1923 region.priv_t = READ; \
AnnaBridge 145:64910690c574 1924 region.user_t = READ; \
AnnaBridge 145:64910690c574 1925 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1926 MMU_GetSectionDescriptor(&descriptor_l1, region);
AnnaBridge 145:64910690c574 1927
AnnaBridge 145:64910690c574 1928 //Sect_Normal_RW. Sect_Normal_Cod, but writeable and not executable
AnnaBridge 145:64910690c574 1929 #define section_normal_rw(descriptor_l1, region) region.rg_t = SECTION; \
AnnaBridge 145:64910690c574 1930 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1931 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1932 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1933 region.inner_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1934 region.outer_norm_t = WB_WA; \
AnnaBridge 145:64910690c574 1935 region.mem_t = NORMAL; \
AnnaBridge 145:64910690c574 1936 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1937 region.xn_t = NON_EXECUTE; \
AnnaBridge 145:64910690c574 1938 region.priv_t = RW; \
AnnaBridge 145:64910690c574 1939 region.user_t = RW; \
AnnaBridge 145:64910690c574 1940 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1941 MMU_GetSectionDescriptor(&descriptor_l1, region);
AnnaBridge 145:64910690c574 1942 //Sect_SO. Strongly-ordered (therefore shareable), not executable, rw, domain 0, base addr 0
AnnaBridge 145:64910690c574 1943 #define section_so(descriptor_l1, region) region.rg_t = SECTION; \
AnnaBridge 145:64910690c574 1944 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1945 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1946 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1947 region.inner_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1948 region.outer_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1949 region.mem_t = STRONGLY_ORDERED; \
AnnaBridge 145:64910690c574 1950 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1951 region.xn_t = NON_EXECUTE; \
AnnaBridge 145:64910690c574 1952 region.priv_t = RW; \
AnnaBridge 145:64910690c574 1953 region.user_t = RW; \
AnnaBridge 145:64910690c574 1954 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1955 MMU_GetSectionDescriptor(&descriptor_l1, region);
AnnaBridge 145:64910690c574 1956
AnnaBridge 145:64910690c574 1957 //Sect_Device_RO. Device, non-shareable, non-executable, ro, domain 0, base addr 0
AnnaBridge 145:64910690c574 1958 #define section_device_ro(descriptor_l1, region) region.rg_t = SECTION; \
AnnaBridge 145:64910690c574 1959 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1960 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1961 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1962 region.inner_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1963 region.outer_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1964 region.mem_t = STRONGLY_ORDERED; \
AnnaBridge 145:64910690c574 1965 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1966 region.xn_t = NON_EXECUTE; \
AnnaBridge 145:64910690c574 1967 region.priv_t = READ; \
AnnaBridge 145:64910690c574 1968 region.user_t = READ; \
AnnaBridge 145:64910690c574 1969 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1970 MMU_GetSectionDescriptor(&descriptor_l1, region);
AnnaBridge 145:64910690c574 1971
AnnaBridge 145:64910690c574 1972 //Sect_Device_RW. Sect_Device_RO, but writeable
AnnaBridge 145:64910690c574 1973 #define section_device_rw(descriptor_l1, region) region.rg_t = SECTION; \
AnnaBridge 145:64910690c574 1974 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1975 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1976 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1977 region.inner_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1978 region.outer_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1979 region.mem_t = STRONGLY_ORDERED; \
AnnaBridge 145:64910690c574 1980 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1981 region.xn_t = NON_EXECUTE; \
AnnaBridge 145:64910690c574 1982 region.priv_t = RW; \
AnnaBridge 145:64910690c574 1983 region.user_t = RW; \
AnnaBridge 145:64910690c574 1984 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1985 MMU_GetSectionDescriptor(&descriptor_l1, region);
AnnaBridge 145:64910690c574 1986 //Page_4k_Device_RW. Shared device, not executable, rw, domain 0
AnnaBridge 145:64910690c574 1987 #define page4k_device_rw(descriptor_l1, descriptor_l2, region) region.rg_t = PAGE_4k; \
AnnaBridge 145:64910690c574 1988 region.domain = 0x0; \
AnnaBridge 145:64910690c574 1989 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 1990 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 1991 region.inner_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1992 region.outer_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 1993 region.mem_t = SHARED_DEVICE; \
AnnaBridge 145:64910690c574 1994 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 1995 region.xn_t = NON_EXECUTE; \
AnnaBridge 145:64910690c574 1996 region.priv_t = RW; \
AnnaBridge 145:64910690c574 1997 region.user_t = RW; \
AnnaBridge 145:64910690c574 1998 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 1999 MMU_GetPageDescriptor(&descriptor_l1, &descriptor_l2, region);
AnnaBridge 145:64910690c574 2000
AnnaBridge 145:64910690c574 2001 //Page_64k_Device_RW. Shared device, not executable, rw, domain 0
AnnaBridge 145:64910690c574 2002 #define page64k_device_rw(descriptor_l1, descriptor_l2, region) region.rg_t = PAGE_64k; \
AnnaBridge 145:64910690c574 2003 region.domain = 0x0; \
AnnaBridge 145:64910690c574 2004 region.e_t = ECC_DISABLED; \
AnnaBridge 145:64910690c574 2005 region.g_t = GLOBAL; \
AnnaBridge 145:64910690c574 2006 region.inner_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 2007 region.outer_norm_t = NON_CACHEABLE; \
AnnaBridge 145:64910690c574 2008 region.mem_t = SHARED_DEVICE; \
AnnaBridge 145:64910690c574 2009 region.sec_t = SECURE; \
AnnaBridge 145:64910690c574 2010 region.xn_t = NON_EXECUTE; \
AnnaBridge 145:64910690c574 2011 region.priv_t = RW; \
AnnaBridge 145:64910690c574 2012 region.user_t = RW; \
AnnaBridge 145:64910690c574 2013 region.sh_t = NON_SHARED; \
AnnaBridge 145:64910690c574 2014 MMU_GetPageDescriptor(&descriptor_l1, &descriptor_l2, region);
AnnaBridge 145:64910690c574 2015
AnnaBridge 145:64910690c574 2016 /** \brief Set section execution-never attribute
AnnaBridge 145:64910690c574 2017
AnnaBridge 145:64910690c574 2018 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2019 \param [in] xn Section execution-never attribute : EXECUTE , NON_EXECUTE.
AnnaBridge 145:64910690c574 2020
AnnaBridge 145:64910690c574 2021 \return 0
AnnaBridge 145:64910690c574 2022 */
AnnaBridge 145:64910690c574 2023 __STATIC_INLINE int MMU_XNSection(uint32_t *descriptor_l1, mmu_execute_Type xn)
AnnaBridge 145:64910690c574 2024 {
AnnaBridge 145:64910690c574 2025 *descriptor_l1 &= SECTION_XN_MASK;
AnnaBridge 145:64910690c574 2026 *descriptor_l1 |= ((xn & 0x1) << SECTION_XN_SHIFT);
AnnaBridge 145:64910690c574 2027 return 0;
AnnaBridge 145:64910690c574 2028 }
AnnaBridge 145:64910690c574 2029
AnnaBridge 145:64910690c574 2030 /** \brief Set section domain
AnnaBridge 145:64910690c574 2031
AnnaBridge 145:64910690c574 2032 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2033 \param [in] domain Section domain
AnnaBridge 145:64910690c574 2034
AnnaBridge 145:64910690c574 2035 \return 0
AnnaBridge 145:64910690c574 2036 */
AnnaBridge 145:64910690c574 2037 __STATIC_INLINE int MMU_DomainSection(uint32_t *descriptor_l1, uint8_t domain)
AnnaBridge 145:64910690c574 2038 {
AnnaBridge 145:64910690c574 2039 *descriptor_l1 &= SECTION_DOMAIN_MASK;
AnnaBridge 145:64910690c574 2040 *descriptor_l1 |= ((domain & 0xF) << SECTION_DOMAIN_SHIFT);
AnnaBridge 145:64910690c574 2041 return 0;
AnnaBridge 145:64910690c574 2042 }
AnnaBridge 145:64910690c574 2043
AnnaBridge 145:64910690c574 2044 /** \brief Set section parity check
AnnaBridge 145:64910690c574 2045
AnnaBridge 145:64910690c574 2046 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2047 \param [in] p_bit Parity check: ECC_DISABLED, ECC_ENABLED
AnnaBridge 145:64910690c574 2048
AnnaBridge 145:64910690c574 2049 \return 0
AnnaBridge 145:64910690c574 2050 */
AnnaBridge 145:64910690c574 2051 __STATIC_INLINE int MMU_PSection(uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
AnnaBridge 145:64910690c574 2052 {
AnnaBridge 145:64910690c574 2053 *descriptor_l1 &= SECTION_P_MASK;
AnnaBridge 145:64910690c574 2054 *descriptor_l1 |= ((p_bit & 0x1) << SECTION_P_SHIFT);
AnnaBridge 145:64910690c574 2055 return 0;
AnnaBridge 145:64910690c574 2056 }
AnnaBridge 145:64910690c574 2057
AnnaBridge 145:64910690c574 2058 /** \brief Set section access privileges
AnnaBridge 145:64910690c574 2059
AnnaBridge 145:64910690c574 2060 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2061 \param [in] user User Level Access: NO_ACCESS, RW, READ
AnnaBridge 145:64910690c574 2062 \param [in] priv Privilege Level Access: NO_ACCESS, RW, READ
AnnaBridge 145:64910690c574 2063 \param [in] afe Access flag enable
AnnaBridge 145:64910690c574 2064
AnnaBridge 145:64910690c574 2065 \return 0
AnnaBridge 145:64910690c574 2066 */
AnnaBridge 145:64910690c574 2067 __STATIC_INLINE int MMU_APSection(uint32_t *descriptor_l1, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
AnnaBridge 145:64910690c574 2068 {
AnnaBridge 145:64910690c574 2069 uint32_t ap = 0;
AnnaBridge 145:64910690c574 2070
AnnaBridge 145:64910690c574 2071 if (afe == 0) { //full access
AnnaBridge 145:64910690c574 2072 if ((priv == NO_ACCESS) && (user == NO_ACCESS)) { ap = 0x0; }
AnnaBridge 145:64910690c574 2073 else if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
AnnaBridge 145:64910690c574 2074 else if ((priv == RW) && (user == READ)) { ap = 0x2; }
AnnaBridge 145:64910690c574 2075 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
AnnaBridge 145:64910690c574 2076 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
AnnaBridge 145:64910690c574 2077 else if ((priv == READ) && (user == READ)) { ap = 0x7; }
AnnaBridge 145:64910690c574 2078 }
AnnaBridge 145:64910690c574 2079
AnnaBridge 145:64910690c574 2080 else { //Simplified access
AnnaBridge 145:64910690c574 2081 if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
AnnaBridge 145:64910690c574 2082 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
AnnaBridge 145:64910690c574 2083 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
AnnaBridge 145:64910690c574 2084 else if ((priv == READ) && (user == READ)) { ap = 0x7; }
AnnaBridge 145:64910690c574 2085 }
AnnaBridge 145:64910690c574 2086
AnnaBridge 145:64910690c574 2087 *descriptor_l1 &= SECTION_AP_MASK;
AnnaBridge 145:64910690c574 2088 *descriptor_l1 |= (ap & 0x3) << SECTION_AP_SHIFT;
AnnaBridge 145:64910690c574 2089 *descriptor_l1 |= ((ap & 0x4)>>2) << SECTION_AP2_SHIFT;
AnnaBridge 145:64910690c574 2090
AnnaBridge 145:64910690c574 2091 return 0;
AnnaBridge 145:64910690c574 2092 }
AnnaBridge 145:64910690c574 2093
AnnaBridge 145:64910690c574 2094 /** \brief Set section shareability
AnnaBridge 145:64910690c574 2095
AnnaBridge 145:64910690c574 2096 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2097 \param [in] s_bit Section shareability: NON_SHARED, SHARED
AnnaBridge 145:64910690c574 2098
AnnaBridge 145:64910690c574 2099 \return 0
AnnaBridge 145:64910690c574 2100 */
AnnaBridge 145:64910690c574 2101 __STATIC_INLINE int MMU_SharedSection(uint32_t *descriptor_l1, mmu_shared_Type s_bit)
AnnaBridge 145:64910690c574 2102 {
AnnaBridge 145:64910690c574 2103 *descriptor_l1 &= SECTION_S_MASK;
AnnaBridge 145:64910690c574 2104 *descriptor_l1 |= ((s_bit & 0x1) << SECTION_S_SHIFT);
AnnaBridge 145:64910690c574 2105 return 0;
AnnaBridge 145:64910690c574 2106 }
AnnaBridge 145:64910690c574 2107
AnnaBridge 145:64910690c574 2108 /** \brief Set section Global attribute
AnnaBridge 145:64910690c574 2109
AnnaBridge 145:64910690c574 2110 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2111 \param [in] g_bit Section attribute: GLOBAL, NON_GLOBAL
AnnaBridge 145:64910690c574 2112
AnnaBridge 145:64910690c574 2113 \return 0
AnnaBridge 145:64910690c574 2114 */
AnnaBridge 145:64910690c574 2115 __STATIC_INLINE int MMU_GlobalSection(uint32_t *descriptor_l1, mmu_global_Type g_bit)
AnnaBridge 145:64910690c574 2116 {
AnnaBridge 145:64910690c574 2117 *descriptor_l1 &= SECTION_NG_MASK;
AnnaBridge 145:64910690c574 2118 *descriptor_l1 |= ((g_bit & 0x1) << SECTION_NG_SHIFT);
AnnaBridge 145:64910690c574 2119 return 0;
AnnaBridge 145:64910690c574 2120 }
AnnaBridge 145:64910690c574 2121
AnnaBridge 145:64910690c574 2122 /** \brief Set section Security attribute
AnnaBridge 145:64910690c574 2123
AnnaBridge 145:64910690c574 2124 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2125 \param [in] s_bit Section Security attribute: SECURE, NON_SECURE
AnnaBridge 145:64910690c574 2126
AnnaBridge 145:64910690c574 2127 \return 0
AnnaBridge 145:64910690c574 2128 */
AnnaBridge 145:64910690c574 2129 __STATIC_INLINE int MMU_SecureSection(uint32_t *descriptor_l1, mmu_secure_Type s_bit)
AnnaBridge 145:64910690c574 2130 {
AnnaBridge 145:64910690c574 2131 *descriptor_l1 &= SECTION_NS_MASK;
AnnaBridge 145:64910690c574 2132 *descriptor_l1 |= ((s_bit & 0x1) << SECTION_NS_SHIFT);
AnnaBridge 145:64910690c574 2133 return 0;
AnnaBridge 145:64910690c574 2134 }
AnnaBridge 145:64910690c574 2135
AnnaBridge 145:64910690c574 2136 /* Page 4k or 64k */
AnnaBridge 145:64910690c574 2137 /** \brief Set 4k/64k page execution-never attribute
AnnaBridge 145:64910690c574 2138
AnnaBridge 145:64910690c574 2139 \param [out] descriptor_l2 L2 descriptor.
AnnaBridge 145:64910690c574 2140 \param [in] xn Page execution-never attribute : EXECUTE , NON_EXECUTE.
AnnaBridge 145:64910690c574 2141 \param [in] page Page size: PAGE_4k, PAGE_64k,
AnnaBridge 145:64910690c574 2142
AnnaBridge 145:64910690c574 2143 \return 0
AnnaBridge 145:64910690c574 2144 */
AnnaBridge 145:64910690c574 2145 __STATIC_INLINE int MMU_XNPage(uint32_t *descriptor_l2, mmu_execute_Type xn, mmu_region_size_Type page)
AnnaBridge 145:64910690c574 2146 {
AnnaBridge 145:64910690c574 2147 if (page == PAGE_4k)
AnnaBridge 145:64910690c574 2148 {
AnnaBridge 145:64910690c574 2149 *descriptor_l2 &= PAGE_XN_4K_MASK;
AnnaBridge 145:64910690c574 2150 *descriptor_l2 |= ((xn & 0x1) << PAGE_XN_4K_SHIFT);
AnnaBridge 145:64910690c574 2151 }
AnnaBridge 145:64910690c574 2152 else
AnnaBridge 145:64910690c574 2153 {
AnnaBridge 145:64910690c574 2154 *descriptor_l2 &= PAGE_XN_64K_MASK;
AnnaBridge 145:64910690c574 2155 *descriptor_l2 |= ((xn & 0x1) << PAGE_XN_64K_SHIFT);
AnnaBridge 145:64910690c574 2156 }
AnnaBridge 145:64910690c574 2157 return 0;
AnnaBridge 145:64910690c574 2158 }
AnnaBridge 145:64910690c574 2159
AnnaBridge 145:64910690c574 2160 /** \brief Set 4k/64k page domain
AnnaBridge 145:64910690c574 2161
AnnaBridge 145:64910690c574 2162 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2163 \param [in] domain Page domain
AnnaBridge 145:64910690c574 2164
AnnaBridge 145:64910690c574 2165 \return 0
AnnaBridge 145:64910690c574 2166 */
AnnaBridge 145:64910690c574 2167 __STATIC_INLINE int MMU_DomainPage(uint32_t *descriptor_l1, uint8_t domain)
AnnaBridge 145:64910690c574 2168 {
AnnaBridge 145:64910690c574 2169 *descriptor_l1 &= PAGE_DOMAIN_MASK;
AnnaBridge 145:64910690c574 2170 *descriptor_l1 |= ((domain & 0xf) << PAGE_DOMAIN_SHIFT);
AnnaBridge 145:64910690c574 2171 return 0;
AnnaBridge 145:64910690c574 2172 }
AnnaBridge 145:64910690c574 2173
AnnaBridge 145:64910690c574 2174 /** \brief Set 4k/64k page parity check
AnnaBridge 145:64910690c574 2175
AnnaBridge 145:64910690c574 2176 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2177 \param [in] p_bit Parity check: ECC_DISABLED, ECC_ENABLED
AnnaBridge 145:64910690c574 2178
AnnaBridge 145:64910690c574 2179 \return 0
AnnaBridge 145:64910690c574 2180 */
AnnaBridge 145:64910690c574 2181 __STATIC_INLINE int MMU_PPage(uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
AnnaBridge 145:64910690c574 2182 {
AnnaBridge 145:64910690c574 2183 *descriptor_l1 &= SECTION_P_MASK;
AnnaBridge 145:64910690c574 2184 *descriptor_l1 |= ((p_bit & 0x1) << SECTION_P_SHIFT);
AnnaBridge 145:64910690c574 2185 return 0;
AnnaBridge 145:64910690c574 2186 }
AnnaBridge 145:64910690c574 2187
AnnaBridge 145:64910690c574 2188 /** \brief Set 4k/64k page access privileges
AnnaBridge 145:64910690c574 2189
AnnaBridge 145:64910690c574 2190 \param [out] descriptor_l2 L2 descriptor.
AnnaBridge 145:64910690c574 2191 \param [in] user User Level Access: NO_ACCESS, RW, READ
AnnaBridge 145:64910690c574 2192 \param [in] priv Privilege Level Access: NO_ACCESS, RW, READ
AnnaBridge 145:64910690c574 2193 \param [in] afe Access flag enable
AnnaBridge 145:64910690c574 2194
AnnaBridge 145:64910690c574 2195 \return 0
AnnaBridge 145:64910690c574 2196 */
AnnaBridge 145:64910690c574 2197 __STATIC_INLINE int MMU_APPage(uint32_t *descriptor_l2, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
AnnaBridge 145:64910690c574 2198 {
AnnaBridge 145:64910690c574 2199 uint32_t ap = 0;
AnnaBridge 145:64910690c574 2200
AnnaBridge 145:64910690c574 2201 if (afe == 0) { //full access
AnnaBridge 145:64910690c574 2202 if ((priv == NO_ACCESS) && (user == NO_ACCESS)) { ap = 0x0; }
AnnaBridge 145:64910690c574 2203 else if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
AnnaBridge 145:64910690c574 2204 else if ((priv == RW) && (user == READ)) { ap = 0x2; }
AnnaBridge 145:64910690c574 2205 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
AnnaBridge 145:64910690c574 2206 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
AnnaBridge 145:64910690c574 2207 else if ((priv == READ) && (user == READ)) { ap = 0x6; }
AnnaBridge 145:64910690c574 2208 }
AnnaBridge 145:64910690c574 2209
AnnaBridge 145:64910690c574 2210 else { //Simplified access
AnnaBridge 145:64910690c574 2211 if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
AnnaBridge 145:64910690c574 2212 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
AnnaBridge 145:64910690c574 2213 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
AnnaBridge 145:64910690c574 2214 else if ((priv == READ) && (user == READ)) { ap = 0x7; }
AnnaBridge 145:64910690c574 2215 }
AnnaBridge 145:64910690c574 2216
AnnaBridge 145:64910690c574 2217 *descriptor_l2 &= PAGE_AP_MASK;
AnnaBridge 145:64910690c574 2218 *descriptor_l2 |= (ap & 0x3) << PAGE_AP_SHIFT;
AnnaBridge 145:64910690c574 2219 *descriptor_l2 |= ((ap & 0x4)>>2) << PAGE_AP2_SHIFT;
AnnaBridge 145:64910690c574 2220
AnnaBridge 145:64910690c574 2221 return 0;
AnnaBridge 145:64910690c574 2222 }
AnnaBridge 145:64910690c574 2223
AnnaBridge 145:64910690c574 2224 /** \brief Set 4k/64k page shareability
AnnaBridge 145:64910690c574 2225
AnnaBridge 145:64910690c574 2226 \param [out] descriptor_l2 L2 descriptor.
AnnaBridge 145:64910690c574 2227 \param [in] s_bit 4k/64k page shareability: NON_SHARED, SHARED
AnnaBridge 145:64910690c574 2228
AnnaBridge 145:64910690c574 2229 \return 0
AnnaBridge 145:64910690c574 2230 */
AnnaBridge 145:64910690c574 2231 __STATIC_INLINE int MMU_SharedPage(uint32_t *descriptor_l2, mmu_shared_Type s_bit)
AnnaBridge 145:64910690c574 2232 {
AnnaBridge 145:64910690c574 2233 *descriptor_l2 &= PAGE_S_MASK;
AnnaBridge 145:64910690c574 2234 *descriptor_l2 |= ((s_bit & 0x1) << PAGE_S_SHIFT);
AnnaBridge 145:64910690c574 2235 return 0;
AnnaBridge 145:64910690c574 2236 }
AnnaBridge 145:64910690c574 2237
AnnaBridge 145:64910690c574 2238 /** \brief Set 4k/64k page Global attribute
AnnaBridge 145:64910690c574 2239
AnnaBridge 145:64910690c574 2240 \param [out] descriptor_l2 L2 descriptor.
AnnaBridge 145:64910690c574 2241 \param [in] g_bit 4k/64k page attribute: GLOBAL, NON_GLOBAL
AnnaBridge 145:64910690c574 2242
AnnaBridge 145:64910690c574 2243 \return 0
AnnaBridge 145:64910690c574 2244 */
AnnaBridge 145:64910690c574 2245 __STATIC_INLINE int MMU_GlobalPage(uint32_t *descriptor_l2, mmu_global_Type g_bit)
AnnaBridge 145:64910690c574 2246 {
AnnaBridge 145:64910690c574 2247 *descriptor_l2 &= PAGE_NG_MASK;
AnnaBridge 145:64910690c574 2248 *descriptor_l2 |= ((g_bit & 0x1) << PAGE_NG_SHIFT);
AnnaBridge 145:64910690c574 2249 return 0;
AnnaBridge 145:64910690c574 2250 }
AnnaBridge 145:64910690c574 2251
AnnaBridge 145:64910690c574 2252 /** \brief Set 4k/64k page Security attribute
AnnaBridge 145:64910690c574 2253
AnnaBridge 145:64910690c574 2254 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2255 \param [in] s_bit 4k/64k page Security attribute: SECURE, NON_SECURE
AnnaBridge 145:64910690c574 2256
AnnaBridge 145:64910690c574 2257 \return 0
AnnaBridge 145:64910690c574 2258 */
AnnaBridge 145:64910690c574 2259 __STATIC_INLINE int MMU_SecurePage(uint32_t *descriptor_l1, mmu_secure_Type s_bit)
AnnaBridge 145:64910690c574 2260 {
AnnaBridge 145:64910690c574 2261 *descriptor_l1 &= PAGE_NS_MASK;
AnnaBridge 145:64910690c574 2262 *descriptor_l1 |= ((s_bit & 0x1) << PAGE_NS_SHIFT);
AnnaBridge 145:64910690c574 2263 return 0;
AnnaBridge 145:64910690c574 2264 }
AnnaBridge 145:64910690c574 2265
AnnaBridge 145:64910690c574 2266 /** \brief Set Section memory attributes
AnnaBridge 145:64910690c574 2267
AnnaBridge 145:64910690c574 2268 \param [out] descriptor_l1 L1 descriptor.
AnnaBridge 145:64910690c574 2269 \param [in] mem Section memory type: NORMAL, DEVICE, SHARED_DEVICE, NON_SHARED_DEVICE, STRONGLY_ORDERED
AnnaBridge 145:64910690c574 2270 \param [in] outer Outer cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
AnnaBridge 145:64910690c574 2271 \param [in] inner Inner cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
AnnaBridge 145:64910690c574 2272
AnnaBridge 145:64910690c574 2273 \return 0
AnnaBridge 145:64910690c574 2274 */
AnnaBridge 145:64910690c574 2275 __STATIC_INLINE int MMU_MemorySection(uint32_t *descriptor_l1, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner)
AnnaBridge 145:64910690c574 2276 {
AnnaBridge 145:64910690c574 2277 *descriptor_l1 &= SECTION_TEXCB_MASK;
AnnaBridge 145:64910690c574 2278
AnnaBridge 145:64910690c574 2279 if (STRONGLY_ORDERED == mem)
AnnaBridge 145:64910690c574 2280 {
AnnaBridge 145:64910690c574 2281 return 0;
AnnaBridge 145:64910690c574 2282 }
AnnaBridge 145:64910690c574 2283 else if (SHARED_DEVICE == mem)
AnnaBridge 145:64910690c574 2284 {
AnnaBridge 145:64910690c574 2285 *descriptor_l1 |= (1 << SECTION_B_SHIFT);
AnnaBridge 145:64910690c574 2286 }
AnnaBridge 145:64910690c574 2287 else if (NON_SHARED_DEVICE == mem)
AnnaBridge 145:64910690c574 2288 {
AnnaBridge 145:64910690c574 2289 *descriptor_l1 |= (1 << SECTION_TEX1_SHIFT);
AnnaBridge 145:64910690c574 2290 }
AnnaBridge 145:64910690c574 2291 else if (NORMAL == mem)
AnnaBridge 145:64910690c574 2292 {
AnnaBridge 145:64910690c574 2293 *descriptor_l1 |= 1 << SECTION_TEX2_SHIFT;
AnnaBridge 145:64910690c574 2294 switch(inner)
AnnaBridge 145:64910690c574 2295 {
AnnaBridge 145:64910690c574 2296 case NON_CACHEABLE:
AnnaBridge 145:64910690c574 2297 break;
AnnaBridge 145:64910690c574 2298 case WB_WA:
AnnaBridge 145:64910690c574 2299 *descriptor_l1 |= (1 << SECTION_B_SHIFT);
AnnaBridge 145:64910690c574 2300 break;
AnnaBridge 145:64910690c574 2301 case WT:
AnnaBridge 145:64910690c574 2302 *descriptor_l1 |= 1 << SECTION_C_SHIFT;
AnnaBridge 145:64910690c574 2303 break;
AnnaBridge 145:64910690c574 2304 case WB_NO_WA:
AnnaBridge 145:64910690c574 2305 *descriptor_l1 |= (1 << SECTION_B_SHIFT) | (1 << SECTION_C_SHIFT);
AnnaBridge 145:64910690c574 2306 break;
AnnaBridge 145:64910690c574 2307 }
AnnaBridge 145:64910690c574 2308 switch(outer)
AnnaBridge 145:64910690c574 2309 {
AnnaBridge 145:64910690c574 2310 case NON_CACHEABLE:
AnnaBridge 145:64910690c574 2311 break;
AnnaBridge 145:64910690c574 2312 case WB_WA:
AnnaBridge 145:64910690c574 2313 *descriptor_l1 |= (1 << SECTION_TEX0_SHIFT);
AnnaBridge 145:64910690c574 2314 break;
AnnaBridge 145:64910690c574 2315 case WT:
AnnaBridge 145:64910690c574 2316 *descriptor_l1 |= 1 << SECTION_TEX1_SHIFT;
AnnaBridge 145:64910690c574 2317 break;
AnnaBridge 145:64910690c574 2318 case WB_NO_WA:
AnnaBridge 145:64910690c574 2319 *descriptor_l1 |= (1 << SECTION_TEX0_SHIFT) | (1 << SECTION_TEX0_SHIFT);
AnnaBridge 145:64910690c574 2320 break;
AnnaBridge 145:64910690c574 2321 }
AnnaBridge 145:64910690c574 2322 }
AnnaBridge 145:64910690c574 2323 return 0;
AnnaBridge 145:64910690c574 2324 }
AnnaBridge 145:64910690c574 2325
AnnaBridge 145:64910690c574 2326 /** \brief Set 4k/64k page memory attributes
AnnaBridge 145:64910690c574 2327
AnnaBridge 145:64910690c574 2328 \param [out] descriptor_l2 L2 descriptor.
AnnaBridge 145:64910690c574 2329 \param [in] mem 4k/64k page memory type: NORMAL, DEVICE, SHARED_DEVICE, NON_SHARED_DEVICE, STRONGLY_ORDERED
AnnaBridge 145:64910690c574 2330 \param [in] outer Outer cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
AnnaBridge 145:64910690c574 2331 \param [in] inner Inner cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
AnnaBridge 145:64910690c574 2332 \param [in] page Page size
AnnaBridge 145:64910690c574 2333
AnnaBridge 145:64910690c574 2334 \return 0
AnnaBridge 145:64910690c574 2335 */
AnnaBridge 145:64910690c574 2336 __STATIC_INLINE int MMU_MemoryPage(uint32_t *descriptor_l2, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner, mmu_region_size_Type page)
AnnaBridge 145:64910690c574 2337 {
AnnaBridge 145:64910690c574 2338 *descriptor_l2 &= PAGE_4K_TEXCB_MASK;
AnnaBridge 145:64910690c574 2339
AnnaBridge 145:64910690c574 2340 if (page == PAGE_64k)
AnnaBridge 145:64910690c574 2341 {
AnnaBridge 145:64910690c574 2342 //same as section
AnnaBridge 145:64910690c574 2343 MMU_MemorySection(descriptor_l2, mem, outer, inner);
AnnaBridge 145:64910690c574 2344 }
AnnaBridge 145:64910690c574 2345 else
AnnaBridge 145:64910690c574 2346 {
AnnaBridge 145:64910690c574 2347 if (STRONGLY_ORDERED == mem)
AnnaBridge 145:64910690c574 2348 {
AnnaBridge 145:64910690c574 2349 return 0;
AnnaBridge 145:64910690c574 2350 }
AnnaBridge 145:64910690c574 2351 else if (SHARED_DEVICE == mem)
AnnaBridge 145:64910690c574 2352 {
AnnaBridge 145:64910690c574 2353 *descriptor_l2 |= (1 << PAGE_4K_B_SHIFT);
AnnaBridge 145:64910690c574 2354 }
AnnaBridge 145:64910690c574 2355 else if (NON_SHARED_DEVICE == mem)
AnnaBridge 145:64910690c574 2356 {
AnnaBridge 145:64910690c574 2357 *descriptor_l2 |= (1 << PAGE_4K_TEX1_SHIFT);
AnnaBridge 145:64910690c574 2358 }
AnnaBridge 145:64910690c574 2359 else if (NORMAL == mem)
AnnaBridge 145:64910690c574 2360 {
AnnaBridge 145:64910690c574 2361 *descriptor_l2 |= 1 << PAGE_4K_TEX2_SHIFT;
AnnaBridge 145:64910690c574 2362 switch(inner)
AnnaBridge 145:64910690c574 2363 {
AnnaBridge 145:64910690c574 2364 case NON_CACHEABLE:
AnnaBridge 145:64910690c574 2365 break;
AnnaBridge 145:64910690c574 2366 case WB_WA:
AnnaBridge 145:64910690c574 2367 *descriptor_l2 |= (1 << PAGE_4K_B_SHIFT);
AnnaBridge 145:64910690c574 2368 break;
AnnaBridge 145:64910690c574 2369 case WT:
AnnaBridge 145:64910690c574 2370 *descriptor_l2 |= 1 << PAGE_4K_C_SHIFT;
AnnaBridge 145:64910690c574 2371 break;
AnnaBridge 145:64910690c574 2372 case WB_NO_WA:
AnnaBridge 145:64910690c574 2373 *descriptor_l2 |= (1 << PAGE_4K_B_SHIFT) | (1 << PAGE_4K_C_SHIFT);
AnnaBridge 145:64910690c574 2374 break;
AnnaBridge 145:64910690c574 2375 }
AnnaBridge 145:64910690c574 2376 switch(outer)
AnnaBridge 145:64910690c574 2377 {
AnnaBridge 145:64910690c574 2378 case NON_CACHEABLE:
AnnaBridge 145:64910690c574 2379 break;
AnnaBridge 145:64910690c574 2380 case WB_WA:
AnnaBridge 145:64910690c574 2381 *descriptor_l2 |= (1 << PAGE_4K_TEX0_SHIFT);
AnnaBridge 145:64910690c574 2382 break;
AnnaBridge 145:64910690c574 2383 case WT:
AnnaBridge 145:64910690c574 2384 *descriptor_l2 |= 1 << PAGE_4K_TEX1_SHIFT;
AnnaBridge 145:64910690c574 2385 break;
AnnaBridge 145:64910690c574 2386 case WB_NO_WA:
AnnaBridge 145:64910690c574 2387 *descriptor_l2 |= (1 << PAGE_4K_TEX0_SHIFT) | (1 << PAGE_4K_TEX0_SHIFT);
AnnaBridge 145:64910690c574 2388 break;
AnnaBridge 145:64910690c574 2389 }
AnnaBridge 145:64910690c574 2390 }
AnnaBridge 145:64910690c574 2391 }
AnnaBridge 145:64910690c574 2392
AnnaBridge 145:64910690c574 2393 return 0;
AnnaBridge 145:64910690c574 2394 }
AnnaBridge 145:64910690c574 2395
AnnaBridge 145:64910690c574 2396 /** \brief Create a L1 section descriptor
AnnaBridge 145:64910690c574 2397
AnnaBridge 145:64910690c574 2398 \param [out] descriptor L1 descriptor
AnnaBridge 145:64910690c574 2399 \param [in] reg Section attributes
AnnaBridge 145:64910690c574 2400
AnnaBridge 145:64910690c574 2401 \return 0
AnnaBridge 145:64910690c574 2402 */
AnnaBridge 145:64910690c574 2403 __STATIC_INLINE int MMU_GetSectionDescriptor(uint32_t *descriptor, mmu_region_attributes_Type reg)
AnnaBridge 145:64910690c574 2404 {
AnnaBridge 145:64910690c574 2405 *descriptor = 0;
AnnaBridge 145:64910690c574 2406
AnnaBridge 145:64910690c574 2407 MMU_MemorySection(descriptor, reg.mem_t, reg.outer_norm_t, reg.inner_norm_t);
AnnaBridge 145:64910690c574 2408 MMU_XNSection(descriptor,reg.xn_t);
AnnaBridge 145:64910690c574 2409 MMU_DomainSection(descriptor, reg.domain);
AnnaBridge 145:64910690c574 2410 MMU_PSection(descriptor, reg.e_t);
AnnaBridge 145:64910690c574 2411 MMU_APSection(descriptor, reg.priv_t, reg.user_t, 1);
AnnaBridge 145:64910690c574 2412 MMU_SharedSection(descriptor,reg.sh_t);
AnnaBridge 145:64910690c574 2413 MMU_GlobalSection(descriptor,reg.g_t);
AnnaBridge 145:64910690c574 2414 MMU_SecureSection(descriptor,reg.sec_t);
AnnaBridge 145:64910690c574 2415 *descriptor &= SECTION_MASK;
AnnaBridge 145:64910690c574 2416 *descriptor |= SECTION_DESCRIPTOR;
AnnaBridge 145:64910690c574 2417
AnnaBridge 145:64910690c574 2418 return 0;
AnnaBridge 145:64910690c574 2419 }
AnnaBridge 145:64910690c574 2420
AnnaBridge 145:64910690c574 2421
AnnaBridge 145:64910690c574 2422 /** \brief Create a L1 and L2 4k/64k page descriptor
AnnaBridge 145:64910690c574 2423
AnnaBridge 145:64910690c574 2424 \param [out] descriptor L1 descriptor
AnnaBridge 145:64910690c574 2425 \param [out] descriptor2 L2 descriptor
AnnaBridge 145:64910690c574 2426 \param [in] reg 4k/64k page attributes
AnnaBridge 145:64910690c574 2427
AnnaBridge 145:64910690c574 2428 \return 0
AnnaBridge 145:64910690c574 2429 */
AnnaBridge 145:64910690c574 2430 __STATIC_INLINE int MMU_GetPageDescriptor(uint32_t *descriptor, uint32_t *descriptor2, mmu_region_attributes_Type reg)
AnnaBridge 145:64910690c574 2431 {
AnnaBridge 145:64910690c574 2432 *descriptor = 0;
AnnaBridge 145:64910690c574 2433 *descriptor2 = 0;
AnnaBridge 145:64910690c574 2434
AnnaBridge 145:64910690c574 2435 switch (reg.rg_t)
AnnaBridge 145:64910690c574 2436 {
AnnaBridge 145:64910690c574 2437 case PAGE_4k:
AnnaBridge 145:64910690c574 2438 MMU_MemoryPage(descriptor2, reg.mem_t, reg.outer_norm_t, reg.inner_norm_t, PAGE_4k);
AnnaBridge 145:64910690c574 2439 MMU_XNPage(descriptor2, reg.xn_t, PAGE_4k);
AnnaBridge 145:64910690c574 2440 MMU_DomainPage(descriptor, reg.domain);
AnnaBridge 145:64910690c574 2441 MMU_PPage(descriptor, reg.e_t);
AnnaBridge 145:64910690c574 2442 MMU_APPage(descriptor2, reg.priv_t, reg.user_t, 1);
AnnaBridge 145:64910690c574 2443 MMU_SharedPage(descriptor2,reg.sh_t);
AnnaBridge 145:64910690c574 2444 MMU_GlobalPage(descriptor2,reg.g_t);
AnnaBridge 145:64910690c574 2445 MMU_SecurePage(descriptor,reg.sec_t);
AnnaBridge 145:64910690c574 2446 *descriptor &= PAGE_L1_MASK;
AnnaBridge 145:64910690c574 2447 *descriptor |= PAGE_L1_DESCRIPTOR;
AnnaBridge 145:64910690c574 2448 *descriptor2 &= PAGE_L2_4K_MASK;
AnnaBridge 145:64910690c574 2449 *descriptor2 |= PAGE_L2_4K_DESC;
AnnaBridge 145:64910690c574 2450 break;
AnnaBridge 145:64910690c574 2451
AnnaBridge 145:64910690c574 2452 case PAGE_64k:
AnnaBridge 145:64910690c574 2453 MMU_MemoryPage(descriptor2, reg.mem_t, reg.outer_norm_t, reg.inner_norm_t, PAGE_64k);
AnnaBridge 145:64910690c574 2454 MMU_XNPage(descriptor2, reg.xn_t, PAGE_64k);
AnnaBridge 145:64910690c574 2455 MMU_DomainPage(descriptor, reg.domain);
AnnaBridge 145:64910690c574 2456 MMU_PPage(descriptor, reg.e_t);
AnnaBridge 145:64910690c574 2457 MMU_APPage(descriptor2, reg.priv_t, reg.user_t, 1);
AnnaBridge 145:64910690c574 2458 MMU_SharedPage(descriptor2,reg.sh_t);
AnnaBridge 145:64910690c574 2459 MMU_GlobalPage(descriptor2,reg.g_t);
AnnaBridge 145:64910690c574 2460 MMU_SecurePage(descriptor,reg.sec_t);
AnnaBridge 145:64910690c574 2461 *descriptor &= PAGE_L1_MASK;
AnnaBridge 145:64910690c574 2462 *descriptor |= PAGE_L1_DESCRIPTOR;
AnnaBridge 145:64910690c574 2463 *descriptor2 &= PAGE_L2_64K_MASK;
AnnaBridge 145:64910690c574 2464 *descriptor2 |= PAGE_L2_64K_DESC;
AnnaBridge 145:64910690c574 2465 break;
AnnaBridge 145:64910690c574 2466
AnnaBridge 145:64910690c574 2467 case SECTION:
AnnaBridge 145:64910690c574 2468 //error
AnnaBridge 145:64910690c574 2469 break;
AnnaBridge 145:64910690c574 2470 }
AnnaBridge 145:64910690c574 2471
AnnaBridge 145:64910690c574 2472 return 0;
AnnaBridge 145:64910690c574 2473 }
AnnaBridge 145:64910690c574 2474
AnnaBridge 145:64910690c574 2475 /** \brief Create a 1MB Section
AnnaBridge 145:64910690c574 2476
AnnaBridge 145:64910690c574 2477 \param [in] ttb Translation table base address
AnnaBridge 145:64910690c574 2478 \param [in] base_address Section base address
AnnaBridge 145:64910690c574 2479 \param [in] count Number of sections to create
AnnaBridge 145:64910690c574 2480 \param [in] descriptor_l1 L1 descriptor (region attributes)
AnnaBridge 145:64910690c574 2481
AnnaBridge 145:64910690c574 2482 */
AnnaBridge 145:64910690c574 2483 __STATIC_INLINE void MMU_TTSection(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1)
AnnaBridge 145:64910690c574 2484 {
AnnaBridge 145:64910690c574 2485 uint32_t offset;
AnnaBridge 145:64910690c574 2486 uint32_t entry;
AnnaBridge 145:64910690c574 2487 uint32_t i;
AnnaBridge 145:64910690c574 2488
AnnaBridge 145:64910690c574 2489 offset = base_address >> 20;
AnnaBridge 145:64910690c574 2490 entry = (base_address & 0xFFF00000) | descriptor_l1;
AnnaBridge 145:64910690c574 2491
AnnaBridge 145:64910690c574 2492 //4 bytes aligned
AnnaBridge 145:64910690c574 2493 ttb = ttb + offset;
AnnaBridge 145:64910690c574 2494
AnnaBridge 145:64910690c574 2495 for (i = 0; i < count; i++ )
AnnaBridge 145:64910690c574 2496 {
AnnaBridge 145:64910690c574 2497 //4 bytes aligned
AnnaBridge 145:64910690c574 2498 *ttb++ = entry;
AnnaBridge 145:64910690c574 2499 entry += OFFSET_1M;
AnnaBridge 145:64910690c574 2500 }
AnnaBridge 145:64910690c574 2501 }
AnnaBridge 145:64910690c574 2502
AnnaBridge 145:64910690c574 2503 /** \brief Create a 4k page entry
AnnaBridge 145:64910690c574 2504
AnnaBridge 145:64910690c574 2505 \param [in] ttb L1 table base address
AnnaBridge 145:64910690c574 2506 \param [in] base_address 4k base address
AnnaBridge 145:64910690c574 2507 \param [in] count Number of 4k pages to create
AnnaBridge 145:64910690c574 2508 \param [in] descriptor_l1 L1 descriptor (region attributes)
AnnaBridge 145:64910690c574 2509 \param [in] ttb_l2 L2 table base address
AnnaBridge 145:64910690c574 2510 \param [in] descriptor_l2 L2 descriptor (region attributes)
AnnaBridge 145:64910690c574 2511
AnnaBridge 145:64910690c574 2512 */
AnnaBridge 145:64910690c574 2513 __STATIC_INLINE void MMU_TTPage4k(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2 )
AnnaBridge 145:64910690c574 2514 {
AnnaBridge 145:64910690c574 2515
AnnaBridge 145:64910690c574 2516 uint32_t offset, offset2;
AnnaBridge 145:64910690c574 2517 uint32_t entry, entry2;
AnnaBridge 145:64910690c574 2518 uint32_t i;
AnnaBridge 145:64910690c574 2519
AnnaBridge 145:64910690c574 2520 offset = base_address >> 20;
AnnaBridge 145:64910690c574 2521 entry = ((int)ttb_l2 & 0xFFFFFC00) | descriptor_l1;
AnnaBridge 145:64910690c574 2522
AnnaBridge 145:64910690c574 2523 //4 bytes aligned
AnnaBridge 145:64910690c574 2524 ttb += offset;
AnnaBridge 145:64910690c574 2525 //create l1_entry
AnnaBridge 145:64910690c574 2526 *ttb = entry;
AnnaBridge 145:64910690c574 2527
AnnaBridge 145:64910690c574 2528 offset2 = (base_address & 0xff000) >> 12;
AnnaBridge 145:64910690c574 2529 ttb_l2 += offset2;
AnnaBridge 145:64910690c574 2530 entry2 = (base_address & 0xFFFFF000) | descriptor_l2;
AnnaBridge 145:64910690c574 2531 for (i = 0; i < count; i++ )
AnnaBridge 145:64910690c574 2532 {
AnnaBridge 145:64910690c574 2533 //4 bytes aligned
AnnaBridge 145:64910690c574 2534 *ttb_l2++ = entry2;
AnnaBridge 145:64910690c574 2535 entry2 += OFFSET_4K;
AnnaBridge 145:64910690c574 2536 }
AnnaBridge 145:64910690c574 2537 }
AnnaBridge 145:64910690c574 2538
AnnaBridge 145:64910690c574 2539 /** \brief Create a 64k page entry
AnnaBridge 145:64910690c574 2540
AnnaBridge 145:64910690c574 2541 \param [in] ttb L1 table base address
AnnaBridge 145:64910690c574 2542 \param [in] base_address 64k base address
AnnaBridge 145:64910690c574 2543 \param [in] count Number of 64k pages to create
AnnaBridge 145:64910690c574 2544 \param [in] descriptor_l1 L1 descriptor (region attributes)
AnnaBridge 145:64910690c574 2545 \param [in] ttb_l2 L2 table base address
AnnaBridge 145:64910690c574 2546 \param [in] descriptor_l2 L2 descriptor (region attributes)
AnnaBridge 145:64910690c574 2547
AnnaBridge 145:64910690c574 2548 */
AnnaBridge 145:64910690c574 2549 __STATIC_INLINE void MMU_TTPage64k(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2 )
AnnaBridge 145:64910690c574 2550 {
AnnaBridge 145:64910690c574 2551 uint32_t offset, offset2;
AnnaBridge 145:64910690c574 2552 uint32_t entry, entry2;
AnnaBridge 145:64910690c574 2553 uint32_t i,j;
AnnaBridge 145:64910690c574 2554
AnnaBridge 145:64910690c574 2555
AnnaBridge 145:64910690c574 2556 offset = base_address >> 20;
AnnaBridge 145:64910690c574 2557 entry = ((int)ttb_l2 & 0xFFFFFC00) | descriptor_l1;
AnnaBridge 145:64910690c574 2558
AnnaBridge 145:64910690c574 2559 //4 bytes aligned
AnnaBridge 145:64910690c574 2560 ttb += offset;
AnnaBridge 145:64910690c574 2561 //create l1_entry
AnnaBridge 145:64910690c574 2562 *ttb = entry;
AnnaBridge 145:64910690c574 2563
AnnaBridge 145:64910690c574 2564 offset2 = (base_address & 0xff000) >> 12;
AnnaBridge 145:64910690c574 2565 ttb_l2 += offset2;
AnnaBridge 145:64910690c574 2566 entry2 = (base_address & 0xFFFF0000) | descriptor_l2;
AnnaBridge 145:64910690c574 2567 for (i = 0; i < count; i++ )
AnnaBridge 145:64910690c574 2568 {
AnnaBridge 145:64910690c574 2569 //create 16 entries
AnnaBridge 145:64910690c574 2570 for (j = 0; j < 16; j++)
AnnaBridge 145:64910690c574 2571 {
AnnaBridge 145:64910690c574 2572 //4 bytes aligned
AnnaBridge 145:64910690c574 2573 *ttb_l2++ = entry2;
AnnaBridge 145:64910690c574 2574 }
AnnaBridge 145:64910690c574 2575 entry2 += OFFSET_64K;
AnnaBridge 145:64910690c574 2576 }
AnnaBridge 145:64910690c574 2577 }
AnnaBridge 145:64910690c574 2578
AnnaBridge 145:64910690c574 2579 /** \brief Enable MMU
AnnaBridge 145:64910690c574 2580 */
Anna Bridge 160:5571c4ff569f 2581 __STATIC_INLINE void MMU_Enable(void)
Anna Bridge 160:5571c4ff569f 2582 {
AnnaBridge 145:64910690c574 2583 // Set M bit 0 to enable the MMU
AnnaBridge 145:64910690c574 2584 // Set AFE bit to enable simplified access permissions model
AnnaBridge 145:64910690c574 2585 // Clear TRE bit to disable TEX remap and A bit to disable strict alignment fault checking
AnnaBridge 145:64910690c574 2586 __set_SCTLR( (__get_SCTLR() & ~(1 << 28) & ~(1 << 1)) | 1 | (1 << 29));
AnnaBridge 145:64910690c574 2587 __ISB();
AnnaBridge 145:64910690c574 2588 }
AnnaBridge 145:64910690c574 2589
AnnaBridge 145:64910690c574 2590 /** \brief Disable MMU
AnnaBridge 145:64910690c574 2591 */
Anna Bridge 160:5571c4ff569f 2592 __STATIC_INLINE void MMU_Disable(void)
Anna Bridge 160:5571c4ff569f 2593 {
AnnaBridge 145:64910690c574 2594 // Clear M bit 0 to disable the MMU
AnnaBridge 145:64910690c574 2595 __set_SCTLR( __get_SCTLR() & ~1);
AnnaBridge 145:64910690c574 2596 __ISB();
AnnaBridge 145:64910690c574 2597 }
AnnaBridge 145:64910690c574 2598
AnnaBridge 145:64910690c574 2599 /** \brief Invalidate entire unified TLB
AnnaBridge 145:64910690c574 2600 */
AnnaBridge 145:64910690c574 2601
Anna Bridge 160:5571c4ff569f 2602 __STATIC_INLINE void MMU_InvalidateTLB(void)
Anna Bridge 160:5571c4ff569f 2603 {
AnnaBridge 145:64910690c574 2604 __set_TLBIALL(0);
AnnaBridge 145:64910690c574 2605 __DSB(); //ensure completion of the invalidation
AnnaBridge 145:64910690c574 2606 __ISB(); //ensure instruction fetch path sees new state
AnnaBridge 145:64910690c574 2607 }
AnnaBridge 145:64910690c574 2608
AnnaBridge 145:64910690c574 2609
AnnaBridge 145:64910690c574 2610 #ifdef __cplusplus
AnnaBridge 145:64910690c574 2611 }
AnnaBridge 145:64910690c574 2612 #endif
AnnaBridge 145:64910690c574 2613
AnnaBridge 145:64910690c574 2614 #endif /* __CORE_CA_H_DEPENDANT */
AnnaBridge 145:64910690c574 2615
AnnaBridge 145:64910690c574 2616 #endif /* __CMSIS_GENERIC */