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:
Tue Feb 03 15:31:20 2015 +0000
Revision:
93:e188a91d3eaa
Child:
108:34e6b704fe68
Release 93 of the mbed library

Main changes:

- Renesas RZ_A1H bugfixes - i2c, ticker
- new targets - Nucleo F303RE, Nucleo F070RB, BLE SMURFS,
Dragonfly 411RE,
- BusXXX - is connected method, plus operators addition
- LPC8xx - I2c fixes
- timestamp_t reverted to uint32_t
- RTX - fixes regarding stack (alignment, magic word)

Who changed what in which revision?

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