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