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:
Mon Jan 16 12:05:23 2017 +0000
Revision:
134:ad3be0349dc5
Parent:
119:aae6fcc7d9bb
Release 134 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3488: Dev stm i2c v2 unitary functions https://github.com/ARMmbed/mbed-os/pull/3488
3492: Fix #3463 CAN read() return value https://github.com/ARMmbed/mbed-os/pull/3492
3503: [LPC15xx] Ensure that PWM=1 is resolved correctly https://github.com/ARMmbed/mbed-os/pull/3503
3504: [LPC15xx] CAN implementation improvements https://github.com/ARMmbed/mbed-os/pull/3504
3539: NUCLEO_F412ZG - Add support of TRNG peripheral https://github.com/ARMmbed/mbed-os/pull/3539
3540: STM: SPI: Initialize Rx in spi_master_write https://github.com/ARMmbed/mbed-os/pull/3540
3438: K64F: Add support for SERIAL ASYNCH API https://github.com/ARMmbed/mbed-os/pull/3438
3519: MCUXpresso: Fix ENET driver to enable interrupts after interrupt handler is set https://github.com/ARMmbed/mbed-os/pull/3519
3544: STM32L4 deepsleep improvement https://github.com/ARMmbed/mbed-os/pull/3544
3546: NUCLEO-F412ZG - Add CAN peripheral https://github.com/ARMmbed/mbed-os/pull/3546
3551: Fix I2C driver for RZ/A1H https://github.com/ARMmbed/mbed-os/pull/3551
3558: K64F UART Asynch API: Fix synchronization issue https://github.com/ARMmbed/mbed-os/pull/3558
3563: LPC4088 - Fix vector checksum https://github.com/ARMmbed/mbed-os/pull/3563
3567: Dev stm32 F0 v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3567
3577: Fixes linking errors when building with debug profile https://github.com/ARMmbed/mbed-os/pull/3577

Who changed what in which revision?

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