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-2010 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 /* Cache Attribute encodings -- lists of access modes for each cache attribute: */ 57 #define XCHAL_FCA_LIST XTHAL_FAM_EXCEPTION XCHAL_SEP \ 58 XTHAL_FAM_CACHED XCHAL_SEP \ 59 XTHAL_FAM_BYPASS XCHAL_SEP \ 60 XTHAL_FAM_CACHED XCHAL_SEP \ 61 XTHAL_FAM_CACHED XCHAL_SEP \ 62 XTHAL_FAM_CACHED XCHAL_SEP \ 63 XTHAL_FAM_EXCEPTION XCHAL_SEP \ 64 XTHAL_FAM_EXCEPTION 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 73 #define XCHAL_LCA_LIST XTHAL_LAM_CACHED_NOALLOC XCHAL_SEP \ 74 XTHAL_LAM_CACHED XCHAL_SEP \ 75 XTHAL_LAM_BYPASSG XCHAL_SEP \ 76 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 77 XTHAL_LAM_CACHED XCHAL_SEP \ 78 XTHAL_LAM_CACHED XCHAL_SEP \ 79 XTHAL_LAM_EXCEPTION XCHAL_SEP \ 80 XTHAL_LAM_EXCEPTION 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_ISOLATE XCHAL_SEP \ 88 XTHAL_LAM_EXCEPTION 89 #define XCHAL_SCA_LIST XTHAL_SAM_WRITETHRU XCHAL_SEP \ 90 XTHAL_SAM_WRITETHRU XCHAL_SEP \ 91 XTHAL_SAM_BYPASS XCHAL_SEP \ 92 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 93 XTHAL_SAM_WRITEBACK XCHAL_SEP \ 94 XTHAL_SAM_WRITEBACK_NOALLOC XCHAL_SEP \ 95 XTHAL_SAM_EXCEPTION XCHAL_SEP \ 96 XTHAL_SAM_EXCEPTION 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_ISOLATE XCHAL_SEP \ 104 XTHAL_SAM_EXCEPTION 105 106 107 /* 108 * Specific encoded cache attribute values of general interest. 109 * If a specific cache mode is not available, the closest available 110 * one is returned instead (eg. writethru instead of writeback, 111 * bypass instead of writethru). 112 */ 113 #define XCHAL_CA_BYPASS 2 /* cache disabled (bypassed) mode */ 114 #define XCHAL_CA_WRITETHRU 1 /* cache enabled (write-through) mode */ 115 #define XCHAL_CA_WRITEBACK 4 /* cache enabled (write-back) mode */ 116 #define XCHAL_CA_WRITEBACK_NOALLOC 4 /* cache enabled (write-back no-allocate) mode */ 117 #define XCHAL_CA_ILLEGAL 15 /* no access allowed (all cause exceptions) mode */ 118 #define XCHAL_CA_ISOLATE 14 /* cache isolate (accesses go to cache not memory) mode */ 119 120 121 /*---------------------------------------------------------------------- 122 MMU 123 ----------------------------------------------------------------------*/ 124 125 /* 126 * General notes on MMU parameters. 127 * 128 * Terminology: 129 * ASID = address-space ID (acts as an "extension" of virtual addresses) 130 * VPN = virtual page number 131 * PPN = physical page number 132 * CA = encoded cache attribute (access modes) 133 * TLB = translation look-aside buffer (term is stretched somewhat here) 134 * I = instruction (fetch accesses) 135 * D = data (load and store accesses) 136 * way = each TLB (ITLB and DTLB) consists of a number of "ways" 137 * that simultaneously match the virtual address of an access; 138 * a TLB successfully translates a virtual address if exactly 139 * one way matches the vaddr; if none match, it is a miss; 140 * if multiple match, one gets a "multihit" exception; 141 * each way can be independently configured in terms of number of 142 * entries, page sizes, which fields are writable or constant, etc. 143 * set = group of contiguous ways with exactly identical parameters 144 * ARF = auto-refill; hardware services a 1st-level miss by loading a PTE 145 * from the page table and storing it in one of the auto-refill ways; 146 * if this PTE load also misses, a miss exception is posted for s/w. 147 * min-wired = a "min-wired" way can be used to map a single (minimum-sized) 148 * page arbitrarily under program control; it has a single entry, 149 * is non-auto-refill (some other way(s) must be auto-refill), 150 * all its fields (VPN, PPN, ASID, CA) are all writable, and it 151 * supports the XCHAL_MMU_MIN_PTE_PAGE_SIZE page size (a current 152 * restriction is that this be the only page size it supports). 153 * 154 * TLB way entries are virtually indexed. 155 * TLB ways that support multiple page sizes: 156 * - must have all writable VPN and PPN fields; 157 * - can only use one page size at any given time (eg. setup at startup), 158 * selected by the respective ITLBCFG or DTLBCFG special register, 159 * whose bits n*4+3 .. n*4 index the list of page sizes for way n 160 * (XCHAL_xTLB_SETm_PAGESZ_LOG2_LIST for set m corresponding to way n); 161 * this list may be sparse for auto-refill ways because auto-refill 162 * ways have independent lists of supported page sizes sharing a 163 * common encoding with PTE entries; the encoding is the index into 164 * this list; unsupported sizes for a given way are zero in the list; 165 * selecting unsupported sizes results in undefined hardware behaviour; 166 * - is only possible for ways 0 thru 7 (due to ITLBCFG/DTLBCFG definition). 167 */ 168 169 #define XCHAL_MMU_ASID_INVALID 0 /* ASID value indicating invalid address space */ 170 #define XCHAL_MMU_ASID_KERNEL 0 /* ASID value indicating kernel (ring 0) address space */ 171 #define XCHAL_MMU_SR_BITS 0 /* number of size-restriction bits supported */ 172 #define XCHAL_MMU_CA_BITS 4 /* number of bits needed to hold cache attribute encoding */ 173 #define XCHAL_MMU_MAX_PTE_PAGE_SIZE 29 /* max page size in a PTE structure (log2) */ 174 #define XCHAL_MMU_MIN_PTE_PAGE_SIZE 29 /* min page size in a PTE structure (log2) */ 175 176 177 /*** Instruction TLB: ***/ 178 179 #define XCHAL_ITLB_WAY_BITS 0 /* number of bits holding the ways */ 180 #define XCHAL_ITLB_WAYS 1 /* number of ways (n-way set-associative TLB) */ 181 #define XCHAL_ITLB_ARF_WAYS 0 /* number of auto-refill ways */ 182 #define XCHAL_ITLB_SETS 1 /* number of sets (groups of ways with identical settings) */ 183 184 /* Way set to which each way belongs: */ 185 #define XCHAL_ITLB_WAY0_SET 0 186 187 /* Ways sets that are used by hardware auto-refill (ARF): */ 188 #define XCHAL_ITLB_ARF_SETS 0 /* number of auto-refill sets */ 189 190 /* Way sets that are "min-wired" (see terminology comment above): */ 191 #define XCHAL_ITLB_MINWIRED_SETS 0 /* number of "min-wired" sets */ 192 193 194 /* ITLB way set 0 (group of ways 0 thru 0): */ 195 #define XCHAL_ITLB_SET0_WAY 0 /* index of first way in this way set */ 196 #define XCHAL_ITLB_SET0_WAYS 1 /* number of (contiguous) ways in this way set */ 197 #define XCHAL_ITLB_SET0_ENTRIES_LOG2 3 /* log2(number of entries in this way) */ 198 #define XCHAL_ITLB_SET0_ENTRIES 8 /* number of entries in this way (always a power of 2) */ 199 #define XCHAL_ITLB_SET0_ARF 0 /* 1=autorefill by h/w, 0=non-autorefill (wired/constant/static) */ 200 #define XCHAL_ITLB_SET0_PAGESIZES 1 /* number of supported page sizes in this way */ 201 #define XCHAL_ITLB_SET0_PAGESZ_BITS 0 /* number of bits to encode the page size */ 202 #define XCHAL_ITLB_SET0_PAGESZ_LOG2_MIN 29 /* log2(minimum supported page size) */ 203 #define XCHAL_ITLB_SET0_PAGESZ_LOG2_MAX 29 /* log2(maximum supported page size) */ 204 #define XCHAL_ITLB_SET0_PAGESZ_LOG2_LIST 29 /* list of log2(page size)s, separated by XCHAL_SEP; 205 2^PAGESZ_BITS entries in list, unsupported entries are zero */ 206 #define XCHAL_ITLB_SET0_ASID_CONSTMASK 0 /* constant ASID bits; 0 if all writable */ 207 #define XCHAL_ITLB_SET0_VPN_CONSTMASK 0x00000000 /* constant VPN bits, not including entry index bits; 0 if all writable */ 208 #define XCHAL_ITLB_SET0_PPN_CONSTMASK 0 /* constant PPN bits, including entry index bits; 0 if all writable */ 209 #define XCHAL_ITLB_SET0_CA_CONSTMASK 0 /* constant CA bits; 0 if all writable */ 210 #define XCHAL_ITLB_SET0_ASID_RESET 0 /* 1 if ASID reset values defined (and all writable); 0 otherwise */ 211 #define XCHAL_ITLB_SET0_VPN_RESET 0 /* 1 if VPN reset values defined (and all writable); 0 otherwise */ 212 #define XCHAL_ITLB_SET0_PPN_RESET 1 /* 1 if PPN reset values defined (and all writable); 0 otherwise */ 213 #define XCHAL_ITLB_SET0_CA_RESET 1 /* 1 if CA reset values defined (and all writable); 0 otherwise */ 214 /* Constant VPN values for each entry of ITLB way set 0 (because VPN_CONSTMASK is non-zero): */ 215 #define XCHAL_ITLB_SET0_E0_VPN_CONST 0x00000000 216 #define XCHAL_ITLB_SET0_E1_VPN_CONST 0x20000000 217 #define XCHAL_ITLB_SET0_E2_VPN_CONST 0x40000000 218 #define XCHAL_ITLB_SET0_E3_VPN_CONST 0x60000000 219 #define XCHAL_ITLB_SET0_E4_VPN_CONST 0x80000000 220 #define XCHAL_ITLB_SET0_E5_VPN_CONST 0xA0000000 221 #define XCHAL_ITLB_SET0_E6_VPN_CONST 0xC0000000 222 #define XCHAL_ITLB_SET0_E7_VPN_CONST 0xE0000000 223 /* Reset PPN values for each entry of ITLB way set 0 (because SET0_PPN_RESET is non-zero): */ 224 #define XCHAL_ITLB_SET0_E0_PPN_RESET 0x00000000 225 #define XCHAL_ITLB_SET0_E1_PPN_RESET 0x20000000 226 #define XCHAL_ITLB_SET0_E2_PPN_RESET 0x40000000 227 #define XCHAL_ITLB_SET0_E3_PPN_RESET 0x60000000 228 #define XCHAL_ITLB_SET0_E4_PPN_RESET 0x80000000 229 #define XCHAL_ITLB_SET0_E5_PPN_RESET 0xA0000000 230 #define XCHAL_ITLB_SET0_E6_PPN_RESET 0xC0000000 231 #define XCHAL_ITLB_SET0_E7_PPN_RESET 0xE0000000 232 /* Reset CA values for each entry of ITLB way set 0 (because SET0_CA_RESET is non-zero): */ 233 #define XCHAL_ITLB_SET0_E0_CA_RESET 0x02 234 #define XCHAL_ITLB_SET0_E1_CA_RESET 0x02 235 #define XCHAL_ITLB_SET0_E2_CA_RESET 0x02 236 #define XCHAL_ITLB_SET0_E3_CA_RESET 0x02 237 #define XCHAL_ITLB_SET0_E4_CA_RESET 0x02 238 #define XCHAL_ITLB_SET0_E5_CA_RESET 0x02 239 #define XCHAL_ITLB_SET0_E6_CA_RESET 0x02 240 #define XCHAL_ITLB_SET0_E7_CA_RESET 0x02 241 242 243 /*** Data TLB: ***/ 244 245 #define XCHAL_DTLB_WAY_BITS 0 /* number of bits holding the ways */ 246 #define XCHAL_DTLB_WAYS 1 /* number of ways (n-way set-associative TLB) */ 247 #define XCHAL_DTLB_ARF_WAYS 0 /* number of auto-refill ways */ 248 #define XCHAL_DTLB_SETS 1 /* number of sets (groups of ways with identical settings) */ 249 250 /* Way set to which each way belongs: */ 251 #define XCHAL_DTLB_WAY0_SET 0 252 253 /* Ways sets that are used by hardware auto-refill (ARF): */ 254 #define XCHAL_DTLB_ARF_SETS 0 /* number of auto-refill sets */ 255 256 /* Way sets that are "min-wired" (see terminology comment above): */ 257 #define XCHAL_DTLB_MINWIRED_SETS 0 /* number of "min-wired" sets */ 258 259 260 /* DTLB way set 0 (group of ways 0 thru 0): */ 261 #define XCHAL_DTLB_SET0_WAY 0 /* index of first way in this way set */ 262 #define XCHAL_DTLB_SET0_WAYS 1 /* number of (contiguous) ways in this way set */ 263 #define XCHAL_DTLB_SET0_ENTRIES_LOG2 3 /* log2(number of entries in this way) */ 264 #define XCHAL_DTLB_SET0_ENTRIES 8 /* number of entries in this way (always a power of 2) */ 265 #define XCHAL_DTLB_SET0_ARF 0 /* 1=autorefill by h/w, 0=non-autorefill (wired/constant/static) */ 266 #define XCHAL_DTLB_SET0_PAGESIZES 1 /* number of supported page sizes in this way */ 267 #define XCHAL_DTLB_SET0_PAGESZ_BITS 0 /* number of bits to encode the page size */ 268 #define XCHAL_DTLB_SET0_PAGESZ_LOG2_MIN 29 /* log2(minimum supported page size) */ 269 #define XCHAL_DTLB_SET0_PAGESZ_LOG2_MAX 29 /* log2(maximum supported page size) */ 270 #define XCHAL_DTLB_SET0_PAGESZ_LOG2_LIST 29 /* list of log2(page size)s, separated by XCHAL_SEP; 271 2^PAGESZ_BITS entries in list, unsupported entries are zero */ 272 #define XCHAL_DTLB_SET0_ASID_CONSTMASK 0 /* constant ASID bits; 0 if all writable */ 273 #define XCHAL_DTLB_SET0_VPN_CONSTMASK 0x00000000 /* constant VPN bits, not including entry index bits; 0 if all writable */ 274 #define XCHAL_DTLB_SET0_PPN_CONSTMASK 0 /* constant PPN bits, including entry index bits; 0 if all writable */ 275 #define XCHAL_DTLB_SET0_CA_CONSTMASK 0 /* constant CA bits; 0 if all writable */ 276 #define XCHAL_DTLB_SET0_ASID_RESET 0 /* 1 if ASID reset values defined (and all writable); 0 otherwise */ 277 #define XCHAL_DTLB_SET0_VPN_RESET 0 /* 1 if VPN reset values defined (and all writable); 0 otherwise */ 278 #define XCHAL_DTLB_SET0_PPN_RESET 1 /* 1 if PPN reset values defined (and all writable); 0 otherwise */ 279 #define XCHAL_DTLB_SET0_CA_RESET 1 /* 1 if CA reset values defined (and all writable); 0 otherwise */ 280 /* Constant VPN values for each entry of DTLB way set 0 (because VPN_CONSTMASK is non-zero): */ 281 #define XCHAL_DTLB_SET0_E0_VPN_CONST 0x00000000 282 #define XCHAL_DTLB_SET0_E1_VPN_CONST 0x20000000 283 #define XCHAL_DTLB_SET0_E2_VPN_CONST 0x40000000 284 #define XCHAL_DTLB_SET0_E3_VPN_CONST 0x60000000 285 #define XCHAL_DTLB_SET0_E4_VPN_CONST 0x80000000 286 #define XCHAL_DTLB_SET0_E5_VPN_CONST 0xA0000000 287 #define XCHAL_DTLB_SET0_E6_VPN_CONST 0xC0000000 288 #define XCHAL_DTLB_SET0_E7_VPN_CONST 0xE0000000 289 /* Reset PPN values for each entry of DTLB way set 0 (because SET0_PPN_RESET is non-zero): */ 290 #define XCHAL_DTLB_SET0_E0_PPN_RESET 0x00000000 291 #define XCHAL_DTLB_SET0_E1_PPN_RESET 0x20000000 292 #define XCHAL_DTLB_SET0_E2_PPN_RESET 0x40000000 293 #define XCHAL_DTLB_SET0_E3_PPN_RESET 0x60000000 294 #define XCHAL_DTLB_SET0_E4_PPN_RESET 0x80000000 295 #define XCHAL_DTLB_SET0_E5_PPN_RESET 0xA0000000 296 #define XCHAL_DTLB_SET0_E6_PPN_RESET 0xC0000000 297 #define XCHAL_DTLB_SET0_E7_PPN_RESET 0xE0000000 298 /* Reset CA values for each entry of DTLB way set 0 (because SET0_CA_RESET is non-zero): */ 299 #define XCHAL_DTLB_SET0_E0_CA_RESET 0x02 300 #define XCHAL_DTLB_SET0_E1_CA_RESET 0x02 301 #define XCHAL_DTLB_SET0_E2_CA_RESET 0x02 302 #define XCHAL_DTLB_SET0_E3_CA_RESET 0x02 303 #define XCHAL_DTLB_SET0_E4_CA_RESET 0x02 304 #define XCHAL_DTLB_SET0_E5_CA_RESET 0x02 305 #define XCHAL_DTLB_SET0_E6_CA_RESET 0x02 306 #define XCHAL_DTLB_SET0_E7_CA_RESET 0x02 307 308 309 310 311 #endif /*XTENSA_CONFIG_CORE_MATMAP_H*/ 312 313