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 14 11:24:20 2017 +0000
Revision:
136:ef9c61f8c49f
Parent:
116:c0f6e94411f5
Release 136 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3432: Target STM USBHOST support https://github.com/ARMmbed/mbed-os/pull/3432
3181: NUCLEO_F207ZG extending PeripheralPins.c: all available alternate functions can be used now https://github.com/ARMmbed/mbed-os/pull/3181
3626: NUCLEO_F412ZG : Add USB Device +Host https://github.com/ARMmbed/mbed-os/pull/3626
3628: Fix warnings https://github.com/ARMmbed/mbed-os/pull/3628
3629: STM32: L0 LL layer https://github.com/ARMmbed/mbed-os/pull/3629
3632: IDE Export support for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3632
3642: Missing IRQ pin fix for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3642
3664: Fix ncs36510 sleep definitions https://github.com/ARMmbed/mbed-os/pull/3664
3655: [STM32F4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3655
3657: [STM32L4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3657
3658: [STM32F3] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3658
3685: STM32: I2C: reset state machine https://github.com/ARMmbed/mbed-os/pull/3685
3692: uVisor: Standardize available legacy heap and stack https://github.com/ARMmbed/mbed-os/pull/3692
3621: Fix for #2884, LPC824: export to LPCXpresso, target running with wron https://github.com/ARMmbed/mbed-os/pull/3621
3649: [STM32F7] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3649
3695: Enforce device_name is valid in targets.json https://github.com/ARMmbed/mbed-os/pull/3695
3723: NCS36510: spi_format function bug fix https://github.com/ARMmbed/mbed-os/pull/3723

Who changed what in which revision?

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