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:
<>
Date:
Mon Jan 16 12:05:23 2017 +0000
Revision:
134:ad3be0349dc5
Parent:
124:2241e3a39974
Release 134 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3488: Dev stm i2c v2 unitary functions https://github.com/ARMmbed/mbed-os/pull/3488
3492: Fix #3463 CAN read() return value https://github.com/ARMmbed/mbed-os/pull/3492
3503: [LPC15xx] Ensure that PWM=1 is resolved correctly https://github.com/ARMmbed/mbed-os/pull/3503
3504: [LPC15xx] CAN implementation improvements https://github.com/ARMmbed/mbed-os/pull/3504
3539: NUCLEO_F412ZG - Add support of TRNG peripheral https://github.com/ARMmbed/mbed-os/pull/3539
3540: STM: SPI: Initialize Rx in spi_master_write https://github.com/ARMmbed/mbed-os/pull/3540
3438: K64F: Add support for SERIAL ASYNCH API https://github.com/ARMmbed/mbed-os/pull/3438
3519: MCUXpresso: Fix ENET driver to enable interrupts after interrupt handler is set https://github.com/ARMmbed/mbed-os/pull/3519
3544: STM32L4 deepsleep improvement https://github.com/ARMmbed/mbed-os/pull/3544
3546: NUCLEO-F412ZG - Add CAN peripheral https://github.com/ARMmbed/mbed-os/pull/3546
3551: Fix I2C driver for RZ/A1H https://github.com/ARMmbed/mbed-os/pull/3551
3558: K64F UART Asynch API: Fix synchronization issue https://github.com/ARMmbed/mbed-os/pull/3558
3563: LPC4088 - Fix vector checksum https://github.com/ARMmbed/mbed-os/pull/3563
3567: Dev stm32 F0 v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3567
3577: Fixes linking errors when building with debug profile https://github.com/ARMmbed/mbed-os/pull/3577

Who changed what in which revision?

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