1 /* 2 * xtensa/config/core-matmap.h -- Memory access and translation mapping 3 * parameters (CHAL) of the Xtensa processor core configuration. 4 * 5 * If you are using Xtensa Tools, see <xtensa/config/core.h> (which includes 6 * this file) for more details. 7 * 8 * In the Xtensa processor products released to date, all parameters 9 * defined in this file are derivable (at least in theory) from 10 * information contained in the core-isa.h header file. 11 * In particular, the following core configuration parameters are relevant: 12 * XCHAL_HAVE_CACHEATTR 13 * XCHAL_HAVE_MIMIC_CACHEATTR 14 * XCHAL_HAVE_XLT_CACHEATTR 15 * XCHAL_HAVE_PTP_MMU 16 * XCHAL_ITLB_ARF_ENTRIES_LOG2 17 * XCHAL_DTLB_ARF_ENTRIES_LOG2 18 * XCHAL_DCACHE_IS_WRITEBACK 19 * XCHAL_ICACHE_SIZE (presence of I-cache) 20 * XCHAL_DCACHE_SIZE (presence of D-cache) 21 * XCHAL_HW_VERSION_MAJOR 22 * XCHAL_HW_VERSION_MINOR 23 */ 24 25 /* Copyright (c) 1999-2016 Tensilica Inc. 26 27 Permission is hereby granted, free of charge, to any person obtaining 28 a copy of this software and associated documentation files (the 29 "Software"), to deal in the Software without restriction, including 30 without limitation the rights to use, copy, modify, merge, publish, 31 distribute, sublicense, and/or sell copies of the Software, and to 32 permit persons to whom the Software is furnished to do so, subject to 33 the following conditions: 34 35 The above copyright notice and this permission notice shall be included 36 in all copies or substantial portions of the Software. 37 38 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 39 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 40 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 41 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 42 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 43 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 45 46 47 #ifndef XTENSA_CONFIG_CORE_MATMAP_H 48 #define XTENSA_CONFIG_CORE_MATMAP_H 49 50 51 /*---------------------------------------------------------------------- 52 CACHE (MEMORY ACCESS) ATTRIBUTES 53 ----------------------------------------------------------------------*/ 54 55 56 57 /* Cache Attribute encodings -- lists of access modes for each cache attribute: */ 58 #define XCHAL_FCA_LIST XTHAL_FAM_EXCEPTION XCHAL_SEP \ 59 XTHAL_FAM_BYPASS XCHAL_SEP \ 60 XTHAL_FAM_BYPASS XCHAL_SEP \ 61 XTHAL_FAM_BYPASS XCHAL_SEP \ 62 XTHAL_FAM_BYPASS XCHAL_SEP \ 63 XTHAL_FAM_BYPASS XCHAL_SEP \ 64 XTHAL_FAM_BYPASS XCHAL_SEP \ 65 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 66 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 67 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 68 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 69 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 70 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 71 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 72 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 73 XTHAL_FAM_EXCEPTION 74 #define XCHAL_LCA_LIST XTHAL_LAM_BYPASSG XCHAL_SEP \ 75 XTHAL_LAM_BYPASSG XCHAL_SEP \ 76 XTHAL_LAM_BYPASSG XCHAL_SEP \ 77 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 78 XTHAL_LAM_BYPASSG XCHAL_SEP \ 79 XTHAL_LAM_BYPASSG XCHAL_SEP \ 80 XTHAL_LAM_BYPASSG XCHAL_SEP \ 81 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 82 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 83 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 84 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 85 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 86 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 87 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 88 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 89 XTHAL_LAM_EXCEPTION 90 #define XCHAL_SCA_LIST XTHAL_SAM_BYPASS XCHAL_SEP \ 91 XTHAL_SAM_BYPASS XCHAL_SEP \ 92 XTHAL_SAM_BYPASS XCHAL_SEP \ 93 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 94 XTHAL_SAM_BYPASS XCHAL_SEP \ 95 XTHAL_SAM_BYPASS XCHAL_SEP \ 96 XTHAL_SAM_BYPASS XCHAL_SEP \ 97 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 98 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 99 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 100 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 101 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 102 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 103 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 104 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 105 XTHAL_SAM_EXCEPTION 106 107 #define XCHAL_CA_R (0xC0 | 0x40000000) 108 #define XCHAL_CA_RX (0xD0 | 0x40000000) 109 #define XCHAL_CA_RW (0xE0 | 0x40000000) 110 #define XCHAL_CA_RWX (0xF0 | 0x40000000) 111 112 /* 113 * Specific encoded cache attribute values of general interest. 114 * If a specific cache mode is not available, the closest available 115 * one is returned instead (eg. writethru instead of writeback, 116 * bypass instead of writethru). 117 */ 118 #define XCHAL_CA_BYPASS 2 /* cache disabled (bypassed) mode */ 119 #define XCHAL_CA_BYPASSBUF 6 /* cache disabled (bypassed) bufferable mode */ 120 #define XCHAL_CA_WRITETHRU 1 /* cache enabled (write-through) mode */ 121 #define XCHAL_CA_WRITEBACK 2 /* cache enabled (write-back) mode */ 122 #define XCHAL_HAVE_CA_WRITEBACK_NOALLOC 0 /* write-back no-allocate availability */ 123 #define XCHAL_CA_WRITEBACK_NOALLOC 2 /* cache enabled (write-back no-allocate) mode */ 124 #define XCHAL_CA_BYPASS_RW 0 /* cache disabled (bypassed) mode (no exec) */ 125 #define XCHAL_CA_WRITETHRU_RW 0 /* cache enabled (write-through) mode (no exec) (FALLBACK) */ 126 #define XCHAL_CA_WRITEBACK_RW 0 /* cache enabled (write-back) mode (no exec) */ 127 #define XCHAL_CA_WRITEBACK_NOALLOC_RW 0 /* cache enabled (write-back no-allocate) mode (no exec) */ 128 #define XCHAL_CA_ILLEGAL 15 /* no access allowed (all cause exceptions) mode */ 129 #define XCHAL_CA_ISOLATE 0 /* cache isolate (accesses go to cache not memory) mode */ 130 131 /*---------------------------------------------------------------------- 132 MMU 133 ----------------------------------------------------------------------*/ 134 135 /* 136 * General notes on MMU parameters. 137 * 138 * Terminology: 139 * ASID = address-space ID (acts as an "extension" of virtual addresses) 140 * VPN = virtual page number 141 * PPN = physical page number 142 * CA = encoded cache attribute (access modes) 143 * TLB = translation look-aside buffer (term is stretched somewhat here) 144 * I = instruction (fetch accesses) 145 * D = data (load and store accesses) 146 * way = each TLB (ITLB and DTLB) consists of a number of "ways" 147 * that simultaneously match the virtual address of an access; 148 * a TLB successfully translates a virtual address if exactly 149 * one way matches the vaddr; if none match, it is a miss; 150 * if multiple match, one gets a "multihit" exception; 151 * each way can be independently configured in terms of number of 152 * entries, page sizes, which fields are writable or constant, etc. 153 * set = group of contiguous ways with exactly identical parameters 154 * ARF = auto-refill; hardware services a 1st-level miss by loading a PTE 155 * from the page table and storing it in one of the auto-refill ways; 156 * if this PTE load also misses, a miss exception is posted for s/w. 157 * min-wired = a "min-wired" way can be used to map a single (minimum-sized) 158 * page arbitrarily under program control; it has a single entry, 159 * is non-auto-refill (some other way(s) must be auto-refill), 160 * all its fields (VPN, PPN, ASID, CA) are all writable, and it 161 * supports the XCHAL_MMU_MIN_PTE_PAGE_SIZE page size (a current 162 * restriction is that this be the only page size it supports). 163 * 164 * TLB way entries are virtually indexed. 165 * TLB ways that support multiple page sizes: 166 * - must have all writable VPN and PPN fields; 167 * - can only use one page size at any given time (eg. setup at startup), 168 * selected by the respective ITLBCFG or DTLBCFG special register, 169 * whose bits n*4+3 .. n*4 index the list of page sizes for way n 170 * (XCHAL_xTLB_SETm_PAGESZ_LOG2_LIST for set m corresponding to way n); 171 * this list may be sparse for auto-refill ways because auto-refill 172 * ways have independent lists of supported page sizes sharing a 173 * common encoding with PTE entries; the encoding is the index into 174 * this list; unsupported sizes for a given way are zero in the list; 175 * selecting unsupported sizes results in undefine hardware behaviour; 176 * - is only possible for ways 0 thru 7 (due to ITLBCFG/DTLBCFG definition). 177 */ 178 179 #define XCHAL_MMU_ASID_INVALID 0 /* ASID value indicating invalid address space */ 180 #define XCHAL_MMU_ASID_KERNEL 0 /* ASID value indicating kernel (ring 0) address space */ 181 #define XCHAL_MMU_SR_BITS 0 /* number of size-restriction bits supported */ 182 #define XCHAL_MMU_CA_BITS 4 /* number of bits needed to hold cache attribute encoding */ 183 #define XCHAL_MMU_MAX_PTE_PAGE_SIZE 29 /* max page size in a PTE structure (log2) */ 184 #define XCHAL_MMU_MIN_PTE_PAGE_SIZE 29 /* min page size in a PTE structure (log2) */ 185 186 187 /*** Instruction TLB: ***/ 188 189 #define XCHAL_ITLB_WAY_BITS 0 /* number of bits holding the ways */ 190 #define XCHAL_ITLB_WAYS 1 /* number of ways (n-way set-associative TLB) */ 191 #define XCHAL_ITLB_ARF_WAYS 0 /* number of auto-refill ways */ 192 #define XCHAL_ITLB_SETS 1 /* number of sets (groups of ways with identical settings) */ 193 194 /* Way set to which each way belongs: */ 195 #define XCHAL_ITLB_WAY0_SET 0 196 197 /* Ways sets that are used by hardware auto-refill (ARF): */ 198 #define XCHAL_ITLB_ARF_SETS 0 /* number of auto-refill sets */ 199 200 /* Way sets that are "min-wired" (see terminology comment above): */ 201 #define XCHAL_ITLB_MINWIRED_SETS 0 /* number of "min-wired" sets */ 202 203 204 /* ITLB way set 0 (group of ways 0 thru 0): */ 205 #define XCHAL_ITLB_SET0_WAY 0 /* index of first way in this way set */ 206 #define XCHAL_ITLB_SET0_WAYS 1 /* number of (contiguous) ways in this way set */ 207 #define XCHAL_ITLB_SET0_ENTRIES_LOG2 3 /* log2(number of entries in this way) */ 208 #define XCHAL_ITLB_SET0_ENTRIES 8 /* number of entries in this way (always a power of 2) */ 209 #define XCHAL_ITLB_SET0_ARF 0 /* 1=autorefill by h/w, 0=non-autorefill (wired/constant/static) */ 210 #define XCHAL_ITLB_SET0_PAGESIZES 1 /* number of supported page sizes in this way */ 211 #define XCHAL_ITLB_SET0_PAGESZ_BITS 0 /* number of bits to encode the page size */ 212 #define XCHAL_ITLB_SET0_PAGESZ_LOG2_MIN 29 /* log2(minimum supported page size) */ 213 #define XCHAL_ITLB_SET0_PAGESZ_LOG2_MAX 29 /* log2(maximum supported page size) */ 214 #define XCHAL_ITLB_SET0_PAGESZ_LOG2_LIST 29 /* list of log2(page size)s, separated by XCHAL_SEP; 215 2^PAGESZ_BITS entries in list, unsupported entries are zero */ 216 #define XCHAL_ITLB_SET0_ASID_CONSTMASK 0 /* constant ASID bits; 0 if all writable */ 217 #define XCHAL_ITLB_SET0_VPN_CONSTMASK 0x00000000 /* constant VPN bits, not including entry index bits; 0 if all writable */ 218 #define XCHAL_ITLB_SET0_PPN_CONSTMASK 0xE0000000 /* constant PPN bits, including entry index bits; 0 if all writable */ 219 #define XCHAL_ITLB_SET0_CA_CONSTMASK 0 /* constant CA bits; 0 if all writable */ 220 #define XCHAL_ITLB_SET0_ASID_RESET 0 /* 1 if ASID reset values defined (and all writable); 0 otherwise */ 221 #define XCHAL_ITLB_SET0_VPN_RESET 0 /* 1 if VPN reset values defined (and all writable); 0 otherwise */ 222 #define XCHAL_ITLB_SET0_PPN_RESET 0 /* 1 if PPN reset values defined (and all writable); 0 otherwise */ 223 #define XCHAL_ITLB_SET0_CA_RESET 1 /* 1 if CA reset values defined (and all writable); 0 otherwise */ 224 /* Constant VPN values for each entry of ITLB way set 0 (because VPN_CONSTMASK is non-zero): */ 225 #define XCHAL_ITLB_SET0_E0_VPN_CONST 0x00000000 226 #define XCHAL_ITLB_SET0_E1_VPN_CONST 0x20000000 227 #define XCHAL_ITLB_SET0_E2_VPN_CONST 0x40000000 228 #define XCHAL_ITLB_SET0_E3_VPN_CONST 0x60000000 229 #define XCHAL_ITLB_SET0_E4_VPN_CONST 0x80000000 230 #define XCHAL_ITLB_SET0_E5_VPN_CONST 0xA0000000 231 #define XCHAL_ITLB_SET0_E6_VPN_CONST 0xC0000000 232 #define XCHAL_ITLB_SET0_E7_VPN_CONST 0xE0000000 233 /* Constant PPN values for each entry of ITLB way set 0 (because PPN_CONSTMASK is non-zero): */ 234 #define XCHAL_ITLB_SET0_E0_PPN_CONST 0x00000000 235 #define XCHAL_ITLB_SET0_E1_PPN_CONST 0x20000000 236 #define XCHAL_ITLB_SET0_E2_PPN_CONST 0x40000000 237 #define XCHAL_ITLB_SET0_E3_PPN_CONST 0x60000000 238 #define XCHAL_ITLB_SET0_E4_PPN_CONST 0x80000000 239 #define XCHAL_ITLB_SET0_E5_PPN_CONST 0xA0000000 240 #define XCHAL_ITLB_SET0_E6_PPN_CONST 0xC0000000 241 #define XCHAL_ITLB_SET0_E7_PPN_CONST 0xE0000000 242 /* Reset CA values for each entry of ITLB way set 0 (because SET0_CA_RESET is non-zero): */ 243 #define XCHAL_ITLB_SET0_E0_CA_RESET 0x02 244 #define XCHAL_ITLB_SET0_E1_CA_RESET 0x02 245 #define XCHAL_ITLB_SET0_E2_CA_RESET 0x02 246 #define XCHAL_ITLB_SET0_E3_CA_RESET 0x02 247 #define XCHAL_ITLB_SET0_E4_CA_RESET 0x02 248 #define XCHAL_ITLB_SET0_E5_CA_RESET 0x02 249 #define XCHAL_ITLB_SET0_E6_CA_RESET 0x02 250 #define XCHAL_ITLB_SET0_E7_CA_RESET 0x02 251 252 253 /*** Data TLB: ***/ 254 255 #define XCHAL_DTLB_WAY_BITS 0 /* number of bits holding the ways */ 256 #define XCHAL_DTLB_WAYS 1 /* number of ways (n-way set-associative TLB) */ 257 #define XCHAL_DTLB_ARF_WAYS 0 /* number of auto-refill ways */ 258 #define XCHAL_DTLB_SETS 1 /* number of sets (groups of ways with identical settings) */ 259 260 /* Way set to which each way belongs: */ 261 #define XCHAL_DTLB_WAY0_SET 0 262 263 /* Ways sets that are used by hardware auto-refill (ARF): */ 264 #define XCHAL_DTLB_ARF_SETS 0 /* number of auto-refill sets */ 265 266 /* Way sets that are "min-wired" (see terminology comment above): */ 267 #define XCHAL_DTLB_MINWIRED_SETS 0 /* number of "min-wired" sets */ 268 269 270 /* DTLB way set 0 (group of ways 0 thru 0): */ 271 #define XCHAL_DTLB_SET0_WAY 0 /* index of first way in this way set */ 272 #define XCHAL_DTLB_SET0_WAYS 1 /* number of (contiguous) ways in this way set */ 273 #define XCHAL_DTLB_SET0_ENTRIES_LOG2 3 /* log2(number of entries in this way) */ 274 #define XCHAL_DTLB_SET0_ENTRIES 8 /* number of entries in this way (always a power of 2) */ 275 #define XCHAL_DTLB_SET0_ARF 0 /* 1=autorefill by h/w, 0=non-autorefill (wired/constant/static) */ 276 #define XCHAL_DTLB_SET0_PAGESIZES 1 /* number of supported page sizes in this way */ 277 #define XCHAL_DTLB_SET0_PAGESZ_BITS 0 /* number of bits to encode the page size */ 278 #define XCHAL_DTLB_SET0_PAGESZ_LOG2_MIN 29 /* log2(minimum supported page size) */ 279 #define XCHAL_DTLB_SET0_PAGESZ_LOG2_MAX 29 /* log2(maximum supported page size) */ 280 #define XCHAL_DTLB_SET0_PAGESZ_LOG2_LIST 29 /* list of log2(page size)s, separated by XCHAL_SEP; 281 2^PAGESZ_BITS entries in list, unsupported entries are zero */ 282 #define XCHAL_DTLB_SET0_ASID_CONSTMASK 0 /* constant ASID bits; 0 if all writable */ 283 #define XCHAL_DTLB_SET0_VPN_CONSTMASK 0x00000000 /* constant VPN bits, not including entry index bits; 0 if all writable */ 284 #define XCHAL_DTLB_SET0_PPN_CONSTMASK 0xE0000000 /* constant PPN bits, including entry index bits; 0 if all writable */ 285 #define XCHAL_DTLB_SET0_CA_CONSTMASK 0 /* constant CA bits; 0 if all writable */ 286 #define XCHAL_DTLB_SET0_ASID_RESET 0 /* 1 if ASID reset values defined (and all writable); 0 otherwise */ 287 #define XCHAL_DTLB_SET0_VPN_RESET 0 /* 1 if VPN reset values defined (and all writable); 0 otherwise */ 288 #define XCHAL_DTLB_SET0_PPN_RESET 0 /* 1 if PPN reset values defined (and all writable); 0 otherwise */ 289 #define XCHAL_DTLB_SET0_CA_RESET 1 /* 1 if CA reset values defined (and all writable); 0 otherwise */ 290 /* Constant VPN values for each entry of DTLB way set 0 (because VPN_CONSTMASK is non-zero): */ 291 #define XCHAL_DTLB_SET0_E0_VPN_CONST 0x00000000 292 #define XCHAL_DTLB_SET0_E1_VPN_CONST 0x20000000 293 #define XCHAL_DTLB_SET0_E2_VPN_CONST 0x40000000 294 #define XCHAL_DTLB_SET0_E3_VPN_CONST 0x60000000 295 #define XCHAL_DTLB_SET0_E4_VPN_CONST 0x80000000 296 #define XCHAL_DTLB_SET0_E5_VPN_CONST 0xA0000000 297 #define XCHAL_DTLB_SET0_E6_VPN_CONST 0xC0000000 298 #define XCHAL_DTLB_SET0_E7_VPN_CONST 0xE0000000 299 /* Constant PPN values for each entry of DTLB way set 0 (because PPN_CONSTMASK is non-zero): */ 300 #define XCHAL_DTLB_SET0_E0_PPN_CONST 0x00000000 301 #define XCHAL_DTLB_SET0_E1_PPN_CONST 0x20000000 302 #define XCHAL_DTLB_SET0_E2_PPN_CONST 0x40000000 303 #define XCHAL_DTLB_SET0_E3_PPN_CONST 0x60000000 304 #define XCHAL_DTLB_SET0_E4_PPN_CONST 0x80000000 305 #define XCHAL_DTLB_SET0_E5_PPN_CONST 0xA0000000 306 #define XCHAL_DTLB_SET0_E6_PPN_CONST 0xC0000000 307 #define XCHAL_DTLB_SET0_E7_PPN_CONST 0xE0000000 308 /* Reset CA values for each entry of DTLB way set 0 (because SET0_CA_RESET is non-zero): */ 309 #define XCHAL_DTLB_SET0_E0_CA_RESET 0x02 310 #define XCHAL_DTLB_SET0_E1_CA_RESET 0x02 311 #define XCHAL_DTLB_SET0_E2_CA_RESET 0x02 312 #define XCHAL_DTLB_SET0_E3_CA_RESET 0x02 313 #define XCHAL_DTLB_SET0_E4_CA_RESET 0x02 314 #define XCHAL_DTLB_SET0_E5_CA_RESET 0x02 315 #define XCHAL_DTLB_SET0_E6_CA_RESET 0x02 316 #define XCHAL_DTLB_SET0_E7_CA_RESET 0x02 317 318 319 320 321 #endif /*XTENSA_CONFIG_CORE_MATMAP_H*/ 322 323