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:
Tue Mar 14 16:20:51 2017 +0000
Revision:
138:093f2bd7b9eb
Parent:
112:6f327212ef96
Release 138 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3716: fix for issue #3715: correction in startup files for ARM and IAR, alignment of system_stm32f429xx.c files https://github.com/ARMmbed/mbed-os/pull/3716
3741: STM32 remove warning in hal_tick_32b.c file https://github.com/ARMmbed/mbed-os/pull/3741
3780: STM32L4 : Fix GPIO G port compatibility https://github.com/ARMmbed/mbed-os/pull/3780
3831: NCS36510: SPISLAVE enabled (Conflict resolved) https://github.com/ARMmbed/mbed-os/pull/3831
3836: Allow to redefine nRF's PSTORAGE_NUM_OF_PAGES outside of the mbed-os https://github.com/ARMmbed/mbed-os/pull/3836
3840: STM32: gpio SPEED - always set High Speed by default https://github.com/ARMmbed/mbed-os/pull/3840
3844: STM32 GPIO: Typo correction. Update comment (GPIO_IP_WITHOUT_BRR) https://github.com/ARMmbed/mbed-os/pull/3844
3850: STM32: change spi error to debug warning https://github.com/ARMmbed/mbed-os/pull/3850
3860: Define GPIO_IP_WITHOUT_BRR for xDot platform https://github.com/ARMmbed/mbed-os/pull/3860
3880: DISCO_F469NI: allow the use of CAN2 instance when CAN1 is not activated https://github.com/ARMmbed/mbed-os/pull/3880
3795: Fix pwm period calc https://github.com/ARMmbed/mbed-os/pull/3795
3828: STM32 CAN API: correct format and type https://github.com/ARMmbed/mbed-os/pull/3828
3842: TARGET_NRF: corrected spi_init() to properly handle re-initialization https://github.com/ARMmbed/mbed-os/pull/3842
3843: STM32L476xG: set APB2 clock to 80MHz (instead of 40MHz) https://github.com/ARMmbed/mbed-os/pull/3843
3879: NUCLEO_F446ZE: Add missing AnalogIn pins on PF_3, PF_5 and PF_10. https://github.com/ARMmbed/mbed-os/pull/3879
3902: Fix heap and stack size for NUCLEO_F746ZG https://github.com/ARMmbed/mbed-os/pull/3902
3829: can_write(): return error code when no tx mailboxes are available https://github.com/ARMmbed/mbed-os/pull/3829

Who changed what in which revision?

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