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