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