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 27 08:07:35 2015 +0100
Revision:
100:cbbeb26dbd92
Child:
108:34e6b704fe68
Release 100 of the mbed library

Changes:
- new target: DISCOF334C8
- API: Ticker/Timer bugfix with constness
- Silabs: RTC, PWM, Serial clocks bufixes
- Renesas: i2c bugfix
- Maxim: 326000 - pin definitions for v2, spi freq fix

Who changed what in which revision?

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