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