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:
Kojto
Date:
Wed May 13 08:08:21 2015 +0200
Revision:
99:dbbf35b96557
Child:
108:34e6b704fe68
Release 99 of the mbed library

Changes:
- new targets - MAXWSNENV, DISCO_L053C8
- STM32F4xx - ST Cube driver
- KSDK mcu - SPI timing fix
- Nordic - update to softdevice s130

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 99:dbbf35b96557 1 ;/**************************************************************************//**
Kojto 99:dbbf35b96557 2 ; * @file core_ca_mmu.h
Kojto 99:dbbf35b96557 3 ; * @brief MMU Startup File for
Kojto 99:dbbf35b96557 4 ; * VE_A9_MP Device Series
Kojto 99:dbbf35b96557 5 ; * @version V1.01
Kojto 99:dbbf35b96557 6 ; * @date 25 March 2013
Kojto 99:dbbf35b96557 7 ; *
Kojto 99:dbbf35b96557 8 ; * @note
Kojto 99:dbbf35b96557 9 ; *
Kojto 99:dbbf35b96557 10 ; ******************************************************************************/
Kojto 99:dbbf35b96557 11 ;/* Copyright (c) 2012 ARM LIMITED
Kojto 99:dbbf35b96557 12 ;
Kojto 99:dbbf35b96557 13 ; All rights reserved.
Kojto 99:dbbf35b96557 14 ; Redistribution and use in source and binary forms, with or without
Kojto 99:dbbf35b96557 15 ; modification, are permitted provided that the following conditions are met:
Kojto 99:dbbf35b96557 16 ; - Redistributions of source code must retain the above copyright
Kojto 99:dbbf35b96557 17 ; notice, this list of conditions and the following disclaimer.
Kojto 99:dbbf35b96557 18 ; - Redistributions in binary form must reproduce the above copyright
Kojto 99:dbbf35b96557 19 ; notice, this list of conditions and the following disclaimer in the
Kojto 99:dbbf35b96557 20 ; documentation and/or other materials provided with the distribution.
Kojto 99:dbbf35b96557 21 ; - Neither the name of ARM nor the names of its contributors may be used
Kojto 99:dbbf35b96557 22 ; to endorse or promote products derived from this software without
Kojto 99:dbbf35b96557 23 ; specific prior written permission.
Kojto 99:dbbf35b96557 24 ; *
Kojto 99:dbbf35b96557 25 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 99:dbbf35b96557 26 ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 99:dbbf35b96557 27 ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Kojto 99:dbbf35b96557 28 ; ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
Kojto 99:dbbf35b96557 29 ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Kojto 99:dbbf35b96557 30 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Kojto 99:dbbf35b96557 31 ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Kojto 99:dbbf35b96557 32 ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Kojto 99:dbbf35b96557 33 ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Kojto 99:dbbf35b96557 34 ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Kojto 99:dbbf35b96557 35 ; POSSIBILITY OF SUCH DAMAGE.
Kojto 99:dbbf35b96557 36 ; ---------------------------------------------------------------------------*/
Kojto 99:dbbf35b96557 37
Kojto 99:dbbf35b96557 38 #ifdef __cplusplus
Kojto 99:dbbf35b96557 39 extern "C" {
Kojto 99:dbbf35b96557 40 #endif
Kojto 99:dbbf35b96557 41
Kojto 99:dbbf35b96557 42 #ifndef _MMU_FUNC_H
Kojto 99:dbbf35b96557 43 #define _MMU_FUNC_H
Kojto 99:dbbf35b96557 44
Kojto 99:dbbf35b96557 45 #define SECTION_DESCRIPTOR (0x2)
Kojto 99:dbbf35b96557 46 #define SECTION_MASK (0xFFFFFFFC)
Kojto 99:dbbf35b96557 47
Kojto 99:dbbf35b96557 48 #define SECTION_TEXCB_MASK (0xFFFF8FF3)
Kojto 99:dbbf35b96557 49 #define SECTION_B_SHIFT (2)
Kojto 99:dbbf35b96557 50 #define SECTION_C_SHIFT (3)
Kojto 99:dbbf35b96557 51 #define SECTION_TEX0_SHIFT (12)
Kojto 99:dbbf35b96557 52 #define SECTION_TEX1_SHIFT (13)
Kojto 99:dbbf35b96557 53 #define SECTION_TEX2_SHIFT (14)
Kojto 99:dbbf35b96557 54
Kojto 99:dbbf35b96557 55 #define SECTION_XN_MASK (0xFFFFFFEF)
Kojto 99:dbbf35b96557 56 #define SECTION_XN_SHIFT (4)
Kojto 99:dbbf35b96557 57
Kojto 99:dbbf35b96557 58 #define SECTION_DOMAIN_MASK (0xFFFFFE1F)
Kojto 99:dbbf35b96557 59 #define SECTION_DOMAIN_SHIFT (5)
Kojto 99:dbbf35b96557 60
Kojto 99:dbbf35b96557 61 #define SECTION_P_MASK (0xFFFFFDFF)
Kojto 99:dbbf35b96557 62 #define SECTION_P_SHIFT (9)
Kojto 99:dbbf35b96557 63
Kojto 99:dbbf35b96557 64 #define SECTION_AP_MASK (0xFFFF73FF)
Kojto 99:dbbf35b96557 65 #define SECTION_AP_SHIFT (10)
Kojto 99:dbbf35b96557 66 #define SECTION_AP2_SHIFT (15)
Kojto 99:dbbf35b96557 67
Kojto 99:dbbf35b96557 68 #define SECTION_S_MASK (0xFFFEFFFF)
Kojto 99:dbbf35b96557 69 #define SECTION_S_SHIFT (16)
Kojto 99:dbbf35b96557 70
Kojto 99:dbbf35b96557 71 #define SECTION_NG_MASK (0xFFFDFFFF)
Kojto 99:dbbf35b96557 72 #define SECTION_NG_SHIFT (17)
Kojto 99:dbbf35b96557 73
Kojto 99:dbbf35b96557 74 #define SECTION_NS_MASK (0xFFF7FFFF)
Kojto 99:dbbf35b96557 75 #define SECTION_NS_SHIFT (19)
Kojto 99:dbbf35b96557 76
Kojto 99:dbbf35b96557 77
Kojto 99:dbbf35b96557 78 #define PAGE_L1_DESCRIPTOR (0x1)
Kojto 99:dbbf35b96557 79 #define PAGE_L1_MASK (0xFFFFFFFC)
Kojto 99:dbbf35b96557 80
Kojto 99:dbbf35b96557 81 #define PAGE_L2_4K_DESC (0x2)
Kojto 99:dbbf35b96557 82 #define PAGE_L2_4K_MASK (0xFFFFFFFD)
Kojto 99:dbbf35b96557 83
Kojto 99:dbbf35b96557 84 #define PAGE_L2_64K_DESC (0x1)
Kojto 99:dbbf35b96557 85 #define PAGE_L2_64K_MASK (0xFFFFFFFC)
Kojto 99:dbbf35b96557 86
Kojto 99:dbbf35b96557 87 #define PAGE_4K_TEXCB_MASK (0xFFFFFE33)
Kojto 99:dbbf35b96557 88 #define PAGE_4K_B_SHIFT (2)
Kojto 99:dbbf35b96557 89 #define PAGE_4K_C_SHIFT (3)
Kojto 99:dbbf35b96557 90 #define PAGE_4K_TEX0_SHIFT (6)
Kojto 99:dbbf35b96557 91 #define PAGE_4K_TEX1_SHIFT (7)
Kojto 99:dbbf35b96557 92 #define PAGE_4K_TEX2_SHIFT (8)
Kojto 99:dbbf35b96557 93
Kojto 99:dbbf35b96557 94 #define PAGE_64K_TEXCB_MASK (0xFFFF8FF3)
Kojto 99:dbbf35b96557 95 #define PAGE_64K_B_SHIFT (2)
Kojto 99:dbbf35b96557 96 #define PAGE_64K_C_SHIFT (3)
Kojto 99:dbbf35b96557 97 #define PAGE_64K_TEX0_SHIFT (12)
Kojto 99:dbbf35b96557 98 #define PAGE_64K_TEX1_SHIFT (13)
Kojto 99:dbbf35b96557 99 #define PAGE_64K_TEX2_SHIFT (14)
Kojto 99:dbbf35b96557 100
Kojto 99:dbbf35b96557 101 #define PAGE_TEXCB_MASK (0xFFFF8FF3)
Kojto 99:dbbf35b96557 102 #define PAGE_B_SHIFT (2)
Kojto 99:dbbf35b96557 103 #define PAGE_C_SHIFT (3)
Kojto 99:dbbf35b96557 104 #define PAGE_TEX_SHIFT (12)
Kojto 99:dbbf35b96557 105
Kojto 99:dbbf35b96557 106 #define PAGE_XN_4K_MASK (0xFFFFFFFE)
Kojto 99:dbbf35b96557 107 #define PAGE_XN_4K_SHIFT (0)
Kojto 99:dbbf35b96557 108 #define PAGE_XN_64K_MASK (0xFFFF7FFF)
Kojto 99:dbbf35b96557 109 #define PAGE_XN_64K_SHIFT (15)
Kojto 99:dbbf35b96557 110
Kojto 99:dbbf35b96557 111
Kojto 99:dbbf35b96557 112 #define PAGE_DOMAIN_MASK (0xFFFFFE1F)
Kojto 99:dbbf35b96557 113 #define PAGE_DOMAIN_SHIFT (5)
Kojto 99:dbbf35b96557 114
Kojto 99:dbbf35b96557 115 #define PAGE_P_MASK (0xFFFFFDFF)
Kojto 99:dbbf35b96557 116 #define PAGE_P_SHIFT (9)
Kojto 99:dbbf35b96557 117
Kojto 99:dbbf35b96557 118 #define PAGE_AP_MASK (0xFFFFFDCF)
Kojto 99:dbbf35b96557 119 #define PAGE_AP_SHIFT (4)
Kojto 99:dbbf35b96557 120 #define PAGE_AP2_SHIFT (9)
Kojto 99:dbbf35b96557 121
Kojto 99:dbbf35b96557 122 #define PAGE_S_MASK (0xFFFFFBFF)
Kojto 99:dbbf35b96557 123 #define PAGE_S_SHIFT (10)
Kojto 99:dbbf35b96557 124
Kojto 99:dbbf35b96557 125 #define PAGE_NG_MASK (0xFFFFF7FF)
Kojto 99:dbbf35b96557 126 #define PAGE_NG_SHIFT (11)
Kojto 99:dbbf35b96557 127
Kojto 99:dbbf35b96557 128 #define PAGE_NS_MASK (0xFFFFFFF7)
Kojto 99:dbbf35b96557 129 #define PAGE_NS_SHIFT (3)
Kojto 99:dbbf35b96557 130
Kojto 99:dbbf35b96557 131 #define OFFSET_1M (0x00100000)
Kojto 99:dbbf35b96557 132 #define OFFSET_64K (0x00010000)
Kojto 99:dbbf35b96557 133 #define OFFSET_4K (0x00001000)
Kojto 99:dbbf35b96557 134
Kojto 99:dbbf35b96557 135 #define DESCRIPTOR_FAULT (0x00000000)
Kojto 99:dbbf35b96557 136
Kojto 99:dbbf35b96557 137 /* ########################### MMU Function Access ########################### */
Kojto 99:dbbf35b96557 138 /** \ingroup MMU_FunctionInterface
Kojto 99:dbbf35b96557 139 \defgroup MMU_Functions MMU Functions Interface
Kojto 99:dbbf35b96557 140 @{
Kojto 99:dbbf35b96557 141 */
Kojto 99:dbbf35b96557 142
Kojto 99:dbbf35b96557 143 /* Attributes enumerations */
Kojto 99:dbbf35b96557 144
Kojto 99:dbbf35b96557 145 /* Region size attributes */
Kojto 99:dbbf35b96557 146 typedef enum
Kojto 99:dbbf35b96557 147 {
Kojto 99:dbbf35b96557 148 SECTION,
Kojto 99:dbbf35b96557 149 PAGE_4k,
Kojto 99:dbbf35b96557 150 PAGE_64k,
Kojto 99:dbbf35b96557 151 } mmu_region_size_Type;
Kojto 99:dbbf35b96557 152
Kojto 99:dbbf35b96557 153 /* Region type attributes */
Kojto 99:dbbf35b96557 154 typedef enum
Kojto 99:dbbf35b96557 155 {
Kojto 99:dbbf35b96557 156 NORMAL,
Kojto 99:dbbf35b96557 157 DEVICE,
Kojto 99:dbbf35b96557 158 SHARED_DEVICE,
Kojto 99:dbbf35b96557 159 NON_SHARED_DEVICE,
Kojto 99:dbbf35b96557 160 STRONGLY_ORDERED
Kojto 99:dbbf35b96557 161 } mmu_memory_Type;
Kojto 99:dbbf35b96557 162
Kojto 99:dbbf35b96557 163 /* Region cacheability attributes */
Kojto 99:dbbf35b96557 164 typedef enum
Kojto 99:dbbf35b96557 165 {
Kojto 99:dbbf35b96557 166 NON_CACHEABLE,
Kojto 99:dbbf35b96557 167 WB_WA,
Kojto 99:dbbf35b96557 168 WT,
Kojto 99:dbbf35b96557 169 WB_NO_WA,
Kojto 99:dbbf35b96557 170 } mmu_cacheability_Type;
Kojto 99:dbbf35b96557 171
Kojto 99:dbbf35b96557 172 /* Region parity check attributes */
Kojto 99:dbbf35b96557 173 typedef enum
Kojto 99:dbbf35b96557 174 {
Kojto 99:dbbf35b96557 175 ECC_DISABLED,
Kojto 99:dbbf35b96557 176 ECC_ENABLED,
Kojto 99:dbbf35b96557 177 } mmu_ecc_check_Type;
Kojto 99:dbbf35b96557 178
Kojto 99:dbbf35b96557 179 /* Region execution attributes */
Kojto 99:dbbf35b96557 180 typedef enum
Kojto 99:dbbf35b96557 181 {
Kojto 99:dbbf35b96557 182 EXECUTE,
Kojto 99:dbbf35b96557 183 NON_EXECUTE,
Kojto 99:dbbf35b96557 184 } mmu_execute_Type;
Kojto 99:dbbf35b96557 185
Kojto 99:dbbf35b96557 186 /* Region global attributes */
Kojto 99:dbbf35b96557 187 typedef enum
Kojto 99:dbbf35b96557 188 {
Kojto 99:dbbf35b96557 189 GLOBAL,
Kojto 99:dbbf35b96557 190 NON_GLOBAL,
Kojto 99:dbbf35b96557 191 } mmu_global_Type;
Kojto 99:dbbf35b96557 192
Kojto 99:dbbf35b96557 193 /* Region shareability attributes */
Kojto 99:dbbf35b96557 194 typedef enum
Kojto 99:dbbf35b96557 195 {
Kojto 99:dbbf35b96557 196 NON_SHARED,
Kojto 99:dbbf35b96557 197 SHARED,
Kojto 99:dbbf35b96557 198 } mmu_shared_Type;
Kojto 99:dbbf35b96557 199
Kojto 99:dbbf35b96557 200 /* Region security attributes */
Kojto 99:dbbf35b96557 201 typedef enum
Kojto 99:dbbf35b96557 202 {
Kojto 99:dbbf35b96557 203 SECURE,
Kojto 99:dbbf35b96557 204 NON_SECURE,
Kojto 99:dbbf35b96557 205 } mmu_secure_Type;
Kojto 99:dbbf35b96557 206
Kojto 99:dbbf35b96557 207 /* Region access attributes */
Kojto 99:dbbf35b96557 208 typedef enum
Kojto 99:dbbf35b96557 209 {
Kojto 99:dbbf35b96557 210 NO_ACCESS,
Kojto 99:dbbf35b96557 211 RW,
Kojto 99:dbbf35b96557 212 READ,
Kojto 99:dbbf35b96557 213 } mmu_access_Type;
Kojto 99:dbbf35b96557 214
Kojto 99:dbbf35b96557 215 /* Memory Region definition */
Kojto 99:dbbf35b96557 216 typedef struct RegionStruct {
Kojto 99:dbbf35b96557 217 mmu_region_size_Type rg_t;
Kojto 99:dbbf35b96557 218 mmu_memory_Type mem_t;
Kojto 99:dbbf35b96557 219 uint8_t domain;
Kojto 99:dbbf35b96557 220 mmu_cacheability_Type inner_norm_t;
Kojto 99:dbbf35b96557 221 mmu_cacheability_Type outer_norm_t;
Kojto 99:dbbf35b96557 222 mmu_ecc_check_Type e_t;
Kojto 99:dbbf35b96557 223 mmu_execute_Type xn_t;
Kojto 99:dbbf35b96557 224 mmu_global_Type g_t;
Kojto 99:dbbf35b96557 225 mmu_secure_Type sec_t;
Kojto 99:dbbf35b96557 226 mmu_access_Type priv_t;
Kojto 99:dbbf35b96557 227 mmu_access_Type user_t;
Kojto 99:dbbf35b96557 228 mmu_shared_Type sh_t;
Kojto 99:dbbf35b96557 229
Kojto 99:dbbf35b96557 230 } mmu_region_attributes_Type;
Kojto 99:dbbf35b96557 231
Kojto 99:dbbf35b96557 232 /** \brief Set section execution-never attribute
Kojto 99:dbbf35b96557 233
Kojto 99:dbbf35b96557 234 The function sets section execution-never attribute
Kojto 99:dbbf35b96557 235
Kojto 99:dbbf35b96557 236 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 237 \param [in] xn Section execution-never attribute : EXECUTE , NON_EXECUTE.
Kojto 99:dbbf35b96557 238
Kojto 99:dbbf35b96557 239 \return 0
Kojto 99:dbbf35b96557 240 */
Kojto 99:dbbf35b96557 241 __STATIC_INLINE int __xn_section(uint32_t *descriptor_l1, mmu_execute_Type xn)
Kojto 99:dbbf35b96557 242 {
Kojto 99:dbbf35b96557 243 *descriptor_l1 &= SECTION_XN_MASK;
Kojto 99:dbbf35b96557 244 *descriptor_l1 |= ((xn & 0x1) << SECTION_XN_SHIFT);
Kojto 99:dbbf35b96557 245 return 0;
Kojto 99:dbbf35b96557 246 }
Kojto 99:dbbf35b96557 247
Kojto 99:dbbf35b96557 248 /** \brief Set section domain
Kojto 99:dbbf35b96557 249
Kojto 99:dbbf35b96557 250 The function sets section domain
Kojto 99:dbbf35b96557 251
Kojto 99:dbbf35b96557 252 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 253 \param [in] domain Section domain
Kojto 99:dbbf35b96557 254
Kojto 99:dbbf35b96557 255 \return 0
Kojto 99:dbbf35b96557 256 */
Kojto 99:dbbf35b96557 257 __STATIC_INLINE int __domain_section(uint32_t *descriptor_l1, uint8_t domain)
Kojto 99:dbbf35b96557 258 {
Kojto 99:dbbf35b96557 259 *descriptor_l1 &= SECTION_DOMAIN_MASK;
Kojto 99:dbbf35b96557 260 *descriptor_l1 |= ((domain & 0xF) << SECTION_DOMAIN_SHIFT);
Kojto 99:dbbf35b96557 261 return 0;
Kojto 99:dbbf35b96557 262 }
Kojto 99:dbbf35b96557 263
Kojto 99:dbbf35b96557 264 /** \brief Set section parity check
Kojto 99:dbbf35b96557 265
Kojto 99:dbbf35b96557 266 The function sets section parity check
Kojto 99:dbbf35b96557 267
Kojto 99:dbbf35b96557 268 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 269 \param [in] p_bit Parity check: ECC_DISABLED, ECC_ENABLED
Kojto 99:dbbf35b96557 270
Kojto 99:dbbf35b96557 271 \return 0
Kojto 99:dbbf35b96557 272 */
Kojto 99:dbbf35b96557 273 __STATIC_INLINE int __p_section(uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
Kojto 99:dbbf35b96557 274 {
Kojto 99:dbbf35b96557 275 *descriptor_l1 &= SECTION_P_MASK;
Kojto 99:dbbf35b96557 276 *descriptor_l1 |= ((p_bit & 0x1) << SECTION_P_SHIFT);
Kojto 99:dbbf35b96557 277 return 0;
Kojto 99:dbbf35b96557 278 }
Kojto 99:dbbf35b96557 279
Kojto 99:dbbf35b96557 280 /** \brief Set section access privileges
Kojto 99:dbbf35b96557 281
Kojto 99:dbbf35b96557 282 The function sets section access privileges
Kojto 99:dbbf35b96557 283
Kojto 99:dbbf35b96557 284 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 285 \param [in] user User Level Access: NO_ACCESS, RW, READ
Kojto 99:dbbf35b96557 286 \param [in] priv Privilege Level Access: NO_ACCESS, RW, READ
Kojto 99:dbbf35b96557 287 \param [in] afe Access flag enable
Kojto 99:dbbf35b96557 288
Kojto 99:dbbf35b96557 289 \return 0
Kojto 99:dbbf35b96557 290 */
Kojto 99:dbbf35b96557 291 __STATIC_INLINE int __ap_section(uint32_t *descriptor_l1, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
Kojto 99:dbbf35b96557 292 {
Kojto 99:dbbf35b96557 293 uint32_t ap = 0;
Kojto 99:dbbf35b96557 294
Kojto 99:dbbf35b96557 295 if (afe == 0) { //full access
Kojto 99:dbbf35b96557 296 if ((priv == NO_ACCESS) && (user == NO_ACCESS)) { ap = 0x0; }
Kojto 99:dbbf35b96557 297 else if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
Kojto 99:dbbf35b96557 298 else if ((priv == RW) && (user == READ)) { ap = 0x2; }
Kojto 99:dbbf35b96557 299 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
Kojto 99:dbbf35b96557 300 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
Kojto 99:dbbf35b96557 301 else if ((priv == READ) && (user == READ)) { ap = 0x6; }
Kojto 99:dbbf35b96557 302 }
Kojto 99:dbbf35b96557 303
Kojto 99:dbbf35b96557 304 else { //Simplified access
Kojto 99:dbbf35b96557 305 if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
Kojto 99:dbbf35b96557 306 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
Kojto 99:dbbf35b96557 307 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
Kojto 99:dbbf35b96557 308 else if ((priv == READ) && (user == READ)) { ap = 0x7; }
Kojto 99:dbbf35b96557 309 }
Kojto 99:dbbf35b96557 310
Kojto 99:dbbf35b96557 311 *descriptor_l1 &= SECTION_AP_MASK;
Kojto 99:dbbf35b96557 312 *descriptor_l1 |= (ap & 0x3) << SECTION_AP_SHIFT;
Kojto 99:dbbf35b96557 313 *descriptor_l1 |= ((ap & 0x4)>>2) << SECTION_AP2_SHIFT;
Kojto 99:dbbf35b96557 314
Kojto 99:dbbf35b96557 315 return 0;
Kojto 99:dbbf35b96557 316 }
Kojto 99:dbbf35b96557 317
Kojto 99:dbbf35b96557 318 /** \brief Set section shareability
Kojto 99:dbbf35b96557 319
Kojto 99:dbbf35b96557 320 The function sets section shareability
Kojto 99:dbbf35b96557 321
Kojto 99:dbbf35b96557 322 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 323 \param [in] s_bit Section shareability: NON_SHARED, SHARED
Kojto 99:dbbf35b96557 324
Kojto 99:dbbf35b96557 325 \return 0
Kojto 99:dbbf35b96557 326 */
Kojto 99:dbbf35b96557 327 __STATIC_INLINE int __shared_section(uint32_t *descriptor_l1, mmu_shared_Type s_bit)
Kojto 99:dbbf35b96557 328 {
Kojto 99:dbbf35b96557 329 *descriptor_l1 &= SECTION_S_MASK;
Kojto 99:dbbf35b96557 330 *descriptor_l1 |= ((s_bit & 0x1) << SECTION_S_SHIFT);
Kojto 99:dbbf35b96557 331 return 0;
Kojto 99:dbbf35b96557 332 }
Kojto 99:dbbf35b96557 333
Kojto 99:dbbf35b96557 334 /** \brief Set section Global attribute
Kojto 99:dbbf35b96557 335
Kojto 99:dbbf35b96557 336 The function sets section Global attribute
Kojto 99:dbbf35b96557 337
Kojto 99:dbbf35b96557 338 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 339 \param [in] g_bit Section attribute: GLOBAL, NON_GLOBAL
Kojto 99:dbbf35b96557 340
Kojto 99:dbbf35b96557 341 \return 0
Kojto 99:dbbf35b96557 342 */
Kojto 99:dbbf35b96557 343 __STATIC_INLINE int __global_section(uint32_t *descriptor_l1, mmu_global_Type g_bit)
Kojto 99:dbbf35b96557 344 {
Kojto 99:dbbf35b96557 345 *descriptor_l1 &= SECTION_NG_MASK;
Kojto 99:dbbf35b96557 346 *descriptor_l1 |= ((g_bit & 0x1) << SECTION_NG_SHIFT);
Kojto 99:dbbf35b96557 347 return 0;
Kojto 99:dbbf35b96557 348 }
Kojto 99:dbbf35b96557 349
Kojto 99:dbbf35b96557 350 /** \brief Set section Security attribute
Kojto 99:dbbf35b96557 351
Kojto 99:dbbf35b96557 352 The function sets section Global attribute
Kojto 99:dbbf35b96557 353
Kojto 99:dbbf35b96557 354 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 355 \param [in] s_bit Section Security attribute: SECURE, NON_SECURE
Kojto 99:dbbf35b96557 356
Kojto 99:dbbf35b96557 357 \return 0
Kojto 99:dbbf35b96557 358 */
Kojto 99:dbbf35b96557 359 __STATIC_INLINE int __secure_section(uint32_t *descriptor_l1, mmu_secure_Type s_bit)
Kojto 99:dbbf35b96557 360 {
Kojto 99:dbbf35b96557 361 *descriptor_l1 &= SECTION_NS_MASK;
Kojto 99:dbbf35b96557 362 *descriptor_l1 |= ((s_bit & 0x1) << SECTION_NS_SHIFT);
Kojto 99:dbbf35b96557 363 return 0;
Kojto 99:dbbf35b96557 364 }
Kojto 99:dbbf35b96557 365
Kojto 99:dbbf35b96557 366 /* Page 4k or 64k */
Kojto 99:dbbf35b96557 367 /** \brief Set 4k/64k page execution-never attribute
Kojto 99:dbbf35b96557 368
Kojto 99:dbbf35b96557 369 The function sets 4k/64k page execution-never attribute
Kojto 99:dbbf35b96557 370
Kojto 99:dbbf35b96557 371 \param [out] descriptor_l2 L2 descriptor.
Kojto 99:dbbf35b96557 372 \param [in] xn Page execution-never attribute : EXECUTE , NON_EXECUTE.
Kojto 99:dbbf35b96557 373 \param [in] page Page size: PAGE_4k, PAGE_64k,
Kojto 99:dbbf35b96557 374
Kojto 99:dbbf35b96557 375 \return 0
Kojto 99:dbbf35b96557 376 */
Kojto 99:dbbf35b96557 377 __STATIC_INLINE int __xn_page(uint32_t *descriptor_l2, mmu_execute_Type xn, mmu_region_size_Type page)
Kojto 99:dbbf35b96557 378 {
Kojto 99:dbbf35b96557 379 if (page == PAGE_4k)
Kojto 99:dbbf35b96557 380 {
Kojto 99:dbbf35b96557 381 *descriptor_l2 &= PAGE_XN_4K_MASK;
Kojto 99:dbbf35b96557 382 *descriptor_l2 |= ((xn & 0x1) << PAGE_XN_4K_SHIFT);
Kojto 99:dbbf35b96557 383 }
Kojto 99:dbbf35b96557 384 else
Kojto 99:dbbf35b96557 385 {
Kojto 99:dbbf35b96557 386 *descriptor_l2 &= PAGE_XN_64K_MASK;
Kojto 99:dbbf35b96557 387 *descriptor_l2 |= ((xn & 0x1) << PAGE_XN_64K_SHIFT);
Kojto 99:dbbf35b96557 388 }
Kojto 99:dbbf35b96557 389 return 0;
Kojto 99:dbbf35b96557 390 }
Kojto 99:dbbf35b96557 391
Kojto 99:dbbf35b96557 392 /** \brief Set 4k/64k page domain
Kojto 99:dbbf35b96557 393
Kojto 99:dbbf35b96557 394 The function sets 4k/64k page domain
Kojto 99:dbbf35b96557 395
Kojto 99:dbbf35b96557 396 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 397 \param [in] domain Page domain
Kojto 99:dbbf35b96557 398
Kojto 99:dbbf35b96557 399 \return 0
Kojto 99:dbbf35b96557 400 */
Kojto 99:dbbf35b96557 401 __STATIC_INLINE int __domain_page(uint32_t *descriptor_l1, uint8_t domain)
Kojto 99:dbbf35b96557 402 {
Kojto 99:dbbf35b96557 403 *descriptor_l1 &= PAGE_DOMAIN_MASK;
Kojto 99:dbbf35b96557 404 *descriptor_l1 |= ((domain & 0xf) << PAGE_DOMAIN_SHIFT);
Kojto 99:dbbf35b96557 405 return 0;
Kojto 99:dbbf35b96557 406 }
Kojto 99:dbbf35b96557 407
Kojto 99:dbbf35b96557 408 /** \brief Set 4k/64k page parity check
Kojto 99:dbbf35b96557 409
Kojto 99:dbbf35b96557 410 The function sets 4k/64k page parity check
Kojto 99:dbbf35b96557 411
Kojto 99:dbbf35b96557 412 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 413 \param [in] p_bit Parity check: ECC_DISABLED, ECC_ENABLED
Kojto 99:dbbf35b96557 414
Kojto 99:dbbf35b96557 415 \return 0
Kojto 99:dbbf35b96557 416 */
Kojto 99:dbbf35b96557 417 __STATIC_INLINE int __p_page(uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
Kojto 99:dbbf35b96557 418 {
Kojto 99:dbbf35b96557 419 *descriptor_l1 &= SECTION_P_MASK;
Kojto 99:dbbf35b96557 420 *descriptor_l1 |= ((p_bit & 0x1) << SECTION_P_SHIFT);
Kojto 99:dbbf35b96557 421 return 0;
Kojto 99:dbbf35b96557 422 }
Kojto 99:dbbf35b96557 423
Kojto 99:dbbf35b96557 424 /** \brief Set 4k/64k page access privileges
Kojto 99:dbbf35b96557 425
Kojto 99:dbbf35b96557 426 The function sets 4k/64k page access privileges
Kojto 99:dbbf35b96557 427
Kojto 99:dbbf35b96557 428 \param [out] descriptor_l2 L2 descriptor.
Kojto 99:dbbf35b96557 429 \param [in] user User Level Access: NO_ACCESS, RW, READ
Kojto 99:dbbf35b96557 430 \param [in] priv Privilege Level Access: NO_ACCESS, RW, READ
Kojto 99:dbbf35b96557 431 \param [in] afe Access flag enable
Kojto 99:dbbf35b96557 432
Kojto 99:dbbf35b96557 433 \return 0
Kojto 99:dbbf35b96557 434 */
Kojto 99:dbbf35b96557 435 __STATIC_INLINE int __ap_page(uint32_t *descriptor_l2, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
Kojto 99:dbbf35b96557 436 {
Kojto 99:dbbf35b96557 437 uint32_t ap = 0;
Kojto 99:dbbf35b96557 438
Kojto 99:dbbf35b96557 439 if (afe == 0) { //full access
Kojto 99:dbbf35b96557 440 if ((priv == NO_ACCESS) && (user == NO_ACCESS)) { ap = 0x0; }
Kojto 99:dbbf35b96557 441 else if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
Kojto 99:dbbf35b96557 442 else if ((priv == RW) && (user == READ)) { ap = 0x2; }
Kojto 99:dbbf35b96557 443 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
Kojto 99:dbbf35b96557 444 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
Kojto 99:dbbf35b96557 445 else if ((priv == READ) && (user == READ)) { ap = 0x6; }
Kojto 99:dbbf35b96557 446 }
Kojto 99:dbbf35b96557 447
Kojto 99:dbbf35b96557 448 else { //Simplified access
Kojto 99:dbbf35b96557 449 if ((priv == RW) && (user == NO_ACCESS)) { ap = 0x1; }
Kojto 99:dbbf35b96557 450 else if ((priv == RW) && (user == RW)) { ap = 0x3; }
Kojto 99:dbbf35b96557 451 else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
Kojto 99:dbbf35b96557 452 else if ((priv == READ) && (user == READ)) { ap = 0x7; }
Kojto 99:dbbf35b96557 453 }
Kojto 99:dbbf35b96557 454
Kojto 99:dbbf35b96557 455 *descriptor_l2 &= PAGE_AP_MASK;
Kojto 99:dbbf35b96557 456 *descriptor_l2 |= (ap & 0x3) << PAGE_AP_SHIFT;
Kojto 99:dbbf35b96557 457 *descriptor_l2 |= ((ap & 0x4)>>2) << PAGE_AP2_SHIFT;
Kojto 99:dbbf35b96557 458
Kojto 99:dbbf35b96557 459 return 0;
Kojto 99:dbbf35b96557 460 }
Kojto 99:dbbf35b96557 461
Kojto 99:dbbf35b96557 462 /** \brief Set 4k/64k page shareability
Kojto 99:dbbf35b96557 463
Kojto 99:dbbf35b96557 464 The function sets 4k/64k page shareability
Kojto 99:dbbf35b96557 465
Kojto 99:dbbf35b96557 466 \param [out] descriptor_l2 L2 descriptor.
Kojto 99:dbbf35b96557 467 \param [in] s_bit 4k/64k page shareability: NON_SHARED, SHARED
Kojto 99:dbbf35b96557 468
Kojto 99:dbbf35b96557 469 \return 0
Kojto 99:dbbf35b96557 470 */
Kojto 99:dbbf35b96557 471 __STATIC_INLINE int __shared_page(uint32_t *descriptor_l2, mmu_shared_Type s_bit)
Kojto 99:dbbf35b96557 472 {
Kojto 99:dbbf35b96557 473 *descriptor_l2 &= PAGE_S_MASK;
Kojto 99:dbbf35b96557 474 *descriptor_l2 |= ((s_bit & 0x1) << PAGE_S_SHIFT);
Kojto 99:dbbf35b96557 475 return 0;
Kojto 99:dbbf35b96557 476 }
Kojto 99:dbbf35b96557 477
Kojto 99:dbbf35b96557 478 /** \brief Set 4k/64k page Global attribute
Kojto 99:dbbf35b96557 479
Kojto 99:dbbf35b96557 480 The function sets 4k/64k page Global attribute
Kojto 99:dbbf35b96557 481
Kojto 99:dbbf35b96557 482 \param [out] descriptor_l2 L2 descriptor.
Kojto 99:dbbf35b96557 483 \param [in] g_bit 4k/64k page attribute: GLOBAL, NON_GLOBAL
Kojto 99:dbbf35b96557 484
Kojto 99:dbbf35b96557 485 \return 0
Kojto 99:dbbf35b96557 486 */
Kojto 99:dbbf35b96557 487 __STATIC_INLINE int __global_page(uint32_t *descriptor_l2, mmu_global_Type g_bit)
Kojto 99:dbbf35b96557 488 {
Kojto 99:dbbf35b96557 489 *descriptor_l2 &= PAGE_NG_MASK;
Kojto 99:dbbf35b96557 490 *descriptor_l2 |= ((g_bit & 0x1) << PAGE_NG_SHIFT);
Kojto 99:dbbf35b96557 491 return 0;
Kojto 99:dbbf35b96557 492 }
Kojto 99:dbbf35b96557 493
Kojto 99:dbbf35b96557 494 /** \brief Set 4k/64k page Security attribute
Kojto 99:dbbf35b96557 495
Kojto 99:dbbf35b96557 496 The function sets 4k/64k page Global attribute
Kojto 99:dbbf35b96557 497
Kojto 99:dbbf35b96557 498 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 499 \param [in] s_bit 4k/64k page Security attribute: SECURE, NON_SECURE
Kojto 99:dbbf35b96557 500
Kojto 99:dbbf35b96557 501 \return 0
Kojto 99:dbbf35b96557 502 */
Kojto 99:dbbf35b96557 503 __STATIC_INLINE int __secure_page(uint32_t *descriptor_l1, mmu_secure_Type s_bit)
Kojto 99:dbbf35b96557 504 {
Kojto 99:dbbf35b96557 505 *descriptor_l1 &= PAGE_NS_MASK;
Kojto 99:dbbf35b96557 506 *descriptor_l1 |= ((s_bit & 0x1) << PAGE_NS_SHIFT);
Kojto 99:dbbf35b96557 507 return 0;
Kojto 99:dbbf35b96557 508 }
Kojto 99:dbbf35b96557 509
Kojto 99:dbbf35b96557 510
Kojto 99:dbbf35b96557 511 /** \brief Set Section memory attributes
Kojto 99:dbbf35b96557 512
Kojto 99:dbbf35b96557 513 The function sets section memory attributes
Kojto 99:dbbf35b96557 514
Kojto 99:dbbf35b96557 515 \param [out] descriptor_l1 L1 descriptor.
Kojto 99:dbbf35b96557 516 \param [in] mem Section memory type: NORMAL, DEVICE, SHARED_DEVICE, NON_SHARED_DEVICE, STRONGLY_ORDERED
Kojto 99:dbbf35b96557 517 \param [in] outer Outer cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
Kojto 99:dbbf35b96557 518 \param [in] inner Inner cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
Kojto 99:dbbf35b96557 519
Kojto 99:dbbf35b96557 520 \return 0
Kojto 99:dbbf35b96557 521 */
Kojto 99:dbbf35b96557 522 __STATIC_INLINE int __memory_section(uint32_t *descriptor_l1, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner)
Kojto 99:dbbf35b96557 523 {
Kojto 99:dbbf35b96557 524 *descriptor_l1 &= SECTION_TEXCB_MASK;
Kojto 99:dbbf35b96557 525
Kojto 99:dbbf35b96557 526 if (STRONGLY_ORDERED == mem)
Kojto 99:dbbf35b96557 527 {
Kojto 99:dbbf35b96557 528 return 0;
Kojto 99:dbbf35b96557 529 }
Kojto 99:dbbf35b96557 530 else if (SHARED_DEVICE == mem)
Kojto 99:dbbf35b96557 531 {
Kojto 99:dbbf35b96557 532 *descriptor_l1 |= (1 << SECTION_B_SHIFT);
Kojto 99:dbbf35b96557 533 }
Kojto 99:dbbf35b96557 534 else if (NON_SHARED_DEVICE == mem)
Kojto 99:dbbf35b96557 535 {
Kojto 99:dbbf35b96557 536 *descriptor_l1 |= (1 << SECTION_TEX1_SHIFT);
Kojto 99:dbbf35b96557 537 }
Kojto 99:dbbf35b96557 538 else if (NORMAL == mem)
Kojto 99:dbbf35b96557 539 {
Kojto 99:dbbf35b96557 540 *descriptor_l1 |= 1 << SECTION_TEX2_SHIFT;
Kojto 99:dbbf35b96557 541 switch(inner)
Kojto 99:dbbf35b96557 542 {
Kojto 99:dbbf35b96557 543 case NON_CACHEABLE:
Kojto 99:dbbf35b96557 544 break;
Kojto 99:dbbf35b96557 545 case WB_WA:
Kojto 99:dbbf35b96557 546 *descriptor_l1 |= (1 << SECTION_B_SHIFT);
Kojto 99:dbbf35b96557 547 break;
Kojto 99:dbbf35b96557 548 case WT:
Kojto 99:dbbf35b96557 549 *descriptor_l1 |= 1 << SECTION_C_SHIFT;
Kojto 99:dbbf35b96557 550 break;
Kojto 99:dbbf35b96557 551 case WB_NO_WA:
Kojto 99:dbbf35b96557 552 *descriptor_l1 |= (1 << SECTION_B_SHIFT) | (1 << SECTION_C_SHIFT);
Kojto 99:dbbf35b96557 553 break;
Kojto 99:dbbf35b96557 554 }
Kojto 99:dbbf35b96557 555 switch(outer)
Kojto 99:dbbf35b96557 556 {
Kojto 99:dbbf35b96557 557 case NON_CACHEABLE:
Kojto 99:dbbf35b96557 558 break;
Kojto 99:dbbf35b96557 559 case WB_WA:
Kojto 99:dbbf35b96557 560 *descriptor_l1 |= (1 << SECTION_TEX0_SHIFT);
Kojto 99:dbbf35b96557 561 break;
Kojto 99:dbbf35b96557 562 case WT:
Kojto 99:dbbf35b96557 563 *descriptor_l1 |= 1 << SECTION_TEX1_SHIFT;
Kojto 99:dbbf35b96557 564 break;
Kojto 99:dbbf35b96557 565 case WB_NO_WA:
Kojto 99:dbbf35b96557 566 *descriptor_l1 |= (1 << SECTION_TEX0_SHIFT) | (1 << SECTION_TEX0_SHIFT);
Kojto 99:dbbf35b96557 567 break;
Kojto 99:dbbf35b96557 568 }
Kojto 99:dbbf35b96557 569 }
Kojto 99:dbbf35b96557 570
Kojto 99:dbbf35b96557 571 return 0;
Kojto 99:dbbf35b96557 572 }
Kojto 99:dbbf35b96557 573
Kojto 99:dbbf35b96557 574 /** \brief Set 4k/64k page memory attributes
Kojto 99:dbbf35b96557 575
Kojto 99:dbbf35b96557 576 The function sets 4k/64k page memory attributes
Kojto 99:dbbf35b96557 577
Kojto 99:dbbf35b96557 578 \param [out] descriptor_l2 L2 descriptor.
Kojto 99:dbbf35b96557 579 \param [in] mem 4k/64k page memory type: NORMAL, DEVICE, SHARED_DEVICE, NON_SHARED_DEVICE, STRONGLY_ORDERED
Kojto 99:dbbf35b96557 580 \param [in] outer Outer cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
Kojto 99:dbbf35b96557 581 \param [in] inner Inner cacheability: NON_CACHEABLE, WB_WA, WT, WB_NO_WA,
Kojto 99:dbbf35b96557 582
Kojto 99:dbbf35b96557 583 \return 0
Kojto 99:dbbf35b96557 584 */
Kojto 99:dbbf35b96557 585 __STATIC_INLINE int __memory_page(uint32_t *descriptor_l2, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner, mmu_region_size_Type page)
Kojto 99:dbbf35b96557 586 {
Kojto 99:dbbf35b96557 587 *descriptor_l2 &= PAGE_4K_TEXCB_MASK;
Kojto 99:dbbf35b96557 588
Kojto 99:dbbf35b96557 589 if (page == PAGE_64k)
Kojto 99:dbbf35b96557 590 {
Kojto 99:dbbf35b96557 591 //same as section
Kojto 99:dbbf35b96557 592 __memory_section(descriptor_l2, mem, outer, inner);
Kojto 99:dbbf35b96557 593 }
Kojto 99:dbbf35b96557 594 else
Kojto 99:dbbf35b96557 595 {
Kojto 99:dbbf35b96557 596 if (STRONGLY_ORDERED == mem)
Kojto 99:dbbf35b96557 597 {
Kojto 99:dbbf35b96557 598 return 0;
Kojto 99:dbbf35b96557 599 }
Kojto 99:dbbf35b96557 600 else if (SHARED_DEVICE == mem)
Kojto 99:dbbf35b96557 601 {
Kojto 99:dbbf35b96557 602 *descriptor_l2 |= (1 << PAGE_4K_B_SHIFT);
Kojto 99:dbbf35b96557 603 }
Kojto 99:dbbf35b96557 604 else if (NON_SHARED_DEVICE == mem)
Kojto 99:dbbf35b96557 605 {
Kojto 99:dbbf35b96557 606 *descriptor_l2 |= (1 << PAGE_4K_TEX1_SHIFT);
Kojto 99:dbbf35b96557 607 }
Kojto 99:dbbf35b96557 608 else if (NORMAL == mem)
Kojto 99:dbbf35b96557 609 {
Kojto 99:dbbf35b96557 610 *descriptor_l2 |= 1 << PAGE_4K_TEX2_SHIFT;
Kojto 99:dbbf35b96557 611 switch(inner)
Kojto 99:dbbf35b96557 612 {
Kojto 99:dbbf35b96557 613 case NON_CACHEABLE:
Kojto 99:dbbf35b96557 614 break;
Kojto 99:dbbf35b96557 615 case WB_WA:
Kojto 99:dbbf35b96557 616 *descriptor_l2 |= (1 << PAGE_4K_B_SHIFT);
Kojto 99:dbbf35b96557 617 break;
Kojto 99:dbbf35b96557 618 case WT:
Kojto 99:dbbf35b96557 619 *descriptor_l2 |= 1 << PAGE_4K_C_SHIFT;
Kojto 99:dbbf35b96557 620 break;
Kojto 99:dbbf35b96557 621 case WB_NO_WA:
Kojto 99:dbbf35b96557 622 *descriptor_l2 |= (1 << PAGE_4K_B_SHIFT) | (1 << PAGE_4K_C_SHIFT);
Kojto 99:dbbf35b96557 623 break;
Kojto 99:dbbf35b96557 624 }
Kojto 99:dbbf35b96557 625 switch(outer)
Kojto 99:dbbf35b96557 626 {
Kojto 99:dbbf35b96557 627 case NON_CACHEABLE:
Kojto 99:dbbf35b96557 628 break;
Kojto 99:dbbf35b96557 629 case WB_WA:
Kojto 99:dbbf35b96557 630 *descriptor_l2 |= (1 << PAGE_4K_TEX0_SHIFT);
Kojto 99:dbbf35b96557 631 break;
Kojto 99:dbbf35b96557 632 case WT:
Kojto 99:dbbf35b96557 633 *descriptor_l2 |= 1 << PAGE_4K_TEX1_SHIFT;
Kojto 99:dbbf35b96557 634 break;
Kojto 99:dbbf35b96557 635 case WB_NO_WA:
Kojto 99:dbbf35b96557 636 *descriptor_l2 |= (1 << PAGE_4K_TEX0_SHIFT) | (1 << PAGE_4K_TEX0_SHIFT);
Kojto 99:dbbf35b96557 637 break;
Kojto 99:dbbf35b96557 638 }
Kojto 99:dbbf35b96557 639 }
Kojto 99:dbbf35b96557 640 }
Kojto 99:dbbf35b96557 641
Kojto 99:dbbf35b96557 642 return 0;
Kojto 99:dbbf35b96557 643 }
Kojto 99:dbbf35b96557 644
Kojto 99:dbbf35b96557 645 /** \brief Create a L1 section descriptor
Kojto 99:dbbf35b96557 646
Kojto 99:dbbf35b96557 647 The function creates a section descriptor.
Kojto 99:dbbf35b96557 648
Kojto 99:dbbf35b96557 649 Assumptions:
Kojto 99:dbbf35b96557 650 - 16MB super sections not suported
Kojto 99:dbbf35b96557 651 - TEX remap disabled, so memory type and attributes are described directly by bits in the descriptor
Kojto 99:dbbf35b96557 652 - Functions always return 0
Kojto 99:dbbf35b96557 653
Kojto 99:dbbf35b96557 654 \param [out] descriptor L1 descriptor
Kojto 99:dbbf35b96557 655 \param [out] descriptor2 L2 descriptor
Kojto 99:dbbf35b96557 656 \param [in] reg Section attributes
Kojto 99:dbbf35b96557 657
Kojto 99:dbbf35b96557 658 \return 0
Kojto 99:dbbf35b96557 659 */
Kojto 99:dbbf35b96557 660 __STATIC_INLINE int __get_section_descriptor(uint32_t *descriptor, mmu_region_attributes_Type reg)
Kojto 99:dbbf35b96557 661 {
Kojto 99:dbbf35b96557 662 *descriptor = 0;
Kojto 99:dbbf35b96557 663
Kojto 99:dbbf35b96557 664 __memory_section(descriptor, reg.mem_t, reg.outer_norm_t, reg.inner_norm_t);
Kojto 99:dbbf35b96557 665 __xn_section(descriptor,reg.xn_t);
Kojto 99:dbbf35b96557 666 __domain_section(descriptor, reg.domain);
Kojto 99:dbbf35b96557 667 __p_section(descriptor, reg.e_t);
Kojto 99:dbbf35b96557 668 __ap_section(descriptor, reg.priv_t, reg.user_t, 1);
Kojto 99:dbbf35b96557 669 __shared_section(descriptor,reg.sh_t);
Kojto 99:dbbf35b96557 670 __global_section(descriptor,reg.g_t);
Kojto 99:dbbf35b96557 671 __secure_section(descriptor,reg.sec_t);
Kojto 99:dbbf35b96557 672 *descriptor &= SECTION_MASK;
Kojto 99:dbbf35b96557 673 *descriptor |= SECTION_DESCRIPTOR;
Kojto 99:dbbf35b96557 674
Kojto 99:dbbf35b96557 675 return 0;
Kojto 99:dbbf35b96557 676
Kojto 99:dbbf35b96557 677 }
Kojto 99:dbbf35b96557 678
Kojto 99:dbbf35b96557 679
Kojto 99:dbbf35b96557 680 /** \brief Create a L1 and L2 4k/64k page descriptor
Kojto 99:dbbf35b96557 681
Kojto 99:dbbf35b96557 682 The function creates a 4k/64k page descriptor.
Kojto 99:dbbf35b96557 683 Assumptions:
Kojto 99:dbbf35b96557 684 - TEX remap disabled, so memory type and attributes are described directly by bits in the descriptor
Kojto 99:dbbf35b96557 685 - Functions always return 0
Kojto 99:dbbf35b96557 686
Kojto 99:dbbf35b96557 687 \param [out] descriptor L1 descriptor
Kojto 99:dbbf35b96557 688 \param [out] descriptor2 L2 descriptor
Kojto 99:dbbf35b96557 689 \param [in] reg 4k/64k page attributes
Kojto 99:dbbf35b96557 690
Kojto 99:dbbf35b96557 691 \return 0
Kojto 99:dbbf35b96557 692 */
Kojto 99:dbbf35b96557 693 __STATIC_INLINE int __get_page_descriptor(uint32_t *descriptor, uint32_t *descriptor2, mmu_region_attributes_Type reg)
Kojto 99:dbbf35b96557 694 {
Kojto 99:dbbf35b96557 695 *descriptor = 0;
Kojto 99:dbbf35b96557 696 *descriptor2 = 0;
Kojto 99:dbbf35b96557 697
Kojto 99:dbbf35b96557 698 switch (reg.rg_t)
Kojto 99:dbbf35b96557 699 {
Kojto 99:dbbf35b96557 700 case PAGE_4k:
Kojto 99:dbbf35b96557 701 __memory_page(descriptor2, reg.mem_t, reg.outer_norm_t, reg.inner_norm_t, PAGE_4k);
Kojto 99:dbbf35b96557 702 __xn_page(descriptor2, reg.xn_t, PAGE_4k);
Kojto 99:dbbf35b96557 703 __domain_page(descriptor, reg.domain);
Kojto 99:dbbf35b96557 704 __p_page(descriptor, reg.e_t);
Kojto 99:dbbf35b96557 705 __ap_page(descriptor2, reg.priv_t, reg.user_t, 1);
Kojto 99:dbbf35b96557 706 __shared_page(descriptor2,reg.sh_t);
Kojto 99:dbbf35b96557 707 __global_page(descriptor2,reg.g_t);
Kojto 99:dbbf35b96557 708 __secure_page(descriptor,reg.sec_t);
Kojto 99:dbbf35b96557 709 *descriptor &= PAGE_L1_MASK;
Kojto 99:dbbf35b96557 710 *descriptor |= PAGE_L1_DESCRIPTOR;
Kojto 99:dbbf35b96557 711 *descriptor2 &= PAGE_L2_4K_MASK;
Kojto 99:dbbf35b96557 712 *descriptor2 |= PAGE_L2_4K_DESC;
Kojto 99:dbbf35b96557 713 break;
Kojto 99:dbbf35b96557 714
Kojto 99:dbbf35b96557 715 case PAGE_64k:
Kojto 99:dbbf35b96557 716 __memory_page(descriptor2, reg.mem_t, reg.outer_norm_t, reg.inner_norm_t, PAGE_64k);
Kojto 99:dbbf35b96557 717 __xn_page(descriptor2, reg.xn_t, PAGE_64k);
Kojto 99:dbbf35b96557 718 __domain_page(descriptor, reg.domain);
Kojto 99:dbbf35b96557 719 __p_page(descriptor, reg.e_t);
Kojto 99:dbbf35b96557 720 __ap_page(descriptor2, reg.priv_t, reg.user_t, 1);
Kojto 99:dbbf35b96557 721 __shared_page(descriptor2,reg.sh_t);
Kojto 99:dbbf35b96557 722 __global_page(descriptor2,reg.g_t);
Kojto 99:dbbf35b96557 723 __secure_page(descriptor,reg.sec_t);
Kojto 99:dbbf35b96557 724 *descriptor &= PAGE_L1_MASK;
Kojto 99:dbbf35b96557 725 *descriptor |= PAGE_L1_DESCRIPTOR;
Kojto 99:dbbf35b96557 726 *descriptor2 &= PAGE_L2_64K_MASK;
Kojto 99:dbbf35b96557 727 *descriptor2 |= PAGE_L2_64K_DESC;
Kojto 99:dbbf35b96557 728 break;
Kojto 99:dbbf35b96557 729
Kojto 99:dbbf35b96557 730 case SECTION:
Kojto 99:dbbf35b96557 731 //error
Kojto 99:dbbf35b96557 732 break;
Kojto 99:dbbf35b96557 733
Kojto 99:dbbf35b96557 734 }
Kojto 99:dbbf35b96557 735
Kojto 99:dbbf35b96557 736 return 0;
Kojto 99:dbbf35b96557 737
Kojto 99:dbbf35b96557 738 }
Kojto 99:dbbf35b96557 739
Kojto 99:dbbf35b96557 740 /** \brief Create a 1MB Section
Kojto 99:dbbf35b96557 741
Kojto 99:dbbf35b96557 742 \param [in] ttb Translation table base address
Kojto 99:dbbf35b96557 743 \param [in] base_address Section base address
Kojto 99:dbbf35b96557 744 \param [in] count Number of sections to create
Kojto 99:dbbf35b96557 745 \param [in] descriptor_l1 L1 descriptor (region attributes)
Kojto 99:dbbf35b96557 746
Kojto 99:dbbf35b96557 747 */
Kojto 99:dbbf35b96557 748 __STATIC_INLINE void __TTSection(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1)
Kojto 99:dbbf35b96557 749 {
Kojto 99:dbbf35b96557 750 uint32_t offset;
Kojto 99:dbbf35b96557 751 uint32_t entry;
Kojto 99:dbbf35b96557 752 uint32_t i;
Kojto 99:dbbf35b96557 753
Kojto 99:dbbf35b96557 754 offset = base_address >> 20;
Kojto 99:dbbf35b96557 755 entry = (base_address & 0xFFF00000) | descriptor_l1;
Kojto 99:dbbf35b96557 756
Kojto 99:dbbf35b96557 757 //4 bytes aligned
Kojto 99:dbbf35b96557 758 ttb = ttb + offset;
Kojto 99:dbbf35b96557 759
Kojto 99:dbbf35b96557 760 for (i = 0; i < count; i++ )
Kojto 99:dbbf35b96557 761 {
Kojto 99:dbbf35b96557 762 //4 bytes aligned
Kojto 99:dbbf35b96557 763 *ttb++ = entry;
Kojto 99:dbbf35b96557 764 entry += OFFSET_1M;
Kojto 99:dbbf35b96557 765 }
Kojto 99:dbbf35b96557 766 }
Kojto 99:dbbf35b96557 767
Kojto 99:dbbf35b96557 768 /** \brief Create a 4k page entry
Kojto 99:dbbf35b96557 769
Kojto 99:dbbf35b96557 770 \param [in] ttb L1 table base address
Kojto 99:dbbf35b96557 771 \param [in] base_address 4k base address
Kojto 99:dbbf35b96557 772 \param [in] count Number of 4k pages to create
Kojto 99:dbbf35b96557 773 \param [in] descriptor_l1 L1 descriptor (region attributes)
Kojto 99:dbbf35b96557 774 \param [in] ttb_l2 L2 table base address
Kojto 99:dbbf35b96557 775 \param [in] descriptor_l2 L2 descriptor (region attributes)
Kojto 99:dbbf35b96557 776
Kojto 99:dbbf35b96557 777 */
Kojto 99:dbbf35b96557 778 __STATIC_INLINE void __TTPage_4k(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2 )
Kojto 99:dbbf35b96557 779 {
Kojto 99:dbbf35b96557 780
Kojto 99:dbbf35b96557 781 uint32_t offset, offset2;
Kojto 99:dbbf35b96557 782 uint32_t entry, entry2;
Kojto 99:dbbf35b96557 783 uint32_t i;
Kojto 99:dbbf35b96557 784
Kojto 99:dbbf35b96557 785
Kojto 99:dbbf35b96557 786 offset = base_address >> 20;
Kojto 99:dbbf35b96557 787 entry = ((int)ttb_l2 & 0xFFFFFC00) | descriptor_l1;
Kojto 99:dbbf35b96557 788
Kojto 99:dbbf35b96557 789 //4 bytes aligned
Kojto 99:dbbf35b96557 790 ttb += offset;
Kojto 99:dbbf35b96557 791 //create l1_entry
Kojto 99:dbbf35b96557 792 *ttb = entry;
Kojto 99:dbbf35b96557 793
Kojto 99:dbbf35b96557 794 offset2 = (base_address & 0xff000) >> 12;
Kojto 99:dbbf35b96557 795 ttb_l2 += offset2;
Kojto 99:dbbf35b96557 796 entry2 = (base_address & 0xFFFFF000) | descriptor_l2;
Kojto 99:dbbf35b96557 797 for (i = 0; i < count; i++ )
Kojto 99:dbbf35b96557 798 {
Kojto 99:dbbf35b96557 799 //4 bytes aligned
Kojto 99:dbbf35b96557 800 *ttb_l2++ = entry2;
Kojto 99:dbbf35b96557 801 entry2 += OFFSET_4K;
Kojto 99:dbbf35b96557 802 }
Kojto 99:dbbf35b96557 803 }
Kojto 99:dbbf35b96557 804
Kojto 99:dbbf35b96557 805 /** \brief Create a 64k page entry
Kojto 99:dbbf35b96557 806
Kojto 99:dbbf35b96557 807 \param [in] ttb L1 table base address
Kojto 99:dbbf35b96557 808 \param [in] base_address 64k base address
Kojto 99:dbbf35b96557 809 \param [in] count Number of 64k pages to create
Kojto 99:dbbf35b96557 810 \param [in] descriptor_l1 L1 descriptor (region attributes)
Kojto 99:dbbf35b96557 811 \param [in] ttb_l2 L2 table base address
Kojto 99:dbbf35b96557 812 \param [in] descriptor_l2 L2 descriptor (region attributes)
Kojto 99:dbbf35b96557 813
Kojto 99:dbbf35b96557 814 */
Kojto 99:dbbf35b96557 815 __STATIC_INLINE void __TTPage_64k(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2 )
Kojto 99:dbbf35b96557 816 {
Kojto 99:dbbf35b96557 817 uint32_t offset, offset2;
Kojto 99:dbbf35b96557 818 uint32_t entry, entry2;
Kojto 99:dbbf35b96557 819 uint32_t i,j;
Kojto 99:dbbf35b96557 820
Kojto 99:dbbf35b96557 821
Kojto 99:dbbf35b96557 822 offset = base_address >> 20;
Kojto 99:dbbf35b96557 823 entry = ((int)ttb_l2 & 0xFFFFFC00) | descriptor_l1;
Kojto 99:dbbf35b96557 824
Kojto 99:dbbf35b96557 825 //4 bytes aligned
Kojto 99:dbbf35b96557 826 ttb += offset;
Kojto 99:dbbf35b96557 827 //create l1_entry
Kojto 99:dbbf35b96557 828 *ttb = entry;
Kojto 99:dbbf35b96557 829
Kojto 99:dbbf35b96557 830 offset2 = (base_address & 0xff000) >> 12;
Kojto 99:dbbf35b96557 831 ttb_l2 += offset2;
Kojto 99:dbbf35b96557 832 entry2 = (base_address & 0xFFFF0000) | descriptor_l2;
Kojto 99:dbbf35b96557 833 for (i = 0; i < count; i++ )
Kojto 99:dbbf35b96557 834 {
Kojto 99:dbbf35b96557 835 //create 16 entries
Kojto 99:dbbf35b96557 836 for (j = 0; j < 16; j++)
Kojto 99:dbbf35b96557 837 //4 bytes aligned
Kojto 99:dbbf35b96557 838 *ttb_l2++ = entry2;
Kojto 99:dbbf35b96557 839 entry2 += OFFSET_64K;
Kojto 99:dbbf35b96557 840 }
Kojto 99:dbbf35b96557 841 }
Kojto 99:dbbf35b96557 842
Kojto 99:dbbf35b96557 843 /*@} end of MMU_Functions */
Kojto 99:dbbf35b96557 844 #endif
Kojto 99:dbbf35b96557 845
Kojto 99:dbbf35b96557 846 #ifdef __cplusplus
Kojto 99:dbbf35b96557 847 }
Kojto 99:dbbf35b96557 848 #endif