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