xref: /titanic_53/usr/src/uts/sun4u/sys/cheetahregs.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_CHEETAHREGS_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_CHEETAHREGS_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <sys/machasi.h>
33*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
34*7c478bd9Sstevel@tonic-gate #include <sys/fpras.h>
35*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate /*
38*7c478bd9Sstevel@tonic-gate  * This file is cpu dependent.
39*7c478bd9Sstevel@tonic-gate  */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
42*7c478bd9Sstevel@tonic-gate extern "C" {
43*7c478bd9Sstevel@tonic-gate #endif
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate /*
46*7c478bd9Sstevel@tonic-gate  * Definitions of UltraSparc III cpu implementations as specified
47*7c478bd9Sstevel@tonic-gate  * in version register
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate #define	CHEETAH_IMPL			0x14
50*7c478bd9Sstevel@tonic-gate #define	IS_CHEETAH(impl)		((impl) == CHEETAH_IMPL)
51*7c478bd9Sstevel@tonic-gate #define	CHEETAH_MAJOR_VERSION(rev)	(((rev) >> 4) & 0xf)
52*7c478bd9Sstevel@tonic-gate #define	CHEETAH_MINOR_VERSION(rev)	((rev) & 0xf)
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /*
55*7c478bd9Sstevel@tonic-gate  * Definitions of UltraSPARC III+ cpu implementation as specified
56*7c478bd9Sstevel@tonic-gate  * in version register
57*7c478bd9Sstevel@tonic-gate  */
58*7c478bd9Sstevel@tonic-gate #define	CHEETAH_PLUS_IMPL		0x15
59*7c478bd9Sstevel@tonic-gate #define	IS_CHEETAH_PLUS(impl)		((impl) == CHEETAH_PLUS_IMPL)
60*7c478bd9Sstevel@tonic-gate #define	CHEETAH_PLUS_MAJOR_VERSION(rev)	CHEETAH_MAJOR_VERSION(rev)
61*7c478bd9Sstevel@tonic-gate #define	CHEETAH_PLUS_MINOR_VERSION(rev)	CHEETAH_MINOR_VERSION(rev)
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * Definitions of UltraSPARC IIIi cpu implementation as specified
65*7c478bd9Sstevel@tonic-gate  * in version register.  Jalapeno major and minor rev's are in
66*7c478bd9Sstevel@tonic-gate  * the same location and are the same size as Cheetah/Cheetah+.
67*7c478bd9Sstevel@tonic-gate  */
68*7c478bd9Sstevel@tonic-gate #define	JALAPENO_IMPL			0x16
69*7c478bd9Sstevel@tonic-gate #define	IS_JALAPENO(impl)		((impl) == JALAPENO_IMPL)
70*7c478bd9Sstevel@tonic-gate #define	JALAPENO_MAJOR_VERSION(rev)	CHEETAH_MAJOR_VERSION(rev)
71*7c478bd9Sstevel@tonic-gate #define	JALAPENO_MINOR_VERSION(rev)	CHEETAH_MINOR_VERSION(rev)
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /*
74*7c478bd9Sstevel@tonic-gate  * Definitions of UltraSPARC IV cpu implementation as specified
75*7c478bd9Sstevel@tonic-gate  * in version register. Jaguar major and minor rev's are in
76*7c478bd9Sstevel@tonic-gate  * the same location and are the same size as Cheetah/Cheetah+.
77*7c478bd9Sstevel@tonic-gate  */
78*7c478bd9Sstevel@tonic-gate #define	JAGUAR_IMPL			0x18
79*7c478bd9Sstevel@tonic-gate #define	IS_JAGUAR(impl)			((impl) == JAGUAR_IMPL)
80*7c478bd9Sstevel@tonic-gate #define	JAGUAR_MAJOR_VERSION(rev)	CHEETAH_MAJOR_VERSION(rev)
81*7c478bd9Sstevel@tonic-gate #define	JAGUAR_MINOR_VERSION(rev)	CHEETAH_MINOR_VERSION(rev)
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate /*
84*7c478bd9Sstevel@tonic-gate  * Definitions of UltraSPARC IIIi+ cpu implementation as specified
85*7c478bd9Sstevel@tonic-gate  * in version register.  Serrano major and minor rev's are in
86*7c478bd9Sstevel@tonic-gate  * the same location and are the same size as Cheetah/Cheetah+.
87*7c478bd9Sstevel@tonic-gate  */
88*7c478bd9Sstevel@tonic-gate #define	SERRANO_IMPL			0x22
89*7c478bd9Sstevel@tonic-gate #define	IS_SERRANO(impl)		((impl) == SERRANO_IMPL)
90*7c478bd9Sstevel@tonic-gate #define	SERRANO_MAJOR_VERSION(rev)	CHEETAH_MAJOR_VERSION(rev)
91*7c478bd9Sstevel@tonic-gate #define	SERRANO_MINOR_VERSION(rev)	CHEETAH_MINOR_VERSION(rev)
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /*
94*7c478bd9Sstevel@tonic-gate  * Definitions of UltraSPARC IV+ cpu implementation as specified
95*7c478bd9Sstevel@tonic-gate  * in version register. Panther major and minor rev's are in
96*7c478bd9Sstevel@tonic-gate  * the same location and are the same size as Cheetah/Cheetah+.
97*7c478bd9Sstevel@tonic-gate  */
98*7c478bd9Sstevel@tonic-gate #define	PANTHER_IMPL			0x19
99*7c478bd9Sstevel@tonic-gate #define	IS_PANTHER(impl)		((impl) == PANTHER_IMPL)
100*7c478bd9Sstevel@tonic-gate #define	PANTHER_MAJOR_VERSION(rev)	CHEETAH_MAJOR_VERSION(rev)
101*7c478bd9Sstevel@tonic-gate #define	PANTHER_MINOR_VERSION(rev)	CHEETAH_MINOR_VERSION(rev)
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate #define	CPU_IMPL_IS_CMP(impl)		(IS_JAGUAR(impl) || IS_PANTHER(impl))
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate /*
106*7c478bd9Sstevel@tonic-gate  * Cheetah includes the process info in its mask to make things
107*7c478bd9Sstevel@tonic-gate  * more difficult.  The process is the low bit of the major mask,
108*7c478bd9Sstevel@tonic-gate  * so to convert to the netlist major:
109*7c478bd9Sstevel@tonic-gate  * netlist_major = ((mask_major >> 1) + 1)
110*7c478bd9Sstevel@tonic-gate  */
111*7c478bd9Sstevel@tonic-gate #define	REMAP_CHEETAH_MASK(x)	(((((x) >> 1) + 0x10) & 0xf0) | ((x) & 0xf))
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate #ifdef _ASM
114*7c478bd9Sstevel@tonic-gate /*
115*7c478bd9Sstevel@tonic-gate  * assembler doesn't understand the 'ull' suffix for C constants so
116*7c478bd9Sstevel@tonic-gate  * use the inttypes.h macros and undefine them here for assembly code
117*7c478bd9Sstevel@tonic-gate  */
118*7c478bd9Sstevel@tonic-gate #undef INT64_C
119*7c478bd9Sstevel@tonic-gate #undef UINT64_C
120*7c478bd9Sstevel@tonic-gate #define	INT64_C(x)	(x)
121*7c478bd9Sstevel@tonic-gate #define	UINT64_C(x)	(x)
122*7c478bd9Sstevel@tonic-gate #endif	/* _ASM */
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate /*
125*7c478bd9Sstevel@tonic-gate  * DCU Control Register
126*7c478bd9Sstevel@tonic-gate  *
127*7c478bd9Sstevel@tonic-gate  * +------+----+----+----+----+----+-----+-----+----+----+----+
128*7c478bd9Sstevel@tonic-gate  * | Resv | CP | CV | ME | RE | PE | HPE | SPE | SL | WE | PM |
129*7c478bd9Sstevel@tonic-gate  * +------+----+----+----+----+----+-----+-----+----+----+----+
130*7c478bd9Sstevel@tonic-gate  *  63:50   49   48   47   46	45    44    43   42   41 40:33
131*7c478bd9Sstevel@tonic-gate  *
132*7c478bd9Sstevel@tonic-gate  * +----+----+----+----+----+----------+-----+----+----+----+---+
133*7c478bd9Sstevel@tonic-gate  * | VM | PR | PW | VR | VW | Reserved | WIH | DM | IM | DC | IC|
134*7c478bd9Sstevel@tonic-gate  * +----+----+----+----+----+----------+-----+----+----+----+---+
135*7c478bd9Sstevel@tonic-gate  * 32:25  24   23   22   21      20:5     4     3    2    1   0
136*7c478bd9Sstevel@tonic-gate  */
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate #define	ASI_DCU	ASI_LSU			    /* same as spitfire ASI_LSU 0x45 */
139*7c478bd9Sstevel@tonic-gate #define	DCU_IC	INT64_C(0x0000000000000001) /* icache enable		*/
140*7c478bd9Sstevel@tonic-gate #define	DCU_DC	INT64_C(0x0000000000000002) /* dcache enable		*/
141*7c478bd9Sstevel@tonic-gate #define	DCU_IM	INT64_C(0x0000000000000004) /* immu enable		*/
142*7c478bd9Sstevel@tonic-gate #define	DCU_DM	INT64_C(0x0000000000000008) /* dmmu enable		*/
143*7c478bd9Sstevel@tonic-gate #define	DCU_WIH	INT64_C(0x0000000000000010) /* Jaguar only - W$ hash index */
144*7c478bd9Sstevel@tonic-gate #define	DCU_VW	INT64_C(0x0000000000200000) /* virt watchpoint write enable  */
145*7c478bd9Sstevel@tonic-gate #define	DCU_VR	INT64_C(0x0000000000400000) /* virt watchpoint read enable   */
146*7c478bd9Sstevel@tonic-gate #define	DCU_PW	INT64_C(0x0000000000800000) /* phys watchpoint write enable  */
147*7c478bd9Sstevel@tonic-gate #define	DCU_PR	INT64_C(0x0000000001000000) /* phys watchpoint read enable   */
148*7c478bd9Sstevel@tonic-gate #define	DCU_VM	INT64_C(0x00000001FE000000) /* virtual watchpoint write mask */
149*7c478bd9Sstevel@tonic-gate #define	DCU_PM	INT64_C(0x000001FE00000000) /* phys watchpoint write mask    */
150*7c478bd9Sstevel@tonic-gate #define	DCU_WE	INT64_C(0x0000020000000000) /* write cache enable	*/
151*7c478bd9Sstevel@tonic-gate #define	DCU_SL	INT64_C(0x0000040000000000) /* second load control	*/
152*7c478bd9Sstevel@tonic-gate #define	DCU_SPE	INT64_C(0x0000080000000000) /* software prefetch enable */
153*7c478bd9Sstevel@tonic-gate #define	DCU_HPE	INT64_C(0x0000100000000000) /* hardware prefetch enable */
154*7c478bd9Sstevel@tonic-gate #define	DCU_PE	INT64_C(0x0000200000000000) /* prefetch enable		*/
155*7c478bd9Sstevel@tonic-gate #define	DCU_RE	INT64_C(0x0000400000000000) /* RAW bypass enable	*/
156*7c478bd9Sstevel@tonic-gate #define	DCU_ME	INT64_C(0x0000800000000000) /* noncache store merging enable */
157*7c478bd9Sstevel@tonic-gate #define	DCU_CV	INT64_C(0x0001000000000000) /* virt cacheability when DM=0   */
158*7c478bd9Sstevel@tonic-gate #define	DCU_CP	INT64_C(0x0002000000000000) /* phys cacheable when DM,IM=0   */
159*7c478bd9Sstevel@tonic-gate #define	DCU_CACHE (DCU_IC|DCU_DC|DCU_WE|DCU_SPE|DCU_HPE|DCU_PE)
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate /*
162*7c478bd9Sstevel@tonic-gate  * bit shifts for the prefetch enable bit
163*7c478bd9Sstevel@tonic-gate  */
164*7c478bd9Sstevel@tonic-gate #define	DCU_PE_SHIFT	45
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate /*
167*7c478bd9Sstevel@tonic-gate  * Safari Configuration Register
168*7c478bd9Sstevel@tonic-gate  */
169*7c478bd9Sstevel@tonic-gate #define	ASI_SAFARI_CONFIG	ASI_UPA_CONFIG /* Safari Config Reg, 0x4A */
170*7c478bd9Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_1	INT64_C(0x0000000000000000) /* 1/1 clock */
171*7c478bd9Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_1_DIV	1	/* clock divisor: 1 */
172*7c478bd9Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_2	INT64_C(0x0000000040000000) /* 1/2 clock */
173*7c478bd9Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_2_DIV	2	/* clock divisor: 2 */
174*7c478bd9Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_32	INT64_C(0x0000000080000000) /* 1/32 clock */
175*7c478bd9Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_32_DIV	32	/* clock divisor: 32 */
176*7c478bd9Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_MASK	(SAFARI_CONFIG_ECLK_32 | SAFARI_CONFIG_ECLK_2)
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
179*7c478bd9Sstevel@tonic-gate /*
180*7c478bd9Sstevel@tonic-gate  * JBUS Configuration Register
181*7c478bd9Sstevel@tonic-gate  */
182*7c478bd9Sstevel@tonic-gate #define	ASI_JBUS_CONFIG		ASI_UPA_CONFIG /* JBUS Config Reg, 0x4A */
183*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_1	INT64_C(0x0000000000000000) /* 1/1 clock */
184*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_1_DIV	1	/* clock divisor: 1 */
185*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_2	INT64_C(0x0000000000002000) /* 1/2 clock */
186*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_2_DIV	2	/* clock divisor: 2 */
187*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_32	INT64_C(0x0000000000004000) /* 1/32 clock */
188*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_32_DIV	32	/* clock divisor: 32 */
189*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_MASK	(JBUS_CONFIG_ECLK_32 | JBUS_CONFIG_ECLK_2)
190*7c478bd9Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_SHIFT	13
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate /*
193*7c478bd9Sstevel@tonic-gate  * Jalapeno/Serrano MCU control registers and ASI
194*7c478bd9Sstevel@tonic-gate  */
195*7c478bd9Sstevel@tonic-gate #define	ASI_MCU_CTRL		0x72		/* MCU Control Reg ASI */
196*7c478bd9Sstevel@tonic-gate #define	JP_MCU_FSM_MASK		INT64_C(0x0000000006000000) /* 26..25 */
197*7c478bd9Sstevel@tonic-gate #define	JP_MCU_FSM_SHIFT	25
198*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate #if defined(SERRANO)
201*7c478bd9Sstevel@tonic-gate #define	ASI_MCU_AFAR2_VA	0x18	/* captures FRC/FRU addr */
202*7c478bd9Sstevel@tonic-gate #endif	/* SERRANO */
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) && defined(JALAPENO_ERRATA_85)
205*7c478bd9Sstevel@tonic-gate /*
206*7c478bd9Sstevel@tonic-gate  * Tomatillo Estar control registers (for JP Errataum 85)
207*7c478bd9Sstevel@tonic-gate  */
208*7c478bd9Sstevel@tonic-gate #define	JBUS_SLAVE_T_PORT_BIT	48
209*7c478bd9Sstevel@tonic-gate #define	TOM_HIGH_PA		0x400		/* Hi 32 bit of Tom reg PA */
210*7c478bd9Sstevel@tonic-gate #define	M_T_ESTAR_CTRL_PA	0x0f410050	/* M T estar PA */
211*7c478bd9Sstevel@tonic-gate #define	S_T_ESTAR_CTRL_PA	0x0e410050	/* S T estar PA */
212*7c478bd9Sstevel@tonic-gate #define	M_T_J_CHNG_INIT_PA	0x0f410058	/* Master T estar PA */
213*7c478bd9Sstevel@tonic-gate #define	TOM_ESTAR_ELCK_MASK	0x23		/* bit 5,1,0 */
214*7c478bd9Sstevel@tonic-gate #define	TOM_FULL_SPEED		0x1
215*7c478bd9Sstevel@tonic-gate #define	TOM_HALF_SPEED		0x2
216*7c478bd9Sstevel@tonic-gate #define	TOM_SLOW_SPEED		0x20
217*7c478bd9Sstevel@tonic-gate #define	TOM_TRIGGER_MASK	0x18
218*7c478bd9Sstevel@tonic-gate #define	TOM_TRIGGER		0x10
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO && JALAPENO_ERRATA_85 */
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate /*
224*7c478bd9Sstevel@tonic-gate  * Miscellaneous ASI definitions not in machasi.h
225*7c478bd9Sstevel@tonic-gate  */
226*7c478bd9Sstevel@tonic-gate #define	ASI_DC_UTAG		0x43	/* Dcache Microtag Fields */
227*7c478bd9Sstevel@tonic-gate #define	ASI_DC_SNP_TAG		0x44	/* Dcache Snoop Tag Fields */
228*7c478bd9Sstevel@tonic-gate #define	ASI_IC_SNP_TAG		0x68	/* Icache Snoop Tag Fields */
229*7c478bd9Sstevel@tonic-gate #define	ASI_IPB_DATA		0x69	/* Instruction Prefetch Buffer Data */
230*7c478bd9Sstevel@tonic-gate #define	ASI_IPB_TAG		0x6A	/* Instruction Prefetch Buffer Tag */
231*7c478bd9Sstevel@tonic-gate #define	ASI_MC_DECODE		0x72	/* Memory Address Decoding Registers */
232*7c478bd9Sstevel@tonic-gate #define	ASI_EC_CFG_TIMING	0x73	/* Jaguar shared Ecache Control Reg */
233*7c478bd9Sstevel@tonic-gate #define	ASI_EC_DATA		0x74	/* Ecache Data Staging Registers */
234*7c478bd9Sstevel@tonic-gate #define	ASI_EC_CTRL		0x75	/* Ecache Control Register */
235*7c478bd9Sstevel@tonic-gate #define	ASI_PC_STATUS_DATA	0x30	/* Pcache Status Data Access */
236*7c478bd9Sstevel@tonic-gate #define	ASI_PC_DATA		0x31	/* Pcache Diagnostic Data Register */
237*7c478bd9Sstevel@tonic-gate #define	ASI_PC_TAG		0x32	/* Pcache Virtual Tag/Valid Field */
238*7c478bd9Sstevel@tonic-gate #define	ASI_PC_SNP_TAG		0x33	/* Pcache Snoop Tag Register */
239*7c478bd9Sstevel@tonic-gate #define	ASI_L2_DATA		0x6B	/* L2 cache Data Diagnostic Access */
240*7c478bd9Sstevel@tonic-gate #define	ASI_L2_TAG		0x6C	/* L2 cache Tag Diagnostic Access */
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate /*
243*7c478bd9Sstevel@tonic-gate  * Bits of Cheetah Asynchronous Fault Status Register
244*7c478bd9Sstevel@tonic-gate  *
245*7c478bd9Sstevel@tonic-gate  * +---+--+----+----+----+----+---+---+---+---+--+----
246*7c478bd9Sstevel@tonic-gate  * |rsv|ME|PRIV|PERR|IERR|ISAP|EMC|EMU|IVC|IVU|TO|BERR
247*7c478bd9Sstevel@tonic-gate  * +---+--+----+----+----+----+---+---+---+---+--+----
248*7c478bd9Sstevel@tonic-gate  * 63:54 53 52   51   50   49   48  47  46  45 44  43
249*7c478bd9Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+------+---+-------+
250*7c478bd9Sstevel@tonic-gate  * |UCC|UCU|CPC|CPU|WDC|WDU|EDC|EDU|UE|CE|rsv|M_SYND|rsv||E_SYND|
251*7c478bd9Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+------+---+-------+
252*7c478bd9Sstevel@tonic-gate  *   42  41  40  39  38  37  36  35 34 33 32:20 19:16 15:9 8:0
253*7c478bd9Sstevel@tonic-gate  *
254*7c478bd9Sstevel@tonic-gate  */
255*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
256*7c478bd9Sstevel@tonic-gate /*
257*7c478bd9Sstevel@tonic-gate  * Bits of Cheetah+ Asynchronous Fault Status Register
258*7c478bd9Sstevel@tonic-gate  *
259*7c478bd9Sstevel@tonic-gate  * +------------------+----------------------------
260*7c478bd9Sstevel@tonic-gate  * |rsv|TUE_SH|IMC|IMU|DTO|DBERR|THCE|TSCE|TUE|DUE|
261*7c478bd9Sstevel@tonic-gate  * +------------------+---------------------------- . . .
262*7c478bd9Sstevel@tonic-gate  *   63    62   61  60  59    58   57   56  55  54
263*7c478bd9Sstevel@tonic-gate  *
264*7c478bd9Sstevel@tonic-gate  * Note that bits 60-62 are only implemented in Panther (reserved
265*7c478bd9Sstevel@tonic-gate  * in Cheetah+ and Jaguar. Also, bit 56 is reserved in Panther instead
266*7c478bd9Sstevel@tonic-gate  * of TSCE since those errors are HW corrected in Panther.
267*7c478bd9Sstevel@tonic-gate  */
268*7c478bd9Sstevel@tonic-gate #define	C_AFSR_TUE_SH INT64_C(0x4000000000000000) /* uncorrectable tag UE  */
269*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IMC  INT64_C(0x2000000000000000)	/* intr vector MTAG ECC */
270*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IMU  INT64_C(0x1000000000000000)	/* intr vector MTAG ECC */
271*7c478bd9Sstevel@tonic-gate #define	C_AFSR_DTO  INT64_C(0x0800000000000000)	/* disrupting TO error */
272*7c478bd9Sstevel@tonic-gate #define	C_AFSR_DBERR INT64_C(0x0400000000000000) /* disrupting BERR error */
273*7c478bd9Sstevel@tonic-gate #define	C_AFSR_THCE INT64_C(0x0200000000000000)	/* h/w correctable E$ tag err */
274*7c478bd9Sstevel@tonic-gate #define	C_AFSR_TSCE INT64_C(0x0100000000000000)	/* s/w correctable E$ tag err */
275*7c478bd9Sstevel@tonic-gate #define	C_AFSR_TUE  INT64_C(0x0080000000000000)	/* uncorrectable E$ tag error */
276*7c478bd9Sstevel@tonic-gate #define	C_AFSR_DUE  INT64_C(0x0040000000000000)	/* disrupting UE error */
277*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
278*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ME   INT64_C(0x0020000000000000)	/* errors > 1, same type!=CE */
279*7c478bd9Sstevel@tonic-gate #define	C_AFSR_PRIV INT64_C(0x0010000000000000)	/* priv code access error    */
280*7c478bd9Sstevel@tonic-gate #define	C_AFSR_PERR INT64_C(0x0008000000000000)	/* system interface protocol */
281*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IERR INT64_C(0x0004000000000000)	/* internal system interface */
282*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ISAP INT64_C(0x0002000000000000)	/* system request parity err */
283*7c478bd9Sstevel@tonic-gate #define	C_AFSR_EMC  INT64_C(0x0001000000000000)	/* mtag   with   CE   error  */
284*7c478bd9Sstevel@tonic-gate #define	C_AFSR_EMU  INT64_C(0x0000800000000000)	/* mtag   with   UE   error  */
285*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IVC  INT64_C(0x0000400000000000)	/* intr vector with CE error */
286*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IVU  INT64_C(0x0000200000000000)	/* intr vector with UE error */
287*7c478bd9Sstevel@tonic-gate #define	C_AFSR_TO   INT64_C(0x0000100000000000)	/* bus timeout from sys bus  */
288*7c478bd9Sstevel@tonic-gate #define	C_AFSR_BERR INT64_C(0x0000080000000000)	/* bus error from system bus */
289*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UCC  INT64_C(0x0000040000000000)	/* E$ with software CE error */
290*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UCU  INT64_C(0x0000020000000000)	/* E$ with software UE error */
291*7c478bd9Sstevel@tonic-gate #define	C_AFSR_CPC  INT64_C(0x0000010000000000) /* copyout  with  CE  error  */
292*7c478bd9Sstevel@tonic-gate #define	C_AFSR_CPU  INT64_C(0x0000008000000000) /* copyout  with  UE  error  */
293*7c478bd9Sstevel@tonic-gate #define	C_AFSR_WDC  INT64_C(0x0000004000000000) /* writeback ecache CE error */
294*7c478bd9Sstevel@tonic-gate #define	C_AFSR_WDU  INT64_C(0x0000002000000000) /* writeback ecache UE error */
295*7c478bd9Sstevel@tonic-gate #define	C_AFSR_EDC  INT64_C(0x0000001000000000) /* ecache  CE  ECC  error    */
296*7c478bd9Sstevel@tonic-gate #define	C_AFSR_EDU  INT64_C(0x0000000800000000) /* ecache  UE  ECC  error    */
297*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UE   INT64_C(0x0000000400000000) /* uncorrectable ECC error   */
298*7c478bd9Sstevel@tonic-gate #define	C_AFSR_CE   INT64_C(0x0000000200000000) /* correctable   ECC error   */
299*7c478bd9Sstevel@tonic-gate #define	C_AFSR_M_SYND	INT64_C(0x00000000000f0000) /* mtag  ECC  syndrome   */
300*7c478bd9Sstevel@tonic-gate #define	C_AFSR_E_SYND	INT64_C(0x00000000000001ff) /* data  ECC  syndrome   */
301*7c478bd9Sstevel@tonic-gate 
302*7c478bd9Sstevel@tonic-gate /* AFSR bits that could result in CPU removal due to E$ error */
303*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L2_SERD_FAIL_UE	(C_AFSR_UCU | C_AFSR_CPU | C_AFSR_WDU | \
304*7c478bd9Sstevel@tonic-gate 				C_AFSR_EDU)
305*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L2_SERD_FAIL_CE	(C_AFSR_UCC | C_AFSR_CPC | C_AFSR_WDC | \
306*7c478bd9Sstevel@tonic-gate 				C_AFSR_EDC)
307*7c478bd9Sstevel@tonic-gate /*
308*7c478bd9Sstevel@tonic-gate  * Bits of the Panther Extended Asynchronous Fault Status Register (AFSR_EXT)
309*7c478bd9Sstevel@tonic-gate  *
310*7c478bd9Sstevel@tonic-gate  * +-----+-------+-----------+-------+-------+---------+------+------+------+
311*7c478bd9Sstevel@tonic-gate  * | rsv |RED_ERR|EFA_PAR_ERR|L3_MECC|L3_THCE|L3_TUE_SH|L3_TUE|L3_EDC|L3_EDU|
312*7c478bd9Sstevel@tonic-gate  * +-----+-------+-----------+-------+-------+---------+------+------+------+
313*7c478bd9Sstevel@tonic-gate  *  63:14   13        12        11       10       9        8      7      6
314*7c478bd9Sstevel@tonic-gate  *
315*7c478bd9Sstevel@tonic-gate  * +------+------+------+------+------+------+
316*7c478bd9Sstevel@tonic-gate  * |L3_UCC|L3_UCU|L3_CPC|L3_CPU|L3_WDC|L3_WDU|
317*7c478bd9Sstevel@tonic-gate  * +------+------+------+------+------+------+
318*7c478bd9Sstevel@tonic-gate  *     5      4      3      2      1      0
319*7c478bd9Sstevel@tonic-gate  *
320*7c478bd9Sstevel@tonic-gate  * If the L3_MECC bit is set along with any of the L3 cache errors (bits 0-7)
321*7c478bd9Sstevel@tonic-gate  * above, it indicates that an address parity error has occured.
322*7c478bd9Sstevel@tonic-gate  */
323*7c478bd9Sstevel@tonic-gate #define	C_AFSR_RED_ERR   INT64_C(0x0000000000002000) /* redunancy Efuse error */
324*7c478bd9Sstevel@tonic-gate #define	C_AFSR_EFA_PAR_ERR INT64_C(0x0000000000001000) /* Efuse parity error */
325*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_MECC   INT64_C(0x0000000000000800) /* L3 address parity */
326*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_THCE   INT64_C(0x0000000000000400) /* tag CE */
327*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_TUE_SH INT64_C(0x0000000000000200) /* tag UE from snp/cpy */
328*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_TUE    INT64_C(0x0000000000000100) /* tag UE */
329*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_EDC    INT64_C(0x0000000000000080) /* L3 cache CE */
330*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_EDU    INT64_C(0x0000000000000040) /* L3 cache UE */
331*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_UCC    INT64_C(0x0000000000000020) /* software recover CE */
332*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_UCU    INT64_C(0x0000000000000010) /* software recover UE */
333*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_CPC    INT64_C(0x0000000000000008) /* copyout with CE */
334*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_CPU    INT64_C(0x0000000000000004) /* copyout with UE */
335*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_WDC    INT64_C(0x0000000000000002) /* writeback CE */
336*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_WDU    INT64_C(0x0000000000000001) /* writeback UE */
337*7c478bd9Sstevel@tonic-gate 
338*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
339*7c478bd9Sstevel@tonic-gate /*
340*7c478bd9Sstevel@tonic-gate  * Bits of Jalapeno Asynchronous Fault Status Register
341*7c478bd9Sstevel@tonic-gate  *
342*7c478bd9Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
343*7c478bd9Sstevel@tonic-gate  * | rsv |JETO|SCE|JEIC|JEIT|ME|PRIV|JEIS|IERR|ISAP|ETP|OM|UMS|IVPE|TO|BERR|
344*7c478bd9Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
345*7c478bd9Sstevel@tonic-gate  * 63:58   57   56   55  54  53  52   51   50   49  48  47  46  45  44  43
346*7c478bd9Sstevel@tonic-gate  *
347*7c478bd9Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
348*7c478bd9Sstevel@tonic-gate  * |UCC|UCU|CPC|CPU|WDC|WDU|EDC|EDU|UE|CE|RUE|RCE|BP|WBP|FRC|FRU|
349*7c478bd9Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
350*7c478bd9Sstevel@tonic-gate  *   42  41  40  39  38  37  36  35 34 33 32  31  30 29  28  27
351*7c478bd9Sstevel@tonic-gate  *
352*7c478bd9Sstevel@tonic-gate  * +-----+-----+-----+------+-----------+-------+
353*7c478bd9Sstevel@tonic-gate  * | JREQ| ETW | rsv |B_SYND| rsv | AID | E_SYND|
354*7c478bd9Sstevel@tonic-gate  * +-----+-----+-----+------+-----+-----+-------+
355*7c478bd9Sstevel@tonic-gate  *  26:24 23:22 21:20  19:16 15:14 13:9   8:0
356*7c478bd9Sstevel@tonic-gate  *
357*7c478bd9Sstevel@tonic-gate  */
358*7c478bd9Sstevel@tonic-gate 
359*7c478bd9Sstevel@tonic-gate /*
360*7c478bd9Sstevel@tonic-gate  * Bits of Serrano Asynchronous Fault Status Register
361*7c478bd9Sstevel@tonic-gate  *
362*7c478bd9Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
363*7c478bd9Sstevel@tonic-gate  * | rsv |JETO|SCE|JEIC|JEIT|ME|PRIV|JEIS|IERR|ISAP|ETU|OM|UMS|IVPE|TO|BERR|
364*7c478bd9Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
365*7c478bd9Sstevel@tonic-gate  * 63:58   57   56   55  54  53  52   51   50   49  48  47  46  45  44  43
366*7c478bd9Sstevel@tonic-gate  *
367*7c478bd9Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
368*7c478bd9Sstevel@tonic-gate  * |UCC|UCU|CPC|CPU|WDC|WDU|EDC|EDU|UE|CE|RUE|RCE|BP|WBP|FRC|FRU|
369*7c478bd9Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
370*7c478bd9Sstevel@tonic-gate  *   42  41  40  39  38  37  36  35 34 33 32  31  30 29  28  27
371*7c478bd9Sstevel@tonic-gate  *
372*7c478bd9Sstevel@tonic-gate  * +-----+-----+------+---+------+---+---+-----+-------+
373*7c478bd9Sstevel@tonic-gate  * | JREQ| ETW | EFES |ETS|B_SYND|ETI|ETC| AID | E_SYND|
374*7c478bd9Sstevel@tonic-gate  * +-----+-----+------+---+------+---+---+-----+-------+
375*7c478bd9Sstevel@tonic-gate  *  26:24 23:22    21   20  19:16  15  14  13:9    8:0
376*7c478bd9Sstevel@tonic-gate  *
377*7c478bd9Sstevel@tonic-gate  */
378*7c478bd9Sstevel@tonic-gate 
379*7c478bd9Sstevel@tonic-gate #define	C_AFSR_JETO	INT64_C(0x0200000000000000) /* JBus Timeout */
380*7c478bd9Sstevel@tonic-gate #define	C_AFSR_SCE	INT64_C(0x0100000000000000) /* Snoop parity error */
381*7c478bd9Sstevel@tonic-gate #define	C_AFSR_JEIC	INT64_C(0x0080000000000000) /* JBus Illegal Cmd */
382*7c478bd9Sstevel@tonic-gate #define	C_AFSR_JEIT	INT64_C(0x0040000000000000) /* Illegal ADTYPE */
383*7c478bd9Sstevel@tonic-gate #define	C_AFSR_JEIS	INT64_C(0x0008000000000000) /* Illegal Install State */
384*7c478bd9Sstevel@tonic-gate #if defined(SERRANO)
385*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ETU	INT64_C(0x0001000000000000) /* L2$ tag CE error */
386*7c478bd9Sstevel@tonic-gate #elif defined(JALAPENO)
387*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ETP	INT64_C(0x0001000000000000) /* L2$ tag parity error */
388*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO */
389*7c478bd9Sstevel@tonic-gate #define	C_AFSR_OM	INT64_C(0x0000800000000000) /* out of range mem error */
390*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UMS	INT64_C(0x0000400000000000) /* Unsupported store */
391*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IVPE	INT64_C(0x0000200000000000) /* intr vector parity err */
392*7c478bd9Sstevel@tonic-gate #define	C_AFSR_RUE	INT64_C(0x0000000100000000) /* remote mem UE error */
393*7c478bd9Sstevel@tonic-gate #define	C_AFSR_RCE	INT64_C(0x0000000080000000) /* remote mem CE error */
394*7c478bd9Sstevel@tonic-gate #define	C_AFSR_BP	INT64_C(0x0000000040000000) /* read data parity err */
395*7c478bd9Sstevel@tonic-gate #define	C_AFSR_WBP	INT64_C(0x0000000020000000) /* wb/bs data parity err */
396*7c478bd9Sstevel@tonic-gate #define	C_AFSR_FRC	INT64_C(0x0000000010000000) /* foregin mem CE error */
397*7c478bd9Sstevel@tonic-gate #define	C_AFSR_FRU	INT64_C(0x0000000008000000) /* foregin mem UE error */
398*7c478bd9Sstevel@tonic-gate #define	C_AFSR_JREQ	INT64_C(0x0000000007000000) /* Active JBus req at err */
399*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ETW	INT64_C(0x0000000000c00000) /* AID causing UE/CE */
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate #if defined(SERRANO)
402*7c478bd9Sstevel@tonic-gate #define	C_AFSR_EFES	INT64_C(0x0000000000200000) /* E-fuse error summary */
403*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ETS	INT64_C(0x0000000000100000) /* L2$ tag SRAM stuck-at */
404*7c478bd9Sstevel@tonic-gate #endif /* SERRANO */
405*7c478bd9Sstevel@tonic-gate 
406*7c478bd9Sstevel@tonic-gate #define	C_AFSR_B_SYND	INT64_C(0x00000000000f0000) /* jbus parity syndrome */
407*7c478bd9Sstevel@tonic-gate 
408*7c478bd9Sstevel@tonic-gate #if defined(SERRANO)
409*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ETI	INT64_C(0x0000000000008000) /* L2$ tag intermittent */
410*7c478bd9Sstevel@tonic-gate #define	C_AFSR_ETC	INT64_C(0x0000000000004000) /* L2$ tag CE */
411*7c478bd9Sstevel@tonic-gate #endif /* SERRANO */
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate #define	C_AFSR_AID	INT64_C(0x0000000000003e00) /* AID causing UE/CE */
414*7c478bd9Sstevel@tonic-gate 
415*7c478bd9Sstevel@tonic-gate /* bit shifts for selected errors */
416*7c478bd9Sstevel@tonic-gate #define	C_AFSR_WDU_SHIFT	37
417*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UCU_SHIFT	41
418*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UCC_SHIFT	42
419*7c478bd9Sstevel@tonic-gate #define	C_AFSR_JREQ_SHIFT	24
420*7c478bd9Sstevel@tonic-gate #define	C_AFSR_AID_SHIFT	9
421*7c478bd9Sstevel@tonic-gate 
422*7c478bd9Sstevel@tonic-gate /*
423*7c478bd9Sstevel@tonic-gate  * Overloaded AFSR fields. During error processing, some of the reserved
424*7c478bd9Sstevel@tonic-gate  * fields within the saved AFSR are overwritten with extra information.
425*7c478bd9Sstevel@tonic-gate  */
426*7c478bd9Sstevel@tonic-gate #define	C_AFSR_PANIC_SHIFT		62
427*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IPE_SHIFT		59
428*7c478bd9Sstevel@tonic-gate #define	C_AFSR_DPE_SHIFT		58
429*7c478bd9Sstevel@tonic-gate 
430*7c478bd9Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
431*7c478bd9Sstevel@tonic-gate 
432*7c478bd9Sstevel@tonic-gate /* bit shifts for selected errors */
433*7c478bd9Sstevel@tonic-gate #define	C_AFSR_WDU_SHIFT	37
434*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UCU_SHIFT	41
435*7c478bd9Sstevel@tonic-gate #define	C_AFSR_UCC_SHIFT	42
436*7c478bd9Sstevel@tonic-gate #define	C_AFSR_L3_UCU_SHIFT	4
437*7c478bd9Sstevel@tonic-gate 
438*7c478bd9Sstevel@tonic-gate /*
439*7c478bd9Sstevel@tonic-gate  * Overloaded AFSR fields. During error processing, some of the reserved fields
440*7c478bd9Sstevel@tonic-gate  * within the saved AFSR are overwritten with extra information.
441*7c478bd9Sstevel@tonic-gate  */
442*7c478bd9Sstevel@tonic-gate #define	C_AFSR_FIRSTFLT_SHIFT	63
443*7c478bd9Sstevel@tonic-gate #define	C_AFSR_PANIC_SHIFT	30
444*7c478bd9Sstevel@tonic-gate #define	C_AFSR_DPE_SHIFT	20
445*7c478bd9Sstevel@tonic-gate #define	C_AFSR_IPE_SHIFT	21
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
448*7c478bd9Sstevel@tonic-gate 
449*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
450*7c478bd9Sstevel@tonic-gate /*
451*7c478bd9Sstevel@tonic-gate  * Jalapeno L2 Cache Control Register Bits.
452*7c478bd9Sstevel@tonic-gate  *
453*7c478bd9Sstevel@tonic-gate  *	Bit#	Name		Description
454*7c478bd9Sstevel@tonic-gate  *	63-24	-		reserved
455*7c478bd9Sstevel@tonic-gate  *	23:20	EC_ACT_WAY	(read only) indicates which sets are present
456*7c478bd9Sstevel@tonic-gate  *	19:16	EC_BLK_WAY	Bit mask indicating which sets are blocked
457*7c478bd9Sstevel@tonic-gate  *				from replacement
458*7c478bd9Sstevel@tonic-gate  *	15:14	EC_SIZE		L2 cache size
459*7c478bd9Sstevel@tonic-gate  *	13:12	-		reserved
460*7c478bd9Sstevel@tonic-gate  *	11	EC_PAR_EN	Enables parity checking on L2 cache tags
461*7c478bd9Sstevel@tonic-gate  *	10	EC_ECC_EN	Enables ECC checking on L2 cache data
462*7c478bd9Sstevel@tonic-gate  *	9	EC_ECC_FORCE	Enables EC_CHECK[8:0] onto L2 cache ECC bits
463*7c478bd9Sstevel@tonic-gate  *	8:0	EC_CHECK	ECC check vector to force onto ECC bits
464*7c478bd9Sstevel@tonic-gate  */
465*7c478bd9Sstevel@tonic-gate 
466*7c478bd9Sstevel@tonic-gate #define	JP_ECCTRL_ECSIZE_MASK		0xc000
467*7c478bd9Sstevel@tonic-gate #define	JP_ECCTRL_ECSIZE_SHIFT		14
468*7c478bd9Sstevel@tonic-gate #define	JP_ECCTRL_ECSIZE_MIN		0x80000
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate /*
471*7c478bd9Sstevel@tonic-gate  * Jalapeno L2 Cache Error Enable Register Bits
472*7c478bd9Sstevel@tonic-gate  *
473*7c478bd9Sstevel@tonic-gate  *	Bit#	Name	Description
474*7c478bd9Sstevel@tonic-gate  *	63-33	-	reserved
475*7c478bd9Sstevel@tonic-gate  *	32	SCDE	Enable detection of JBUS control parity error
476*7c478bd9Sstevel@tonic-gate  *	31:24	-	reserved
477*7c478bd9Sstevel@tonic-gate  *	23	IAEN	Enable trap on illegal physical address
478*7c478bd9Sstevel@tonic-gate  *	22	IERREN	Enable FERR system reset on CPU internal errors
479*7c478bd9Sstevel@tonic-gate  *	21	PERREN	Enable FERR system reset on JBUS protocol errors
480*7c478bd9Sstevel@tonic-gate  *	20	SCEN	Enable FERR system reset on JBUS control parity error
481*7c478bd9Sstevel@tonic-gate  *	19:11	FMED	Forced error on the memory ECC
482*7c478bd9Sstevel@tonic-gate  *	10	FME	Force error on memory ECC
483*7c478bd9Sstevel@tonic-gate  *	9:6	FPD	Bits to use when FSP forces JBUS addr/data parity error
484*7c478bd9Sstevel@tonic-gate  *	5	FSP	Force error on outgoing JBUS addr/data parity
485*7c478bd9Sstevel@tonic-gate  *	4	ETPEN	Enable FERR system reset on L2 tags parity error
486*7c478bd9Sstevel@tonic-gate  *	3	UCEEN	Enable trap on SW handled external cache error
487*7c478bd9Sstevel@tonic-gate  *	2	ISAPEN	Enable FERR system reset on request parity error
488*7c478bd9Sstevel@tonic-gate  *	1	NCEEN	Enable trap on uncorrectable ECC error and system err
489*7c478bd9Sstevel@tonic-gate  *	0	CEEN	Enable trap on correctable ECC errors
490*7c478bd9Sstevel@tonic-gate  */
491*7c478bd9Sstevel@tonic-gate 
492*7c478bd9Sstevel@tonic-gate #define	EN_REG_UCEEN	INT64_C(0x0000000000000008) /* enable UCC,UCU */
493*7c478bd9Sstevel@tonic-gate #define	EN_REG_ISAPEN	INT64_C(0x0000000000000004) /* enable ISAP */
494*7c478bd9Sstevel@tonic-gate #define	EN_REG_NCEEN INT64_C(0x0000000000000002) /* UE,EDU,WDU,BERR,IVU,EMU */
495*7c478bd9Sstevel@tonic-gate #define	EN_REG_CEEN INT64_C(0x0000000000000001) /* enable CE,EDC,WDC,IVC,EMC */
496*7c478bd9Sstevel@tonic-gate 
497*7c478bd9Sstevel@tonic-gate #define	EN_REG_DISABLE	INT64_C(0x0000000000000000) /* no errors enabled */
498*7c478bd9Sstevel@tonic-gate #define	EN_REG_ECC_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN)
499*7c478bd9Sstevel@tonic-gate #define	EN_REG_CE_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN)
500*7c478bd9Sstevel@tonic-gate #define	EN_REG_ENABLE \
501*7c478bd9Sstevel@tonic-gate 	(EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN | EN_REG_CEEN)
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
504*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
505*7c478bd9Sstevel@tonic-gate /*
506*7c478bd9Sstevel@tonic-gate  * Cheetah+ External Cache Control Register Bits.
507*7c478bd9Sstevel@tonic-gate  */
508*7c478bd9Sstevel@tonic-gate #define	ECCR_ASSOC	INT64_C(0x0000000001000000) /* Ecache Assoc. */
509*7c478bd9Sstevel@tonic-gate #define	ECCR_ASSOC_SHIFT	24
510*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
511*7c478bd9Sstevel@tonic-gate 
512*7c478bd9Sstevel@tonic-gate /*
513*7c478bd9Sstevel@tonic-gate  * Bits of Cheetah External Cache Error Enable Register
514*7c478bd9Sstevel@tonic-gate  *
515*7c478bd9Sstevel@tonic-gate  * +-----+-----+-------+-----+-------+-------+--------+-------+------+
516*7c478bd9Sstevel@tonic-gate  * | rsv | FMT | FMECC | FMD | FDECC | UCEEN | ISAPEN | NCEEN | CEEN |
517*7c478bd9Sstevel@tonic-gate  * +-----+-----+-------+-----+-------+-------+--------+-------+------+
518*7c478bd9Sstevel@tonic-gate  *  63:19   18  17  14    13    12:4     3        2       1       0
519*7c478bd9Sstevel@tonic-gate  *
520*7c478bd9Sstevel@tonic-gate  */
521*7c478bd9Sstevel@tonic-gate #define	EN_REG_FMT	INT64_C(0x0000000000040000) /* force system mtag ECC */
522*7c478bd9Sstevel@tonic-gate #define	EN_REG_FMECC	INT64_C(0x000000000003C000) /* forced mtag ECC vector */
523*7c478bd9Sstevel@tonic-gate #define	EN_REG_FMD	INT64_C(0x0000000000002000) /* force system data ECC */
524*7c478bd9Sstevel@tonic-gate #define	EN_REG_FDECC	INT64_C(0x0000000000001ff0) /* forced data ECC vector */
525*7c478bd9Sstevel@tonic-gate #define	EN_REG_UCEEN	INT64_C(0x0000000000000008) /* enable UCC,UCU */
526*7c478bd9Sstevel@tonic-gate #define	EN_REG_ISAPEN	INT64_C(0x0000000000000004) /* enable ISAP */
527*7c478bd9Sstevel@tonic-gate #define	EN_REG_NCEEN INT64_C(0x0000000000000002) /* UE,EDU,WDU,BERR,IVU,EMU */
528*7c478bd9Sstevel@tonic-gate #define	EN_REG_CEEN INT64_C(0x0000000000000001) /* enable CE,EDC,WDC,IVC,EMC */
529*7c478bd9Sstevel@tonic-gate #define	EN_REG_DISABLE	INT64_C(0x0000000000000000) /* no errors enabled */
530*7c478bd9Sstevel@tonic-gate #define	EN_REG_ECC_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN)
531*7c478bd9Sstevel@tonic-gate #define	EN_REG_CE_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN)
532*7c478bd9Sstevel@tonic-gate #define	EN_REG_ENABLE \
533*7c478bd9Sstevel@tonic-gate 	(EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN | EN_REG_CEEN)
534*7c478bd9Sstevel@tonic-gate #endif	/* JALAPENO || SERRANO */
535*7c478bd9Sstevel@tonic-gate 
536*7c478bd9Sstevel@tonic-gate /*
537*7c478bd9Sstevel@tonic-gate  * bit shifts for selected bits
538*7c478bd9Sstevel@tonic-gate  */
539*7c478bd9Sstevel@tonic-gate #define	EN_REG_CEEN_SHIFT	0
540*7c478bd9Sstevel@tonic-gate 
541*7c478bd9Sstevel@tonic-gate /* Cheetah/Cheetah+ Dcache size */
542*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_SIZE		0x10000
543*7c478bd9Sstevel@tonic-gate 
544*7c478bd9Sstevel@tonic-gate /* Cheetah/Cheetah+ Dcache linesize */
545*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_LSIZE		0x20
546*7c478bd9Sstevel@tonic-gate 
547*7c478bd9Sstevel@tonic-gate /* Cheetah/Cheetah+/Jaguar Icache size */
548*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_SIZE		0x8000
549*7c478bd9Sstevel@tonic-gate 
550*7c478bd9Sstevel@tonic-gate /* Cheetah/Cheetah+/Jaguar Icache linesize */
551*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_LSIZE		0x20
552*7c478bd9Sstevel@tonic-gate 
553*7c478bd9Sstevel@tonic-gate /* Panther Icache size */
554*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_SIZE		0x10000
555*7c478bd9Sstevel@tonic-gate 
556*7c478bd9Sstevel@tonic-gate /* Panther Icache linesize */
557*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_LSIZE		0x40
558*7c478bd9Sstevel@tonic-gate 
559*7c478bd9Sstevel@tonic-gate /* Pcache size for the cheetah family of CPUs */
560*7c478bd9Sstevel@tonic-gate #define	CH_PCACHE_SIZE		0x800
561*7c478bd9Sstevel@tonic-gate 
562*7c478bd9Sstevel@tonic-gate /* Pcache linesize  for the cheetah family of CPUs */
563*7c478bd9Sstevel@tonic-gate #define	CH_PCACHE_LSIZE		0x40
564*7c478bd9Sstevel@tonic-gate 
565*7c478bd9Sstevel@tonic-gate /*
566*7c478bd9Sstevel@tonic-gate  * The cheetah+ CPU module handles Cheetah+, Jaguar, and Panther so
567*7c478bd9Sstevel@tonic-gate  * we have to pick max size and min linesize values for the Icache
568*7c478bd9Sstevel@tonic-gate  * accordingly.
569*7c478bd9Sstevel@tonic-gate  */
570*7c478bd9Sstevel@tonic-gate #define	CHP_ICACHE_MAX_SIZE	PN_ICACHE_SIZE
571*7c478bd9Sstevel@tonic-gate #define	CHP_ICACHE_MIN_LSIZE	CH_ICACHE_LSIZE
572*7c478bd9Sstevel@tonic-gate 
573*7c478bd9Sstevel@tonic-gate /*
574*7c478bd9Sstevel@tonic-gate  * The minimum size needed to ensure consistency on a virtually address
575*7c478bd9Sstevel@tonic-gate  * cache.  Computed by taking the largest virtually indexed cache and dividing
576*7c478bd9Sstevel@tonic-gate  * by its associativity.
577*7c478bd9Sstevel@tonic-gate  */
578*7c478bd9Sstevel@tonic-gate #define	CH_VAC_SIZE		0x4000
579*7c478bd9Sstevel@tonic-gate 
580*7c478bd9Sstevel@tonic-gate /*
581*7c478bd9Sstevel@tonic-gate  * The following definitions give the syndromes that will be seen when attempts
582*7c478bd9Sstevel@tonic-gate  * are made to read data that has been intentionally poisoned.  Intentional
583*7c478bd9Sstevel@tonic-gate  * poisoning is performed when an error has been detected, and is designed to
584*7c478bd9Sstevel@tonic-gate  * allow software to effectively distinguish between root problems and secondary
585*7c478bd9Sstevel@tonic-gate  * effects.  The following syndromes and their descriptions are taken from the
586*7c478bd9Sstevel@tonic-gate  * UltraSPARC-III Cu Error Manual, Section 5.4.3.1.
587*7c478bd9Sstevel@tonic-gate  */
588*7c478bd9Sstevel@tonic-gate 
589*7c478bd9Sstevel@tonic-gate /*
590*7c478bd9Sstevel@tonic-gate  * For a DSTAT = 2 or 3 event (see Sec 5.3.4.4) from the system bus for a
591*7c478bd9Sstevel@tonic-gate  * cacheable load, data bits [1:0] are inverted in the data stored in the
592*7c478bd9Sstevel@tonic-gate  * L2-cache.  The syndrome seen when one of these signalling words is read will
593*7c478bd9Sstevel@tonic-gate  * be 0x11c.
594*7c478bd9Sstevel@tonic-gate  */
595*7c478bd9Sstevel@tonic-gate #define	CH_POISON_SYND_FROM_DSTAT23	0x11c
596*7c478bd9Sstevel@tonic-gate 
597*7c478bd9Sstevel@tonic-gate /*
598*7c478bd9Sstevel@tonic-gate  * For an uncorrectable data ECC error from the L2-cache, data bits [127:126]
599*7c478bd9Sstevel@tonic-gate  * are inverted in data sent to the system bus as part of a writeback or
600*7c478bd9Sstevel@tonic-gate  * copyout.  The syndrome seen when one of these signalling words is read will
601*7c478bd9Sstevel@tonic-gate  * be 0x071.
602*7c478bd9Sstevel@tonic-gate  */
603*7c478bd9Sstevel@tonic-gate #define	CH_POISON_SYND_FROM_XXU_WRITE	0x71
604*7c478bd9Sstevel@tonic-gate 
605*7c478bd9Sstevel@tonic-gate /*
606*7c478bd9Sstevel@tonic-gate  * For uncorrectable data ECC error on the L2-cache read done to complete a
607*7c478bd9Sstevel@tonic-gate  * store merge event, where bytes written by the processor are merged with
608*7c478bd9Sstevel@tonic-gate  * bytes from an L2-cache line, ECC check bits [1:0] are inverted in the data
609*7c478bd9Sstevel@tonic-gate  * scrubbed back to the L2-cache.  The syndrome seen when one of these
610*7c478bd9Sstevel@tonic-gate  * signalling words is read will be 0x003.
611*7c478bd9Sstevel@tonic-gate  */
612*7c478bd9Sstevel@tonic-gate #define	CH_POISON_SYND_FROM_XXU_WRMERGE	0x3
613*7c478bd9Sstevel@tonic-gate 
614*7c478bd9Sstevel@tonic-gate /*
615*7c478bd9Sstevel@tonic-gate  * To help understand the following definitions, this block of comments
616*7c478bd9Sstevel@tonic-gate  * provides information on Cheetah's E$.
617*7c478bd9Sstevel@tonic-gate  *
618*7c478bd9Sstevel@tonic-gate  * Cheetah supports three different E$ sizes (1MB, 4MB, and 8MB). The
619*7c478bd9Sstevel@tonic-gate  * number of E$ lines remains constant regardless of the size of the E$
620*7c478bd9Sstevel@tonic-gate  * as does the subblock size, however the number of 64-byte subblocks per
621*7c478bd9Sstevel@tonic-gate  * line varies depending on the E$ size.
622*7c478bd9Sstevel@tonic-gate  *
623*7c478bd9Sstevel@tonic-gate  * An E$ tag (for an E$ line) contains an EC_tag field, corresponding to the
624*7c478bd9Sstevel@tonic-gate  * high order physical address bits of that E$ line's contents, and 1 to 8
625*7c478bd9Sstevel@tonic-gate  * EC_state fields, indicating the state of each subblock. Due to the E$ line
626*7c478bd9Sstevel@tonic-gate  * size variance depending on the total size of the E$, the number of bits in
627*7c478bd9Sstevel@tonic-gate  * the EC_tag field varies as does the number of subblocks (and EC_state
628*7c478bd9Sstevel@tonic-gate  * fields) per E$ line.
629*7c478bd9Sstevel@tonic-gate  *
630*7c478bd9Sstevel@tonic-gate  * A 1MB E$ has a line size of 64 bytes, containing 1 subblock per line.
631*7c478bd9Sstevel@tonic-gate  * A 4MB E$ has a line size of 256 bytes, containing 4 subblocks per line.
632*7c478bd9Sstevel@tonic-gate  * An 8MB E$ has a line size of 512 bytes, containing 8 subblocks per line.
633*7c478bd9Sstevel@tonic-gate  *
634*7c478bd9Sstevel@tonic-gate  * An E$ tag for a particular E$ line can be read via a diagnostic ASI
635*7c478bd9Sstevel@tonic-gate  * as a 64-bit value.
636*7c478bd9Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_tag field is interpreted as follows:
637*7c478bd9Sstevel@tonic-gate  *	- for a 1MB E$, the EC_tag is in bits <43:21> and corresponds
638*7c478bd9Sstevel@tonic-gate  *		to physical address bits <42:20> (bits <41:19> for Cheetah+)
639*7c478bd9Sstevel@tonic-gate  *	- for a 4MB E$, the EC_tag is in bits <43:23> and corresponds
640*7c478bd9Sstevel@tonic-gate  *		to physical address bits <42:22> (bits <41:21> for Cheetah+)
641*7c478bd9Sstevel@tonic-gate  *	- for an 8MB E$, the EC_tag is in bits <43:24> and corresponds
642*7c478bd9Sstevel@tonic-gate  *		to physical address bits <42:23> (bits <41:22> for Cheetah+)
643*7c478bd9Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_state field(s) is(are) interpreted
644*7c478bd9Sstevel@tonic-gate  * as follows:
645*7c478bd9Sstevel@tonic-gate  *	- for a 1MB E$, EC_state0 is in bits <2:0>
646*7c478bd9Sstevel@tonic-gate  *	- for a 4MB E$, EC_state0 is in bits <2:0>, EC_state1 is in
647*7c478bd9Sstevel@tonic-gate  *		bits <5:3>, EC_state2 is in bits <8:6>, EC_state3 is
648*7c478bd9Sstevel@tonic-gate  *		in bits <11:9>
649*7c478bd9Sstevel@tonic-gate  *	- for an 8MB E$, EC_state0 is in bits <2:0>, EC_state1 is in
650*7c478bd9Sstevel@tonic-gate  *		bits <5:3>, EC_state2 is in bits <8:6>, EC_state3 is
651*7c478bd9Sstevel@tonic-gate  *		in bits <11:9>, EC_state4 is in bits <14:12>, EC_state5
652*7c478bd9Sstevel@tonic-gate  *		is in bits <17:15>, EC_state6 is in bits <20:18>,
653*7c478bd9Sstevel@tonic-gate  *		EC_state7 is in bits <23:21>
654*7c478bd9Sstevel@tonic-gate  * Note that each EC_state field contains a value representing the state
655*7c478bd9Sstevel@tonic-gate  * of its corresponding subblock.
656*7c478bd9Sstevel@tonic-gate  *
657*7c478bd9Sstevel@tonic-gate  */
658*7c478bd9Sstevel@tonic-gate /*
659*7c478bd9Sstevel@tonic-gate  * Jaguar changes from Cheetah/Cheetah+ Ecache:
660*7c478bd9Sstevel@tonic-gate  *
661*7c478bd9Sstevel@tonic-gate  * The Jaguar Ecache is similiar to that used for Cheetah/Cheetah+ with a
662*7c478bd9Sstevel@tonic-gate  * couple of differences :
663*7c478bd9Sstevel@tonic-gate  *	- Jaguar Ecache only comes in 4MB and 8MB versions.
664*7c478bd9Sstevel@tonic-gate  *		- 8MB E$ has 2 64 byte subblocks per line.
665*7c478bd9Sstevel@tonic-gate  *		- 4MB E$ has 1 64 byte subblock per line.
666*7c478bd9Sstevel@tonic-gate  *
667*7c478bd9Sstevel@tonic-gate  * An E$ tag for a particular E$ line can be read via a diagnostic ASI
668*7c478bd9Sstevel@tonic-gate  * as a 64-bit value.
669*7c478bd9Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_tag field is interpreted as follows:
670*7c478bd9Sstevel@tonic-gate  *	- for a 4MB E$, the EC_tag is in bits <41:21> and corresponds
671*7c478bd9Sstevel@tonic-gate  *		to physical address bits <41:21>
672*7c478bd9Sstevel@tonic-gate  *	- for a 8MB E$, the EC_tag is in bits <41:22> and corresponds
673*7c478bd9Sstevel@tonic-gate  *		to physical address bits <41:22>
674*7c478bd9Sstevel@tonic-gate  *
675*7c478bd9Sstevel@tonic-gate  * The Jaguar E$ tag also contains LRU field in bit <42> which must be
676*7c478bd9Sstevel@tonic-gate  * masked off when the tag value is being compared to a PA.
677*7c478bd9Sstevel@tonic-gate  *
678*7c478bd9Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_state field(s) is(are) interpreted
679*7c478bd9Sstevel@tonic-gate  * as follows:
680*7c478bd9Sstevel@tonic-gate  *	- for 4MB E$, EC_state0 is in bits <2:0>
681*7c478bd9Sstevel@tonic-gate  *	- for 8MB E$, EC_state0 is in bits <2:0>, EC_state1 is in bits <5:3>.
682*7c478bd9Sstevel@tonic-gate  * Each EC_state field contains a value representing the state of its
683*7c478bd9Sstevel@tonic-gate  * corresponding subblock.
684*7c478bd9Sstevel@tonic-gate  *
685*7c478bd9Sstevel@tonic-gate  * Note that the subblock size and state values are the same for both
686*7c478bd9Sstevel@tonic-gate  * Cheetah/Cheetah+ and Jaguar.
687*7c478bd9Sstevel@tonic-gate  */
688*7c478bd9Sstevel@tonic-gate 
689*7c478bd9Sstevel@tonic-gate /* Ecache sizes */
690*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_8M_SIZE	0x800000
691*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_4M_SIZE	0x400000
692*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_1M_SIZE	0x100000
693*7c478bd9Sstevel@tonic-gate 
694*7c478bd9Sstevel@tonic-gate #define	PN_L2_SIZE		0x200000
695*7c478bd9Sstevel@tonic-gate #define	PN_L2_LINESIZE		64
696*7c478bd9Sstevel@tonic-gate #define	PN_L2_ECC_WORDS		2
697*7c478bd9Sstevel@tonic-gate #define	PN_L2_NWAYS		4
698*7c478bd9Sstevel@tonic-gate #define	PN_L2_SET_SIZE		(PN_L2_SIZE / PN_L2_NWAYS)
699*7c478bd9Sstevel@tonic-gate #define	PN_L2_MAX_SET		(PN_L2_SIZE - PN_L2_SET_SIZE)
700*7c478bd9Sstevel@tonic-gate #define	PN_L2_DATA_ECC_SEL	0x200000 /* bit 21 selects ECC */
701*7c478bd9Sstevel@tonic-gate #define	PN_L2_ECC_LO_REG	0x20 /* bit 5 set for L2 tag access */
702*7c478bd9Sstevel@tonic-gate #define	PN_L2_INDEX_MASK	0x7ffc0 /* bits 18:6 */
703*7c478bd9Sstevel@tonic-gate #define	PN_L2_WAY_INCR		0x80000	/* l2-ec-way = <20:19> */
704*7c478bd9Sstevel@tonic-gate #define	PN_L2_WAY_LIM		INT64_C(0x200000)
705*7c478bd9Sstevel@tonic-gate #define	PN_L2_WAY_SHIFT		19
706*7c478bd9Sstevel@tonic-gate 
707*7c478bd9Sstevel@tonic-gate #define	PN_L3_SIZE		0x2000000
708*7c478bd9Sstevel@tonic-gate #define	PN_L3_LINESIZE		64
709*7c478bd9Sstevel@tonic-gate #define	PN_L3_NWAYS		4
710*7c478bd9Sstevel@tonic-gate #define	PN_L3_SET_SIZE		(PN_L3_SIZE / PN_L3_NWAYS)
711*7c478bd9Sstevel@tonic-gate #define	PN_L3_MAX_SET		(PN_L3_SIZE - PN_L3_SET_SIZE)
712*7c478bd9Sstevel@tonic-gate #define	PN_L3_WAY_SHIFT		23
713*7c478bd9Sstevel@tonic-gate #define	PN_L3_TAG_RD_MASK	0x7fffc0	/* ec_tag = PA<22:6>  */
714*7c478bd9Sstevel@tonic-gate #define	PN_L3_WAY_INCR		0x800000	/* ec_way = <24:23> */
715*7c478bd9Sstevel@tonic-gate #define	PN_L3_WAY_LIM		INT64_C(0x2000000)
716*7c478bd9Sstevel@tonic-gate 
717*7c478bd9Sstevel@tonic-gate /* Pcache Defines */
718*7c478bd9Sstevel@tonic-gate #define	PN_PCACHE_ADDR_MASK	0x1c0		/* PC_addr = <8:6> */
719*7c478bd9Sstevel@tonic-gate #define	PN_PCACHE_WAY_INCR	0x200		/* PC_way = <10:9> */
720*7c478bd9Sstevel@tonic-gate #define	PN_PCACHE_WORD_SHIFT	3		/* PC_dbl_word = <5:3> */
721*7c478bd9Sstevel@tonic-gate #define	PN_PCACHE_NWAYS		4
722*7c478bd9Sstevel@tonic-gate 
723*7c478bd9Sstevel@tonic-gate /* Cheetah Ecache is direct-mapped, Cheetah+ can be 2-way or direct-mapped */
724*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_NWAY		1
725*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
726*7c478bd9Sstevel@tonic-gate #define	CHP_ECACHE_NWAY		2
727*7c478bd9Sstevel@tonic-gate #define	PN_ECACHE_NWAY		4
728*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
729*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
730*7c478bd9Sstevel@tonic-gate #define	JP_ECACHE_NWAY		4
731*7c478bd9Sstevel@tonic-gate #define	JP_ECACHE_NWAY_SHIFT	2
732*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
733*7c478bd9Sstevel@tonic-gate 
734*7c478bd9Sstevel@tonic-gate /* Maximum Ecache size */
735*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_MAX_SIZE	CH_ECACHE_8M_SIZE
736*7c478bd9Sstevel@tonic-gate 
737*7c478bd9Sstevel@tonic-gate /* Minimum Ecache line size */
738*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_MIN_LSIZE	64
739*7c478bd9Sstevel@tonic-gate 
740*7c478bd9Sstevel@tonic-gate /* Maximum Ecache line size - 8Mb Ecache has 512 byte linesize */
741*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_MAX_LSIZE	512
742*7c478bd9Sstevel@tonic-gate 
743*7c478bd9Sstevel@tonic-gate /* Size of Ecache data staging register size (see Cheetah PRM 10.7.2) */
744*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_STGREG_SIZE	32
745*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_STGREG_TOTALSIZE	40	/* data regs + ecc */
746*7c478bd9Sstevel@tonic-gate 
747*7c478bd9Sstevel@tonic-gate /* The number of staging registers containing data, for ASI_EC_DATA */
748*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_STGREG_NUM	(CH_ECACHE_STGREG_SIZE / sizeof (uint64_t))
749*7c478bd9Sstevel@tonic-gate 
750*7c478bd9Sstevel@tonic-gate /* Size of Ecache data subblock which has state field in Ecache tag */
751*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_SUBBLK_SIZE	64
752*7c478bd9Sstevel@tonic-gate #define	CH_ECACHE_SUBBLK_SHIFT	6
753*7c478bd9Sstevel@tonic-gate 
754*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
755*7c478bd9Sstevel@tonic-gate #define	JP_ECACHE_MAX_LSIZE	CH_ECACHE_SUBBLK_SIZE
756*7c478bd9Sstevel@tonic-gate #define	JP_ECACHE_MAX_SIZE	0x400000
757*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
758*7c478bd9Sstevel@tonic-gate 
759*7c478bd9Sstevel@tonic-gate /*
760*7c478bd9Sstevel@tonic-gate  * Maximum ecache setsize to support page coloring of heterogenous
761*7c478bd9Sstevel@tonic-gate  * cheetah+ cpus. Max ecache setsize is calculated to be the max ecache size
762*7c478bd9Sstevel@tonic-gate  * divided by the minimum associativity of the max ecache.
763*7c478bd9Sstevel@tonic-gate  *
764*7c478bd9Sstevel@tonic-gate  * NOTE: CHP_ECACHE_MAX_SIZE and CHP_ECACHE_MIN_NWAY need to be updated with
765*7c478bd9Sstevel@tonic-gate  * new cheetah+ cpus. The maximum setsize may not necessarily be associated with
766*7c478bd9Sstevel@tonic-gate  * the max ecache size if the cache associativity is large. If so, MAX_SETSIZE
767*7c478bd9Sstevel@tonic-gate  * needs to be updated accordingly.
768*7c478bd9Sstevel@tonic-gate  */
769*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
770*7c478bd9Sstevel@tonic-gate #define	CHP_ECACHE_MIN_NWAY	1	/* direct-mapped */
771*7c478bd9Sstevel@tonic-gate #define	CHP_ECACHE_MAX_SIZE	CH_ECACHE_MAX_SIZE
772*7c478bd9Sstevel@tonic-gate #define	CHP_ECACHE_MAX_SETSIZE	(CHP_ECACHE_MAX_SIZE / CHP_ECACHE_MIN_NWAY)
773*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
774*7c478bd9Sstevel@tonic-gate 
775*7c478bd9Sstevel@tonic-gate /*
776*7c478bd9Sstevel@tonic-gate  * Bits to shift EC_tag field of E$ tag to form PA
777*7c478bd9Sstevel@tonic-gate  * (See Cheetah PRM 10.7.4, Cheetah+ Delta PRM 10.7)
778*7c478bd9Sstevel@tonic-gate  */
779*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
780*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_SHIFT	18
781*7c478bd9Sstevel@tonic-gate #elif defined(CHEETAH_PLUS)
782*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_SHIFT	2
783*7c478bd9Sstevel@tonic-gate #else	/* CHEETAH_PLUS */
784*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_SHIFT	1
785*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
786*7c478bd9Sstevel@tonic-gate #define	PN_L3TAG_PA_SHIFT	1
787*7c478bd9Sstevel@tonic-gate #define	PN_L3TAG_PA_MASK	0xfffff000000	/* tag bits[43:24] */
788*7c478bd9Sstevel@tonic-gate #define	PN_L2TAG_PA_MASK	0x7fffff80000	/* tag bits[42:19] */
789*7c478bd9Sstevel@tonic-gate 
790*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
791*7c478bd9Sstevel@tonic-gate /*
792*7c478bd9Sstevel@tonic-gate  * Macros for Jalapeno L2 Cache Tag/State/Parity
793*7c478bd9Sstevel@tonic-gate  *
794*7c478bd9Sstevel@tonic-gate  * +-----------+--------+--------+----------------------+
795*7c478bd9Sstevel@tonic-gate  * |   -       | EC_par |EC_state|  EC_tag = PA[42:18]  |
796*7c478bd9Sstevel@tonic-gate  * +-----------+--------+--------+----------------------+
797*7c478bd9Sstevel@tonic-gate  *    63:29        28      27:25         24:0
798*7c478bd9Sstevel@tonic-gate  */
799*7c478bd9Sstevel@tonic-gate /*
800*7c478bd9Sstevel@tonic-gate  * Constants representing the complete Jalapeno Ecache tag state:
801*7c478bd9Sstevel@tonic-gate  */
802*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_SIZE		3		/* three bits */
803*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_MASK		0x7		/* three bit field */
804*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_INV		0x0		/* invalid */
805*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_SHR		0x1		/* shared */
806*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_RES1		0x2		/* reserved */
807*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_EXL		0x3		/* exclusive */
808*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_RES2		0x4		/* reserved */
809*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_OWN		0x5		/* owner */
810*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_MOD		0x7		/* modified */
811*7c478bd9Sstevel@tonic-gate #define	JP_ECSTATE_RES3		0x6		/* reserved */
812*7c478bd9Sstevel@tonic-gate #define	JP_ECTAG_STATE_SHIFT	25
813*7c478bd9Sstevel@tonic-gate 
814*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_SIZE		JP_ECSTATE_SIZE
815*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_MASK		JP_ECSTATE_MASK
816*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_INV		JP_ECSTATE_INV
817*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_SHR		JP_ECSTATE_SHR
818*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_EXL		JP_ECSTATE_EXL
819*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_OWN		JP_ECSTATE_OWN
820*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_MOD		JP_ECSTATE_MOD
821*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_RES1		JP_ECSTATE_RES1
822*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_OWS		JP_ECSTATE_RES3
823*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_RES2		JP_ECSTATE_RES2
824*7c478bd9Sstevel@tonic-gate 
825*7c478bd9Sstevel@tonic-gate /* Number of subblock states per Ecache line. */
826*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_NSUBBLKS(totalsize)	1
827*7c478bd9Sstevel@tonic-gate 
828*7c478bd9Sstevel@tonic-gate /* Mask for Tag state(s) field, 3 bits per subblock state. */
829*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_STATE_SHIFT(subblk)	JP_ECTAG_STATE_SHIFT
830*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_STATE_MASK(totalsize)			\
831*7c478bd9Sstevel@tonic-gate 	((uint64_t)(JP_ECSTATE_MASK<<JP_ECTAG_STATE_SHIFT))
832*7c478bd9Sstevel@tonic-gate 
833*7c478bd9Sstevel@tonic-gate /* For a line to be invalid, all of its subblock states must be invalid. */
834*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_LINE_INVALID(totalsize, tag)		\
835*7c478bd9Sstevel@tonic-gate 	(((tag) & CH_ECTAG_STATE_MASK(totalsize)) == 0)
836*7c478bd9Sstevel@tonic-gate 
837*7c478bd9Sstevel@tonic-gate /* Build address mask for tag physical address bits. */
838*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_MASK(setsize)	P2ALIGN(C_AFAR_PA, (int)(setsize))
839*7c478bd9Sstevel@tonic-gate 
840*7c478bd9Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an E$ tag */
841*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_TO_PA(setsize, tag)	(((tag) << CH_ECTAG_PA_SHIFT) &	\
842*7c478bd9Sstevel@tonic-gate 	CH_ECTAG_PA_MASK(setsize))
843*7c478bd9Sstevel@tonic-gate 
844*7c478bd9Sstevel@tonic-gate /* Given a physical address, compute index for subblock tag state. */
845*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK(totalsize, pa)		1
846*7c478bd9Sstevel@tonic-gate 
847*7c478bd9Sstevel@tonic-gate /* Given a physical address and assoc. tag, get the subblock state. */
848*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK_STATE(totalsize, pa, tag)			\
849*7c478bd9Sstevel@tonic-gate 	(((tag) >> JP_ECTAG_STATE_SHIFT) &	JP_ECSTATE_MASK)
850*7c478bd9Sstevel@tonic-gate 
851*7c478bd9Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
852*7c478bd9Sstevel@tonic-gate 
853*7c478bd9Sstevel@tonic-gate /*
854*7c478bd9Sstevel@tonic-gate  * Constants representing the complete Cheetah Ecache tag state:
855*7c478bd9Sstevel@tonic-gate  */
856*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_SIZE		3		/* three bits per subblock */
857*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_MASK		0x7		/* three bit field */
858*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_INV		0x0		/* invalid */
859*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_SHR		0x1		/* shared */
860*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_EXL		0x2		/* exclusive */
861*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_OWN		0x3		/* owner */
862*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_MOD		0x4		/* modified */
863*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_RES1		0x5		/* reserved */
864*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_OWS		0x6		/* owner/shared */
865*7c478bd9Sstevel@tonic-gate #define	CH_ECSTATE_RES2		0x7		/* reserved */
866*7c478bd9Sstevel@tonic-gate 
867*7c478bd9Sstevel@tonic-gate /*
868*7c478bd9Sstevel@tonic-gate  * Macros for Cheetah Ecache tags
869*7c478bd9Sstevel@tonic-gate  */
870*7c478bd9Sstevel@tonic-gate 
871*7c478bd9Sstevel@tonic-gate /* Number of subblock states per Ecache line. */
872*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_NSUBBLKS(totalsize)	((totalsize) / CH_ECACHE_1M_SIZE)
873*7c478bd9Sstevel@tonic-gate 
874*7c478bd9Sstevel@tonic-gate /* Mask for Tag state(s) field, 3 bits per subblock state. */
875*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_STATE_SHIFT(subblk)	(subblk * CH_ECSTATE_SIZE)
876*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_STATE_MASK(totalsize)			\
877*7c478bd9Sstevel@tonic-gate 	((uint64_t)					\
878*7c478bd9Sstevel@tonic-gate 	((1 << (CH_ECTAG_NSUBBLKS(totalsize) * CH_ECSTATE_SIZE)) - 1))
879*7c478bd9Sstevel@tonic-gate 
880*7c478bd9Sstevel@tonic-gate /* For a line to be invalid, all of its subblock states must be invalid. */
881*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_LINE_INVALID(totalsize, tag)		\
882*7c478bd9Sstevel@tonic-gate 	(((tag) & CH_ECTAG_STATE_MASK(totalsize)) == 0)
883*7c478bd9Sstevel@tonic-gate 
884*7c478bd9Sstevel@tonic-gate /* Build address mask for tag physical address bits. */
885*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_MASK(setsize)	P2ALIGN(C_AFAR_PA, (int)(setsize))
886*7c478bd9Sstevel@tonic-gate 
887*7c478bd9Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an E$ tag */
888*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_TO_PA(setsize, tag)	(((tag) >> CH_ECTAG_PA_SHIFT) &	\
889*7c478bd9Sstevel@tonic-gate 	CH_ECTAG_PA_MASK(setsize))
890*7c478bd9Sstevel@tonic-gate 
891*7c478bd9Sstevel@tonic-gate /* Given a physical address, compute index for subblock tag state. */
892*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK(totalsize, pa)		\
893*7c478bd9Sstevel@tonic-gate 	(((pa) >> CH_ECACHE_SUBBLK_SHIFT) & (CH_ECTAG_NSUBBLKS(totalsize) - 1))
894*7c478bd9Sstevel@tonic-gate 
895*7c478bd9Sstevel@tonic-gate /* Given a physical address and assoc. tag, get the subblock state. */
896*7c478bd9Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK_STATE(totalsize, pa, tag)			\
897*7c478bd9Sstevel@tonic-gate 	(((tag) >>							\
898*7c478bd9Sstevel@tonic-gate 	(CH_ECTAG_PA_TO_SUBBLK(totalsize, pa) * CH_ECSTATE_SIZE)) &	\
899*7c478bd9Sstevel@tonic-gate 	CH_ECSTATE_MASK)
900*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
901*7c478bd9Sstevel@tonic-gate 
902*7c478bd9Sstevel@tonic-gate /* Panther only has one EC_State field in the L3 tag */
903*7c478bd9Sstevel@tonic-gate #define	PN_L3_LINE_INVALID(tag)		(((tag) & CH_ECSTATE_MASK) == 0)
904*7c478bd9Sstevel@tonic-gate 
905*7c478bd9Sstevel@tonic-gate /* Panther only has one State field in the L2 tag */
906*7c478bd9Sstevel@tonic-gate #define	PN_L2_LINE_INVALID(tag)		(((tag) & CH_ECSTATE_MASK) == 0)
907*7c478bd9Sstevel@tonic-gate 
908*7c478bd9Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an L3$ tag */
909*7c478bd9Sstevel@tonic-gate #define	PN_L3TAG_TO_PA(tag)		(((tag) & PN_L3TAG_PA_MASK) >> \
910*7c478bd9Sstevel@tonic-gate 	PN_L3TAG_PA_SHIFT)
911*7c478bd9Sstevel@tonic-gate 
912*7c478bd9Sstevel@tonic-gate /* Get physical address bits from the tag field of an L2$ tag */
913*7c478bd9Sstevel@tonic-gate #define	PN_L2TAG_TO_PA(tag)		((tag) & PN_L2TAG_PA_MASK)
914*7c478bd9Sstevel@tonic-gate 
915*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
916*7c478bd9Sstevel@tonic-gate /*
917*7c478bd9Sstevel@tonic-gate  * Jalapeno L2 Cache ASI_ECACHE_FLUSH:
918*7c478bd9Sstevel@tonic-gate  * +-------+-----------------+--------+---+-----+-------------+------+
919*7c478bd9Sstevel@tonic-gate  * |   -   | Port_ID |   -   | EC_Way | 1 |  -  | EC_Tag_Addr |   -  |
920*7c478bd9Sstevel@tonic-gate  * +-------+-----------------+--------+---+-----+-------------+------+
921*7c478bd9Sstevel@tonic-gate  *  63:41     40:36    35:34    33:32  31  30:18      17:6       5:0
922*7c478bd9Sstevel@tonic-gate  */
923*7c478bd9Sstevel@tonic-gate 
924*7c478bd9Sstevel@tonic-gate #define	JP_EC_TO_SET_SIZE_SHIFT		2
925*7c478bd9Sstevel@tonic-gate #define	JP_ECACHE_IDX_DISP_FLUSH	INT64_C(0x0000000080000000)
926*7c478bd9Sstevel@tonic-gate #define	JP_ECFLUSH_PORTID_SHIFT		36
927*7c478bd9Sstevel@tonic-gate #define	JP_ECFLUSH_EC_WAY_SHIFT		32
928*7c478bd9Sstevel@tonic-gate #define	JP_EC_TAG_DATA_WAY_SHIFT	JP_ECFLUSH_EC_WAY_SHIFT
929*7c478bd9Sstevel@tonic-gate #endif	/* JALAPENO || SERRANO */
930*7c478bd9Sstevel@tonic-gate 
931*7c478bd9Sstevel@tonic-gate /*
932*7c478bd9Sstevel@tonic-gate  * Macros for Jaguar Ecache tags
933*7c478bd9Sstevel@tonic-gate  */
934*7c478bd9Sstevel@tonic-gate 
935*7c478bd9Sstevel@tonic-gate /* Ecache sizes */
936*7c478bd9Sstevel@tonic-gate #define	JG_ECACHE_8M_SIZE	0x800000
937*7c478bd9Sstevel@tonic-gate #define	JG_ECACHE_4M_SIZE	0x400000
938*7c478bd9Sstevel@tonic-gate 
939*7c478bd9Sstevel@tonic-gate /* Jaguar E$ tag LRU mask */
940*7c478bd9Sstevel@tonic-gate #define	JG_LRU_MASK UINT64_C(0x0000040000000000) /* PA<42> LRU bit */
941*7c478bd9Sstevel@tonic-gate 
942*7c478bd9Sstevel@tonic-gate /*
943*7c478bd9Sstevel@tonic-gate  * Note that Jaguar and Cheetah/Cheetah+ have the same subblock state size
944*7c478bd9Sstevel@tonic-gate  * so rather than duplicating existing defn's we can use the Cheetah+ versions
945*7c478bd9Sstevel@tonic-gate  * in the Jaguar defn's below.
946*7c478bd9Sstevel@tonic-gate  */
947*7c478bd9Sstevel@tonic-gate /* Number of subblock states per Ecache line. */
948*7c478bd9Sstevel@tonic-gate #define	JG_ECTAG_NSUBBLKS(cachesize)	((cachesize) / JG_ECACHE_4M_SIZE)
949*7c478bd9Sstevel@tonic-gate 
950*7c478bd9Sstevel@tonic-gate /* Mask for Tag state(s) field, 3 bits per subblock state. */
951*7c478bd9Sstevel@tonic-gate #define	JG_ECTAG_STATE_MASK(totalsize)			\
952*7c478bd9Sstevel@tonic-gate 	((uint64_t)					\
953*7c478bd9Sstevel@tonic-gate 	((1 << (JG_ECTAG_NSUBBLKS(totalsize) * CH_ECSTATE_SIZE)) - 1))
954*7c478bd9Sstevel@tonic-gate 
955*7c478bd9Sstevel@tonic-gate /* For a line to be invalid, all of its subblock states must be invalid. */
956*7c478bd9Sstevel@tonic-gate #define	JG_ECTAG_LINE_INVALID(totalsize, tag)		\
957*7c478bd9Sstevel@tonic-gate 	(((tag) & JG_ECTAG_STATE_MASK(totalsize)) == 0)
958*7c478bd9Sstevel@tonic-gate 
959*7c478bd9Sstevel@tonic-gate /* Build address mask for tag physical address bits. */
960*7c478bd9Sstevel@tonic-gate #define	JG_ECTAG_PA_MASK(setsize)	P2ALIGN(((~JG_LRU_MASK) & C_AFAR_PA), \
961*7c478bd9Sstevel@tonic-gate 							(int)(setsize))
962*7c478bd9Sstevel@tonic-gate 
963*7c478bd9Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an E$ tag */
964*7c478bd9Sstevel@tonic-gate #define	JG_ECTAG_TO_PA(setsize, tag)	((tag & JG_ECTAG_PA_MASK(setsize)))
965*7c478bd9Sstevel@tonic-gate 
966*7c478bd9Sstevel@tonic-gate /* Given a physical address, compute index for subblock tag state. */
967*7c478bd9Sstevel@tonic-gate #define	JG_ECTAG_PA_TO_SUBBLK(totalsize, pa)		\
968*7c478bd9Sstevel@tonic-gate 	(((pa) >> CH_ECACHE_SUBBLK_SHIFT) & (JG_ECTAG_NSUBBLKS(totalsize) - 1))
969*7c478bd9Sstevel@tonic-gate 
970*7c478bd9Sstevel@tonic-gate /* Given a physical address and assoc. tag, get the subblock state. */
971*7c478bd9Sstevel@tonic-gate #define	JG_ECTAG_PA_TO_SUBBLK_STATE(totalsize, pa, tag)			\
972*7c478bd9Sstevel@tonic-gate 	(((tag) >>							\
973*7c478bd9Sstevel@tonic-gate 	(JG_ECTAG_PA_TO_SUBBLK(totalsize, pa) * CH_ECSTATE_SIZE)) &	\
974*7c478bd9Sstevel@tonic-gate 	CH_ECSTATE_MASK)
975*7c478bd9Sstevel@tonic-gate 
976*7c478bd9Sstevel@tonic-gate 
977*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
978*7c478bd9Sstevel@tonic-gate /*
979*7c478bd9Sstevel@tonic-gate  * Cheetah+ Tag ECC Bit and Displacement Flush Bit in Ecache Tag Access.
980*7c478bd9Sstevel@tonic-gate  * See Cheetah+ Delta PRM 10.7
981*7c478bd9Sstevel@tonic-gate  */
982*7c478bd9Sstevel@tonic-gate #define	CHP_ECACHE_IDX_TAG_ECC		INT64_C(0x0000000000800000)
983*7c478bd9Sstevel@tonic-gate #define	CHP_ECACHE_IDX_DISP_FLUSH	INT64_C(0x0000000001000000)
984*7c478bd9Sstevel@tonic-gate #define	PN_L2_IDX_DISP_FLUSH		INT64_C(0x0000000000800000)
985*7c478bd9Sstevel@tonic-gate #define	PN_L3_IDX_DISP_FLUSH		INT64_C(0x0000000004000000)
986*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
987*7c478bd9Sstevel@tonic-gate 
988*7c478bd9Sstevel@tonic-gate /*
989*7c478bd9Sstevel@tonic-gate  * Macros for Cheetah Dcache diagnostic accesses.
990*7c478bd9Sstevel@tonic-gate  */
991*7c478bd9Sstevel@tonic-gate 
992*7c478bd9Sstevel@tonic-gate /*
993*7c478bd9Sstevel@tonic-gate  * Dcache Index Mask for bits from *AFAR*.  Note that Dcache is virtually
994*7c478bd9Sstevel@tonic-gate  * indexed, so only bits [12:5] are valid from the AFAR.  This
995*7c478bd9Sstevel@tonic-gate  * means we have to search through the 4 ways + bit 13 (i.e. we have
996*7c478bd9Sstevel@tonic-gate  * to try 8 indexes).
997*7c478bd9Sstevel@tonic-gate  */
998*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_IDX_MASK		0x01fe0
999*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_IDX_INCR		0x02000
1000*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_IDX_LIMIT		0x10000
1001*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_NWAY			4
1002*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_WAY_MASK		0x0c000
1003*7c478bd9Sstevel@tonic-gate #define	CH_DCACHE_WAY_SHIFT		14
1004*7c478bd9Sstevel@tonic-gate #define	CH_DCIDX_TO_WAY(idx)		(((idx) & CH_DCACHE_WAY_MASK) >> \
1005*7c478bd9Sstevel@tonic-gate 						CH_DCACHE_WAY_SHIFT)
1006*7c478bd9Sstevel@tonic-gate #define	CH_DCTAG_PA_MASK		INT64_C(0x000007ffffffe000)
1007*7c478bd9Sstevel@tonic-gate #define	CH_DCTAG_PA_SHIFT		12
1008*7c478bd9Sstevel@tonic-gate #define	CH_DCTAG_VALID_BIT		INT64_C(0x0000000000000001)
1009*7c478bd9Sstevel@tonic-gate #define	CH_DCTAG_LINE_INVALID(tag)	(((tag) & CH_DCTAG_VALID_BIT) == 0)
1010*7c478bd9Sstevel@tonic-gate #define	CH_DCIDX_TO_ADDR(idx)		((idx) & CH_DCACHE_IDX_MASK)
1011*7c478bd9Sstevel@tonic-gate #define	CH_DCTAG_TO_PA(tag)		(((tag) << CH_DCTAG_PA_SHIFT) & \
1012*7c478bd9Sstevel@tonic-gate 					    CH_DCTAG_PA_MASK)
1013*7c478bd9Sstevel@tonic-gate #define	CH_DCTAG_MATCH(tag, pa)		(!CH_DCTAG_LINE_INVALID(tag) && \
1014*7c478bd9Sstevel@tonic-gate 			    ((pa) & CH_DCTAG_PA_MASK) == CH_DCTAG_TO_PA(tag))
1015*7c478bd9Sstevel@tonic-gate #define	CH_DCSNTAG_MASK			INT64_C(0x000007ffffffe000)
1016*7c478bd9Sstevel@tonic-gate #define	CH_DCSNTAG_TO_PA(tag)		((tag << CH_DCTAG_PA_SHIFT) \
1017*7c478bd9Sstevel@tonic-gate 							& CH_DCSNTAG_MASK)
1018*7c478bd9Sstevel@tonic-gate #define	CH_DCUTAG_TO_UTAG(tag)		((tag) & 0xff)
1019*7c478bd9Sstevel@tonic-gate #define	CH_DCUTAG_TO_VA(tag)		((tag & 0xff) << 14)
1020*7c478bd9Sstevel@tonic-gate #define	CH_DCUTAG_IDX_MASK		0x03fe0
1021*7c478bd9Sstevel@tonic-gate #define	CH_DC_DATA_REG_SIZE		32
1022*7c478bd9Sstevel@tonic-gate #define	CH_DC_UTAG_MASK			0xff
1023*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS) || defined(JALAPENO) || defined(SERRANO)
1024*7c478bd9Sstevel@tonic-gate #define	CHP_DCTAG_PARMASK		INT64_C(0x000000007ffffffe)
1025*7c478bd9Sstevel@tonic-gate #define	CHP_DCSNTAG_PARMASK		INT64_C(0x000000007ffffffe)
1026*7c478bd9Sstevel@tonic-gate #define	CHP_DCTAG_MASK			INT64_C(0x000003ffffffe000)
1027*7c478bd9Sstevel@tonic-gate #define	CHP_DCSNTAG_MASK		INT64_C(0x000003ffffffe000)
1028*7c478bd9Sstevel@tonic-gate #define	CHP_DCWAY_MASK			INT64_C(0x0000000000003fe0)
1029*7c478bd9Sstevel@tonic-gate #define	CHP_DCUTAG_TO_UTAG(tag)		((tag) & 0xffff)
1030*7c478bd9Sstevel@tonic-gate #define	CHP_DCPATAG_TO_PA(tag)		((tag << CH_DCTAG_PA_SHIFT) \
1031*7c478bd9Sstevel@tonic-gate 							& CHP_DCTAG_MASK)
1032*7c478bd9Sstevel@tonic-gate #define	CHP_DCSNTAG_TO_PA(tag)		((tag << CH_DCTAG_PA_SHIFT) \
1033*7c478bd9Sstevel@tonic-gate 							& CHP_DCSNTAG_MASK)
1034*7c478bd9Sstevel@tonic-gate #define	CHP_DC_IDX(dcp)			((dcp->dc_idx & 0x1fc0) >> 5)
1035*7c478bd9Sstevel@tonic-gate #define	CHP_DCTAG_PARITY(tag)		(tag & CHP_DC_TAG)
1036*7c478bd9Sstevel@tonic-gate #define	CHP_DCSNTAG_PARITY(tag)		(tag & CHP_DC_SNTAG)
1037*7c478bd9Sstevel@tonic-gate #define	CHP_DC_TAG			0x1
1038*7c478bd9Sstevel@tonic-gate #define	CHP_DC_SNTAG			0x2
1039*7c478bd9Sstevel@tonic-gate #define	PN_DC_DATA_PARITY_SHIFT    	8
1040*7c478bd9Sstevel@tonic-gate #define	PN_DC_DATA_PARITY_MASK    	0xff
1041*7c478bd9Sstevel@tonic-gate #define	PN_DC_DATA_ALL_PARITY_MASK    	0xffffffff
1042*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS || JALAPENO || SERRANO */
1043*7c478bd9Sstevel@tonic-gate #define	PN_DC_DATA_PARITY_BIT_SHIFT    	16
1044*7c478bd9Sstevel@tonic-gate 
1045*7c478bd9Sstevel@tonic-gate /*
1046*7c478bd9Sstevel@tonic-gate  * Macros for Cheetah Icache diagnostic accesses.
1047*7c478bd9Sstevel@tonic-gate  */
1048*7c478bd9Sstevel@tonic-gate 
1049*7c478bd9Sstevel@tonic-gate /*
1050*7c478bd9Sstevel@tonic-gate  * Icache Index Mask for bits from *AFAR*. Note that the Icache is virtually
1051*7c478bd9Sstevel@tonic-gate  * indexed for Panther and physically indexed for other CPUs. For Panther,
1052*7c478bd9Sstevel@tonic-gate  * we obtain an index by looking at bits[12:6] of the AFAR PA and we check
1053*7c478bd9Sstevel@tonic-gate  * both lines associated with bit 13 = 0 or 1 (total of 8 entries to check).
1054*7c478bd9Sstevel@tonic-gate  * For non-Panther CPUs we get our index by just looking at bits[12:5] of
1055*7c478bd9Sstevel@tonic-gate  * the AFAR PA (total of 4 entries to check). The Icache index is also
1056*7c478bd9Sstevel@tonic-gate  * confusing because we need to shift the virtual address bits left by one
1057*7c478bd9Sstevel@tonic-gate  * for the index.
1058*7c478bd9Sstevel@tonic-gate  */
1059*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_IDX_MASK		0x01fe0
1060*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_IDX_MASK		0x03fc0
1061*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_VA_IDX_MASK		0x01fc0
1062*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_IDX_SHIFT		1
1063*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_IDX_INCR		0x04000
1064*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_IDX_INCR		0x08000
1065*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_IDX_LIMIT		0x10000
1066*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_IDX_LIMIT		0x20000
1067*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_NWAY			4
1068*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_WAY_MASK		0x0c000
1069*7c478bd9Sstevel@tonic-gate #define	CH_ICACHE_WAY_SHIFT		14
1070*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_WAY_MASK		0x18000
1071*7c478bd9Sstevel@tonic-gate #define	PN_ICACHE_WAY_SHIFT		15
1072*7c478bd9Sstevel@tonic-gate #define	CH_ICTAG_PA			0x00
1073*7c478bd9Sstevel@tonic-gate #define	CH_ICTAG_UTAG			0x08
1074*7c478bd9Sstevel@tonic-gate #define	CH_ICTAG_UPPER			0x10
1075*7c478bd9Sstevel@tonic-gate #define	CH_ICTAG_LOWER			0x30
1076*7c478bd9Sstevel@tonic-gate #define	CH_ICTAG_TMASK			0x3f
1077*7c478bd9Sstevel@tonic-gate #define	CH_ICPATAG_MASK			INT64_C(0x000007ffffffe000)
1078*7c478bd9Sstevel@tonic-gate #define	CH_ICPATAG_LBITS		0xff	/* lower 8 bits undefined */
1079*7c478bd9Sstevel@tonic-gate #define	CH_ICPATAG_SHIFT		5
1080*7c478bd9Sstevel@tonic-gate #define	CH_ICIDX_TO_WAY(idx)		(((idx) & CH_ICACHE_WAY_MASK) >> \
1081*7c478bd9Sstevel@tonic-gate 						CH_ICACHE_WAY_SHIFT)
1082*7c478bd9Sstevel@tonic-gate #define	PN_ICIDX_TO_WAY(idx)		(((idx) & PN_ICACHE_WAY_MASK) >> \
1083*7c478bd9Sstevel@tonic-gate 						PN_ICACHE_WAY_SHIFT)
1084*7c478bd9Sstevel@tonic-gate #define	CH_ICIDX_TO_ADDR(idx)		(((idx) >> CH_ICACHE_IDX_SHIFT) & \
1085*7c478bd9Sstevel@tonic-gate 						CH_ICACHE_IDX_MASK)
1086*7c478bd9Sstevel@tonic-gate #define	PN_ICIDX_TO_ADDR(idx)		(((idx) >> CH_ICACHE_IDX_SHIFT) & \
1087*7c478bd9Sstevel@tonic-gate 						PN_ICACHE_IDX_MASK)
1088*7c478bd9Sstevel@tonic-gate #define	CH_ICPATAG_TO_PA(tag)		(((tag) << CH_ICPATAG_SHIFT) & \
1089*7c478bd9Sstevel@tonic-gate 						CH_ICPATAG_MASK)
1090*7c478bd9Sstevel@tonic-gate #define	CH_ICPATAG_MATCH(tag, pa)	(CH_ICPATAG_TO_PA(tag) == \
1091*7c478bd9Sstevel@tonic-gate 						((pa) & CH_ICPATAG_MASK))
1092*7c478bd9Sstevel@tonic-gate #define	CH_ICUTAG_MASK			INT64_C(0x00000000001fe000)
1093*7c478bd9Sstevel@tonic-gate #define	CH_ICUTAG_TO_UTAG(tag)		(((tag) >> 38) & 0xff)
1094*7c478bd9Sstevel@tonic-gate #define	CH_ICUTAG_TO_VA(tag)		(((tag) >> 25) & CH_ICUTAG_MASK)
1095*7c478bd9Sstevel@tonic-gate #define	CH_ICSNTAG_MASK			INT64_C(0x000007ffffffe000)
1096*7c478bd9Sstevel@tonic-gate #define	CH_ICSNTAG_TO_PA(tag)		(((tag) << 5) & CH_ICSNTAG_MASK)
1097*7c478bd9Sstevel@tonic-gate #define	CH_ICLOWER_VALID		INT64_C(0x0004000000000000)
1098*7c478bd9Sstevel@tonic-gate #define	CH_ICUPPER_VALID		INT64_C(0x0004000000000000)
1099*7c478bd9Sstevel@tonic-gate #define	CH_ICLOWER_TO_VPRED(lower)	(((lower) >> 46) & 0xf)
1100*7c478bd9Sstevel@tonic-gate #define	CH_ICUPPER_TO_VPRED(upper)	(((upper) >> 46) & 0xf)
1101*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
1102*7c478bd9Sstevel@tonic-gate #define	CH_ICTAG_MATCH(icp, pa)		(((icp->ic_lower | icp->ic_upper) & \
1103*7c478bd9Sstevel@tonic-gate 					    CH_ICLOWER_VALID) && \
1104*7c478bd9Sstevel@tonic-gate 					    CH_ICPATAG_MATCH(icp->ic_patag, pa))
1105*7c478bd9Sstevel@tonic-gate #define	PN_ICUTAG_TO_VA(tag)		((tag >> 24) & PN_ICUTAG_MASK)
1106*7c478bd9Sstevel@tonic-gate #else	/* CHEETAH_PLUS */
1107*7c478bd9Sstevel@tonic-gate #define	CH_ICTAG_MATCH(icp, pa)		((icp->ic_lower & CH_ICLOWER_VALID) &&\
1108*7c478bd9Sstevel@tonic-gate 					    CH_ICPATAG_MATCH(icp->ic_patag, pa))
1109*7c478bd9Sstevel@tonic-gate #define	PN_ICUTAG_TO_VA(tag)		0
1110*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
1111*7c478bd9Sstevel@tonic-gate 
1112*7c478bd9Sstevel@tonic-gate #define	CH_IC_DATA_REG_SIZE		64
1113*7c478bd9Sstevel@tonic-gate #define	PN_IC_DATA_REG_SIZE		128
1114*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS) || defined(JALAPENO) || defined(SERRANO)
1115*7c478bd9Sstevel@tonic-gate #define	CHP_IC_IDX(icp)			((icp->ic_idx & 0x3fc0) >> 6)
1116*7c478bd9Sstevel@tonic-gate #define	PN_IC_IDX(icp)			((icp->ic_idx & 0x7f80) >> 7)
1117*7c478bd9Sstevel@tonic-gate #define	CHP_ICPATAG_MASK		INT64_C(0x000003ffffffe000)
1118*7c478bd9Sstevel@tonic-gate #define	CHP_ICSNTAG_MASK		INT64_C(0x000003ffffffe000)
1119*7c478bd9Sstevel@tonic-gate #define	CHP_ICUTAG_MASK			INT64_C(0x00000000001fe000)
1120*7c478bd9Sstevel@tonic-gate #define	PN_ICUTAG_MASK			INT64_C(0x00000000003fc000)
1121*7c478bd9Sstevel@tonic-gate #define	CHP_ICWAY_MASK			INT64_C(0x0000000000003fe0)
1122*7c478bd9Sstevel@tonic-gate #define	CHP_ICPATAG_TO_PA(tag)		((tag << 5) & CHP_ICPATAG_MASK)
1123*7c478bd9Sstevel@tonic-gate #define	CHP_ICSNTAG_TO_PA(tag)		((tag << 5) & CHP_ICSNTAG_MASK)
1124*7c478bd9Sstevel@tonic-gate #define	CHP_ICUTAG_TO_VA(tag)		((tag >> 25) & CHP_ICUTAG_MASK)
1125*7c478bd9Sstevel@tonic-gate #define	CHP_ICPATAG_PARMASK		INT64_C(0x0000003fffffff00)
1126*7c478bd9Sstevel@tonic-gate #define	CHP_ICSNTAG_PARMASK		INT64_C(0x0000003fffffff00)
1127*7c478bd9Sstevel@tonic-gate 
1128*7c478bd9Sstevel@tonic-gate /*
1129*7c478bd9Sstevel@tonic-gate  * Cheetah+ Icache data parity masks, see Cheetah+ Delta PRM 7.3
1130*7c478bd9Sstevel@tonic-gate  * PC-relative instructions have different bits protected by parity.
1131*7c478bd9Sstevel@tonic-gate  * Predecode bit 7 is not parity protected and indicates if the instruction
1132*7c478bd9Sstevel@tonic-gate  * is PC-relative or not.
1133*7c478bd9Sstevel@tonic-gate  */
1134*7c478bd9Sstevel@tonic-gate #define	CH_ICDATA_PRED_ISPCREL		INT64_C(0x0000008000000000)
1135*7c478bd9Sstevel@tonic-gate #define	CHP_ICDATA_PCREL_PARMASK	INT64_C(0x0000039ffffff800)
1136*7c478bd9Sstevel@tonic-gate #define	CHP_ICDATA_NPCREL_PARMASK	INT64_C(0x000003bfffffffff)
1137*7c478bd9Sstevel@tonic-gate #define	PN_ICDATA_PARITY_BIT_MASK	INT64_C(0x40000000000)
1138*7c478bd9Sstevel@tonic-gate #define	CHP_ICTAG_PARITY(tag)		(tag & CHP_IC_TAG)
1139*7c478bd9Sstevel@tonic-gate #define	CHP_ICSNTAG_PARITY(tag)		(tag & CHP_IC_SNTAG)
1140*7c478bd9Sstevel@tonic-gate #define	CHP_IC_TAG			0x1
1141*7c478bd9Sstevel@tonic-gate #define	CHP_IC_SNTAG			0x2
1142*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS || JALAPENO || SERRANO */
1143*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
1144*7c478bd9Sstevel@tonic-gate #define	PN_IPB_TAG_ADDR_LINESIZE	0x40
1145*7c478bd9Sstevel@tonic-gate #define	PN_IPB_TAG_ADDR_MAX		0x3c0
1146*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
1147*7c478bd9Sstevel@tonic-gate 
1148*7c478bd9Sstevel@tonic-gate /*
1149*7c478bd9Sstevel@tonic-gate  * Macros for Pcache diagnostic accesses.
1150*7c478bd9Sstevel@tonic-gate  */
1151*7c478bd9Sstevel@tonic-gate #define	CH_PC_WAY_MASK			0x600
1152*7c478bd9Sstevel@tonic-gate #define	CH_PC_WAY_SHIFT			9
1153*7c478bd9Sstevel@tonic-gate #define	CH_PCIDX_TO_WAY(idx)		(((idx) & CH_PC_WAY_MASK) >> \
1154*7c478bd9Sstevel@tonic-gate 						CH_PC_WAY_SHIFT)
1155*7c478bd9Sstevel@tonic-gate #define	CH_PC_DATA_REG_SIZE		64
1156*7c478bd9Sstevel@tonic-gate #define	CH_PCACHE_NWAY			4
1157*7c478bd9Sstevel@tonic-gate #define	PN_PC_PARITY_SHIFT		50
1158*7c478bd9Sstevel@tonic-gate #define	PN_PC_PARITY_MASK		0xff
1159*7c478bd9Sstevel@tonic-gate #define	PN_PC_PARITY_BITS(status)	\
1160*7c478bd9Sstevel@tonic-gate 	(((status) >> PN_PC_PARITY_SHIFT) & PN_PC_PARITY_MASK)
1161*7c478bd9Sstevel@tonic-gate #define	CH_PC_IDX_ADR(pcp)		((pcp->pc_idx & 0x1c0) >> 6)
1162*7c478bd9Sstevel@tonic-gate #define	CH_PCTAG_ADDR_SHIFT		6
1163*7c478bd9Sstevel@tonic-gate #define	CH_PC_PA_MASK			0x7ffffffffc0
1164*7c478bd9Sstevel@tonic-gate #define	CH_PCTAG_TO_VA(tag)		((tag) << CH_PCTAG_ADDR_SHIFT)
1165*7c478bd9Sstevel@tonic-gate #define	CH_PCSTAG_TO_PA(tag)		(((tag) << CH_PCTAG_ADDR_SHIFT) & \
1166*7c478bd9Sstevel@tonic-gate 					    CH_PC_PA_MASK)
1167*7c478bd9Sstevel@tonic-gate #define	CH_PCTAG_BNK0_VALID_MASK	0x2000000000000000
1168*7c478bd9Sstevel@tonic-gate #define	CH_PCTAG_BNK1_VALID_MASK	0x1000000000000000
1169*7c478bd9Sstevel@tonic-gate #define	CH_PCTAG_BNK0_INVALID(tag)	(((tag) & CH_PCTAG_BNK0_VALID_MASK) == \
1170*7c478bd9Sstevel@tonic-gate 					    0)
1171*7c478bd9Sstevel@tonic-gate #define	CH_PCTAG_BNK1_INVALID(tag)	(((tag) & CH_PCTAG_BNK1_VALID_MASK) == \
1172*7c478bd9Sstevel@tonic-gate 					    0)
1173*7c478bd9Sstevel@tonic-gate 
1174*7c478bd9Sstevel@tonic-gate /*
1175*7c478bd9Sstevel@tonic-gate  * CPU Log Out Structure parameters.
1176*7c478bd9Sstevel@tonic-gate  * This structure is filled in by the Error Trap handlers and captures the
1177*7c478bd9Sstevel@tonic-gate  * Ecache/Dcache/Icache line(s) associated with the AFAR.
1178*7c478bd9Sstevel@tonic-gate  * For Cheetah Phase II, this structure is filled in at the TL=0 code.  For
1179*7c478bd9Sstevel@tonic-gate  * Cheetah Phase III, this will be filled in at the trap handlers.
1180*7c478bd9Sstevel@tonic-gate  */
1181*7c478bd9Sstevel@tonic-gate 
1182*7c478bd9Sstevel@tonic-gate /*
1183*7c478bd9Sstevel@tonic-gate  * We use this to mark the LOGOUT structure as invalid.  Note that
1184*7c478bd9Sstevel@tonic-gate  * this cannot be a valid AFAR, as AFAR bits outside of [41:5] should always
1185*7c478bd9Sstevel@tonic-gate  * be zero.
1186*7c478bd9Sstevel@tonic-gate  */
1187*7c478bd9Sstevel@tonic-gate #define	LOGOUT_INVALID_U32	0xecc1ecc1
1188*7c478bd9Sstevel@tonic-gate #define	LOGOUT_INVALID_L32	0xecc1ecc1
1189*7c478bd9Sstevel@tonic-gate #define	LOGOUT_INVALID		UINT64_C(0xecc1ecc1ecc1ecc1)
1190*7c478bd9Sstevel@tonic-gate 
1191*7c478bd9Sstevel@tonic-gate /*
1192*7c478bd9Sstevel@tonic-gate  * Max number of TLs to support for Fast ECC or Cache Parity Errors
1193*7c478bd9Sstevel@tonic-gate  * at TL>0.  Traps are OK from TL=1-2, at TL>=3, we will Red Mode.
1194*7c478bd9Sstevel@tonic-gate  */
1195*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL1_TLMAX	2
1196*7c478bd9Sstevel@tonic-gate 
1197*7c478bd9Sstevel@tonic-gate /*
1198*7c478bd9Sstevel@tonic-gate  * Software traps used by TL>0 handlers.
1199*7c478bd9Sstevel@tonic-gate  */
1200*7c478bd9Sstevel@tonic-gate #define	SWTRAP_0		0	/* Used by Fast ECC */
1201*7c478bd9Sstevel@tonic-gate #define	SWTRAP_1		1	/* Used by Dcache Parity */
1202*7c478bd9Sstevel@tonic-gate #define	SWTRAP_2		2	/* Used by Icache Parity */
1203*7c478bd9Sstevel@tonic-gate 
1204*7c478bd9Sstevel@tonic-gate /*
1205*7c478bd9Sstevel@tonic-gate  * Bit mask defines for various Cheetah Error conditions.
1206*7c478bd9Sstevel@tonic-gate  */
1207*7c478bd9Sstevel@tonic-gate #define	CH_ERR_FECC	0x01	/* Data/Event is Fast ECC */
1208*7c478bd9Sstevel@tonic-gate #define	CH_ERR_IPE	0x02	/* Data/Event is Icache Parity Error */
1209*7c478bd9Sstevel@tonic-gate #define	CH_ERR_DPE	0x04	/* Data/Event is Dcache Parity Error */
1210*7c478bd9Sstevel@tonic-gate #define	CH_ERR_PANIC	0x08	/* Fatal error in TL>0 handler */
1211*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL	0x10	/* Error occured at TL>0 */
1212*7c478bd9Sstevel@tonic-gate #define	CH_ERR_ME_SHIFT	   8	/* If multiple errors, shift left newest */
1213*7c478bd9Sstevel@tonic-gate #define	CH_ERR_ME_FLAGS(x)	((x) >> CH_ERR_ME_SHIFT)
1214*7c478bd9Sstevel@tonic-gate 
1215*7c478bd9Sstevel@tonic-gate /*
1216*7c478bd9Sstevel@tonic-gate  * Defines for Bit8 (CH_ERR_TSTATE_IC_ON) and Bit9 (CH_ERR_TSTATE_DC_ON)
1217*7c478bd9Sstevel@tonic-gate  * in %tstate, which is used to remember D$/I$ state on Fast ECC handler
1218*7c478bd9Sstevel@tonic-gate  * at TL>0.  Note that DCU_IC=0x1, DCU_DC=0x2.
1219*7c478bd9Sstevel@tonic-gate  */
1220*7c478bd9Sstevel@tonic-gate #define	CH_ERR_G2_TO_TSTATE_SHFT	10
1221*7c478bd9Sstevel@tonic-gate #define	CH_ERR_DCU_TO_TSTATE_SHFT	8
1222*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TSTATE_IC_ON	(DCU_IC << CH_ERR_DCU_TO_TSTATE_SHFT)
1223*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TSTATE_DC_ON	(DCU_DC << CH_ERR_DCU_TO_TSTATE_SHFT)
1224*7c478bd9Sstevel@tonic-gate 
1225*7c478bd9Sstevel@tonic-gate /*
1226*7c478bd9Sstevel@tonic-gate  * Multiple offset TL>0 handler structure elements
1227*7c478bd9Sstevel@tonic-gate  */
1228*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL1_DATA		(CH_ERR_TL1_LOGOUT + CH_CLO_DATA)
1229*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL1_SDW_DATA	(CH_ERR_TL1_LOGOUT + CH_CLO_SDW_DATA)
1230*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL1_NEST_CNT	(CH_ERR_TL1_LOGOUT + CH_CLO_NEST_CNT)
1231*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL1_AFSR		(CH_ERR_TL1_DATA + CH_CHD_AFSR)
1232*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL1_SDW_AFSR	(CH_ERR_TL1_SDW_DATA + CH_CHD_AFSR)
1233*7c478bd9Sstevel@tonic-gate #define	CH_ERR_TL1_SDW_AFSR_EXT	(CH_ERR_TL1_SDW_DATA + CH_CHD_AFSR_EXT)
1234*7c478bd9Sstevel@tonic-gate 
1235*7c478bd9Sstevel@tonic-gate /*
1236*7c478bd9Sstevel@tonic-gate  * Interval for deferred CEEN reenable
1237*7c478bd9Sstevel@tonic-gate  */
1238*7c478bd9Sstevel@tonic-gate #define	CPU_CEEN_DELAY_SECS		6
1239*7c478bd9Sstevel@tonic-gate 
1240*7c478bd9Sstevel@tonic-gate /*
1241*7c478bd9Sstevel@tonic-gate  * flags for flt_trapped_ce variable
1242*7c478bd9Sstevel@tonic-gate  */
1243*7c478bd9Sstevel@tonic-gate #define	CE_CEEN_DEFER		0x1	/* no CEEN reenable in trap handler */
1244*7c478bd9Sstevel@tonic-gate #define	CE_CEEN_NODEFER		0x2	/* reenable CEEN in handler */
1245*7c478bd9Sstevel@tonic-gate #define	CE_CEEN_TIMEOUT		0x4	/* CE caught by timeout */
1246*7c478bd9Sstevel@tonic-gate #define	CE_CEEN_TRAPPED		0x8	/* CE caught by trap */
1247*7c478bd9Sstevel@tonic-gate 
1248*7c478bd9Sstevel@tonic-gate /*
1249*7c478bd9Sstevel@tonic-gate  * default value for cpu_ce_not_deferred
1250*7c478bd9Sstevel@tonic-gate  */
1251*7c478bd9Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
1252*7c478bd9Sstevel@tonic-gate #define	CPU_CE_NOT_DEFERRED	(C_AFSR_CECC_ERRS & \
1253*7c478bd9Sstevel@tonic-gate 		~(C_AFSR_CE | C_AFSR_FRC | C_AFSR_RCE | C_AFSR_EMC))
1254*7c478bd9Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
1255*7c478bd9Sstevel@tonic-gate #define	CPU_CE_NOT_DEFERRED		C_AFSR_CECC_ERRS & \
1256*7c478bd9Sstevel@tonic-gate 					    ~(C_AFSR_CE | C_AFSR_EMC)
1257*7c478bd9Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
1258*7c478bd9Sstevel@tonic-gate 
1259*7c478bd9Sstevel@tonic-gate #define	CPU_CE_NOT_DEFERRED_EXT		C_AFSR_EXT_CECC_ERRS
1260*7c478bd9Sstevel@tonic-gate 
1261*7c478bd9Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
1262*7c478bd9Sstevel@tonic-gate 
1263*7c478bd9Sstevel@tonic-gate /*
1264*7c478bd9Sstevel@tonic-gate  * VA for primary and shadow AFSR/AFAR/AFSR_EXT registers
1265*7c478bd9Sstevel@tonic-gate  */
1266*7c478bd9Sstevel@tonic-gate #define	ASI_SHADOW_REG_VA	0x8
1267*7c478bd9Sstevel@tonic-gate #define	ASI_AFSR_EXT_VA		0x10
1268*7c478bd9Sstevel@tonic-gate #define	ASI_SHADOW_AFSR_EXT_VA	0x18
1269*7c478bd9Sstevel@tonic-gate 
1270*7c478bd9Sstevel@tonic-gate /*
1271*7c478bd9Sstevel@tonic-gate  * Bitmask for keeping track of core parking in ECC error handlers.
1272*7c478bd9Sstevel@tonic-gate  * We share a register that also saves the DCUCR value so we use
1273*7c478bd9Sstevel@tonic-gate  * one of the reserved bit positions of the DCUCR register to keep
1274*7c478bd9Sstevel@tonic-gate  * track of whether or not we have parked our sibling core.
1275*7c478bd9Sstevel@tonic-gate  */
1276*7c478bd9Sstevel@tonic-gate #define	PN_PARKED_OTHER_CORE	0x20
1277*7c478bd9Sstevel@tonic-gate #define	PN_BOTH_CORES_RUNNING	0x3
1278*7c478bd9Sstevel@tonic-gate 
1279*7c478bd9Sstevel@tonic-gate /*
1280*7c478bd9Sstevel@tonic-gate  * Panther EMU Activity Status Register Bits.
1281*7c478bd9Sstevel@tonic-gate  */
1282*7c478bd9Sstevel@tonic-gate #define	ASI_EMU_ACT_STATUS_VA	0x18
1283*7c478bd9Sstevel@tonic-gate #define	MCU_ACT_STATUS		INT64_C(0x0000000000000001)
1284*7c478bd9Sstevel@tonic-gate #define	SIU_ACT_STATUS		INT64_C(0x0000000000000002)
1285*7c478bd9Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
1286*7c478bd9Sstevel@tonic-gate 
1287*7c478bd9Sstevel@tonic-gate #define	ASI_CESR_ID_VA		0x40    /* ASI_CESRD_ID per-core registers */
1288*7c478bd9Sstevel@tonic-gate 
1289*7c478bd9Sstevel@tonic-gate #define	ASR_DISPATCH_CONTROL		%asr18
1290*7c478bd9Sstevel@tonic-gate #define	ASR_DISPATCH_CONTROL_BPE	0x20
1291*7c478bd9Sstevel@tonic-gate 
1292*7c478bd9Sstevel@tonic-gate /*
1293*7c478bd9Sstevel@tonic-gate  * Max number of E$ sets logged in ch_diag_data structure
1294*7c478bd9Sstevel@tonic-gate  */
1295*7c478bd9Sstevel@tonic-gate #define	CHD_EC_DATA_SETS	4	/* max 4 sets of E$ data */
1296*7c478bd9Sstevel@tonic-gate 
1297*7c478bd9Sstevel@tonic-gate /*
1298*7c478bd9Sstevel@tonic-gate  * Definitions for Panther TLB parity handling.
1299*7c478bd9Sstevel@tonic-gate  */
1300*7c478bd9Sstevel@tonic-gate #define	PN_ITLB_NWAYS		2
1301*7c478bd9Sstevel@tonic-gate #define	PN_NUM_512_ITLBS	1
1302*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_NWAYS		2
1303*7c478bd9Sstevel@tonic-gate #define	PN_NUM_512_DTLBS	2
1304*7c478bd9Sstevel@tonic-gate #define	PN_SFSR_PARITY_SHIFT	12
1305*7c478bd9Sstevel@tonic-gate #define	PN_ITLB_PGSZ_SHIFT	22
1306*7c478bd9Sstevel@tonic-gate #define	PN_ITLB_PGSZ_MASK	(7 << PN_ITLB_PGSZ_SHIFT)
1307*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_PGSZ0_SHIFT	16
1308*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_PGSZ0_MASK	(7 << PN_DTLB_PGSZ0_SHIFT)
1309*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_PGSZ1_SHIFT	19
1310*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_PGSZ1_MASK	(7 << PN_DTLB_PGSZ1_SHIFT)
1311*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_PGSZ_MASK	(PN_DTLB_PGSZ1_MASK | PN_DTLB_PGSZ0_MASK)
1312*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_T512_0		(2 << 16)
1313*7c478bd9Sstevel@tonic-gate #define	PN_DTLB_T512_1		(3 << 16)
1314*7c478bd9Sstevel@tonic-gate #define	PN_TLO_INFO_IMMU_SHIFT	14
1315*7c478bd9Sstevel@tonic-gate #define	PN_TLO_INFO_IMMU	(1 << PN_TLO_INFO_IMMU_SHIFT)
1316*7c478bd9Sstevel@tonic-gate #define	PN_TLO_INFO_TL1_SHIFT	13
1317*7c478bd9Sstevel@tonic-gate #define	PN_TLO_INFO_TL1		(1 << PN_TLO_INFO_TL1_SHIFT)
1318*7c478bd9Sstevel@tonic-gate #define	PN_ITLB_T512		(2 << 16)
1319*7c478bd9Sstevel@tonic-gate #define	PN_TLB_ACC_IDX_SHIFT	3
1320*7c478bd9Sstevel@tonic-gate #define	PN_TLB_ACC_WAY_BIT	(1 << 11)
1321*7c478bd9Sstevel@tonic-gate #define	PN_TLB_DIAGACC_OFFSET	0x40000	/* Diag Acc ASI VA offset */
1322*7c478bd9Sstevel@tonic-gate /*
1323*7c478bd9Sstevel@tonic-gate  * tag parity = XOR(Size[2:0],Global,VA[63:21],Context[12:0])
1324*7c478bd9Sstevel@tonic-gate  * which requires looking at both the tag and the data.
1325*7c478bd9Sstevel@tonic-gate  */
1326*7c478bd9Sstevel@tonic-gate #define	PN_TLB_TAG_PARITY_TAG_MASK	0xffffffffffe01fff
1327*7c478bd9Sstevel@tonic-gate #define	PN_TLB_TAG_PARITY_DATA_MASK	0x6001400000000001
1328*7c478bd9Sstevel@tonic-gate /* data parity = XOR(NFO,IE,PA[42:13],CP,CV,E,P,W) */
1329*7c478bd9Sstevel@tonic-gate #define	PN_TLB_DATA_PARITY_DATA_MASK	0x180087ffffffe03e
1330*7c478bd9Sstevel@tonic-gate 
1331*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
1332*7c478bd9Sstevel@tonic-gate 
1333*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
1334*7c478bd9Sstevel@tonic-gate 
1335*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
1336*7c478bd9Sstevel@tonic-gate 
1337*7c478bd9Sstevel@tonic-gate /*
1338*7c478bd9Sstevel@tonic-gate  * One Ecache data element, 32 bytes of data, 8 bytes of ECC.
1339*7c478bd9Sstevel@tonic-gate  * See Cheetah PRM 10.7.2.
1340*7c478bd9Sstevel@tonic-gate  */
1341*7c478bd9Sstevel@tonic-gate typedef struct ec_data_elm {
1342*7c478bd9Sstevel@tonic-gate 	uint64_t ec_d8[CH_ECACHE_STGREG_NUM];
1343*7c478bd9Sstevel@tonic-gate 	uint64_t ec_eccd;	/* EC_data_ECC field */
1344*7c478bd9Sstevel@tonic-gate } ec_data_elm_t;
1345*7c478bd9Sstevel@tonic-gate 
1346*7c478bd9Sstevel@tonic-gate /*
1347*7c478bd9Sstevel@tonic-gate  * L2 and L3 cache data captured by cpu log out code.
1348*7c478bd9Sstevel@tonic-gate  * See Cheetah PRM 10.7.4.
1349*7c478bd9Sstevel@tonic-gate  */
1350*7c478bd9Sstevel@tonic-gate typedef struct ch_ec_data {
1351*7c478bd9Sstevel@tonic-gate 	uint64_t ec_logflag;	/* Flag indicates if data was logged */
1352*7c478bd9Sstevel@tonic-gate 	uint64_t ec_idx;	/* Ecache index */
1353*7c478bd9Sstevel@tonic-gate 	uint64_t ec_way;	/* Ecache way */
1354*7c478bd9Sstevel@tonic-gate 	uint64_t ec_tag;	/* Ecache Tag */
1355*7c478bd9Sstevel@tonic-gate 	uint64_t ec_tag_ecc;	/* Ecache Tag ECC (Cheetah+ only) */
1356*7c478bd9Sstevel@tonic-gate 	ec_data_elm_t ec_data[CH_ECACHE_SUBBLK_SIZE/CH_ECACHE_STGREG_SIZE];
1357*7c478bd9Sstevel@tonic-gate } ch_ec_data_t;
1358*7c478bd9Sstevel@tonic-gate 
1359*7c478bd9Sstevel@tonic-gate /*
1360*7c478bd9Sstevel@tonic-gate  * Dcache data captured by cpu log out code and get_dcache_dtag.
1361*7c478bd9Sstevel@tonic-gate  * See Cheetah PRM 10.6.[1-4].
1362*7c478bd9Sstevel@tonic-gate  */
1363*7c478bd9Sstevel@tonic-gate typedef struct ch_dc_data {
1364*7c478bd9Sstevel@tonic-gate 	uint64_t dc_logflag;	/* Flag indicates if data was logged */
1365*7c478bd9Sstevel@tonic-gate 	uint64_t dc_idx;	/* Dcache index */
1366*7c478bd9Sstevel@tonic-gate 	uint64_t dc_way;	/* Dcache way */
1367*7c478bd9Sstevel@tonic-gate 	uint64_t dc_tag;	/* Tag/Valid Fields */
1368*7c478bd9Sstevel@tonic-gate 	uint64_t dc_utag;	/* Microtag */
1369*7c478bd9Sstevel@tonic-gate 	uint64_t dc_sntag;	/* Snoop Tag */
1370*7c478bd9Sstevel@tonic-gate 	uint64_t dc_data[CH_DC_DATA_REG_SIZE/sizeof (uint64_t)]; /* Data */
1371*7c478bd9Sstevel@tonic-gate 	uint64_t dc_pn_data_parity;	/* Data parity bits for Panther */
1372*7c478bd9Sstevel@tonic-gate } ch_dc_data_t;
1373*7c478bd9Sstevel@tonic-gate 
1374*7c478bd9Sstevel@tonic-gate /*
1375*7c478bd9Sstevel@tonic-gate  * Icache data captured by cpu log out code and get_icache_dtag.
1376*7c478bd9Sstevel@tonic-gate  * See Cheetah PRM 10.4.[1-3].
1377*7c478bd9Sstevel@tonic-gate  */
1378*7c478bd9Sstevel@tonic-gate typedef struct ch_ic_data {
1379*7c478bd9Sstevel@tonic-gate 	uint64_t ic_logflag;	/* Flag indicates if data was logged */
1380*7c478bd9Sstevel@tonic-gate 	uint64_t ic_idx;	/* Icache index */
1381*7c478bd9Sstevel@tonic-gate 	uint64_t ic_way;	/* Icache way */
1382*7c478bd9Sstevel@tonic-gate 	uint64_t ic_patag;	/* Physical address tag */
1383*7c478bd9Sstevel@tonic-gate 	uint64_t ic_utag;	/* Microtag */
1384*7c478bd9Sstevel@tonic-gate 	uint64_t ic_upper;	/* Upper valid/predict tag */
1385*7c478bd9Sstevel@tonic-gate 	uint64_t ic_lower;	/* Lower valid/predict tag */
1386*7c478bd9Sstevel@tonic-gate 	uint64_t ic_sntag;	/* Snoop Tag */
1387*7c478bd9Sstevel@tonic-gate 	uint64_t ic_data[PN_IC_DATA_REG_SIZE/sizeof (uint64_t)]; /* Data */
1388*7c478bd9Sstevel@tonic-gate } ch_ic_data_t;
1389*7c478bd9Sstevel@tonic-gate 
1390*7c478bd9Sstevel@tonic-gate /*
1391*7c478bd9Sstevel@tonic-gate  * Pcache data captured by get_pcache_dtag
1392*7c478bd9Sstevel@tonic-gate  */
1393*7c478bd9Sstevel@tonic-gate typedef struct ch_pc_data {
1394*7c478bd9Sstevel@tonic-gate 	uint64_t pc_logflag;	/* Flag indicates if data was logged */
1395*7c478bd9Sstevel@tonic-gate 	uint64_t pc_idx;	/* Pcache index */
1396*7c478bd9Sstevel@tonic-gate 	uint64_t pc_way;	/* Pcache way */
1397*7c478bd9Sstevel@tonic-gate 	uint64_t pc_status;	/* Pcache status data */
1398*7c478bd9Sstevel@tonic-gate 	uint64_t pc_tag;	/* Tag/Valid Fields */
1399*7c478bd9Sstevel@tonic-gate 	uint64_t pc_sntag;	/* Snoop Tag */
1400*7c478bd9Sstevel@tonic-gate 	uint64_t pc_data[CH_PC_DATA_REG_SIZE/sizeof (uint64_t)]; /* Data */
1401*7c478bd9Sstevel@tonic-gate } ch_pc_data_t;
1402*7c478bd9Sstevel@tonic-gate 
1403*7c478bd9Sstevel@tonic-gate /*
1404*7c478bd9Sstevel@tonic-gate  * CPU Error State
1405*7c478bd9Sstevel@tonic-gate  */
1406*7c478bd9Sstevel@tonic-gate typedef struct ch_cpu_errors {
1407*7c478bd9Sstevel@tonic-gate 	uint64_t afsr;		/* AFSR */
1408*7c478bd9Sstevel@tonic-gate 	uint64_t afar;		/* AFAR */
1409*7c478bd9Sstevel@tonic-gate 	/*
1410*7c478bd9Sstevel@tonic-gate 	 * The following registers don't exist on cheetah
1411*7c478bd9Sstevel@tonic-gate 	 */
1412*7c478bd9Sstevel@tonic-gate 	uint64_t shadow_afsr;	/* Shadow AFSR */
1413*7c478bd9Sstevel@tonic-gate 	uint64_t shadow_afar;	/* Shadow AFAR */
1414*7c478bd9Sstevel@tonic-gate 	uint64_t afsr_ext;	/* AFSR1_EXT */
1415*7c478bd9Sstevel@tonic-gate 	uint64_t shadow_afsr_ext;	/* AFSR2_EXT */
1416*7c478bd9Sstevel@tonic-gate 	uint64_t afar2;		/* AFAR2 - Serrano only */
1417*7c478bd9Sstevel@tonic-gate } ch_cpu_errors_t;
1418*7c478bd9Sstevel@tonic-gate 
1419*7c478bd9Sstevel@tonic-gate /*
1420*7c478bd9Sstevel@tonic-gate  * CPU logout structures.
1421*7c478bd9Sstevel@tonic-gate  * NOTE: These structures should be the same for Cheetah, Cheetah+,
1422*7c478bd9Sstevel@tonic-gate  *	 Jaguar, Panther, and Jalapeno since the assembler code relies
1423*7c478bd9Sstevel@tonic-gate  *	 on one set of offsets. Panther is the only processor that
1424*7c478bd9Sstevel@tonic-gate  *	 uses the chd_l2_data field since it has both L3 and L2 caches.
1425*7c478bd9Sstevel@tonic-gate  */
1426*7c478bd9Sstevel@tonic-gate typedef struct ch_diag_data {
1427*7c478bd9Sstevel@tonic-gate 	uint64_t chd_afar;				/* AFAR */
1428*7c478bd9Sstevel@tonic-gate 	uint64_t chd_afsr;				/* AFSR */
1429*7c478bd9Sstevel@tonic-gate 	uint64_t chd_afsr_ext;				/* AFSR_EXT */
1430*7c478bd9Sstevel@tonic-gate 	uint64_t chd_afar2;			/* AFAR2 - Serrano only */
1431*7c478bd9Sstevel@tonic-gate 	ch_ec_data_t chd_ec_data[CHD_EC_DATA_SETS];	/* Ecache data */
1432*7c478bd9Sstevel@tonic-gate 	ch_ec_data_t chd_l2_data[PN_L2_NWAYS];		/* L2 cache data */
1433*7c478bd9Sstevel@tonic-gate 	ch_dc_data_t chd_dc_data;			/* Dcache data */
1434*7c478bd9Sstevel@tonic-gate 	ch_ic_data_t chd_ic_data;			/* Icache data */
1435*7c478bd9Sstevel@tonic-gate } ch_diag_data_t;
1436*7c478bd9Sstevel@tonic-gate 
1437*7c478bd9Sstevel@tonic-gate 
1438*7c478bd9Sstevel@tonic-gate /*
1439*7c478bd9Sstevel@tonic-gate  * Top level CPU logout structure.
1440*7c478bd9Sstevel@tonic-gate  * clo_flags is used to hold information such as trap type, trap level,
1441*7c478bd9Sstevel@tonic-gate  * CEEN value, etc that is needed by the individual trap handlers. Not
1442*7c478bd9Sstevel@tonic-gate  * all fields in this flag are used by all trap handlers but when they
1443*7c478bd9Sstevel@tonic-gate  * are used, here's how they are laid out:
1444*7c478bd9Sstevel@tonic-gate  *
1445*7c478bd9Sstevel@tonic-gate  * |-------------------------------------------------------|
1446*7c478bd9Sstevel@tonic-gate  * |        | trap type | trap level |  |UCEEN| |NCEEN|CEEN|
1447*7c478bd9Sstevel@tonic-gate  * |-------------------------------------------------------|
1448*7c478bd9Sstevel@tonic-gate  *  63       19       12 11         8      3   2   1    0
1449*7c478bd9Sstevel@tonic-gate  *
1450*7c478bd9Sstevel@tonic-gate  * Note that the *CEEN bits correspond exactly to the same bit positions
1451*7c478bd9Sstevel@tonic-gate  * that are used in the error enable register.
1452*7c478bd9Sstevel@tonic-gate  */
1453*7c478bd9Sstevel@tonic-gate typedef struct ch_cpu_logout {
1454*7c478bd9Sstevel@tonic-gate 	uint64_t clo_flags;		/* Information about this trap */
1455*7c478bd9Sstevel@tonic-gate 	uint64_t clo_nest_cnt;		/* To force an upper bound */
1456*7c478bd9Sstevel@tonic-gate 	ch_diag_data_t clo_data;	/* Diag data for primary AFAR */
1457*7c478bd9Sstevel@tonic-gate 	ch_diag_data_t clo_sdw_data;	/* Diag data for shadow AFAR */
1458*7c478bd9Sstevel@tonic-gate } ch_cpu_logout_t;
1459*7c478bd9Sstevel@tonic-gate 
1460*7c478bd9Sstevel@tonic-gate typedef struct ch_tte_entry {
1461*7c478bd9Sstevel@tonic-gate 	uint64_t ch_tte_tag;
1462*7c478bd9Sstevel@tonic-gate 	uint64_t ch_tte_data;
1463*7c478bd9Sstevel@tonic-gate } ch_tte_entry_t;
1464*7c478bd9Sstevel@tonic-gate 
1465*7c478bd9Sstevel@tonic-gate /*
1466*7c478bd9Sstevel@tonic-gate  * Top level CPU logout structure for TLB parity errors.
1467*7c478bd9Sstevel@tonic-gate  *
1468*7c478bd9Sstevel@tonic-gate  * tlo_logflag  - Flag indicates if data was logged
1469*7c478bd9Sstevel@tonic-gate  * tlo_info	- Used to keep track of a number of values:
1470*7c478bd9Sstevel@tonic-gate  *   itlb pgsz	  - Page size of the VA whose lookup in the ITLB caused
1471*7c478bd9Sstevel@tonic-gate  *		    the exception (from ASI_IMMU_TAG_ACCESS_EXT.)
1472*7c478bd9Sstevel@tonic-gate  *   dtlb pgsz1	  - Page size of the VA whose lookup in the DTLB T512_1
1473*7c478bd9Sstevel@tonic-gate  *		    caused the exception (from ASI_DMMU_TAG_ACCESS_EXT.).
1474*7c478bd9Sstevel@tonic-gate  *   dtlb pgsz0	  - Page size of the VA whose lookup in the DTLB T512_0
1475*7c478bd9Sstevel@tonic-gate  *		    caused the exception (from ASI_DMMU_TAG_ACCESS_EXT.).
1476*7c478bd9Sstevel@tonic-gate  *   immu	  - Trap is the result of an ITLB exception if immu == 1.
1477*7c478bd9Sstevel@tonic-gate  *		    Otherwise, for DTLB exceptions immu == 0.
1478*7c478bd9Sstevel@tonic-gate  *   tl1	  - Set to 1 if the exception occured at TL>0.
1479*7c478bd9Sstevel@tonic-gate  *   context	  - Context of the VA whose lookup in the TLB caused the
1480*7c478bd9Sstevel@tonic-gate  *		    exception (from ASI_[I|D]MMU_TAG_ACCESS.)
1481*7c478bd9Sstevel@tonic-gate  * |---------------------------------------------------------------------|
1482*7c478bd9Sstevel@tonic-gate  * |...| itlb pgsz  | dtlb pgsz1 | dtlb pgsz0 |...| immu | tl1 | context |
1483*7c478bd9Sstevel@tonic-gate  * |---------------------------------------------------------------------|
1484*7c478bd9Sstevel@tonic-gate  *      24        22 21        19 18        16       14    13   12      0
1485*7c478bd9Sstevel@tonic-gate  *
1486*7c478bd9Sstevel@tonic-gate  * tlo_addr	- VA that cause the MMU exception trap.
1487*7c478bd9Sstevel@tonic-gate  * tlo_pc	- PC where the exception occured.
1488*7c478bd9Sstevel@tonic-gate  * tlo_itlb_tte	- TTEs that were in the ITLB after the trap at the index
1489*7c478bd9Sstevel@tonic-gate  *		  specific to the VA and page size in question.
1490*7c478bd9Sstevel@tonic-gate  * tlo_dtlb_tte	- TTEs that were in the DTLB after the trap at the index
1491*7c478bd9Sstevel@tonic-gate  *		  specific to the VA and page size in question.
1492*7c478bd9Sstevel@tonic-gate  */
1493*7c478bd9Sstevel@tonic-gate typedef struct pn_tlb_logout {
1494*7c478bd9Sstevel@tonic-gate 	uint64_t tlo_logflag;
1495*7c478bd9Sstevel@tonic-gate 	uint64_t tlo_info;
1496*7c478bd9Sstevel@tonic-gate 	uint64_t tlo_addr;
1497*7c478bd9Sstevel@tonic-gate 	uint64_t tlo_pc;
1498*7c478bd9Sstevel@tonic-gate 	ch_tte_entry_t tlo_itlb_tte[PN_ITLB_NWAYS * PN_NUM_512_ITLBS];
1499*7c478bd9Sstevel@tonic-gate 	ch_tte_entry_t tlo_dtlb_tte[PN_DTLB_NWAYS * PN_NUM_512_DTLBS];
1500*7c478bd9Sstevel@tonic-gate } pn_tlb_logout_t;
1501*7c478bd9Sstevel@tonic-gate 
1502*7c478bd9Sstevel@tonic-gate #if defined(CPU_IMP_L1_CACHE_PARITY)
1503*7c478bd9Sstevel@tonic-gate /*
1504*7c478bd9Sstevel@tonic-gate  * Parity error logging structure.
1505*7c478bd9Sstevel@tonic-gate  */
1506*7c478bd9Sstevel@tonic-gate typedef union ch_l1_parity_log {
1507*7c478bd9Sstevel@tonic-gate 	struct {
1508*7c478bd9Sstevel@tonic-gate 		int cpl_way;				/* Faulty line way */
1509*7c478bd9Sstevel@tonic-gate 		int cpl_off;				/* Faulty line offset */
1510*7c478bd9Sstevel@tonic-gate 		int cpl_tag;				/* Faulty tags list */
1511*7c478bd9Sstevel@tonic-gate 		int cpl_lcnt;				/* Faulty cache lines */
1512*7c478bd9Sstevel@tonic-gate 		ch_dc_data_t cpl_dc[CH_DCACHE_NWAY];	/* D$ data nWays */
1513*7c478bd9Sstevel@tonic-gate 		ch_pc_data_t cpl_pc[CH_PCACHE_NWAY];	/* P$ data nWays */
1514*7c478bd9Sstevel@tonic-gate 		int cpl_cache;				/* error in D$ or P$? */
1515*7c478bd9Sstevel@tonic-gate 	} dpe;	/* D$ parity error */
1516*7c478bd9Sstevel@tonic-gate 	struct {
1517*7c478bd9Sstevel@tonic-gate 		int cpl_way;				/* Faulty line way */
1518*7c478bd9Sstevel@tonic-gate 		int cpl_off;				/* Faulty line offset */
1519*7c478bd9Sstevel@tonic-gate 		int cpl_tag;				/* Faulty tags list */
1520*7c478bd9Sstevel@tonic-gate 		int cpl_lcnt;				/* Faulty cache lines */
1521*7c478bd9Sstevel@tonic-gate 		ch_ic_data_t cpl_ic[CH_ICACHE_NWAY];	/* I$ data nWays */
1522*7c478bd9Sstevel@tonic-gate 	} ipe;	/* I$ parity error */
1523*7c478bd9Sstevel@tonic-gate } ch_l1_parity_log_t;
1524*7c478bd9Sstevel@tonic-gate 
1525*7c478bd9Sstevel@tonic-gate #endif	/* CPU_IMP_L1_CACHE_PARITY */
1526*7c478bd9Sstevel@tonic-gate 
1527*7c478bd9Sstevel@tonic-gate /*
1528*7c478bd9Sstevel@tonic-gate  * Error at TL>0 CPU logout data.
1529*7c478bd9Sstevel@tonic-gate  *   Needs some extra space to save %g registers and miscellaneous info.
1530*7c478bd9Sstevel@tonic-gate  */
1531*7c478bd9Sstevel@tonic-gate typedef struct ch_err_tl1_data {
1532*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_g1;		/* Saved %g1 */
1533*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_g2;		/* Saved %g2 */
1534*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_g3;		/* Saved %g3 */
1535*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_g4;		/* Saved %g4 */
1536*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_g5;		/* Saved %g5 */
1537*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_g6;		/* Saved %g6 */
1538*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_g7;		/* Saved %g7 */
1539*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_tpc;	/* Trap PC */
1540*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_flags;	/* miscellaneous flags */
1541*7c478bd9Sstevel@tonic-gate 	uint64_t ch_err_tl1_tmp;	/* some handlers may use as tmp */
1542*7c478bd9Sstevel@tonic-gate 	ch_cpu_logout_t ch_err_tl1_logout;	/* logout */
1543*7c478bd9Sstevel@tonic-gate } ch_err_tl1_data_t;
1544*7c478bd9Sstevel@tonic-gate 
1545*7c478bd9Sstevel@tonic-gate /* Indices into chsm_outstanding and friends */
1546*7c478bd9Sstevel@tonic-gate #define	CACHE_SCRUBBER_INFO_E	0
1547*7c478bd9Sstevel@tonic-gate #define	CACHE_SCRUBBER_INFO_D	1
1548*7c478bd9Sstevel@tonic-gate #define	CACHE_SCRUBBER_INFO_I	2
1549*7c478bd9Sstevel@tonic-gate 
1550*7c478bd9Sstevel@tonic-gate /* We define 3 scrubbers: E$, D$, and I$ */
1551*7c478bd9Sstevel@tonic-gate #define	CACHE_SCRUBBER_COUNT	3
1552*7c478bd9Sstevel@tonic-gate 
1553*7c478bd9Sstevel@tonic-gate /*
1554*7c478bd9Sstevel@tonic-gate  * The ch_scrub_misc structure contains miscellaneous bookkeeping
1555*7c478bd9Sstevel@tonic-gate  * items for scrubbing the I$, D$, and E$.
1556*7c478bd9Sstevel@tonic-gate  *
1557*7c478bd9Sstevel@tonic-gate  * For a description of the use of chsm_core_state and why it's not needed
1558*7c478bd9Sstevel@tonic-gate  * on Jaguar, see the comment above cpu_scrub_cpu_setup() in us3_cheetahplus.c.
1559*7c478bd9Sstevel@tonic-gate  */
1560*7c478bd9Sstevel@tonic-gate typedef struct ch_scrub_misc {
1561*7c478bd9Sstevel@tonic-gate 	uint32_t	chsm_outstanding[CACHE_SCRUBBER_COUNT];
1562*7c478bd9Sstevel@tonic-gate 						/* outstanding requests */
1563*7c478bd9Sstevel@tonic-gate 	int		chsm_flush_index[CACHE_SCRUBBER_COUNT];
1564*7c478bd9Sstevel@tonic-gate 						/* next line to flush */
1565*7c478bd9Sstevel@tonic-gate 	int		chsm_enable[CACHE_SCRUBBER_COUNT];
1566*7c478bd9Sstevel@tonic-gate 				/* is this scrubber enabled on this core? */
1567*7c478bd9Sstevel@tonic-gate 	int		chsm_ecache_nlines;	/* no. of E$ lines */
1568*7c478bd9Sstevel@tonic-gate 	int		chsm_ecache_busy;	/* keeps track if cpu busy */
1569*7c478bd9Sstevel@tonic-gate 	int		chsm_icache_nlines;	/* no. of I$ lines */
1570*7c478bd9Sstevel@tonic-gate 	int		chsm_core_state;	/* which core the scrubber is */
1571*7c478bd9Sstevel@tonic-gate 						/* running on (Panther only) */
1572*7c478bd9Sstevel@tonic-gate } ch_scrub_misc_t;
1573*7c478bd9Sstevel@tonic-gate 
1574*7c478bd9Sstevel@tonic-gate /*
1575*7c478bd9Sstevel@tonic-gate  * Cheetah module private data structure.  One of these is allocated for
1576*7c478bd9Sstevel@tonic-gate  * each valid cpu at setup time and is pointed to by the machcpu
1577*7c478bd9Sstevel@tonic-gate  * "cpu_private" pointer.  For Cheetah, we have the miscellaneous scrubber
1578*7c478bd9Sstevel@tonic-gate  * variables and cpu log out structures for Fast ECC traps at TL=0,
1579*7c478bd9Sstevel@tonic-gate  * Disrupting (correctable) traps and Deferred (asynchronous) traps.  For
1580*7c478bd9Sstevel@tonic-gate  * Disrupting traps only one log out structure is needed because we cannot
1581*7c478bd9Sstevel@tonic-gate  * get a TL>0 disrupting trap since it obeys IE.  For Deferred traps we
1582*7c478bd9Sstevel@tonic-gate  * cannot get a TL>0 because we turn off NCEEN during log out capture.  E$
1583*7c478bd9Sstevel@tonic-gate  * set size (E$ size / nways) is saved here to avoid repeated calculations.
1584*7c478bd9Sstevel@tonic-gate  * NB: The ch_err_tl1_data_t structures cannot cross a page boundary
1585*7c478bd9Sstevel@tonic-gate  *      because we use physical addresses to access them.  We ensure this
1586*7c478bd9Sstevel@tonic-gate  *      by allocating them near the front of cheetah_private_t, which is
1587*7c478bd9Sstevel@tonic-gate  *      aligned on PAGESIZE (8192) via kmem_cache_create, and by ASSERTing
1588*7c478bd9Sstevel@tonic-gate  *	sizeof (chpr_tl1_err_data) <= CH_ECACHE_MAX_LSIZE in the
1589*7c478bd9Sstevel@tonic-gate  *	cpu_init_private routines.
1590*7c478bd9Sstevel@tonic-gate  * NB:  chpr_icache_size and chpr_icache_linesize need to be at the front
1591*7c478bd9Sstevel@tonic-gate  *	of cheetah_private_t because putting them after chpr_tl1_err_data
1592*7c478bd9Sstevel@tonic-gate  *	would make their offsets > 4195.
1593*7c478bd9Sstevel@tonic-gate  */
1594*7c478bd9Sstevel@tonic-gate typedef struct cheetah_private {
1595*7c478bd9Sstevel@tonic-gate 	int			chpr_icache_size;
1596*7c478bd9Sstevel@tonic-gate 	int			chpr_icache_linesize;
1597*7c478bd9Sstevel@tonic-gate 	ch_err_tl1_data_t	chpr_tl1_err_data[CH_ERR_TL1_TLMAX];
1598*7c478bd9Sstevel@tonic-gate 	ch_scrub_misc_t		chpr_scrub_misc;
1599*7c478bd9Sstevel@tonic-gate 	int			chpr_ec_set_size;
1600*7c478bd9Sstevel@tonic-gate 	ch_cpu_logout_t		chpr_fecctl0_logout;
1601*7c478bd9Sstevel@tonic-gate 	ch_cpu_logout_t		chpr_cecc_logout;
1602*7c478bd9Sstevel@tonic-gate 	ch_cpu_logout_t		chpr_async_logout;
1603*7c478bd9Sstevel@tonic-gate 	pn_tlb_logout_t		chpr_tlb_logout;
1604*7c478bd9Sstevel@tonic-gate 	uint64_t		chpr_fpras_timestamp[FPRAS_NCOPYOPS];
1605*7c478bd9Sstevel@tonic-gate 	hrtime_t		chpr_ceptnr_seltime;
1606*7c478bd9Sstevel@tonic-gate 	int			chpr_ceptnr_id;
1607*7c478bd9Sstevel@tonic-gate } cheetah_private_t;
1608*7c478bd9Sstevel@tonic-gate 
1609*7c478bd9Sstevel@tonic-gate #endif /* _ASM */
1610*7c478bd9Sstevel@tonic-gate 
1611*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
1612*7c478bd9Sstevel@tonic-gate 
1613*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1614*7c478bd9Sstevel@tonic-gate }
1615*7c478bd9Sstevel@tonic-gate #endif
1616*7c478bd9Sstevel@tonic-gate 
1617*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_CHEETAHREGS_H */
1618