ctlreg.h revision 1.10 1 1.10 eeh /* $NetBSD: ctlreg.h,v 1.10 1999/05/31 00:13:16 eeh Exp $ */
2 1.1 eeh
3 1.1 eeh /*
4 1.1 eeh * Copyright (c) 1996
5 1.1 eeh * The President and Fellows of Harvard College. All rights reserved.
6 1.1 eeh * Copyright (c) 1992, 1993
7 1.1 eeh * The Regents of the University of California. All rights reserved.
8 1.1 eeh *
9 1.1 eeh * This software was developed by the Computer Systems Engineering group
10 1.1 eeh * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
11 1.1 eeh * contributed to Berkeley.
12 1.1 eeh *
13 1.1 eeh * All advertising materials mentioning features or use of this software
14 1.1 eeh * must display the following acknowledgement:
15 1.1 eeh * This product includes software developed by Harvard University.
16 1.1 eeh * This product includes software developed by the University of
17 1.1 eeh * California, Lawrence Berkeley Laboratory.
18 1.1 eeh *
19 1.1 eeh * Redistribution and use in source and binary forms, with or without
20 1.1 eeh * modification, are permitted provided that the following conditions
21 1.1 eeh * are met:
22 1.1 eeh * 1. Redistributions of source code must retain the above copyright
23 1.1 eeh * notice, this list of conditions and the following disclaimer.
24 1.1 eeh * 2. Redistributions in binary form must reproduce the above copyright
25 1.1 eeh * notice, this list of conditions and the following disclaimer in the
26 1.1 eeh * documentation and/or other materials provided with the distribution.
27 1.1 eeh * 3. All advertising materials mentioning features or use of this software
28 1.1 eeh * must display the following acknowledgement:
29 1.1 eeh * This product includes software developed by the University of
30 1.1 eeh * California, Berkeley and its contributors.
31 1.1 eeh * 4. Neither the name of the University nor the names of its contributors
32 1.1 eeh * may be used to endorse or promote products derived from this software
33 1.1 eeh * without specific prior written permission.
34 1.1 eeh *
35 1.1 eeh * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
36 1.1 eeh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 1.1 eeh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 1.1 eeh * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39 1.1 eeh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 1.1 eeh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 1.1 eeh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 1.1 eeh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 1.1 eeh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 1.1 eeh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 1.1 eeh * SUCH DAMAGE.
46 1.1 eeh *
47 1.1 eeh * @(#)ctlreg.h 8.1 (Berkeley) 6/11/93
48 1.1 eeh */
49 1.1 eeh
50 1.1 eeh /*
51 1.1 eeh * Sun4u support by Eduardo Horvath
52 1.1 eeh * Changes Copyright (c) 1996 Eduardo Horvath
53 1.1 eeh * All rights reserved.
54 1.1 eeh */
55 1.1 eeh
56 1.1 eeh /*
57 1.1 eeh * Sun 4u control registers. (includes address space definitions
58 1.1 eeh * and some registers in control space).
59 1.1 eeh */
60 1.1 eeh
61 1.1 eeh /*
62 1.1 eeh * The Alternate address spaces.
63 1.1 eeh *
64 1.1 eeh * 0x00-0x7f are privileged
65 1.1 eeh * 0x80-0xff can be used by users
66 1.1 eeh */
67 1.1 eeh
68 1.1 eeh #define ASI_LITTLE 0x08 /* This bit should make an ASI little endian */
69 1.1 eeh
70 1.1 eeh #define ASI_NUCLEUS 0x04 /* [4u] kernel address space */
71 1.1 eeh #define ASI_NUCLEUS_LITTLE 0x0c /* [4u] kernel address space, little endian */
72 1.1 eeh
73 1.1 eeh #define ASI_AS_IF_USER_PRIMARY 0x10 /* [4u] primary user address space */
74 1.1 eeh #define ASI_AS_IF_USER_SECONDARY 0x11 /* [4u] secondary user address space */
75 1.1 eeh
76 1.1 eeh #define ASI_PHYS_CACHED 0x14 /* [4u] MMU bypass to main memory */
77 1.1 eeh #define ASI_PHYS_NON_CACHED 0x15 /* [4u] MMU bypass to I/O location */
78 1.1 eeh
79 1.1 eeh #define ASI_AS_IF_USER_PRIMARY_LITTLE 0x18 /* [4u] primary user address space, little endian */
80 1.1 eeh #define ASI_AS_IF_USER_SECONDARY_LITTIE 0x19 /* [4u] secondary user address space, little endian */
81 1.1 eeh
82 1.1 eeh #define ASI_PHYS_CACHED_LITTLE 0x1c /* [4u] MMU bypass to main memory, little endian */
83 1.1 eeh #define ASI_PHYS_NON_CACHED_LITTLE 0x1d /* [4u] MMU bypass to I/O location, little endian */
84 1.1 eeh
85 1.1 eeh #define ASI_NUCLEUS_QUAD_LDD 0x24 /* [4u] use w/LDDA to load 128-bit item */
86 1.1 eeh #define ASI_NUCLEUS_QUAD_LDD_LITTLE 0x2c /* [4u] use w/LDDA to load 128-bit item, little endian */
87 1.1 eeh
88 1.1 eeh #define ASI_FLUSH_D_PAGE_PRIMARY 0x38 /* [4u] flush D-cache page using primary context */
89 1.1 eeh #define ASI_FLUSH_D_PAGE_SECONDARY 0x39 /* [4u] flush D-cache page using secondary context */
90 1.1 eeh #define ASI_FLUSH_D_CTX_PRIMARY 0x3a /* [4u] flush D-cache context using primary context */
91 1.1 eeh #define ASI_FLUSH_D_CTX_SECONDARY 0x3b /* [4u] flush D-cache context using secondary context */
92 1.6 eeh
93 1.6 eeh #define ASI_LSU_CONTROL_REGISTER 0x45 /* [4u] load/store unit control register */
94 1.6 eeh
95 1.1 eeh #define ASI_DCACHE_DATA 0x46 /* [4u] diagnostic access to D-cache data RAM */
96 1.1 eeh #define ASI_DCACHE_TAG 0x47 /* [4u] diagnostic access to D-cache tag RAM */
97 1.1 eeh
98 1.1 eeh #define ASI_INTR_DISPATCH_STATUS 0x48 /* [4u] interrupt dispatch status register */
99 1.1 eeh #define ASI_INTR_RECEIVE 0x49 /* [4u] interrupt receive status register */
100 1.1 eeh #define ASI_MID_REG 0x4a /* [4u] hardware config and MID */
101 1.1 eeh #define ASI_ERROR_EN_REG 0x4b /* [4u] asynchronous error enables */
102 1.1 eeh #define ASI_AFSR 0x4c /* [4u] asynchronous fault status register */
103 1.1 eeh #define ASI_AFAR 0x4d /* [4u] asynchronous fault address register */
104 1.1 eeh
105 1.1 eeh #define ASI_ICACHE_DATA 0x66 /* [4u] diagnostic access to D-cache data RAM */
106 1.1 eeh #define ASI_ICACHE_TAG 0x67 /* [4u] diagnostic access to D-cache tag RAM */
107 1.1 eeh #define ASI_FLUSH_I_PAGE_PRIMARY 0x68 /* [4u] flush D-cache page using primary context */
108 1.1 eeh #define ASI_FLUSH_I_PAGE_SECONDARY 0x69 /* [4u] flush D-cache page using secondary context */
109 1.1 eeh #define ASI_FLUSH_I_CTX_PRIMARY 0x6a /* [4u] flush D-cache context using primary context */
110 1.1 eeh #define ASI_FLUSH_I_CTX_SECONDARY 0x6b /* [4u] flush D-cache context using secondary context */
111 1.1 eeh
112 1.1 eeh #define ASI_BLOCK_AS_IF_USER_PRIMARY 0x70 /* [4u] primary user address space, block loads/stores */
113 1.1 eeh #define ASI_BLOCK_AS_IF_USER_SECONDARY 0x71 /* [4u] secondary user address space, block loads/stores */
114 1.1 eeh
115 1.1 eeh #define ASI_ECACHE_DIAG 0x76 /* [4u] diag access to E-cache tag and data */
116 1.1 eeh #define ASI_DATAPATH_ERR_REG_WRITE 0x77 /* [4u] ASI is reused */
117 1.1 eeh
118 1.1 eeh #define ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE 0x78 /* [4u] primary user address space, block loads/stores */
119 1.1 eeh #define ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE 0x79 /* [4u] secondary user address space, block loads/stores */
120 1.1 eeh
121 1.1 eeh #define ASI_INTERRUPT_RECEIVE_DATA 0x7f /* [4u] interrupt receive data registers {0,1,2} */
122 1.1 eeh #define ASI_DATAPATH_ERR_REG_READ 0x7f /* [4u] read access to datapath error registers (ASI reused) */
123 1.1 eeh
124 1.1 eeh #define ASI_PRIMARY 0x80 /* [4u] primary address space */
125 1.1 eeh #define ASI_SECONDARY 0x81 /* [4u] secondary address space */
126 1.1 eeh #define ASI_PRIMARY_NO_FAULT 0x82 /* [4u] primary address space, no fault */
127 1.1 eeh #define ASI_SECONDARY_NO_FAULT 0x83 /* [4u] secondary address space, no fault */
128 1.1 eeh
129 1.1 eeh #define ASI_PRIMARY_LITTLE 0x88 /* [4u] primary address space, little endian */
130 1.1 eeh #define ASI_SECONDARY_LITTLE 0x89 /* [4u] secondary address space, little endian */
131 1.1 eeh #define ASI_PRIMARY_NO_FAULT_LITTLE 0x8a /* [4u] primary address space, no fault, little endian */
132 1.1 eeh #define ASI_SECONDARY_NO_FAULT_LITTLE 0x8b /* [4u] secondary address space, no fault, little endian */
133 1.1 eeh
134 1.1 eeh #define ASI_PST8_PRIMARY 0xc0 /* [VIS] Eight 8-bit partial store, primary */
135 1.1 eeh #define ASI_PST8_SECONDARY 0xc1 /* [VIS] Eight 8-bit partial store, secondary */
136 1.1 eeh #define ASI_PST16_PRIMARY 0xc2 /* [VIS] Four 16-bit partial store, primary */
137 1.1 eeh #define ASI_PST16_SECONDARY 0xc3 /* [VIS] Fout 16-bit partial store, secondary */
138 1.1 eeh #define ASI_PST32_PRIMARY 0xc4 /* [VIS] Two 32-bit partial store, primary */
139 1.1 eeh #define ASI_PST32_SECONDARY 0xc5 /* [VIS] Two 32-bit partial store, secondary */
140 1.1 eeh
141 1.1 eeh #define ASI_PST8_PRIMARY_LITTLE 0xc8 /* [VIS] Eight 8-bit partial store, primary, little endian */
142 1.1 eeh #define ASI_PST8_SECONDARY_LITTLE 0xc9 /* [VIS] Eight 8-bit partial store, secondary, little endian */
143 1.1 eeh #define ASI_PST16_PRIMARY_LITTLE 0xca /* [VIS] Four 16-bit partial store, primary, little endian */
144 1.1 eeh #define ASI_PST16_SECONDARY_LITTLE 0xcb /* [VIS] Fout 16-bit partial store, secondary, little endian */
145 1.1 eeh #define ASI_PST32_PRIMARY_LITTLE 0xcc /* [VIS] Two 32-bit partial store, primary, little endian */
146 1.1 eeh #define ASI_PST32_SECONDARY_LITTLE 0xcd /* [VIS] Two 32-bit partial store, secondary, little endian */
147 1.1 eeh
148 1.1 eeh #define ASI_FL8_PRIMARY 0xd0 /* [VIS] One 8-bit load/store floating, primary */
149 1.1 eeh #define ASI_FL8_SECONDARY 0xd1 /* [VIS] One 8-bit load/store floating, secondary */
150 1.1 eeh #define ASI_FL16_PRIMARY 0xd2 /* [VIS] One 16-bit load/store floating, primary */
151 1.1 eeh #define ASI_FL16_SECONDARY 0xd3 /* [VIS] One 16-bit load/store floating, secondary */
152 1.1 eeh
153 1.1 eeh #define ASI_FL8_PRIMARY_LITTLE 0xd8 /* [VIS] One 8-bit load/store floating, primary, little endian */
154 1.1 eeh #define ASI_FL8_SECONDARY_LITTLE 0xd9 /* [VIS] One 8-bit load/store floating, secondary, little endian */
155 1.1 eeh #define ASI_FL16_PRIMARY_LITTLE 0xda /* [VIS] One 16-bit load/store floating, primary, little endian */
156 1.1 eeh #define ASI_FL16_SECONDARY_LITTLE 0xdb /* [VIS] One 16-bit load/store floating, secondary, little endian */
157 1.1 eeh
158 1.1 eeh #define ASI_BLOCK_COMMIT_PRIMARY 0xe0 /* [4u] block store with commit, primary */
159 1.1 eeh #define ASI_BLOCK_COMMIT_SECONDARY 0xe1 /* [4u] block store with commit, secondary */
160 1.1 eeh #define ASI_BLOCK_PRIMARY 0xf0 /* [4u] block load/store, primary */
161 1.1 eeh #define ASI_BLOCK_SECONDARY 0xf1 /* [4u] block load/store, secondary */
162 1.1 eeh #define ASI_BLOCK_PRIMARY_LITTLE 0xf8 /* [4u] block load/store, primary, little endian */
163 1.1 eeh #define ASI_BLOCK_SECONDARY_LITTLE 0xf9 /* [4u] block load/store, secondary, little endian */
164 1.1 eeh
165 1.1 eeh
166 1.1 eeh /*
167 1.1 eeh * These are the shorter names used by Solaris
168 1.1 eeh */
169 1.1 eeh
170 1.1 eeh #define ASI_N ASI_NUCLEUS
171 1.1 eeh #define ASI_NL ASI_NUCLEUS_LITTLE
172 1.1 eeh #define ASI_AIUP ASI_AS_IF_USER_PRIMARY
173 1.1 eeh #define ASI_AIUS ASI_AS_IF_USER_SECONDARY
174 1.1 eeh #define ASI_AIUPL ASI_AS_IF_USER_PRIMARY_LITTLE
175 1.1 eeh #define ASI_AIUSL ASI_AS_IF_USER_SECONDARY_LITTLE
176 1.1 eeh #define ASI_P ASI_PRIMARY
177 1.1 eeh #define ASI_S ASI_SECONDARY
178 1.1 eeh #define ASI_PNF ASI_PRIMARY_NO_FAULT
179 1.1 eeh #define ASI_SNF ASI_SECONDARY_NO_FAULT
180 1.1 eeh #define ASI_PL ASI_PRIMARY_LITTLE
181 1.1 eeh #define ASI_SL ASI_SECONDARY_LITTLE
182 1.1 eeh #define ASI_PNFL ASI_PRIMARY_NO_FAULT_LITTLE
183 1.1 eeh #define ASI_SNFL ASI_SECONDARY_NO_FAULT_LITTLE
184 1.1 eeh #define ASI_BLK_AIUP ASI_BLOCK_AS_IF_USER_PRIMARY
185 1.1 eeh #define ASI_BLK_AIUPL ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE
186 1.1 eeh #define ASI_BLK_AIUS ASI_BLOCK_AS_IF_USER_SECONDARY
187 1.1 eeh #define ASI_BLK_AIUSL ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE
188 1.1 eeh #define ASI_BLK_COMMIT_P ASI_BLOCK_COMMIT_PRIMARY
189 1.1 eeh #define ASI_BLK_COMMIT_PRIMARY ASI_BLOCK_COMMIT_PRIMARY
190 1.1 eeh #define ASI_BLK_COMMIT_S ASI_BLOCK_COMMIT_SECONDARY
191 1.1 eeh #define ASI_BLK_COMMIT_SECONDARY ASI_BLOCK_COMMIT_SECONDARY
192 1.1 eeh #define ASI_BLK_P ASI_BLOCK_PRIMARY
193 1.1 eeh #define ASI_BLK_PL ASI_BLOCK_PRIMARY_LITTLE
194 1.1 eeh #define ASI_BLK_S ASI_BLOCK_SECONDARY
195 1.1 eeh #define ASI_BLK_SL ASI_BLOCK_SECONDARY_LITTLE
196 1.1 eeh
197 1.1 eeh /*
198 1.1 eeh * The following are 4u control registers
199 1.1 eeh */
200 1.1 eeh
201 1.1 eeh /*
202 1.1 eeh * [4u] MMU and Cache Control Register (MCCR)
203 1.1 eeh * use ASI = 0x45
204 1.1 eeh */
205 1.6 eeh #define ASI_MCCR ASI_LSU_CONTROL_REGISTER
206 1.1 eeh #define MCCR 0x00
207 1.1 eeh
208 1.1 eeh /* MCCR Bits and their meanings */
209 1.1 eeh #define MCCR_DMMU_EN 0x08
210 1.1 eeh #define MCCR_IMMU_EN 0x04
211 1.1 eeh #define MCCR_DCACHE_EN 0x02
212 1.1 eeh #define MCCR_ICACHE_EN 0x01
213 1.1 eeh
214 1.1 eeh
215 1.1 eeh /*
216 1.1 eeh * MMU control registers
217 1.1 eeh */
218 1.1 eeh
219 1.1 eeh /* Choose an MMU */
220 1.1 eeh #define ASI_DMMU 0x58
221 1.1 eeh #define ASI_IMMU 0x50
222 1.1 eeh
223 1.1 eeh /* Other assorted MMU ASIs */
224 1.1 eeh #define ASI_IMMU_8KPTR 0x51
225 1.1 eeh #define ASI_IMMU_64KPTR 0x52
226 1.1 eeh #define ASI_IMMU_DATA_IN 0x54
227 1.1 eeh #define ASI_IMMU_TLB_DATA 0x55
228 1.1 eeh #define ASI_IMMU_TLB_TAG 0x56
229 1.1 eeh #define ASI_DMMU_8KPTR 0x59
230 1.1 eeh #define ASI_DMMU_64KPTR 0x5a
231 1.1 eeh #define ASI_DMMU_DATA_IN 0x5c
232 1.1 eeh #define ASI_DMMU_TLB_DATA 0x5d
233 1.1 eeh #define ASI_DMMU_TLB_TAG 0x5e
234 1.1 eeh
235 1.1 eeh /*
236 1.1 eeh * The following are the control registers
237 1.1 eeh * They work on both MMUs unless noted.
238 1.1 eeh *
239 1.1 eeh * Register contents are defined later on individual registers.
240 1.1 eeh */
241 1.1 eeh #define TSB_TAG_TARGET 0x0
242 1.1 eeh #define TLB_DATA_IN 0x0
243 1.1 eeh #define CTX_PRIMARY 0x08 /* primary context -- DMMU only */
244 1.1 eeh #define CTX_SECONDARY 0x10 /* secondary context -- DMMU only */
245 1.1 eeh #define SFSR 0x18
246 1.1 eeh #define SFAR 0x20 /* fault address -- DMMU only */
247 1.1 eeh #define TSB 0x28
248 1.1 eeh #define TLB_TAG_ACCESS 0x30
249 1.1 eeh #define VIRTUAL_WATCHPOINT 0x38
250 1.1 eeh #define PHYSICAL_WATCHPOINT 0x40
251 1.1 eeh
252 1.1 eeh /* Tag Target bits */
253 1.1 eeh #define TAG_TARGET_VA_MASK 0x03ffffffffffffffffLL
254 1.1 eeh #define TAG_TARGET_VA(x) (((x)<<22)&TAG_TARGET_VA_MASK)
255 1.1 eeh #define TAG_TARGET_CONTEXT(x) ((x)>>48)
256 1.1 eeh #define TAG_TARGET(c,v) ((((uint64_t)c)<<48)|(((uint64_t)v)&TAG_TARGET_VA_MASK))
257 1.1 eeh
258 1.1 eeh /* SFSR bits for both D_SFSR and I_SFSR */
259 1.1 eeh #define SFSR_ASI(x) ((x)>>16)
260 1.1 eeh #define SFSR_FT_VA_OOR_2 0x02000 /* IMMU: jumpl or return to unsupportd VA */
261 1.1 eeh #define SFSR_FT_VA_OOR_1 0x01000 /* fault at unsupported VA */
262 1.1 eeh #define SFSR_FT_NFO 0x00800 /* DMMU: Access to page marked NFO */
263 1.1 eeh #define SFSR_ILL_ASI 0x00400 /* DMMU: Illegal (unsupported) ASI */
264 1.1 eeh #define SFSR_FT_IO_ATOMIC 0x00200 /* DMMU: Atomic access to noncacheable page */
265 1.1 eeh #define SFSR_FT_ILL_NF 0x00100 /* DMMU: NF load or flush to page marked E (has side effects) */
266 1.1 eeh #define SFSR_FT_PRIV 0x00080 /* Privilege violation */
267 1.1 eeh #define SFSR_FT_E 0x00040 /* DMUU: value of E bit associated address */
268 1.1 eeh #define SFSR_CTXT(x) (((x)>>4)&0x3)
269 1.1 eeh #define SFSR_CTXT_IS_PRIM(x) (SFSR_CTXT(x)==0x00)
270 1.1 eeh #define SFSR_CTXT_IS_SECOND(x) (SFSR_CTXT(x)==0x01)
271 1.1 eeh #define SFSR_CTXT_IS_NUCLEUS(x) (SFSR_CTXT(x)==0x02)
272 1.1 eeh #define SFSR_PRIV 0x00008 /* value of PSTATE.PRIV for faulting access */
273 1.1 eeh #define SFSR_W 0x00004 /* DMMU: attempted write */
274 1.1 eeh #define SFSR_OW 0x00002 /* Overwrite; prev vault was still valid */
275 1.1 eeh #define SFSR_FV 0x00001 /* Fault is valid */
276 1.1 eeh #define SFSR_FT (SFSR_FT_VA_OOR_2|SFSR_FT_VA_OOR_1|SFSR_FT_NFO|SFSR_ILL_ASI|SFSR_FT_IO_ATOMIC|SFSR_FT_ILL_NF|SFSR_FT_PRIV)
277 1.1 eeh
278 1.3 eeh #if 0
279 1.3 eeh /* Old bits */
280 1.1 eeh #define SFSR_BITS "\40\16VAT\15VAD\14NFO\13ASI\12A\11NF\10PRIV\7E\6NUCLEUS\5SECONDCTX\4PRIV\3W\2OW\1FV"
281 1.3 eeh #else
282 1.3 eeh /* New bits */
283 1.3 eeh #define SFSR_BITS "\177\20" \
284 1.3 eeh "f\20\30ASI\0" "b\16VAT\0" "b\15VAD\0" "b\14NFO\0" "b\13ASI\0" "b\12A\0" "b\11NF\0" "b\10PRIV\0" \
285 1.3 eeh "b\7E\0" "b\6NUCLEUS\0" "b\5SECONDCTX\0" "b\4PRIV\0" "b\3W\0" "b\2OW\0" "b\1FV\0"
286 1.3 eeh #endif
287 1.3 eeh
288 1.3 eeh /* ASFR bits */
289 1.3 eeh #define ASFR_ME 0x100000000LL
290 1.3 eeh #define ASFR_PRIV 0x080000000LL
291 1.3 eeh #define ASFR_ISAP 0x040000000LL
292 1.3 eeh #define ASFR_ETP 0x020000000LL
293 1.3 eeh #define ASFR_IVUE 0x010000000LL
294 1.3 eeh #define ASFR_TO 0x008000000LL
295 1.3 eeh #define ASFR_BERR 0x004000000LL
296 1.3 eeh #define ASFR_LDP 0x002000000LL
297 1.3 eeh #define ASFR_CP 0x001000000LL
298 1.3 eeh #define ASFR_WP 0x000800000LL
299 1.3 eeh #define ASFR_EDP 0x000400000LL
300 1.3 eeh #define ASFR_UE 0x000200000LL
301 1.3 eeh #define ASFR_CE 0x000100000LL
302 1.3 eeh #define ASFR_ETS 0x0000f0000LL
303 1.3 eeh #define ASFT_P_SYND 0x00000ffffLL
304 1.3 eeh
305 1.3 eeh #define AFSR_BITS "\177\20" \
306 1.3 eeh "b\40ME\0" "b\37PRIV\0" "b\36ISAP\0" "b\35ETP\0" \
307 1.3 eeh "b\34IVUE\0" "b\33TO\0" "b\32BERR\0" "b\31LDP\0" \
308 1.3 eeh "b\30CP\0" "b\27WP\0" "b\26EDP\0" "b\25UE\0" \
309 1.3 eeh "b\24CE\0" "f\20\4ETS\0" "f\0\20P_SYND\0"
310 1.3 eeh
311 1.1 eeh /*
312 1.1 eeh * Here's the spitfire TSB control register bits.
313 1.1 eeh *
314 1.1 eeh * Each TSB entry is 16-bytes wide. The TSB must be size aligned
315 1.1 eeh */
316 1.1 eeh #define TSB_SIZE_512 0x0 /* 8kB, etc. */
317 1.1 eeh #define TSB_SIZE_1K 0x01
318 1.1 eeh #define TSB_SIZE_2K 0x02
319 1.1 eeh #define TSB_SIZE_4K 0x03
320 1.1 eeh #define TSB_SIZE_8K 0x04
321 1.1 eeh #define TSB_SIZE_16K 0x05
322 1.1 eeh #define TSB_SIZE_32K 0x06
323 1.1 eeh #define TSB_SIZE_64K 0x07
324 1.1 eeh #define TSB_SPLIT 0x1000
325 1.1 eeh #define TSB_BASE 0xffffffffffffe000
326 1.1 eeh
327 1.1 eeh /* TLB Tag Access bits */
328 1.1 eeh #define TLB_TAG_ACCESS_VA 0xffffffffffffe000
329 1.1 eeh #define TLB_TAG_ACCESS_CTX 0x0000000000001fff
330 1.1 eeh
331 1.1 eeh /*
332 1.1 eeh * TLB demap registers. TTEs are defined in v9pte.h
333 1.1 eeh *
334 1.1 eeh * Use the address space to select between IMMU and DMMU.
335 1.1 eeh * The address of the register selects which context register
336 1.1 eeh * to read the ASI from.
337 1.1 eeh *
338 1.1 eeh * The data stored in the register is interpreted as the VA to
339 1.1 eeh * use. The DEMAP_CTX_<> registers ignore the address and demap the
340 1.1 eeh * entire ASI.
341 1.1 eeh *
342 1.1 eeh */
343 1.1 eeh #define ASI_IMMU_DEMAP 0x57 /* [4u] IMMU TLB demap */
344 1.1 eeh #define ASI_DMMU_DEMAP 0x5f /* [4u] IMMU TLB demap */
345 1.1 eeh
346 1.1 eeh #define DEMAP_PAGE_NUCLEUS ((0x02)<<4) /* Demap page from kernel AS */
347 1.1 eeh #define DEMAP_PAGE_PRIMARY ((0x00)<<4) /* Demap a page from primary CTXT */
348 1.1 eeh #define DEMAP_PAGE_SECONDARY ((0x01)<<4) /* Demap page from secondary CTXT (DMMU only) */
349 1.1 eeh #define DEMAP_CTX_NUCLEUS ((0x06)<<4) /* Demap all of kernel CTXT */
350 1.1 eeh #define DEMAP_CTX_PRIMARY ((0x04)<<4) /* Demap all of primary CTXT */
351 1.1 eeh #define DEMAP_CTX_SECONDARY ((0x05)<<4) /* Demap all of secondary CTXT */
352 1.1 eeh
353 1.1 eeh /*
354 1.1 eeh * Interrupt registers. This really gets hairy.
355 1.1 eeh */
356 1.1 eeh
357 1.1 eeh /* IRSR -- Interrupt Receive Status Ragister */
358 1.1 eeh #define ASI_IRSR 0x49
359 1.1 eeh #define IRSR 0x00
360 1.1 eeh #define IRSR_BUSY 0x010
361 1.1 eeh #define IRSR_MID(x) (x&0xf)
362 1.1 eeh
363 1.1 eeh /* IRDR -- Interrupt Receive Data Registers */
364 1.1 eeh #define ASI_IRDR 0x7f
365 1.1 eeh #define IRDR_0H 0x40
366 1.1 eeh #define IRDR_0L 0x48 /* unimplemented */
367 1.1 eeh #define IRDR_1H 0x50
368 1.1 eeh #define IRDR_1L 0x58 /* unimplemented */
369 1.1 eeh #define IRDR_2H 0x60
370 1.1 eeh #define IRDR_2L 0x68 /* unimplemented */
371 1.1 eeh #define IRDR_3H 0x70 /* unimplemented */
372 1.1 eeh #define IRDR_3L 0x78 /* unimplemented */
373 1.1 eeh
374 1.1 eeh /* SOFTINT ASRs */
375 1.1 eeh #define SET_SOFTINT %asr20 /* Sets these bits */
376 1.1 eeh #define CLEAR_SOFTINT %asr21 /* Clears these bits */
377 1.1 eeh #define SOFTINT %asr22 /* Reads the register */
378 1.9 eeh #define TICK_CMPR %asr23
379 1.1 eeh
380 1.1 eeh #define TICK_INT 0x01 /* level-14 clock tick */
381 1.1 eeh #define SOFTINT1 (0x1<<1)
382 1.1 eeh #define SOFTINT2 (0x1<<2)
383 1.1 eeh #define SOFTINT3 (0x1<<3)
384 1.1 eeh #define SOFTINT4 (0x1<<4)
385 1.1 eeh #define SOFTINT5 (0x1<<5)
386 1.1 eeh #define SOFTINT6 (0x1<<6)
387 1.1 eeh #define SOFTINT7 (0x1<<7)
388 1.1 eeh #define SOFTINT8 (0x1<<8)
389 1.1 eeh #define SOFTINT9 (0x1<<9)
390 1.1 eeh #define SOFTINT10 (0x1<<10)
391 1.1 eeh #define SOFTINT11 (0x1<<11)
392 1.1 eeh #define SOFTINT12 (0x1<<12)
393 1.1 eeh #define SOFTINT13 (0x1<<13)
394 1.1 eeh #define SOFTINT14 (0x1<<14)
395 1.1 eeh #define SOFTINT15 (0x1<<15)
396 1.1 eeh
397 1.1 eeh /* Interrupt Dispatch -- usually reserved for cross-calls */
398 1.1 eeh #define ASR_IDSR 0x48 /* Interrupt dispatch status reg */
399 1.1 eeh #define IDSR 0x00
400 1.1 eeh #define IDSR_NACK 0x02
401 1.1 eeh #define IDSR_BUSY 0x01
402 1.1 eeh
403 1.1 eeh #define ASI_INTERRUPT_DISPATCH 0x77 /* [4u] spitfire interrupt dispatch regs */
404 1.1 eeh #define IDCR(x) (((x)<<14)&0x70) /* Store anything to this address to dispatch crosscall to CPU (x) */
405 1.1 eeh #define IDDR_0H 0x40 /* Store data to send in these regs */
406 1.1 eeh #define IDDR_0L 0x48 /* unimplemented */
407 1.1 eeh #define IDDR_1H 0x50
408 1.1 eeh #define IDDR_1L 0x58 /* unimplemented */
409 1.1 eeh #define IDDR_2H 0x60
410 1.1 eeh #define IDDR_2L 0x68 /* unimplemented */
411 1.1 eeh #define IDDR_3H 0x70 /* unimplemented */
412 1.1 eeh #define IDDR_3L 0x78 /* unimplemented */
413 1.1 eeh
414 1.1 eeh /*
415 1.1 eeh * Error registers
416 1.1 eeh */
417 1.1 eeh
418 1.1 eeh /* Since we won't try to fix async errs, we don't care about the bits in the regs */
419 1.1 eeh #define ASI_AFAR 0x4d /* Asynchronous fault address register */
420 1.1 eeh #define AFAR 0x00
421 1.1 eeh #define ASI_AFSR 0x4c /* Asynchronous fault status register */
422 1.1 eeh #define AFSR 0x00
423 1.1 eeh
424 1.1 eeh #define ASI_P_EER 0x4b /* Error enable register */
425 1.1 eeh #define P_EER 0x00
426 1.1 eeh #define P_EER_ISAPEN 0x04 /* Enable fatal on ISAP */
427 1.1 eeh #define P_EER_NCEEN 0x02 /* Enable trap on uncorrectable errs */
428 1.1 eeh #define P_EER_CEEN 0x01 /* Enable trap on correctable errs */
429 1.1 eeh
430 1.1 eeh #define ASI_DATAPATH_READ 0x7f /* Read the regs */
431 1.1 eeh #define ASI_DATAPATH_WRITE 0x77 /* Write to the regs */
432 1.1 eeh #define P_DPER_0 0x00 /* Datapath err reg 0 */
433 1.1 eeh #define P_DPER_1 0x18 /* Datapath err reg 1 */
434 1.1 eeh #define P_DCR_0 0x20 /* Datapath control reg 0 */
435 1.1 eeh #define P_DCR_1 0x38 /* Datapath control reg 0 */
436 1.1 eeh
437 1.2 eeh
438 1.2 eeh /* From sparc64/asm.h which I think I'll deprecate since it makes bus.h a pain. */
439 1.2 eeh
440 1.1 eeh /*
441 1.2 eeh * GCC __asm constructs for doing assembly stuff.
442 1.1 eeh */
443 1.2 eeh
444 1.2 eeh /*
445 1.2 eeh * ``Routines'' to load and store from/to alternate address space.
446 1.2 eeh * The location can be a variable, the asi value (address space indicator)
447 1.2 eeh * must be a constant.
448 1.1 eeh *
449 1.2 eeh * N.B.: You can put as many special functions here as you like, since
450 1.2 eeh * they cost no kernel space or time if they are not used.
451 1.1 eeh *
452 1.2 eeh * These were static inline functions, but gcc screws up the constraints
453 1.2 eeh * on the address space identifiers (the "n"umeric value part) because
454 1.2 eeh * it inlines too late, so we have to use the funny valued-macro syntax.
455 1.2 eeh */
456 1.6 eeh
457 1.6 eeh /* DCACHE_BUG forces a flush of the D$ line on every ASI load */
458 1.6 eeh #define DCACHE_BUG
459 1.6 eeh
460 1.9 eeh #ifdef __arch64__
461 1.2 eeh /* load byte from alternate address space */
462 1.6 eeh #ifdef DCACHE_BUG
463 1.6 eeh #define lduba(loc, asi) ({ \
464 1.6 eeh register int _lduba_v; \
465 1.6 eeh if (asi == ASI_PHYS_CACHED) { \
466 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; " \
467 1.7 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %3; membar #Sync; " \
468 1.9 eeh " lduba [%1]%%asi,%0" : "=&r" (_lduba_v) : \
469 1.8 eeh "r" ((long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
470 1.6 eeh } else { \
471 1.9 eeh __asm __volatile("wr %2,%%g0,%%asi; lduba [%1]%%asi,%0" : "=r" (_lduba_v) : \
472 1.9 eeh "r" ((long)(loc)), "r" (asi)); \
473 1.6 eeh } \
474 1.6 eeh _lduba_v; \
475 1.6 eeh })
476 1.6 eeh #else
477 1.2 eeh #define lduba(loc, asi) ({ \
478 1.2 eeh register int _lduba_v; \
479 1.2 eeh __asm __volatile("wr %2,%%g0,%%asi; lduba [%1]%%asi,%0" : "=r" (_lduba_v) : \
480 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
481 1.2 eeh _lduba_v; \
482 1.2 eeh })
483 1.6 eeh #endif
484 1.9 eeh #else
485 1.9 eeh /* load byte from alternate address space */
486 1.9 eeh #ifdef DCACHE_BUG
487 1.9 eeh #define lduba(loc, asi) ({ \
488 1.9 eeh register int _lduba_v, _loc_hi; \
489 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
490 1.9 eeh if (asi == ASI_PHYS_CACHED) { \
491 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; " \
492 1.10 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %4; " \
493 1.10 eeh " sllx %2,32,%0; or %0,%1,%0; membar #Sync; lduba [%0]%%asi,%0" : "=&r" (_lduba_v) : \
494 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), \
495 1.9 eeh "r" (asi), "n" (ASI_DCACHE_TAG)); \
496 1.9 eeh } else { \
497 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
498 1.9 eeh " or %0,%1,%0; lduba [%0]%%asi,%0" : "=&r" (_lduba_v) : \
499 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
500 1.9 eeh } \
501 1.9 eeh _lduba_v; \
502 1.9 eeh })
503 1.9 eeh #else
504 1.9 eeh #define lduba(loc, asi) ({ \
505 1.9 eeh register int _lduba_v, _loc_hi; \
506 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
507 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
508 1.9 eeh " or %0,%1,%0; lduba [%0]%%asi,%0" : "=&r" (_lduba_v) : \
509 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
510 1.9 eeh _lduba_v; \
511 1.9 eeh })
512 1.9 eeh #endif
513 1.9 eeh #endif
514 1.2 eeh
515 1.9 eeh #ifdef __arch64__
516 1.2 eeh /* load half-word from alternate address space */
517 1.6 eeh #ifdef DCACHE_BUG
518 1.6 eeh #define lduha(loc, asi) ({ \
519 1.6 eeh register int _lduha_v; \
520 1.6 eeh if (asi == ASI_PHYS_CACHED) { \
521 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; " \
522 1.7 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %3; membar #Sync; " \
523 1.9 eeh " lduha [%1]%%asi,%0" : "=&r" (_lduha_v) : \
524 1.8 eeh "r" ((long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
525 1.6 eeh } else { \
526 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; lduha [%1]%%asi,%0" : "=r" (_lduha_v) : \
527 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
528 1.6 eeh } \
529 1.6 eeh _lduha_v; \
530 1.6 eeh })
531 1.6 eeh #else
532 1.2 eeh #define lduha(loc, asi) ({ \
533 1.2 eeh register int _lduha_v; \
534 1.2 eeh __asm __volatile("wr %2,%%g0,%%asi; lduha [%1]%%asi,%0" : "=r" (_lduha_v) : \
535 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
536 1.2 eeh _lduha_v; \
537 1.2 eeh })
538 1.6 eeh #endif
539 1.9 eeh #else
540 1.9 eeh /* load half-word from alternate address space */
541 1.9 eeh #ifdef DCACHE_BUG
542 1.9 eeh #define lduha(loc, asi) ({ \
543 1.9 eeh register int _lduha_v, _loc_hi; \
544 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
545 1.9 eeh if (asi == ASI_PHYS_CACHED) { \
546 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; " \
547 1.10 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %4; " \
548 1.10 eeh " sllx %2,32,%0; or %0,%1,%0; membar #Sync; lduha [%0]%%asi,%0" : "=&r" (_lduha_v) : \
549 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), \
550 1.9 eeh "r" (asi), "n" (ASI_DCACHE_TAG)); \
551 1.9 eeh } else { \
552 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
553 1.9 eeh " or %0,%1,%0; lduha [%0]%%asi,%0" : "=&r" (_lduha_v) : \
554 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
555 1.9 eeh } \
556 1.9 eeh _lduha_v; \
557 1.9 eeh })
558 1.9 eeh #else
559 1.9 eeh #define lduha(loc, asi) ({ \
560 1.9 eeh register int _lduha_v, _loc_hi; \
561 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
562 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
563 1.9 eeh " or %0,%1,%0; lduha [%0]%%asi,%0" : "=&r" (_lduha_v) : \
564 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
565 1.9 eeh _lduha_v; \
566 1.9 eeh })
567 1.9 eeh #endif
568 1.9 eeh #endif
569 1.2 eeh
570 1.9 eeh #ifdef __arch64__
571 1.6 eeh /* load unsigned int from alternate address space */
572 1.6 eeh #ifdef DCACHE_BUG
573 1.6 eeh #define lda(loc, asi) ({ \
574 1.6 eeh register int _lda_v; \
575 1.6 eeh if (asi == ASI_PHYS_CACHED) { \
576 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; " \
577 1.7 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %3; membar #Sync; " \
578 1.9 eeh " lda [%1]%%asi,%0" : "=&r" (_lda_v) : \
579 1.8 eeh "r" ((long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
580 1.6 eeh } else { \
581 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; lda [%1]%%asi,%0" : "=r" (_lda_v) : \
582 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
583 1.6 eeh } \
584 1.6 eeh _lda_v; \
585 1.6 eeh })
586 1.6 eeh
587 1.6 eeh /* load signed int from alternate address space */
588 1.6 eeh #define ldswa(loc, asi) ({ \
589 1.6 eeh register int _lda_v; \
590 1.6 eeh if (asi == ASI_PHYS_CACHED) { \
591 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; " \
592 1.7 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %3; membar #Sync; " \
593 1.9 eeh " ldswa [%1]%%asi,%0" : "=&r" (_lda_v) : \
594 1.8 eeh "r" ((long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
595 1.6 eeh } else { \
596 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; ldswa [%1]%%asi,%0" : "=r" (_lda_v) : \
597 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
598 1.6 eeh } \
599 1.6 eeh _lda_v; \
600 1.6 eeh })
601 1.6 eeh #else
602 1.2 eeh #define lda(loc, asi) ({ \
603 1.2 eeh register int _lda_v; \
604 1.2 eeh __asm __volatile("wr %2,%%g0,%%asi; lda [%1]%%asi,%0" : "=r" (_lda_v) : \
605 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
606 1.2 eeh _lda_v; \
607 1.2 eeh })
608 1.2 eeh
609 1.2 eeh #define ldswa(loc, asi) ({ \
610 1.2 eeh register int _lda_v; \
611 1.2 eeh __asm __volatile("wr %2,%%g0,%%asi; ldswa [%1]%%asi,%0" : "=r" (_lda_v) : \
612 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
613 1.2 eeh _lda_v; \
614 1.2 eeh })
615 1.6 eeh #endif
616 1.9 eeh #else /* __arch64__ */
617 1.9 eeh /* load unsigned int from alternate address space */
618 1.9 eeh #ifdef DCACHE_BUG
619 1.9 eeh #define lda(loc, asi) ({ \
620 1.9 eeh register int _lda_v, _loc_hi; \
621 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
622 1.9 eeh if (asi == ASI_PHYS_CACHED) { \
623 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; " \
624 1.10 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %4; " \
625 1.10 eeh " sllx %2,32,%0; or %0,%1,%0; membar #Sync; lda [%1]%%asi,%0" : "=&r" (_lda_v) : \
626 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), \
627 1.9 eeh "r" (asi), "n" (ASI_DCACHE_TAG)); \
628 1.9 eeh } else { \
629 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
630 1.9 eeh " or %0,%1,%0; lda [%0]%%asi,%0" : "=&r" (_lda_v) : \
631 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
632 1.9 eeh } \
633 1.9 eeh _lda_v; \
634 1.9 eeh })
635 1.9 eeh
636 1.9 eeh /* load signed int from alternate address space */
637 1.9 eeh #define ldswa(loc, asi) ({ \
638 1.9 eeh register int _lda_v, _loc_hi; \
639 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
640 1.9 eeh if (asi == ASI_PHYS_CACHED) { \
641 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; " \
642 1.10 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %4; " \
643 1.10 eeh " sllx %2,32,%0; or %0,%1,%0; membar #Sync; ldswa [%1]%%asi,%0" : "=&r" (_lda_v) : \
644 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), \
645 1.9 eeh "r" (asi), "n" (ASI_DCACHE_TAG)); \
646 1.9 eeh } else { \
647 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
648 1.9 eeh " or %0,%1,%0; ldswa [%0]%%asi,%0" : "=&r" (_lda_v) : \
649 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
650 1.9 eeh } \
651 1.9 eeh _lda_v; \
652 1.9 eeh })
653 1.9 eeh #else
654 1.9 eeh #define lda(loc, asi) ({ \
655 1.9 eeh register int _lda_v, _loc_hi; \
656 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
657 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
658 1.9 eeh " or %0,%1,%0; lda [%0]%%asi,%0" : "=&r" (_lda_v) : \
659 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
660 1.9 eeh _lda_v; \
661 1.9 eeh })
662 1.9 eeh
663 1.9 eeh #define ldswa(loc, asi) ({ \
664 1.9 eeh register int _lda_v, _loc_hi; \
665 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
666 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
667 1.9 eeh " or %0,%1,%0; ldswa [%0]%%asi,%0" : "=&r" (_lda_v) : \
668 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
669 1.9 eeh _lda_v; \
670 1.9 eeh })
671 1.9 eeh #endif
672 1.9 eeh #endif /* __arch64__ */
673 1.6 eeh
674 1.6 eeh #ifdef DCACHE_BUG
675 1.2 eeh
676 1.9 eeh #ifdef __arch64__
677 1.6 eeh /* load 64-bit int from alternate address space */
678 1.6 eeh #define ldda(loc, asi) ({ \
679 1.6 eeh register long long _lda_v; \
680 1.6 eeh if (asi == ASI_PHYS_CACHED) { \
681 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; " \
682 1.7 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %3; membar #Sync; " \
683 1.9 eeh " ldda [%1]%%asi,%0" : "=&r" (_lda_v) : \
684 1.8 eeh "r" ((long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
685 1.6 eeh } else { \
686 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; ldda [%1]%%asi,%0" : "=r" (_lda_v) : \
687 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
688 1.6 eeh } \
689 1.6 eeh _lda_v; \
690 1.2 eeh })
691 1.9 eeh #else
692 1.9 eeh /* load 64-bit int from alternate address space */
693 1.9 eeh #define ldda(loc, asi) ({ \
694 1.9 eeh register long long _lda_v, _loc_hi; \
695 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
696 1.9 eeh if (asi == ASI_PHYS_CACHED) { \
697 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; " \
698 1.10 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %4; " \
699 1.10 eeh " sllx %2,32,%0; or %0,%1,%0; membar #Sync; ldda [%0]%%asi,%0" : "=&r" (_lda_v) : \
700 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi), "n" (ASI_DCACHE_TAG)); \
701 1.9 eeh } else { \
702 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
703 1.9 eeh " or %0,%1,%0; ldda [%0]%%asi,%0" : "=&r" (_lda_v) : \
704 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
705 1.9 eeh } \
706 1.9 eeh _lda_v; \
707 1.9 eeh })
708 1.9 eeh #endif
709 1.2 eeh
710 1.6 eeh #ifdef __arch64__
711 1.6 eeh /* native load 64-bit int from alternate address space w/64-bit compiler*/
712 1.6 eeh #define ldxa(loc, asi) ({ \
713 1.6 eeh register long _lda_v; \
714 1.6 eeh if (asi == ASI_PHYS_CACHED) { \
715 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; "\
716 1.7 eeh " andn %1,0x1f,%0; stxa %%g0,[%0] %3; membar #Sync; " \
717 1.9 eeh " ldxa [%1]%%asi,%0" : "=&r" (_lda_v) : \
718 1.6 eeh "r" ((long)(loc)), "r" (asi), "n" (ASI_DCACHE_TAG)); \
719 1.6 eeh } else { \
720 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; ldxa [%1]%%asi,%0" : "=r" (_lda_v) : \
721 1.6 eeh "r" ((long)(loc)), "r" (asi)); \
722 1.6 eeh } \
723 1.6 eeh _lda_v; \
724 1.6 eeh })
725 1.6 eeh #else
726 1.6 eeh /* native load 64-bit int from alternate address space w/32-bit compiler*/
727 1.6 eeh #define ldxa(loc, asi) ({ \
728 1.10 eeh register long _ldxa_lo, _ldxa_hi, _loc_hi; \
729 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
730 1.6 eeh if (asi == ASI_PHYS_CACHED) { \
731 1.9 eeh __asm __volatile("wr %4,%%g0,%%asi; " \
732 1.10 eeh " andn %2,0x1f,%0; stxa %%g0,[%0] %5; " \
733 1.10 eeh " sllx %3,32,%0; or %0,%2,%0; membar #Sync; ldxa [%0]%%asi,%0; " \
734 1.9 eeh " srlx %0,32,%1; srl %0,0,%0" : \
735 1.9 eeh "=&r" (_ldxa_lo), "=&r" (_ldxa_hi) : \
736 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), \
737 1.9 eeh "r" (asi), "n" (ASI_DCACHE_TAG)); \
738 1.6 eeh } else { \
739 1.10 eeh __asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
740 1.10 eeh " or %0,%2,%0; ldxa [%0]%%asi,%0; srlx %0,32,%1; srl %0,0,%0;" : \
741 1.9 eeh "=&r" (_ldxa_lo), "=&r" (_ldxa_hi) : \
742 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
743 1.6 eeh } \
744 1.6 eeh ((((int64_t)_ldxa_hi)<<32)|_ldxa_lo); \
745 1.2 eeh })
746 1.6 eeh #endif
747 1.2 eeh
748 1.6 eeh #else
749 1.2 eeh
750 1.9 eeh #ifdef __arch64__
751 1.2 eeh /* load 64-bit int from alternate address space */
752 1.2 eeh #define ldda(loc, asi) ({ \
753 1.2 eeh register long long _lda_v; \
754 1.2 eeh __asm __volatile("wr %2,%%g0,%%asi; ldda [%1]%%asi,%0" : "=r" (_lda_v) : \
755 1.8 eeh "r" ((long)(loc)), "r" (asi)); \
756 1.2 eeh _lda_v; \
757 1.2 eeh })
758 1.9 eeh #else
759 1.9 eeh #define ldda(loc, asi) ({ \
760 1.9 eeh register long long _lda_v, _loc_hi; \
761 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
762 1.9 eeh __asm __volatile("wr %3,%%g0,%%asi; sllx %2,32,%0; " \
763 1.9 eeh " or %0,%1,%0; ldda [%0]%%asi,%0" : "=&r" (_lda_v) : \
764 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
765 1.9 eeh _lda_v; \
766 1.9 eeh })
767 1.9 eeh #endif
768 1.2 eeh
769 1.5 mrg #ifdef __arch64__
770 1.2 eeh /* native load 64-bit int from alternate address space w/64-bit compiler*/
771 1.2 eeh #define ldxa(loc, asi) ({ \
772 1.2 eeh register long _lda_v; \
773 1.2 eeh __asm __volatile("wr %2,%%g0,%%asi; ldxa [%1]%%asi,%0" : "=r" (_lda_v) : \
774 1.2 eeh "r" ((long)(loc)), "r" (asi)); \
775 1.2 eeh _lda_v; \
776 1.2 eeh })
777 1.2 eeh #else
778 1.2 eeh /* native load 64-bit int from alternate address space w/32-bit compiler*/
779 1.2 eeh #define ldxa(loc, asi) ({ \
780 1.10 eeh register long _ldxa_lo, _ldxa_hi, _loc_hi; \
781 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
782 1.9 eeh __asm __volatile("wr %4,%%g0,%%asi; sllx %2,32,%0; " \
783 1.9 eeh " or %0,%1,%0; ldxa [%2]%%asi,%0; srlx %0,32,%1; srl %0,0,%0;" : \
784 1.9 eeh "=&r" (_ldxa_lo), "=&r" (_ldxa_hi) : \
785 1.9 eeh "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
786 1.4 eeh ((((int64_t)_ldxa_hi)<<32)|_ldxa_lo); \
787 1.2 eeh })
788 1.2 eeh #endif
789 1.6 eeh #endif
790 1.6 eeh
791 1.6 eeh
792 1.6 eeh /* store byte to alternate address space */
793 1.9 eeh #ifdef __arch64__
794 1.6 eeh #define stba(loc, asi, value) ({ \
795 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; stba %0,[%1]%%asi" : : \
796 1.8 eeh "r" ((int)(value)), "r" ((long)(loc)), "r" (asi)); \
797 1.6 eeh })
798 1.9 eeh #else
799 1.9 eeh #define stba(loc, asi, value) ({ \
800 1.9 eeh register int _loc_hi; \
801 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
802 1.9 eeh __asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
803 1.9 eeh " or %2,%0,%0; stba %1,[%0]%%asi" : "=&r" (_loc_hi) : \
804 1.9 eeh "r" ((int)(value)), "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
805 1.9 eeh })
806 1.9 eeh #endif
807 1.6 eeh
808 1.6 eeh /* store half-word to alternate address space */
809 1.9 eeh #ifdef __arch64__
810 1.6 eeh #define stha(loc, asi, value) ({ \
811 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; stha %0,[%1]%%asi" : : \
812 1.8 eeh "r" ((int)(value)), "r" ((long)(loc)), "r" (asi)); \
813 1.6 eeh })
814 1.9 eeh #else
815 1.9 eeh #define stha(loc, asi, value) ({ \
816 1.9 eeh register int _loc_hi; \
817 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
818 1.9 eeh __asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
819 1.9 eeh " or %2,%0,%0; stha %1,[%0]%%asi" : "=&r" (_loc_hi) : \
820 1.9 eeh "r" ((int)(value)), "r" ((long)(loc)), "r" (_loc_hi), "r" (asi)); \
821 1.9 eeh })
822 1.9 eeh #endif
823 1.6 eeh
824 1.6 eeh /* store int to alternate address space */
825 1.9 eeh #ifdef __arch64__
826 1.6 eeh #define sta(loc, asi, value) ({ \
827 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; sta %0,[%1]%%asi" : : \
828 1.8 eeh "r" ((int)(value)), "r" ((long)(loc)), "r" (asi)); \
829 1.6 eeh })
830 1.9 eeh #else
831 1.9 eeh #define sta(loc, asi, value) ({ \
832 1.9 eeh register int _loc_hi; \
833 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
834 1.9 eeh __asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
835 1.9 eeh " or %2,%0,%0; sta %1,[%0]%%asi" : "=&r" (_loc_hi) : \
836 1.9 eeh "r" ((int)(value)), "r" ((int)(loc)), "r" (_loc_hi), "r" (asi)); \
837 1.9 eeh })
838 1.9 eeh #endif
839 1.6 eeh
840 1.6 eeh /* store 64-bit int to alternate address space */
841 1.9 eeh #ifdef __arch64__
842 1.6 eeh #define stda(loc, asi, value) ({ \
843 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; stda %0,[%1]%%asi" : : \
844 1.8 eeh "r" ((long long)(value)), "r" ((long)(loc)), "r" (asi)); \
845 1.6 eeh })
846 1.9 eeh #else
847 1.9 eeh #define stda(loc, asi, value) ({ \
848 1.9 eeh register int _loc_hi; \
849 1.9 eeh _loc_hi = (((u_int64_t)loc)>>32); \
850 1.9 eeh __asm __volatile("wr %4,%%g0,%%asi; sllx %3,32,%0; " \
851 1.9 eeh " or %2,%0,%0; stda %1,[%0]%%asi" : "=&r" (_loc_hi) : \
852 1.9 eeh "r" ((long long)(value)), "r" ((int)(loc)), "r" (_loc_hi), "r" (asi)); \
853 1.9 eeh })
854 1.9 eeh #endif
855 1.1 eeh
856 1.5 mrg #ifdef __arch64__
857 1.2 eeh /* native store 64-bit int to alternate address space w/64-bit compiler*/
858 1.2 eeh #define stxa(loc, asi, value) ({ \
859 1.6 eeh __asm __volatile("wr %2,%%g0,%%asi; stxa %0,[%1]%%asi" : : \
860 1.2 eeh "r" ((long)(value)), "r" ((long)(loc)), "r" (asi)); \
861 1.2 eeh })
862 1.2 eeh #else
863 1.2 eeh /* native store 64-bit int to alternate address space w/32-bit compiler*/
864 1.2 eeh #define stxa(loc, asi, value) ({ \
865 1.9 eeh int _stxa_lo, _stxa_hi, _loc_hi; \
866 1.9 eeh _stxa_lo = value; _stxa_hi = ((u_int64_t)value)>>32; \
867 1.10 eeh _loc_hi = (((u_int64_t)(long)loc)>>32); \
868 1.9 eeh __asm __volatile("wr %6,%%g0,%%asi; sllx %3,32,%1; sllx %5,32,%0; " \
869 1.9 eeh " or %1,%2,%1; or %0,%4,%0; stxa %1,[%0]%%asi" : \
870 1.9 eeh "=&r" (_loc_hi), "=&r" (_stxa_hi) : \
871 1.9 eeh "r" ((int)(_stxa_lo)), "r" ((int)(_stxa_hi)), \
872 1.9 eeh "r" ((int)(loc)), "r" (_loc_hi), "r" (asi)); \
873 1.2 eeh })
874 1.1 eeh #endif
875 1.1 eeh
876 1.2 eeh /* flush address from data cache */
877 1.2 eeh #define flush(loc) ({ \
878 1.2 eeh __asm __volatile("flush %0" : : \
879 1.2 eeh "r" ((long)(loc))); \
880 1.2 eeh })
881 1.2 eeh
882 1.6 eeh /* Flush a D$ line */
883 1.6 eeh #if 0
884 1.6 eeh #define flushline(loc) ({ \
885 1.6 eeh stxa(((paddr_t)loc)&(~0x1f), (ASI_DCACHE_TAG), 0); \
886 1.6 eeh membar_sync(); \
887 1.6 eeh })
888 1.6 eeh #else
889 1.6 eeh #define flushline(loc)
890 1.6 eeh #endif
891 1.6 eeh
892 1.6 eeh /* The following two enable or disable the dcache in the LSU control register */
893 1.6 eeh #define dcenable() ({ \
894 1.6 eeh int res; \
895 1.6 eeh __asm __volatile("ldxa [%%g0] %1,%0; or %0,%2,%0; stxa %0,[%%g0] %1; membar #Sync" \
896 1.6 eeh : "r" (res) : "n" (ASI_MCCR), "n" (MCCR_DCACHE_EN)); \
897 1.6 eeh })
898 1.6 eeh #define dcdisable() ({ \
899 1.6 eeh int res; \
900 1.6 eeh __asm __volatile("ldxa [%%g0] %1,%0; andn %0,%2,%0; stxa %0,[%%g0] %1; membar #Sync" \
901 1.6 eeh : "r" (res) : "n" (ASI_MCCR), "n" (MCCR_DCACHE_EN)); \
902 1.6 eeh })
903 1.6 eeh
904 1.6 eeh /*
905 1.6 eeh * SPARC V9 memory barrier instructions.
906 1.6 eeh */
907 1.6 eeh /* Make all stores complete before next store */
908 1.6 eeh #define membar_storestore() __asm __volatile("membar #StoreStore" : :)
909 1.6 eeh /* Make all loads complete before next store */
910 1.6 eeh #define membar_loadstore() __asm __volatile("membar #LoadStore" : :)
911 1.6 eeh /* Make all stores complete before next load */
912 1.6 eeh #define membar_storeload() __asm __volatile("membar #StoreLoad" : :)
913 1.6 eeh /* Make all loads complete before next load */
914 1.6 eeh #define membar_loadload() __asm __volatile("membar #LoadLoad" : :)
915 1.6 eeh /* Complete all outstanding memory operations and exceptions */
916 1.2 eeh #define membar_sync() __asm __volatile("membar #Sync" : :)
917 1.6 eeh /* Complete all outstanding memory operations */
918 1.6 eeh #define membar_memissue() __asm __volatile("membar #MemIssue" : :)
919 1.6 eeh /* Complete all outstanding stores before any new loads */
920 1.6 eeh #define membar_lookaside() __asm __volatile("membar #Lookaside" : :)
921 1.2 eeh
922 1.5 mrg #ifdef __arch64__
923 1.2 eeh /* read 64-bit %tick register */
924 1.2 eeh #define tick() ({ \
925 1.3 eeh register u_long _tick_tmp; \
926 1.2 eeh __asm __volatile("rdpr %%tick, %0" : "=r" (_tick_tmp) :); \
927 1.2 eeh _tick_tmp; \
928 1.2 eeh })
929 1.2 eeh #else
930 1.9 eeh /* read 64-bit %tick register on 32-bit system */
931 1.2 eeh #define tick() ({ \
932 1.10 eeh register int _tick_hi = 0, _tick_lo = 0; \
933 1.10 eeh __asm __volatile("rdpr %%tick, %1; srlx %0,32,%2; srl %0,0,%0 " \
934 1.10 eeh : "=r" (_tick_hi), "=r" (_tick_lo) : ); \
935 1.10 eeh (((u_int64_t)_tick_hi)<<32)|((u_int64_t)_tick_lo); \
936 1.2 eeh })
937 1.1 eeh #endif
938 1.2 eeh
939 1.9 eeh #ifndef _LOCORE
940 1.9 eeh extern next_tick __P((long));
941 1.9 eeh #endif
942