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