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:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
108:34e6b704fe68
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

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