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