xref: /onnv-gate/usr/src/uts/sun4u/sys/cheetahregs.h (revision 6330:2eaeee151663)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51772Sjl139090  * Common Development and Distribution License (the "License").
61772Sjl139090  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
226230Sss137449  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_CHEETAHREGS_H
270Sstevel@tonic-gate #define	_SYS_CHEETAHREGS_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/machasi.h>
321772Sjl139090 #include <sys/cpu_impl.h>
330Sstevel@tonic-gate #ifdef _KERNEL
340Sstevel@tonic-gate #include <sys/fpras.h>
350Sstevel@tonic-gate #endif /* _KERNEL */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate /*
380Sstevel@tonic-gate  * This file is cpu dependent.
390Sstevel@tonic-gate  */
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #ifdef	__cplusplus
420Sstevel@tonic-gate extern "C" {
430Sstevel@tonic-gate #endif
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * Cheetah includes the process info in its mask to make things
470Sstevel@tonic-gate  * more difficult.  The process is the low bit of the major mask,
480Sstevel@tonic-gate  * so to convert to the netlist major:
490Sstevel@tonic-gate  * netlist_major = ((mask_major >> 1) + 1)
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate #define	REMAP_CHEETAH_MASK(x)	(((((x) >> 1) + 0x10) & 0xf0) | ((x) & 0xf))
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #ifdef _ASM
540Sstevel@tonic-gate /*
550Sstevel@tonic-gate  * assembler doesn't understand the 'ull' suffix for C constants so
560Sstevel@tonic-gate  * use the inttypes.h macros and undefine them here for assembly code
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate #undef INT64_C
590Sstevel@tonic-gate #undef UINT64_C
600Sstevel@tonic-gate #define	INT64_C(x)	(x)
610Sstevel@tonic-gate #define	UINT64_C(x)	(x)
620Sstevel@tonic-gate #endif	/* _ASM */
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate  * DCU Control Register
660Sstevel@tonic-gate  *
670Sstevel@tonic-gate  * +------+----+----+----+----+----+-----+-----+----+----+----+
680Sstevel@tonic-gate  * | Resv | CP | CV | ME | RE | PE | HPE | SPE | SL | WE | PM |
690Sstevel@tonic-gate  * +------+----+----+----+----+----+-----+-----+----+----+----+
700Sstevel@tonic-gate  *  63:50   49   48   47   46	45    44    43   42   41 40:33
710Sstevel@tonic-gate  *
720Sstevel@tonic-gate  * +----+----+----+----+----+----------+-----+----+----+----+---+
730Sstevel@tonic-gate  * | VM | PR | PW | VR | VW | Reserved | WIH | DM | IM | DC | IC|
740Sstevel@tonic-gate  * +----+----+----+----+----+----------+-----+----+----+----+---+
750Sstevel@tonic-gate  * 32:25  24   23   22   21      20:5     4     3    2    1   0
760Sstevel@tonic-gate  */
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #define	ASI_DCU	ASI_LSU			    /* same as spitfire ASI_LSU 0x45 */
790Sstevel@tonic-gate #define	DCU_IC	INT64_C(0x0000000000000001) /* icache enable		*/
800Sstevel@tonic-gate #define	DCU_DC	INT64_C(0x0000000000000002) /* dcache enable		*/
810Sstevel@tonic-gate #define	DCU_IM	INT64_C(0x0000000000000004) /* immu enable		*/
820Sstevel@tonic-gate #define	DCU_DM	INT64_C(0x0000000000000008) /* dmmu enable		*/
830Sstevel@tonic-gate #define	DCU_WIH	INT64_C(0x0000000000000010) /* Jaguar only - W$ hash index */
840Sstevel@tonic-gate #define	DCU_VW	INT64_C(0x0000000000200000) /* virt watchpoint write enable  */
850Sstevel@tonic-gate #define	DCU_VR	INT64_C(0x0000000000400000) /* virt watchpoint read enable   */
860Sstevel@tonic-gate #define	DCU_PW	INT64_C(0x0000000000800000) /* phys watchpoint write enable  */
870Sstevel@tonic-gate #define	DCU_PR	INT64_C(0x0000000001000000) /* phys watchpoint read enable   */
880Sstevel@tonic-gate #define	DCU_VM	INT64_C(0x00000001FE000000) /* virtual watchpoint write mask */
890Sstevel@tonic-gate #define	DCU_PM	INT64_C(0x000001FE00000000) /* phys watchpoint write mask    */
900Sstevel@tonic-gate #define	DCU_WE	INT64_C(0x0000020000000000) /* write cache enable	*/
910Sstevel@tonic-gate #define	DCU_SL	INT64_C(0x0000040000000000) /* second load control	*/
920Sstevel@tonic-gate #define	DCU_SPE	INT64_C(0x0000080000000000) /* software prefetch enable */
930Sstevel@tonic-gate #define	DCU_HPE	INT64_C(0x0000100000000000) /* hardware prefetch enable */
940Sstevel@tonic-gate #define	DCU_PE	INT64_C(0x0000200000000000) /* prefetch enable		*/
950Sstevel@tonic-gate #define	DCU_RE	INT64_C(0x0000400000000000) /* RAW bypass enable	*/
960Sstevel@tonic-gate #define	DCU_ME	INT64_C(0x0000800000000000) /* noncache store merging enable */
970Sstevel@tonic-gate #define	DCU_CV	INT64_C(0x0001000000000000) /* virt cacheability when DM=0   */
980Sstevel@tonic-gate #define	DCU_CP	INT64_C(0x0002000000000000) /* phys cacheable when DM,IM=0   */
990Sstevel@tonic-gate #define	DCU_CACHE (DCU_IC|DCU_DC|DCU_WE|DCU_SPE|DCU_HPE|DCU_PE)
100*6330Sjc25722 #define	DCU_IPS_MASK	INT64_C(0x0030000000000000)
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /*
1030Sstevel@tonic-gate  * bit shifts for the prefetch enable bit
1040Sstevel@tonic-gate  */
1050Sstevel@tonic-gate #define	DCU_PE_SHIFT	45
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate /*
1080Sstevel@tonic-gate  * Safari Configuration Register
1090Sstevel@tonic-gate  */
1100Sstevel@tonic-gate #define	ASI_SAFARI_CONFIG	ASI_UPA_CONFIG /* Safari Config Reg, 0x4A */
1110Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_1	INT64_C(0x0000000000000000) /* 1/1 clock */
1120Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_1_DIV	1	/* clock divisor: 1 */
1130Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_2	INT64_C(0x0000000040000000) /* 1/2 clock */
1140Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_2_DIV	2	/* clock divisor: 2 */
1150Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_32	INT64_C(0x0000000080000000) /* 1/32 clock */
1160Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_32_DIV	32	/* clock divisor: 32 */
1170Sstevel@tonic-gate #define	SAFARI_CONFIG_ECLK_MASK	(SAFARI_CONFIG_ECLK_32 | SAFARI_CONFIG_ECLK_2)
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
1200Sstevel@tonic-gate /*
1210Sstevel@tonic-gate  * JBUS Configuration Register
1220Sstevel@tonic-gate  */
1230Sstevel@tonic-gate #define	ASI_JBUS_CONFIG		ASI_UPA_CONFIG /* JBUS Config Reg, 0x4A */
1240Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_1	INT64_C(0x0000000000000000) /* 1/1 clock */
1250Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_1_DIV	1	/* clock divisor: 1 */
1260Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_2	INT64_C(0x0000000000002000) /* 1/2 clock */
1270Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_2_DIV	2	/* clock divisor: 2 */
1280Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_32	INT64_C(0x0000000000004000) /* 1/32 clock */
1290Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_32_DIV	32	/* clock divisor: 32 */
1300Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_MASK	(JBUS_CONFIG_ECLK_32 | JBUS_CONFIG_ECLK_2)
1310Sstevel@tonic-gate #define	JBUS_CONFIG_ECLK_SHIFT	13
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate /*
1340Sstevel@tonic-gate  * Jalapeno/Serrano MCU control registers and ASI
1350Sstevel@tonic-gate  */
1360Sstevel@tonic-gate #define	ASI_MCU_CTRL		0x72		/* MCU Control Reg ASI */
1370Sstevel@tonic-gate #define	JP_MCU_FSM_MASK		INT64_C(0x0000000006000000) /* 26..25 */
1380Sstevel@tonic-gate #define	JP_MCU_FSM_SHIFT	25
1390Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate #if defined(SERRANO)
1420Sstevel@tonic-gate #define	ASI_MCU_AFAR2_VA	0x18	/* captures FRC/FRU addr */
1430Sstevel@tonic-gate #endif	/* SERRANO */
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate #if defined(JALAPENO) && defined(JALAPENO_ERRATA_85)
1460Sstevel@tonic-gate /*
1470Sstevel@tonic-gate  * Tomatillo Estar control registers (for JP Errataum 85)
1480Sstevel@tonic-gate  */
1490Sstevel@tonic-gate #define	JBUS_SLAVE_T_PORT_BIT	48
1500Sstevel@tonic-gate #define	TOM_HIGH_PA		0x400		/* Hi 32 bit of Tom reg PA */
1510Sstevel@tonic-gate #define	M_T_ESTAR_CTRL_PA	0x0f410050	/* M T estar PA */
1520Sstevel@tonic-gate #define	S_T_ESTAR_CTRL_PA	0x0e410050	/* S T estar PA */
1530Sstevel@tonic-gate #define	M_T_J_CHNG_INIT_PA	0x0f410058	/* Master T estar PA */
1540Sstevel@tonic-gate #define	TOM_ESTAR_ELCK_MASK	0x23		/* bit 5,1,0 */
1550Sstevel@tonic-gate #define	TOM_FULL_SPEED		0x1
1560Sstevel@tonic-gate #define	TOM_HALF_SPEED		0x2
1570Sstevel@tonic-gate #define	TOM_SLOW_SPEED		0x20
1580Sstevel@tonic-gate #define	TOM_TRIGGER_MASK	0x18
1590Sstevel@tonic-gate #define	TOM_TRIGGER		0x10
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate #endif /* JALAPENO && JALAPENO_ERRATA_85 */
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate /*
1650Sstevel@tonic-gate  * Miscellaneous ASI definitions not in machasi.h
1660Sstevel@tonic-gate  */
1670Sstevel@tonic-gate #define	ASI_DC_UTAG		0x43	/* Dcache Microtag Fields */
1680Sstevel@tonic-gate #define	ASI_DC_SNP_TAG		0x44	/* Dcache Snoop Tag Fields */
1690Sstevel@tonic-gate #define	ASI_IC_SNP_TAG		0x68	/* Icache Snoop Tag Fields */
1700Sstevel@tonic-gate #define	ASI_IPB_DATA		0x69	/* Instruction Prefetch Buffer Data */
1710Sstevel@tonic-gate #define	ASI_IPB_TAG		0x6A	/* Instruction Prefetch Buffer Tag */
1720Sstevel@tonic-gate #define	ASI_MC_DECODE		0x72	/* Memory Address Decoding Registers */
1730Sstevel@tonic-gate #define	ASI_EC_CFG_TIMING	0x73	/* Jaguar shared Ecache Control Reg */
1740Sstevel@tonic-gate #define	ASI_EC_DATA		0x74	/* Ecache Data Staging Registers */
1750Sstevel@tonic-gate #define	ASI_EC_CTRL		0x75	/* Ecache Control Register */
1760Sstevel@tonic-gate #define	ASI_PC_STATUS_DATA	0x30	/* Pcache Status Data Access */
1770Sstevel@tonic-gate #define	ASI_PC_DATA		0x31	/* Pcache Diagnostic Data Register */
1780Sstevel@tonic-gate #define	ASI_PC_TAG		0x32	/* Pcache Virtual Tag/Valid Field */
1790Sstevel@tonic-gate #define	ASI_PC_SNP_TAG		0x33	/* Pcache Snoop Tag Register */
1800Sstevel@tonic-gate #define	ASI_L2_DATA		0x6B	/* L2 cache Data Diagnostic Access */
1810Sstevel@tonic-gate #define	ASI_L2_TAG		0x6C	/* L2 cache Tag Diagnostic Access */
1826230Sss137449 #define	ASI_L2CACHE_CTRL	0x6D	/* L2 cache Control Register */
1830Sstevel@tonic-gate 
1840Sstevel@tonic-gate /*
1850Sstevel@tonic-gate  * Bits of Cheetah Asynchronous Fault Status Register
1860Sstevel@tonic-gate  *
1870Sstevel@tonic-gate  * +---+--+----+----+----+----+---+---+---+---+--+----
1880Sstevel@tonic-gate  * |rsv|ME|PRIV|PERR|IERR|ISAP|EMC|EMU|IVC|IVU|TO|BERR
1890Sstevel@tonic-gate  * +---+--+----+----+----+----+---+---+---+---+--+----
1900Sstevel@tonic-gate  * 63:54 53 52   51   50   49   48  47  46  45 44  43
1910Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+------+---+-------+
1920Sstevel@tonic-gate  * |UCC|UCU|CPC|CPU|WDC|WDU|EDC|EDU|UE|CE|rsv|M_SYND|rsv||E_SYND|
1930Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+------+---+-------+
1940Sstevel@tonic-gate  *   42  41  40  39  38  37  36  35 34 33 32:20 19:16 15:9 8:0
1950Sstevel@tonic-gate  *
1960Sstevel@tonic-gate  */
1970Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
1980Sstevel@tonic-gate /*
1990Sstevel@tonic-gate  * Bits of Cheetah+ Asynchronous Fault Status Register
2000Sstevel@tonic-gate  *
2010Sstevel@tonic-gate  * +------------------+----------------------------
2020Sstevel@tonic-gate  * |rsv|TUE_SH|IMC|IMU|DTO|DBERR|THCE|TSCE|TUE|DUE|
2030Sstevel@tonic-gate  * +------------------+---------------------------- . . .
2040Sstevel@tonic-gate  *   63    62   61  60  59    58   57   56  55  54
2050Sstevel@tonic-gate  *
2060Sstevel@tonic-gate  * Note that bits 60-62 are only implemented in Panther (reserved
2070Sstevel@tonic-gate  * in Cheetah+ and Jaguar. Also, bit 56 is reserved in Panther instead
2080Sstevel@tonic-gate  * of TSCE since those errors are HW corrected in Panther.
2090Sstevel@tonic-gate  */
2100Sstevel@tonic-gate #define	C_AFSR_TUE_SH INT64_C(0x4000000000000000) /* uncorrectable tag UE  */
2110Sstevel@tonic-gate #define	C_AFSR_IMC  INT64_C(0x2000000000000000)	/* intr vector MTAG ECC */
2120Sstevel@tonic-gate #define	C_AFSR_IMU  INT64_C(0x1000000000000000)	/* intr vector MTAG ECC */
2130Sstevel@tonic-gate #define	C_AFSR_DTO  INT64_C(0x0800000000000000)	/* disrupting TO error */
2140Sstevel@tonic-gate #define	C_AFSR_DBERR INT64_C(0x0400000000000000) /* disrupting BERR error */
2150Sstevel@tonic-gate #define	C_AFSR_THCE INT64_C(0x0200000000000000)	/* h/w correctable E$ tag err */
2160Sstevel@tonic-gate #define	C_AFSR_TSCE INT64_C(0x0100000000000000)	/* s/w correctable E$ tag err */
2170Sstevel@tonic-gate #define	C_AFSR_TUE  INT64_C(0x0080000000000000)	/* uncorrectable E$ tag error */
2180Sstevel@tonic-gate #define	C_AFSR_DUE  INT64_C(0x0040000000000000)	/* disrupting UE error */
2190Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
2200Sstevel@tonic-gate #define	C_AFSR_ME   INT64_C(0x0020000000000000)	/* errors > 1, same type!=CE */
2210Sstevel@tonic-gate #define	C_AFSR_PRIV INT64_C(0x0010000000000000)	/* priv code access error    */
2220Sstevel@tonic-gate #define	C_AFSR_PERR INT64_C(0x0008000000000000)	/* system interface protocol */
2230Sstevel@tonic-gate #define	C_AFSR_IERR INT64_C(0x0004000000000000)	/* internal system interface */
2240Sstevel@tonic-gate #define	C_AFSR_ISAP INT64_C(0x0002000000000000)	/* system request parity err */
2250Sstevel@tonic-gate #define	C_AFSR_EMC  INT64_C(0x0001000000000000)	/* mtag   with   CE   error  */
2260Sstevel@tonic-gate #define	C_AFSR_EMU  INT64_C(0x0000800000000000)	/* mtag   with   UE   error  */
2270Sstevel@tonic-gate #define	C_AFSR_IVC  INT64_C(0x0000400000000000)	/* intr vector with CE error */
2280Sstevel@tonic-gate #define	C_AFSR_IVU  INT64_C(0x0000200000000000)	/* intr vector with UE error */
2290Sstevel@tonic-gate #define	C_AFSR_TO   INT64_C(0x0000100000000000)	/* bus timeout from sys bus  */
2300Sstevel@tonic-gate #define	C_AFSR_BERR INT64_C(0x0000080000000000)	/* bus error from system bus */
2310Sstevel@tonic-gate #define	C_AFSR_UCC  INT64_C(0x0000040000000000)	/* E$ with software CE error */
2320Sstevel@tonic-gate #define	C_AFSR_UCU  INT64_C(0x0000020000000000)	/* E$ with software UE error */
2330Sstevel@tonic-gate #define	C_AFSR_CPC  INT64_C(0x0000010000000000) /* copyout  with  CE  error  */
2340Sstevel@tonic-gate #define	C_AFSR_CPU  INT64_C(0x0000008000000000) /* copyout  with  UE  error  */
2350Sstevel@tonic-gate #define	C_AFSR_WDC  INT64_C(0x0000004000000000) /* writeback ecache CE error */
2360Sstevel@tonic-gate #define	C_AFSR_WDU  INT64_C(0x0000002000000000) /* writeback ecache UE error */
2370Sstevel@tonic-gate #define	C_AFSR_EDC  INT64_C(0x0000001000000000) /* ecache  CE  ECC  error    */
2380Sstevel@tonic-gate #define	C_AFSR_EDU  INT64_C(0x0000000800000000) /* ecache  UE  ECC  error    */
2390Sstevel@tonic-gate #define	C_AFSR_UE   INT64_C(0x0000000400000000) /* uncorrectable ECC error   */
2400Sstevel@tonic-gate #define	C_AFSR_CE   INT64_C(0x0000000200000000) /* correctable   ECC error   */
2410Sstevel@tonic-gate #define	C_AFSR_M_SYND	INT64_C(0x00000000000f0000) /* mtag  ECC  syndrome   */
2420Sstevel@tonic-gate #define	C_AFSR_E_SYND	INT64_C(0x00000000000001ff) /* data  ECC  syndrome   */
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate /* AFSR bits that could result in CPU removal due to E$ error */
2450Sstevel@tonic-gate #define	C_AFSR_L2_SERD_FAIL_UE	(C_AFSR_UCU | C_AFSR_CPU | C_AFSR_WDU | \
2460Sstevel@tonic-gate 				C_AFSR_EDU)
2470Sstevel@tonic-gate #define	C_AFSR_L2_SERD_FAIL_CE	(C_AFSR_UCC | C_AFSR_CPC | C_AFSR_WDC | \
2480Sstevel@tonic-gate 				C_AFSR_EDC)
2490Sstevel@tonic-gate /*
2500Sstevel@tonic-gate  * Bits of the Panther Extended Asynchronous Fault Status Register (AFSR_EXT)
2510Sstevel@tonic-gate  *
2520Sstevel@tonic-gate  * +-----+-------+-----------+-------+-------+---------+------+------+------+
2530Sstevel@tonic-gate  * | rsv |RED_ERR|EFA_PAR_ERR|L3_MECC|L3_THCE|L3_TUE_SH|L3_TUE|L3_EDC|L3_EDU|
2540Sstevel@tonic-gate  * +-----+-------+-----------+-------+-------+---------+------+------+------+
2550Sstevel@tonic-gate  *  63:14   13        12        11       10       9        8      7      6
2560Sstevel@tonic-gate  *
2570Sstevel@tonic-gate  * +------+------+------+------+------+------+
2580Sstevel@tonic-gate  * |L3_UCC|L3_UCU|L3_CPC|L3_CPU|L3_WDC|L3_WDU|
2590Sstevel@tonic-gate  * +------+------+------+------+------+------+
2600Sstevel@tonic-gate  *     5      4      3      2      1      0
2610Sstevel@tonic-gate  *
2620Sstevel@tonic-gate  * If the L3_MECC bit is set along with any of the L3 cache errors (bits 0-7)
2630Sstevel@tonic-gate  * above, it indicates that an address parity error has occured.
2640Sstevel@tonic-gate  */
2650Sstevel@tonic-gate #define	C_AFSR_RED_ERR   INT64_C(0x0000000000002000) /* redunancy Efuse error */
2660Sstevel@tonic-gate #define	C_AFSR_EFA_PAR_ERR INT64_C(0x0000000000001000) /* Efuse parity error */
2670Sstevel@tonic-gate #define	C_AFSR_L3_MECC   INT64_C(0x0000000000000800) /* L3 address parity */
2680Sstevel@tonic-gate #define	C_AFSR_L3_THCE   INT64_C(0x0000000000000400) /* tag CE */
2690Sstevel@tonic-gate #define	C_AFSR_L3_TUE_SH INT64_C(0x0000000000000200) /* tag UE from snp/cpy */
2700Sstevel@tonic-gate #define	C_AFSR_L3_TUE    INT64_C(0x0000000000000100) /* tag UE */
2710Sstevel@tonic-gate #define	C_AFSR_L3_EDC    INT64_C(0x0000000000000080) /* L3 cache CE */
2720Sstevel@tonic-gate #define	C_AFSR_L3_EDU    INT64_C(0x0000000000000040) /* L3 cache UE */
2730Sstevel@tonic-gate #define	C_AFSR_L3_UCC    INT64_C(0x0000000000000020) /* software recover CE */
2740Sstevel@tonic-gate #define	C_AFSR_L3_UCU    INT64_C(0x0000000000000010) /* software recover UE */
2750Sstevel@tonic-gate #define	C_AFSR_L3_CPC    INT64_C(0x0000000000000008) /* copyout with CE */
2760Sstevel@tonic-gate #define	C_AFSR_L3_CPU    INT64_C(0x0000000000000004) /* copyout with UE */
2770Sstevel@tonic-gate #define	C_AFSR_L3_WDC    INT64_C(0x0000000000000002) /* writeback CE */
2780Sstevel@tonic-gate #define	C_AFSR_L3_WDU    INT64_C(0x0000000000000001) /* writeback UE */
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
2810Sstevel@tonic-gate /*
2820Sstevel@tonic-gate  * Bits of Jalapeno Asynchronous Fault Status Register
2830Sstevel@tonic-gate  *
2840Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
2850Sstevel@tonic-gate  * | rsv |JETO|SCE|JEIC|JEIT|ME|PRIV|JEIS|IERR|ISAP|ETP|OM|UMS|IVPE|TO|BERR|
2860Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
2870Sstevel@tonic-gate  * 63:58   57   56   55  54  53  52   51   50   49  48  47  46  45  44  43
2880Sstevel@tonic-gate  *
2890Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
2900Sstevel@tonic-gate  * |UCC|UCU|CPC|CPU|WDC|WDU|EDC|EDU|UE|CE|RUE|RCE|BP|WBP|FRC|FRU|
2910Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
2920Sstevel@tonic-gate  *   42  41  40  39  38  37  36  35 34 33 32  31  30 29  28  27
2930Sstevel@tonic-gate  *
2940Sstevel@tonic-gate  * +-----+-----+-----+------+-----------+-------+
2950Sstevel@tonic-gate  * | JREQ| ETW | rsv |B_SYND| rsv | AID | E_SYND|
2960Sstevel@tonic-gate  * +-----+-----+-----+------+-----+-----+-------+
2970Sstevel@tonic-gate  *  26:24 23:22 21:20  19:16 15:14 13:9   8:0
2980Sstevel@tonic-gate  *
2990Sstevel@tonic-gate  */
3000Sstevel@tonic-gate 
3010Sstevel@tonic-gate /*
3020Sstevel@tonic-gate  * Bits of Serrano Asynchronous Fault Status Register
3030Sstevel@tonic-gate  *
3040Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
3050Sstevel@tonic-gate  * | rsv |JETO|SCE|JEIC|JEIT|ME|PRIV|JEIS|IERR|ISAP|ETU|OM|UMS|IVPE|TO|BERR|
3060Sstevel@tonic-gate  * +-----+------------------------------------------------------------------
3070Sstevel@tonic-gate  * 63:58   57   56   55  54  53  52   51   50   49  48  47  46  45  44  43
3080Sstevel@tonic-gate  *
3090Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
3100Sstevel@tonic-gate  * |UCC|UCU|CPC|CPU|WDC|WDU|EDC|EDU|UE|CE|RUE|RCE|BP|WBP|FRC|FRU|
3110Sstevel@tonic-gate  * +---+---+---+---+---+---+---+---+--+--+---+---+--+---+-------+
3120Sstevel@tonic-gate  *   42  41  40  39  38  37  36  35 34 33 32  31  30 29  28  27
3130Sstevel@tonic-gate  *
3140Sstevel@tonic-gate  * +-----+-----+------+---+------+---+---+-----+-------+
3150Sstevel@tonic-gate  * | JREQ| ETW | EFES |ETS|B_SYND|ETI|ETC| AID | E_SYND|
3160Sstevel@tonic-gate  * +-----+-----+------+---+------+---+---+-----+-------+
3170Sstevel@tonic-gate  *  26:24 23:22    21   20  19:16  15  14  13:9    8:0
3180Sstevel@tonic-gate  *
3190Sstevel@tonic-gate  */
3200Sstevel@tonic-gate 
3210Sstevel@tonic-gate #define	C_AFSR_JETO	INT64_C(0x0200000000000000) /* JBus Timeout */
3220Sstevel@tonic-gate #define	C_AFSR_SCE	INT64_C(0x0100000000000000) /* Snoop parity error */
3230Sstevel@tonic-gate #define	C_AFSR_JEIC	INT64_C(0x0080000000000000) /* JBus Illegal Cmd */
3240Sstevel@tonic-gate #define	C_AFSR_JEIT	INT64_C(0x0040000000000000) /* Illegal ADTYPE */
3250Sstevel@tonic-gate #define	C_AFSR_JEIS	INT64_C(0x0008000000000000) /* Illegal Install State */
3260Sstevel@tonic-gate #if defined(SERRANO)
3270Sstevel@tonic-gate #define	C_AFSR_ETU	INT64_C(0x0001000000000000) /* L2$ tag CE error */
3280Sstevel@tonic-gate #elif defined(JALAPENO)
3290Sstevel@tonic-gate #define	C_AFSR_ETP	INT64_C(0x0001000000000000) /* L2$ tag parity error */
3300Sstevel@tonic-gate #endif /* JALAPENO */
3310Sstevel@tonic-gate #define	C_AFSR_OM	INT64_C(0x0000800000000000) /* out of range mem error */
3320Sstevel@tonic-gate #define	C_AFSR_UMS	INT64_C(0x0000400000000000) /* Unsupported store */
3330Sstevel@tonic-gate #define	C_AFSR_IVPE	INT64_C(0x0000200000000000) /* intr vector parity err */
3340Sstevel@tonic-gate #define	C_AFSR_RUE	INT64_C(0x0000000100000000) /* remote mem UE error */
3350Sstevel@tonic-gate #define	C_AFSR_RCE	INT64_C(0x0000000080000000) /* remote mem CE error */
3360Sstevel@tonic-gate #define	C_AFSR_BP	INT64_C(0x0000000040000000) /* read data parity err */
3370Sstevel@tonic-gate #define	C_AFSR_WBP	INT64_C(0x0000000020000000) /* wb/bs data parity err */
3380Sstevel@tonic-gate #define	C_AFSR_FRC	INT64_C(0x0000000010000000) /* foregin mem CE error */
3390Sstevel@tonic-gate #define	C_AFSR_FRU	INT64_C(0x0000000008000000) /* foregin mem UE error */
3400Sstevel@tonic-gate #define	C_AFSR_JREQ	INT64_C(0x0000000007000000) /* Active JBus req at err */
3410Sstevel@tonic-gate #define	C_AFSR_ETW	INT64_C(0x0000000000c00000) /* AID causing UE/CE */
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate #if defined(SERRANO)
3440Sstevel@tonic-gate #define	C_AFSR_EFES	INT64_C(0x0000000000200000) /* E-fuse error summary */
3450Sstevel@tonic-gate #define	C_AFSR_ETS	INT64_C(0x0000000000100000) /* L2$ tag SRAM stuck-at */
3460Sstevel@tonic-gate #endif /* SERRANO */
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate #define	C_AFSR_B_SYND	INT64_C(0x00000000000f0000) /* jbus parity syndrome */
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate #if defined(SERRANO)
3510Sstevel@tonic-gate #define	C_AFSR_ETI	INT64_C(0x0000000000008000) /* L2$ tag intermittent */
3520Sstevel@tonic-gate #define	C_AFSR_ETC	INT64_C(0x0000000000004000) /* L2$ tag CE */
3530Sstevel@tonic-gate #endif /* SERRANO */
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate #define	C_AFSR_AID	INT64_C(0x0000000000003e00) /* AID causing UE/CE */
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate /* bit shifts for selected errors */
3580Sstevel@tonic-gate #define	C_AFSR_WDU_SHIFT	37
3590Sstevel@tonic-gate #define	C_AFSR_UCU_SHIFT	41
3600Sstevel@tonic-gate #define	C_AFSR_UCC_SHIFT	42
3610Sstevel@tonic-gate #define	C_AFSR_JREQ_SHIFT	24
3620Sstevel@tonic-gate #define	C_AFSR_AID_SHIFT	9
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate /*
3650Sstevel@tonic-gate  * Overloaded AFSR fields. During error processing, some of the reserved
3660Sstevel@tonic-gate  * fields within the saved AFSR are overwritten with extra information.
3670Sstevel@tonic-gate  */
3680Sstevel@tonic-gate #define	C_AFSR_PANIC_SHIFT		62
3690Sstevel@tonic-gate #define	C_AFSR_IPE_SHIFT		59
3700Sstevel@tonic-gate #define	C_AFSR_DPE_SHIFT		58
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate /* bit shifts for selected errors */
3750Sstevel@tonic-gate #define	C_AFSR_WDU_SHIFT	37
3760Sstevel@tonic-gate #define	C_AFSR_UCU_SHIFT	41
3770Sstevel@tonic-gate #define	C_AFSR_UCC_SHIFT	42
3780Sstevel@tonic-gate #define	C_AFSR_L3_UCU_SHIFT	4
3790Sstevel@tonic-gate 
3800Sstevel@tonic-gate /*
3810Sstevel@tonic-gate  * Overloaded AFSR fields. During error processing, some of the reserved fields
3820Sstevel@tonic-gate  * within the saved AFSR are overwritten with extra information.
3830Sstevel@tonic-gate  */
3840Sstevel@tonic-gate #define	C_AFSR_FIRSTFLT_SHIFT	63
3850Sstevel@tonic-gate #define	C_AFSR_PANIC_SHIFT	30
3860Sstevel@tonic-gate #define	C_AFSR_DPE_SHIFT	20
3870Sstevel@tonic-gate #define	C_AFSR_IPE_SHIFT	21
3880Sstevel@tonic-gate 
3890Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
3920Sstevel@tonic-gate /*
3930Sstevel@tonic-gate  * Jalapeno L2 Cache Control Register Bits.
3940Sstevel@tonic-gate  *
3950Sstevel@tonic-gate  *	Bit#	Name		Description
3960Sstevel@tonic-gate  *	63-24	-		reserved
3970Sstevel@tonic-gate  *	23:20	EC_ACT_WAY	(read only) indicates which sets are present
3980Sstevel@tonic-gate  *	19:16	EC_BLK_WAY	Bit mask indicating which sets are blocked
3990Sstevel@tonic-gate  *				from replacement
4000Sstevel@tonic-gate  *	15:14	EC_SIZE		L2 cache size
4010Sstevel@tonic-gate  *	13:12	-		reserved
4020Sstevel@tonic-gate  *	11	EC_PAR_EN	Enables parity checking on L2 cache tags
4030Sstevel@tonic-gate  *	10	EC_ECC_EN	Enables ECC checking on L2 cache data
4040Sstevel@tonic-gate  *	9	EC_ECC_FORCE	Enables EC_CHECK[8:0] onto L2 cache ECC bits
4050Sstevel@tonic-gate  *	8:0	EC_CHECK	ECC check vector to force onto ECC bits
4060Sstevel@tonic-gate  */
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate #define	JP_ECCTRL_ECSIZE_MASK		0xc000
4090Sstevel@tonic-gate #define	JP_ECCTRL_ECSIZE_SHIFT		14
4100Sstevel@tonic-gate #define	JP_ECCTRL_ECSIZE_MIN		0x80000
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate /*
4130Sstevel@tonic-gate  * Jalapeno L2 Cache Error Enable Register Bits
4140Sstevel@tonic-gate  *
4150Sstevel@tonic-gate  *	Bit#	Name	Description
4160Sstevel@tonic-gate  *	63-33	-	reserved
4170Sstevel@tonic-gate  *	32	SCDE	Enable detection of JBUS control parity error
4180Sstevel@tonic-gate  *	31:24	-	reserved
4190Sstevel@tonic-gate  *	23	IAEN	Enable trap on illegal physical address
4200Sstevel@tonic-gate  *	22	IERREN	Enable FERR system reset on CPU internal errors
4210Sstevel@tonic-gate  *	21	PERREN	Enable FERR system reset on JBUS protocol errors
4220Sstevel@tonic-gate  *	20	SCEN	Enable FERR system reset on JBUS control parity error
4230Sstevel@tonic-gate  *	19:11	FMED	Forced error on the memory ECC
4240Sstevel@tonic-gate  *	10	FME	Force error on memory ECC
4250Sstevel@tonic-gate  *	9:6	FPD	Bits to use when FSP forces JBUS addr/data parity error
4260Sstevel@tonic-gate  *	5	FSP	Force error on outgoing JBUS addr/data parity
4270Sstevel@tonic-gate  *	4	ETPEN	Enable FERR system reset on L2 tags parity error
4280Sstevel@tonic-gate  *	3	UCEEN	Enable trap on SW handled external cache error
4290Sstevel@tonic-gate  *	2	ISAPEN	Enable FERR system reset on request parity error
4300Sstevel@tonic-gate  *	1	NCEEN	Enable trap on uncorrectable ECC error and system err
4310Sstevel@tonic-gate  *	0	CEEN	Enable trap on correctable ECC errors
4320Sstevel@tonic-gate  */
4330Sstevel@tonic-gate 
4340Sstevel@tonic-gate #define	EN_REG_UCEEN	INT64_C(0x0000000000000008) /* enable UCC,UCU */
4350Sstevel@tonic-gate #define	EN_REG_ISAPEN	INT64_C(0x0000000000000004) /* enable ISAP */
4360Sstevel@tonic-gate #define	EN_REG_NCEEN INT64_C(0x0000000000000002) /* UE,EDU,WDU,BERR,IVU,EMU */
4370Sstevel@tonic-gate #define	EN_REG_CEEN INT64_C(0x0000000000000001) /* enable CE,EDC,WDC,IVC,EMC */
4380Sstevel@tonic-gate 
4390Sstevel@tonic-gate #define	EN_REG_DISABLE	INT64_C(0x0000000000000000) /* no errors enabled */
4400Sstevel@tonic-gate #define	EN_REG_ECC_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN)
4410Sstevel@tonic-gate #define	EN_REG_CE_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN)
4420Sstevel@tonic-gate #define	EN_REG_ENABLE \
4430Sstevel@tonic-gate 	(EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN | EN_REG_CEEN)
4440Sstevel@tonic-gate 
4450Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
4460Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
4470Sstevel@tonic-gate /*
4480Sstevel@tonic-gate  * Cheetah+ External Cache Control Register Bits.
4490Sstevel@tonic-gate  */
4500Sstevel@tonic-gate #define	ECCR_ASSOC	INT64_C(0x0000000001000000) /* Ecache Assoc. */
4510Sstevel@tonic-gate #define	ECCR_ASSOC_SHIFT	24
4520Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate /*
4550Sstevel@tonic-gate  * Bits of Cheetah External Cache Error Enable Register
4560Sstevel@tonic-gate  *
4570Sstevel@tonic-gate  * +-----+-----+-------+-----+-------+-------+--------+-------+------+
4580Sstevel@tonic-gate  * | rsv | FMT | FMECC | FMD | FDECC | UCEEN | ISAPEN | NCEEN | CEEN |
4590Sstevel@tonic-gate  * +-----+-----+-------+-----+-------+-------+--------+-------+------+
4600Sstevel@tonic-gate  *  63:19   18  17  14    13    12:4     3        2       1       0
4610Sstevel@tonic-gate  *
4620Sstevel@tonic-gate  */
4630Sstevel@tonic-gate #define	EN_REG_FMT	INT64_C(0x0000000000040000) /* force system mtag ECC */
4640Sstevel@tonic-gate #define	EN_REG_FMECC	INT64_C(0x000000000003C000) /* forced mtag ECC vector */
4650Sstevel@tonic-gate #define	EN_REG_FMD	INT64_C(0x0000000000002000) /* force system data ECC */
4660Sstevel@tonic-gate #define	EN_REG_FDECC	INT64_C(0x0000000000001ff0) /* forced data ECC vector */
4670Sstevel@tonic-gate #define	EN_REG_UCEEN	INT64_C(0x0000000000000008) /* enable UCC,UCU */
4680Sstevel@tonic-gate #define	EN_REG_ISAPEN	INT64_C(0x0000000000000004) /* enable ISAP */
4690Sstevel@tonic-gate #define	EN_REG_NCEEN INT64_C(0x0000000000000002) /* UE,EDU,WDU,BERR,IVU,EMU */
4700Sstevel@tonic-gate #define	EN_REG_CEEN INT64_C(0x0000000000000001) /* enable CE,EDC,WDC,IVC,EMC */
4710Sstevel@tonic-gate #define	EN_REG_DISABLE	INT64_C(0x0000000000000000) /* no errors enabled */
4720Sstevel@tonic-gate #define	EN_REG_ECC_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN)
4730Sstevel@tonic-gate #define	EN_REG_CE_DISABLE (EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN)
4740Sstevel@tonic-gate #define	EN_REG_ENABLE \
4750Sstevel@tonic-gate 	(EN_REG_UCEEN | EN_REG_ISAPEN | EN_REG_NCEEN | EN_REG_CEEN)
4760Sstevel@tonic-gate #endif	/* JALAPENO || SERRANO */
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate /*
4790Sstevel@tonic-gate  * bit shifts for selected bits
4800Sstevel@tonic-gate  */
4810Sstevel@tonic-gate #define	EN_REG_CEEN_SHIFT	0
4820Sstevel@tonic-gate 
4830Sstevel@tonic-gate /* Cheetah/Cheetah+ Dcache size */
4840Sstevel@tonic-gate #define	CH_DCACHE_SIZE		0x10000
4850Sstevel@tonic-gate 
4860Sstevel@tonic-gate /* Cheetah/Cheetah+ Dcache linesize */
4870Sstevel@tonic-gate #define	CH_DCACHE_LSIZE		0x20
4880Sstevel@tonic-gate 
4890Sstevel@tonic-gate /* Cheetah/Cheetah+/Jaguar Icache size */
4900Sstevel@tonic-gate #define	CH_ICACHE_SIZE		0x8000
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate /* Cheetah/Cheetah+/Jaguar Icache linesize */
4930Sstevel@tonic-gate #define	CH_ICACHE_LSIZE		0x20
4940Sstevel@tonic-gate 
4950Sstevel@tonic-gate /* Panther Icache size */
4960Sstevel@tonic-gate #define	PN_ICACHE_SIZE		0x10000
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate /* Panther Icache linesize */
4990Sstevel@tonic-gate #define	PN_ICACHE_LSIZE		0x40
5000Sstevel@tonic-gate 
5010Sstevel@tonic-gate /* Pcache size for the cheetah family of CPUs */
5020Sstevel@tonic-gate #define	CH_PCACHE_SIZE		0x800
5030Sstevel@tonic-gate 
5040Sstevel@tonic-gate /* Pcache linesize  for the cheetah family of CPUs */
5050Sstevel@tonic-gate #define	CH_PCACHE_LSIZE		0x40
5060Sstevel@tonic-gate 
5070Sstevel@tonic-gate /*
5080Sstevel@tonic-gate  * The cheetah+ CPU module handles Cheetah+, Jaguar, and Panther so
5090Sstevel@tonic-gate  * we have to pick max size and min linesize values for the Icache
5100Sstevel@tonic-gate  * accordingly.
5110Sstevel@tonic-gate  */
5120Sstevel@tonic-gate #define	CHP_ICACHE_MAX_SIZE	PN_ICACHE_SIZE
5130Sstevel@tonic-gate #define	CHP_ICACHE_MIN_LSIZE	CH_ICACHE_LSIZE
5140Sstevel@tonic-gate 
5150Sstevel@tonic-gate /*
5160Sstevel@tonic-gate  * The minimum size needed to ensure consistency on a virtually address
5170Sstevel@tonic-gate  * cache.  Computed by taking the largest virtually indexed cache and dividing
5180Sstevel@tonic-gate  * by its associativity.
5190Sstevel@tonic-gate  */
5200Sstevel@tonic-gate #define	CH_VAC_SIZE		0x4000
5210Sstevel@tonic-gate 
5220Sstevel@tonic-gate /*
5230Sstevel@tonic-gate  * The following definitions give the syndromes that will be seen when attempts
5240Sstevel@tonic-gate  * are made to read data that has been intentionally poisoned.  Intentional
5250Sstevel@tonic-gate  * poisoning is performed when an error has been detected, and is designed to
5260Sstevel@tonic-gate  * allow software to effectively distinguish between root problems and secondary
5270Sstevel@tonic-gate  * effects.  The following syndromes and their descriptions are taken from the
5280Sstevel@tonic-gate  * UltraSPARC-III Cu Error Manual, Section 5.4.3.1.
5290Sstevel@tonic-gate  */
5300Sstevel@tonic-gate 
5310Sstevel@tonic-gate /*
5320Sstevel@tonic-gate  * For a DSTAT = 2 or 3 event (see Sec 5.3.4.4) from the system bus for a
5330Sstevel@tonic-gate  * cacheable load, data bits [1:0] are inverted in the data stored in the
5340Sstevel@tonic-gate  * L2-cache.  The syndrome seen when one of these signalling words is read will
5350Sstevel@tonic-gate  * be 0x11c.
5360Sstevel@tonic-gate  */
5370Sstevel@tonic-gate #define	CH_POISON_SYND_FROM_DSTAT23	0x11c
5380Sstevel@tonic-gate 
5390Sstevel@tonic-gate /*
5400Sstevel@tonic-gate  * For an uncorrectable data ECC error from the L2-cache, data bits [127:126]
5410Sstevel@tonic-gate  * are inverted in data sent to the system bus as part of a writeback or
5420Sstevel@tonic-gate  * copyout.  The syndrome seen when one of these signalling words is read will
5430Sstevel@tonic-gate  * be 0x071.
5440Sstevel@tonic-gate  */
5450Sstevel@tonic-gate #define	CH_POISON_SYND_FROM_XXU_WRITE	0x71
5460Sstevel@tonic-gate 
5470Sstevel@tonic-gate /*
5480Sstevel@tonic-gate  * For uncorrectable data ECC error on the L2-cache read done to complete a
5490Sstevel@tonic-gate  * store merge event, where bytes written by the processor are merged with
5500Sstevel@tonic-gate  * bytes from an L2-cache line, ECC check bits [1:0] are inverted in the data
5510Sstevel@tonic-gate  * scrubbed back to the L2-cache.  The syndrome seen when one of these
5520Sstevel@tonic-gate  * signalling words is read will be 0x003.
5530Sstevel@tonic-gate  */
5540Sstevel@tonic-gate #define	CH_POISON_SYND_FROM_XXU_WRMERGE	0x3
5550Sstevel@tonic-gate 
5560Sstevel@tonic-gate /*
5570Sstevel@tonic-gate  * To help understand the following definitions, this block of comments
5580Sstevel@tonic-gate  * provides information on Cheetah's E$.
5590Sstevel@tonic-gate  *
5600Sstevel@tonic-gate  * Cheetah supports three different E$ sizes (1MB, 4MB, and 8MB). The
5610Sstevel@tonic-gate  * number of E$ lines remains constant regardless of the size of the E$
5620Sstevel@tonic-gate  * as does the subblock size, however the number of 64-byte subblocks per
5630Sstevel@tonic-gate  * line varies depending on the E$ size.
5640Sstevel@tonic-gate  *
5650Sstevel@tonic-gate  * An E$ tag (for an E$ line) contains an EC_tag field, corresponding to the
5660Sstevel@tonic-gate  * high order physical address bits of that E$ line's contents, and 1 to 8
5670Sstevel@tonic-gate  * EC_state fields, indicating the state of each subblock. Due to the E$ line
5680Sstevel@tonic-gate  * size variance depending on the total size of the E$, the number of bits in
5690Sstevel@tonic-gate  * the EC_tag field varies as does the number of subblocks (and EC_state
5700Sstevel@tonic-gate  * fields) per E$ line.
5710Sstevel@tonic-gate  *
5720Sstevel@tonic-gate  * A 1MB E$ has a line size of 64 bytes, containing 1 subblock per line.
5730Sstevel@tonic-gate  * A 4MB E$ has a line size of 256 bytes, containing 4 subblocks per line.
5740Sstevel@tonic-gate  * An 8MB E$ has a line size of 512 bytes, containing 8 subblocks per line.
5750Sstevel@tonic-gate  *
5760Sstevel@tonic-gate  * An E$ tag for a particular E$ line can be read via a diagnostic ASI
5770Sstevel@tonic-gate  * as a 64-bit value.
5780Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_tag field is interpreted as follows:
5790Sstevel@tonic-gate  *	- for a 1MB E$, the EC_tag is in bits <43:21> and corresponds
5800Sstevel@tonic-gate  *		to physical address bits <42:20> (bits <41:19> for Cheetah+)
5810Sstevel@tonic-gate  *	- for a 4MB E$, the EC_tag is in bits <43:23> and corresponds
5820Sstevel@tonic-gate  *		to physical address bits <42:22> (bits <41:21> for Cheetah+)
5830Sstevel@tonic-gate  *	- for an 8MB E$, the EC_tag is in bits <43:24> and corresponds
5840Sstevel@tonic-gate  *		to physical address bits <42:23> (bits <41:22> for Cheetah+)
5850Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_state field(s) is(are) interpreted
5860Sstevel@tonic-gate  * as follows:
5870Sstevel@tonic-gate  *	- for a 1MB E$, EC_state0 is in bits <2:0>
5880Sstevel@tonic-gate  *	- for a 4MB E$, EC_state0 is in bits <2:0>, EC_state1 is in
5890Sstevel@tonic-gate  *		bits <5:3>, EC_state2 is in bits <8:6>, EC_state3 is
5900Sstevel@tonic-gate  *		in bits <11:9>
5910Sstevel@tonic-gate  *	- for an 8MB E$, EC_state0 is in bits <2:0>, EC_state1 is in
5920Sstevel@tonic-gate  *		bits <5:3>, EC_state2 is in bits <8:6>, EC_state3 is
5930Sstevel@tonic-gate  *		in bits <11:9>, EC_state4 is in bits <14:12>, EC_state5
5940Sstevel@tonic-gate  *		is in bits <17:15>, EC_state6 is in bits <20:18>,
5950Sstevel@tonic-gate  *		EC_state7 is in bits <23:21>
5960Sstevel@tonic-gate  * Note that each EC_state field contains a value representing the state
5970Sstevel@tonic-gate  * of its corresponding subblock.
5980Sstevel@tonic-gate  *
5990Sstevel@tonic-gate  */
6000Sstevel@tonic-gate /*
6010Sstevel@tonic-gate  * Jaguar changes from Cheetah/Cheetah+ Ecache:
6020Sstevel@tonic-gate  *
6030Sstevel@tonic-gate  * The Jaguar Ecache is similiar to that used for Cheetah/Cheetah+ with a
6040Sstevel@tonic-gate  * couple of differences :
6050Sstevel@tonic-gate  *	- Jaguar Ecache only comes in 4MB and 8MB versions.
6060Sstevel@tonic-gate  *		- 8MB E$ has 2 64 byte subblocks per line.
6070Sstevel@tonic-gate  *		- 4MB E$ has 1 64 byte subblock per line.
6080Sstevel@tonic-gate  *
6090Sstevel@tonic-gate  * An E$ tag for a particular E$ line can be read via a diagnostic ASI
6100Sstevel@tonic-gate  * as a 64-bit value.
6110Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_tag field is interpreted as follows:
6120Sstevel@tonic-gate  *	- for a 4MB E$, the EC_tag is in bits <41:21> and corresponds
6130Sstevel@tonic-gate  *		to physical address bits <41:21>
6140Sstevel@tonic-gate  *	- for a 8MB E$, the EC_tag is in bits <41:22> and corresponds
6150Sstevel@tonic-gate  *		to physical address bits <41:22>
6160Sstevel@tonic-gate  *
6170Sstevel@tonic-gate  * The Jaguar E$ tag also contains LRU field in bit <42> which must be
6180Sstevel@tonic-gate  * masked off when the tag value is being compared to a PA.
6190Sstevel@tonic-gate  *
6200Sstevel@tonic-gate  * Within the E$ tag 64-bit value, the EC_state field(s) is(are) interpreted
6210Sstevel@tonic-gate  * as follows:
6220Sstevel@tonic-gate  *	- for 4MB E$, EC_state0 is in bits <2:0>
6230Sstevel@tonic-gate  *	- for 8MB E$, EC_state0 is in bits <2:0>, EC_state1 is in bits <5:3>.
6240Sstevel@tonic-gate  * Each EC_state field contains a value representing the state of its
6250Sstevel@tonic-gate  * corresponding subblock.
6260Sstevel@tonic-gate  *
6270Sstevel@tonic-gate  * Note that the subblock size and state values are the same for both
6280Sstevel@tonic-gate  * Cheetah/Cheetah+ and Jaguar.
6290Sstevel@tonic-gate  */
6300Sstevel@tonic-gate 
6310Sstevel@tonic-gate /* Ecache sizes */
6320Sstevel@tonic-gate #define	CH_ECACHE_8M_SIZE	0x800000
6330Sstevel@tonic-gate #define	CH_ECACHE_4M_SIZE	0x400000
6340Sstevel@tonic-gate #define	CH_ECACHE_1M_SIZE	0x100000
6350Sstevel@tonic-gate 
6360Sstevel@tonic-gate #define	PN_L2_SIZE		0x200000
6370Sstevel@tonic-gate #define	PN_L2_LINESIZE		64
6380Sstevel@tonic-gate #define	PN_L2_ECC_WORDS		2
6390Sstevel@tonic-gate #define	PN_L2_NWAYS		4
6400Sstevel@tonic-gate #define	PN_L2_SET_SIZE		(PN_L2_SIZE / PN_L2_NWAYS)
6410Sstevel@tonic-gate #define	PN_L2_MAX_SET		(PN_L2_SIZE - PN_L2_SET_SIZE)
6420Sstevel@tonic-gate #define	PN_L2_DATA_ECC_SEL	0x200000 /* bit 21 selects ECC */
6430Sstevel@tonic-gate #define	PN_L2_ECC_LO_REG	0x20 /* bit 5 set for L2 tag access */
6440Sstevel@tonic-gate #define	PN_L2_INDEX_MASK	0x7ffc0 /* bits 18:6 */
6450Sstevel@tonic-gate #define	PN_L2_WAY_INCR		0x80000	/* l2-ec-way = <20:19> */
6460Sstevel@tonic-gate #define	PN_L2_WAY_LIM		INT64_C(0x200000)
6470Sstevel@tonic-gate #define	PN_L2_WAY_SHIFT		19
6486230Sss137449 #define	PN_L2_WAY_MASK		(3ULL << PN_L2_WAY_SHIFT) /* <20:19> */
6496230Sss137449 #define	PN_L2_HW_ECC_SHIFT	22 /* Set to force HW ECC generation */
6506230Sss137449 #define	PN_L2_SPLIT_EN_SHIFT	2 /* L2_Cache_Ctrl<2> = L2_split_en */
6510Sstevel@tonic-gate 
6520Sstevel@tonic-gate #define	PN_L3_SIZE		0x2000000
6530Sstevel@tonic-gate #define	PN_L3_LINESIZE		64
6540Sstevel@tonic-gate #define	PN_L3_NWAYS		4
6550Sstevel@tonic-gate #define	PN_L3_SET_SIZE		(PN_L3_SIZE / PN_L3_NWAYS)
6560Sstevel@tonic-gate #define	PN_L3_MAX_SET		(PN_L3_SIZE - PN_L3_SET_SIZE)
6570Sstevel@tonic-gate #define	PN_L3_WAY_SHIFT		23
6586230Sss137449 #define	PN_L3_HW_ECC_SHIFT	25	/* Set to force HW ECC generation */
6590Sstevel@tonic-gate #define	PN_L3_TAG_RD_MASK	0x7fffc0	/* ec_tag = PA<22:6>  */
6600Sstevel@tonic-gate #define	PN_L3_WAY_INCR		0x800000	/* ec_way = <24:23> */
6616230Sss137449 #define	PN_L3_WAY_MASK		(3ULL << PN_L3_WAY_SHIFT) /* <24:23> */
6620Sstevel@tonic-gate #define	PN_L3_WAY_LIM		INT64_C(0x2000000)
6636230Sss137449 #define	PN_L3_SPLIT_EN_SHIFT	30	/* L3_Cache_Ctrl<30> = L3_split_en */
6640Sstevel@tonic-gate 
6650Sstevel@tonic-gate /* Pcache Defines */
6660Sstevel@tonic-gate #define	PN_PCACHE_ADDR_MASK	0x1c0		/* PC_addr = <8:6> */
6670Sstevel@tonic-gate #define	PN_PCACHE_WAY_INCR	0x200		/* PC_way = <10:9> */
6680Sstevel@tonic-gate #define	PN_PCACHE_WORD_SHIFT	3		/* PC_dbl_word = <5:3> */
6690Sstevel@tonic-gate #define	PN_PCACHE_NWAYS		4
6700Sstevel@tonic-gate 
6710Sstevel@tonic-gate /* Cheetah Ecache is direct-mapped, Cheetah+ can be 2-way or direct-mapped */
6720Sstevel@tonic-gate #define	CH_ECACHE_NWAY		1
6730Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
6740Sstevel@tonic-gate #define	CHP_ECACHE_NWAY		2
6750Sstevel@tonic-gate #define	PN_ECACHE_NWAY		4
6760Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
6770Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
6780Sstevel@tonic-gate #define	JP_ECACHE_NWAY		4
6790Sstevel@tonic-gate #define	JP_ECACHE_NWAY_SHIFT	2
6800Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
6810Sstevel@tonic-gate 
6820Sstevel@tonic-gate /* Maximum Ecache size */
6830Sstevel@tonic-gate #define	CH_ECACHE_MAX_SIZE	CH_ECACHE_8M_SIZE
6840Sstevel@tonic-gate 
6850Sstevel@tonic-gate /* Minimum Ecache line size */
6860Sstevel@tonic-gate #define	CH_ECACHE_MIN_LSIZE	64
6870Sstevel@tonic-gate 
6880Sstevel@tonic-gate /* Maximum Ecache line size - 8Mb Ecache has 512 byte linesize */
6890Sstevel@tonic-gate #define	CH_ECACHE_MAX_LSIZE	512
6900Sstevel@tonic-gate 
6910Sstevel@tonic-gate /* Size of Ecache data staging register size (see Cheetah PRM 10.7.2) */
6920Sstevel@tonic-gate #define	CH_ECACHE_STGREG_SIZE	32
6930Sstevel@tonic-gate #define	CH_ECACHE_STGREG_TOTALSIZE	40	/* data regs + ecc */
6940Sstevel@tonic-gate 
6950Sstevel@tonic-gate /* The number of staging registers containing data, for ASI_EC_DATA */
6960Sstevel@tonic-gate #define	CH_ECACHE_STGREG_NUM	(CH_ECACHE_STGREG_SIZE / sizeof (uint64_t))
6970Sstevel@tonic-gate 
6980Sstevel@tonic-gate /* Size of Ecache data subblock which has state field in Ecache tag */
6990Sstevel@tonic-gate #define	CH_ECACHE_SUBBLK_SIZE	64
7000Sstevel@tonic-gate #define	CH_ECACHE_SUBBLK_SHIFT	6
7010Sstevel@tonic-gate 
7020Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
7030Sstevel@tonic-gate #define	JP_ECACHE_MAX_LSIZE	CH_ECACHE_SUBBLK_SIZE
7040Sstevel@tonic-gate #define	JP_ECACHE_MAX_SIZE	0x400000
7050Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
7060Sstevel@tonic-gate 
7070Sstevel@tonic-gate /*
7080Sstevel@tonic-gate  * Maximum ecache setsize to support page coloring of heterogenous
7090Sstevel@tonic-gate  * cheetah+ cpus. Max ecache setsize is calculated to be the max ecache size
7100Sstevel@tonic-gate  * divided by the minimum associativity of the max ecache.
7110Sstevel@tonic-gate  *
7120Sstevel@tonic-gate  * NOTE: CHP_ECACHE_MAX_SIZE and CHP_ECACHE_MIN_NWAY need to be updated with
7130Sstevel@tonic-gate  * new cheetah+ cpus. The maximum setsize may not necessarily be associated with
7140Sstevel@tonic-gate  * the max ecache size if the cache associativity is large. If so, MAX_SETSIZE
7150Sstevel@tonic-gate  * needs to be updated accordingly.
7160Sstevel@tonic-gate  */
7170Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
7180Sstevel@tonic-gate #define	CHP_ECACHE_MIN_NWAY	1	/* direct-mapped */
7190Sstevel@tonic-gate #define	CHP_ECACHE_MAX_SIZE	CH_ECACHE_MAX_SIZE
7200Sstevel@tonic-gate #define	CHP_ECACHE_MAX_SETSIZE	(CHP_ECACHE_MAX_SIZE / CHP_ECACHE_MIN_NWAY)
7210Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
7220Sstevel@tonic-gate 
7230Sstevel@tonic-gate /*
7240Sstevel@tonic-gate  * Bits to shift EC_tag field of E$ tag to form PA
7250Sstevel@tonic-gate  * (See Cheetah PRM 10.7.4, Cheetah+ Delta PRM 10.7)
7260Sstevel@tonic-gate  */
7270Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
7280Sstevel@tonic-gate #define	CH_ECTAG_PA_SHIFT	18
7290Sstevel@tonic-gate #elif defined(CHEETAH_PLUS)
7300Sstevel@tonic-gate #define	CH_ECTAG_PA_SHIFT	2
7310Sstevel@tonic-gate #else	/* CHEETAH_PLUS */
7320Sstevel@tonic-gate #define	CH_ECTAG_PA_SHIFT	1
7330Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
7340Sstevel@tonic-gate #define	PN_L3TAG_PA_SHIFT	1
7350Sstevel@tonic-gate #define	PN_L3TAG_PA_MASK	0xfffff000000	/* tag bits[43:24] */
7360Sstevel@tonic-gate #define	PN_L2TAG_PA_MASK	0x7fffff80000	/* tag bits[42:19] */
7370Sstevel@tonic-gate 
7380Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
7390Sstevel@tonic-gate /*
7400Sstevel@tonic-gate  * Macros for Jalapeno L2 Cache Tag/State/Parity
7410Sstevel@tonic-gate  *
7420Sstevel@tonic-gate  * +-----------+--------+--------+----------------------+
7430Sstevel@tonic-gate  * |   -       | EC_par |EC_state|  EC_tag = PA[42:18]  |
7440Sstevel@tonic-gate  * +-----------+--------+--------+----------------------+
7450Sstevel@tonic-gate  *    63:29        28      27:25         24:0
7460Sstevel@tonic-gate  */
7470Sstevel@tonic-gate /*
7480Sstevel@tonic-gate  * Constants representing the complete Jalapeno Ecache tag state:
7490Sstevel@tonic-gate  */
7500Sstevel@tonic-gate #define	JP_ECSTATE_SIZE		3		/* three bits */
7510Sstevel@tonic-gate #define	JP_ECSTATE_MASK		0x7		/* three bit field */
7520Sstevel@tonic-gate #define	JP_ECSTATE_INV		0x0		/* invalid */
7530Sstevel@tonic-gate #define	JP_ECSTATE_SHR		0x1		/* shared */
7540Sstevel@tonic-gate #define	JP_ECSTATE_RES1		0x2		/* reserved */
7550Sstevel@tonic-gate #define	JP_ECSTATE_EXL		0x3		/* exclusive */
7560Sstevel@tonic-gate #define	JP_ECSTATE_RES2		0x4		/* reserved */
7570Sstevel@tonic-gate #define	JP_ECSTATE_OWN		0x5		/* owner */
7580Sstevel@tonic-gate #define	JP_ECSTATE_MOD		0x7		/* modified */
7590Sstevel@tonic-gate #define	JP_ECSTATE_RES3		0x6		/* reserved */
7600Sstevel@tonic-gate #define	JP_ECTAG_STATE_SHIFT	25
7610Sstevel@tonic-gate 
7620Sstevel@tonic-gate #define	CH_ECSTATE_SIZE		JP_ECSTATE_SIZE
7630Sstevel@tonic-gate #define	CH_ECSTATE_MASK		JP_ECSTATE_MASK
7640Sstevel@tonic-gate #define	CH_ECSTATE_INV		JP_ECSTATE_INV
7650Sstevel@tonic-gate #define	CH_ECSTATE_SHR		JP_ECSTATE_SHR
7660Sstevel@tonic-gate #define	CH_ECSTATE_EXL		JP_ECSTATE_EXL
7670Sstevel@tonic-gate #define	CH_ECSTATE_OWN		JP_ECSTATE_OWN
7680Sstevel@tonic-gate #define	CH_ECSTATE_MOD		JP_ECSTATE_MOD
7690Sstevel@tonic-gate #define	CH_ECSTATE_RES1		JP_ECSTATE_RES1
7700Sstevel@tonic-gate #define	CH_ECSTATE_OWS		JP_ECSTATE_RES3
7710Sstevel@tonic-gate #define	CH_ECSTATE_RES2		JP_ECSTATE_RES2
7720Sstevel@tonic-gate 
7730Sstevel@tonic-gate /* Number of subblock states per Ecache line. */
7740Sstevel@tonic-gate #define	CH_ECTAG_NSUBBLKS(totalsize)	1
7750Sstevel@tonic-gate 
7760Sstevel@tonic-gate /* Mask for Tag state(s) field, 3 bits per subblock state. */
7770Sstevel@tonic-gate #define	CH_ECTAG_STATE_SHIFT(subblk)	JP_ECTAG_STATE_SHIFT
7780Sstevel@tonic-gate #define	CH_ECTAG_STATE_MASK(totalsize)			\
7790Sstevel@tonic-gate 	((uint64_t)(JP_ECSTATE_MASK<<JP_ECTAG_STATE_SHIFT))
7800Sstevel@tonic-gate 
7810Sstevel@tonic-gate /* For a line to be invalid, all of its subblock states must be invalid. */
7820Sstevel@tonic-gate #define	CH_ECTAG_LINE_INVALID(totalsize, tag)		\
7830Sstevel@tonic-gate 	(((tag) & CH_ECTAG_STATE_MASK(totalsize)) == 0)
7840Sstevel@tonic-gate 
7850Sstevel@tonic-gate /* Build address mask for tag physical address bits. */
7860Sstevel@tonic-gate #define	CH_ECTAG_PA_MASK(setsize)	P2ALIGN(C_AFAR_PA, (int)(setsize))
7870Sstevel@tonic-gate 
7880Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an E$ tag */
7890Sstevel@tonic-gate #define	CH_ECTAG_TO_PA(setsize, tag)	(((tag) << CH_ECTAG_PA_SHIFT) &	\
7900Sstevel@tonic-gate 	CH_ECTAG_PA_MASK(setsize))
7910Sstevel@tonic-gate 
7920Sstevel@tonic-gate /* Given a physical address, compute index for subblock tag state. */
7930Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK(totalsize, pa)		1
7940Sstevel@tonic-gate 
7950Sstevel@tonic-gate /* Given a physical address and assoc. tag, get the subblock state. */
7960Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK_STATE(totalsize, pa, tag)			\
7970Sstevel@tonic-gate 	(((tag) >> JP_ECTAG_STATE_SHIFT) &	JP_ECSTATE_MASK)
7980Sstevel@tonic-gate 
7990Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
8000Sstevel@tonic-gate 
8010Sstevel@tonic-gate /*
8020Sstevel@tonic-gate  * Constants representing the complete Cheetah Ecache tag state:
8030Sstevel@tonic-gate  */
8040Sstevel@tonic-gate #define	CH_ECSTATE_SIZE		3		/* three bits per subblock */
8050Sstevel@tonic-gate #define	CH_ECSTATE_MASK		0x7		/* three bit field */
8060Sstevel@tonic-gate #define	CH_ECSTATE_INV		0x0		/* invalid */
8070Sstevel@tonic-gate #define	CH_ECSTATE_SHR		0x1		/* shared */
8080Sstevel@tonic-gate #define	CH_ECSTATE_EXL		0x2		/* exclusive */
8090Sstevel@tonic-gate #define	CH_ECSTATE_OWN		0x3		/* owner */
8100Sstevel@tonic-gate #define	CH_ECSTATE_MOD		0x4		/* modified */
8110Sstevel@tonic-gate #define	CH_ECSTATE_RES1		0x5		/* reserved */
8120Sstevel@tonic-gate #define	CH_ECSTATE_OWS		0x6		/* owner/shared */
8130Sstevel@tonic-gate #define	CH_ECSTATE_RES2		0x7		/* reserved */
8140Sstevel@tonic-gate 
8150Sstevel@tonic-gate /*
8160Sstevel@tonic-gate  * Macros for Cheetah Ecache tags
8170Sstevel@tonic-gate  */
8180Sstevel@tonic-gate 
8190Sstevel@tonic-gate /* Number of subblock states per Ecache line. */
8200Sstevel@tonic-gate #define	CH_ECTAG_NSUBBLKS(totalsize)	((totalsize) / CH_ECACHE_1M_SIZE)
8210Sstevel@tonic-gate 
8220Sstevel@tonic-gate /* Mask for Tag state(s) field, 3 bits per subblock state. */
8230Sstevel@tonic-gate #define	CH_ECTAG_STATE_SHIFT(subblk)	(subblk * CH_ECSTATE_SIZE)
8240Sstevel@tonic-gate #define	CH_ECTAG_STATE_MASK(totalsize)			\
8250Sstevel@tonic-gate 	((uint64_t)					\
8260Sstevel@tonic-gate 	((1 << (CH_ECTAG_NSUBBLKS(totalsize) * CH_ECSTATE_SIZE)) - 1))
8270Sstevel@tonic-gate 
8280Sstevel@tonic-gate /* For a line to be invalid, all of its subblock states must be invalid. */
8290Sstevel@tonic-gate #define	CH_ECTAG_LINE_INVALID(totalsize, tag)		\
8300Sstevel@tonic-gate 	(((tag) & CH_ECTAG_STATE_MASK(totalsize)) == 0)
8310Sstevel@tonic-gate 
8320Sstevel@tonic-gate /* Build address mask for tag physical address bits. */
8330Sstevel@tonic-gate #define	CH_ECTAG_PA_MASK(setsize)	P2ALIGN(C_AFAR_PA, (int)(setsize))
8340Sstevel@tonic-gate 
8350Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an E$ tag */
8360Sstevel@tonic-gate #define	CH_ECTAG_TO_PA(setsize, tag)	(((tag) >> CH_ECTAG_PA_SHIFT) &	\
8370Sstevel@tonic-gate 	CH_ECTAG_PA_MASK(setsize))
8380Sstevel@tonic-gate 
8390Sstevel@tonic-gate /* Given a physical address, compute index for subblock tag state. */
8400Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK(totalsize, pa)		\
8410Sstevel@tonic-gate 	(((pa) >> CH_ECACHE_SUBBLK_SHIFT) & (CH_ECTAG_NSUBBLKS(totalsize) - 1))
8420Sstevel@tonic-gate 
8430Sstevel@tonic-gate /* Given a physical address and assoc. tag, get the subblock state. */
8440Sstevel@tonic-gate #define	CH_ECTAG_PA_TO_SUBBLK_STATE(totalsize, pa, tag)			\
8450Sstevel@tonic-gate 	(((tag) >>							\
8460Sstevel@tonic-gate 	(CH_ECTAG_PA_TO_SUBBLK(totalsize, pa) * CH_ECSTATE_SIZE)) &	\
8470Sstevel@tonic-gate 	CH_ECSTATE_MASK)
8480Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
8490Sstevel@tonic-gate 
8500Sstevel@tonic-gate /* Panther only has one EC_State field in the L3 tag */
8510Sstevel@tonic-gate #define	PN_L3_LINE_INVALID(tag)		(((tag) & CH_ECSTATE_MASK) == 0)
8520Sstevel@tonic-gate 
8530Sstevel@tonic-gate /* Panther only has one State field in the L2 tag */
8540Sstevel@tonic-gate #define	PN_L2_LINE_INVALID(tag)		(((tag) & CH_ECSTATE_MASK) == 0)
8550Sstevel@tonic-gate 
8560Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an L3$ tag */
8570Sstevel@tonic-gate #define	PN_L3TAG_TO_PA(tag)		(((tag) & PN_L3TAG_PA_MASK) >> \
8580Sstevel@tonic-gate 	PN_L3TAG_PA_SHIFT)
8590Sstevel@tonic-gate 
8600Sstevel@tonic-gate /* Get physical address bits from the tag field of an L2$ tag */
8610Sstevel@tonic-gate #define	PN_L2TAG_TO_PA(tag)		((tag) & PN_L2TAG_PA_MASK)
8620Sstevel@tonic-gate 
8630Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
8640Sstevel@tonic-gate /*
8650Sstevel@tonic-gate  * Jalapeno L2 Cache ASI_ECACHE_FLUSH:
8660Sstevel@tonic-gate  * +-------+-----------------+--------+---+-----+-------------+------+
8670Sstevel@tonic-gate  * |   -   | Port_ID |   -   | EC_Way | 1 |  -  | EC_Tag_Addr |   -  |
8680Sstevel@tonic-gate  * +-------+-----------------+--------+---+-----+-------------+------+
8690Sstevel@tonic-gate  *  63:41     40:36    35:34    33:32  31  30:18      17:6       5:0
8700Sstevel@tonic-gate  */
8710Sstevel@tonic-gate 
8720Sstevel@tonic-gate #define	JP_EC_TO_SET_SIZE_SHIFT		2
8730Sstevel@tonic-gate #define	JP_ECACHE_IDX_DISP_FLUSH	INT64_C(0x0000000080000000)
8740Sstevel@tonic-gate #define	JP_ECFLUSH_PORTID_SHIFT		36
8750Sstevel@tonic-gate #define	JP_ECFLUSH_EC_WAY_SHIFT		32
8760Sstevel@tonic-gate #define	JP_EC_TAG_DATA_WAY_SHIFT	JP_ECFLUSH_EC_WAY_SHIFT
8770Sstevel@tonic-gate #endif	/* JALAPENO || SERRANO */
8780Sstevel@tonic-gate 
8790Sstevel@tonic-gate /*
8800Sstevel@tonic-gate  * Macros for Jaguar Ecache tags
8810Sstevel@tonic-gate  */
8820Sstevel@tonic-gate 
8830Sstevel@tonic-gate /* Ecache sizes */
8840Sstevel@tonic-gate #define	JG_ECACHE_8M_SIZE	0x800000
8850Sstevel@tonic-gate #define	JG_ECACHE_4M_SIZE	0x400000
8860Sstevel@tonic-gate 
8870Sstevel@tonic-gate /* Jaguar E$ tag LRU mask */
8880Sstevel@tonic-gate #define	JG_LRU_MASK UINT64_C(0x0000040000000000) /* PA<42> LRU bit */
8890Sstevel@tonic-gate 
8900Sstevel@tonic-gate /*
8910Sstevel@tonic-gate  * Note that Jaguar and Cheetah/Cheetah+ have the same subblock state size
8920Sstevel@tonic-gate  * so rather than duplicating existing defn's we can use the Cheetah+ versions
8930Sstevel@tonic-gate  * in the Jaguar defn's below.
8940Sstevel@tonic-gate  */
8950Sstevel@tonic-gate /* Number of subblock states per Ecache line. */
8960Sstevel@tonic-gate #define	JG_ECTAG_NSUBBLKS(cachesize)	((cachesize) / JG_ECACHE_4M_SIZE)
8970Sstevel@tonic-gate 
8980Sstevel@tonic-gate /* Mask for Tag state(s) field, 3 bits per subblock state. */
8990Sstevel@tonic-gate #define	JG_ECTAG_STATE_MASK(totalsize)			\
9000Sstevel@tonic-gate 	((uint64_t)					\
9010Sstevel@tonic-gate 	((1 << (JG_ECTAG_NSUBBLKS(totalsize) * CH_ECSTATE_SIZE)) - 1))
9020Sstevel@tonic-gate 
9030Sstevel@tonic-gate /* For a line to be invalid, all of its subblock states must be invalid. */
9040Sstevel@tonic-gate #define	JG_ECTAG_LINE_INVALID(totalsize, tag)		\
9050Sstevel@tonic-gate 	(((tag) & JG_ECTAG_STATE_MASK(totalsize)) == 0)
9060Sstevel@tonic-gate 
9070Sstevel@tonic-gate /* Build address mask for tag physical address bits. */
9080Sstevel@tonic-gate #define	JG_ECTAG_PA_MASK(setsize)	P2ALIGN(((~JG_LRU_MASK) & C_AFAR_PA), \
9090Sstevel@tonic-gate 							(int)(setsize))
9100Sstevel@tonic-gate 
9110Sstevel@tonic-gate /* Get physical address bits from the EC_tag field of an E$ tag */
9120Sstevel@tonic-gate #define	JG_ECTAG_TO_PA(setsize, tag)	((tag & JG_ECTAG_PA_MASK(setsize)))
9130Sstevel@tonic-gate 
9140Sstevel@tonic-gate /* Given a physical address, compute index for subblock tag state. */
9150Sstevel@tonic-gate #define	JG_ECTAG_PA_TO_SUBBLK(totalsize, pa)		\
9160Sstevel@tonic-gate 	(((pa) >> CH_ECACHE_SUBBLK_SHIFT) & (JG_ECTAG_NSUBBLKS(totalsize) - 1))
9170Sstevel@tonic-gate 
9180Sstevel@tonic-gate /* Given a physical address and assoc. tag, get the subblock state. */
9190Sstevel@tonic-gate #define	JG_ECTAG_PA_TO_SUBBLK_STATE(totalsize, pa, tag)			\
9200Sstevel@tonic-gate 	(((tag) >>							\
9210Sstevel@tonic-gate 	(JG_ECTAG_PA_TO_SUBBLK(totalsize, pa) * CH_ECSTATE_SIZE)) &	\
9220Sstevel@tonic-gate 	CH_ECSTATE_MASK)
9230Sstevel@tonic-gate 
9240Sstevel@tonic-gate 
9250Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
9260Sstevel@tonic-gate /*
9270Sstevel@tonic-gate  * Cheetah+ Tag ECC Bit and Displacement Flush Bit in Ecache Tag Access.
9280Sstevel@tonic-gate  * See Cheetah+ Delta PRM 10.7
9290Sstevel@tonic-gate  */
9300Sstevel@tonic-gate #define	CHP_ECACHE_IDX_TAG_ECC		INT64_C(0x0000000000800000)
9310Sstevel@tonic-gate #define	CHP_ECACHE_IDX_DISP_FLUSH	INT64_C(0x0000000001000000)
9320Sstevel@tonic-gate #define	PN_L2_IDX_DISP_FLUSH		INT64_C(0x0000000000800000)
9330Sstevel@tonic-gate #define	PN_L3_IDX_DISP_FLUSH		INT64_C(0x0000000004000000)
9340Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
9350Sstevel@tonic-gate 
9360Sstevel@tonic-gate /*
9370Sstevel@tonic-gate  * Macros for Cheetah Dcache diagnostic accesses.
9380Sstevel@tonic-gate  */
9390Sstevel@tonic-gate 
9400Sstevel@tonic-gate /*
9410Sstevel@tonic-gate  * Dcache Index Mask for bits from *AFAR*.  Note that Dcache is virtually
9420Sstevel@tonic-gate  * indexed, so only bits [12:5] are valid from the AFAR.  This
9430Sstevel@tonic-gate  * means we have to search through the 4 ways + bit 13 (i.e. we have
9440Sstevel@tonic-gate  * to try 8 indexes).
9450Sstevel@tonic-gate  */
9460Sstevel@tonic-gate #define	CH_DCACHE_IDX_MASK		0x01fe0
9470Sstevel@tonic-gate #define	CH_DCACHE_IDX_INCR		0x02000
9480Sstevel@tonic-gate #define	CH_DCACHE_IDX_LIMIT		0x10000
9490Sstevel@tonic-gate #define	CH_DCACHE_NWAY			4
9500Sstevel@tonic-gate #define	CH_DCACHE_WAY_MASK		0x0c000
9510Sstevel@tonic-gate #define	CH_DCACHE_WAY_SHIFT		14
9520Sstevel@tonic-gate #define	CH_DCIDX_TO_WAY(idx)		(((idx) & CH_DCACHE_WAY_MASK) >> \
9530Sstevel@tonic-gate 						CH_DCACHE_WAY_SHIFT)
9540Sstevel@tonic-gate #define	CH_DCTAG_PA_MASK		INT64_C(0x000007ffffffe000)
9550Sstevel@tonic-gate #define	CH_DCTAG_PA_SHIFT		12
9560Sstevel@tonic-gate #define	CH_DCTAG_VALID_BIT		INT64_C(0x0000000000000001)
9570Sstevel@tonic-gate #define	CH_DCTAG_LINE_INVALID(tag)	(((tag) & CH_DCTAG_VALID_BIT) == 0)
9580Sstevel@tonic-gate #define	CH_DCIDX_TO_ADDR(idx)		((idx) & CH_DCACHE_IDX_MASK)
9590Sstevel@tonic-gate #define	CH_DCTAG_TO_PA(tag)		(((tag) << CH_DCTAG_PA_SHIFT) & \
9600Sstevel@tonic-gate 					    CH_DCTAG_PA_MASK)
9610Sstevel@tonic-gate #define	CH_DCTAG_MATCH(tag, pa)		(!CH_DCTAG_LINE_INVALID(tag) && \
9620Sstevel@tonic-gate 			    ((pa) & CH_DCTAG_PA_MASK) == CH_DCTAG_TO_PA(tag))
9630Sstevel@tonic-gate #define	CH_DCSNTAG_MASK			INT64_C(0x000007ffffffe000)
9640Sstevel@tonic-gate #define	CH_DCSNTAG_TO_PA(tag)		((tag << CH_DCTAG_PA_SHIFT) \
9650Sstevel@tonic-gate 							& CH_DCSNTAG_MASK)
9660Sstevel@tonic-gate #define	CH_DCUTAG_TO_UTAG(tag)		((tag) & 0xff)
9670Sstevel@tonic-gate #define	CH_DCUTAG_TO_VA(tag)		((tag & 0xff) << 14)
9680Sstevel@tonic-gate #define	CH_DCUTAG_IDX_MASK		0x03fe0
9690Sstevel@tonic-gate #define	CH_DC_DATA_REG_SIZE		32
9700Sstevel@tonic-gate #define	CH_DC_UTAG_MASK			0xff
9710Sstevel@tonic-gate #if defined(CHEETAH_PLUS) || defined(JALAPENO) || defined(SERRANO)
9720Sstevel@tonic-gate #define	CHP_DCTAG_PARMASK		INT64_C(0x000000007ffffffe)
9730Sstevel@tonic-gate #define	CHP_DCSNTAG_PARMASK		INT64_C(0x000000007ffffffe)
9740Sstevel@tonic-gate #define	CHP_DCTAG_MASK			INT64_C(0x000003ffffffe000)
9750Sstevel@tonic-gate #define	CHP_DCSNTAG_MASK		INT64_C(0x000003ffffffe000)
9760Sstevel@tonic-gate #define	CHP_DCWAY_MASK			INT64_C(0x0000000000003fe0)
9770Sstevel@tonic-gate #define	CHP_DCUTAG_TO_UTAG(tag)		((tag) & 0xffff)
9780Sstevel@tonic-gate #define	CHP_DCPATAG_TO_PA(tag)		((tag << CH_DCTAG_PA_SHIFT) \
9790Sstevel@tonic-gate 							& CHP_DCTAG_MASK)
9800Sstevel@tonic-gate #define	CHP_DCSNTAG_TO_PA(tag)		((tag << CH_DCTAG_PA_SHIFT) \
9810Sstevel@tonic-gate 							& CHP_DCSNTAG_MASK)
9820Sstevel@tonic-gate #define	CHP_DC_IDX(dcp)			((dcp->dc_idx & 0x1fc0) >> 5)
9830Sstevel@tonic-gate #define	CHP_DCTAG_PARITY(tag)		(tag & CHP_DC_TAG)
9840Sstevel@tonic-gate #define	CHP_DCSNTAG_PARITY(tag)		(tag & CHP_DC_SNTAG)
9850Sstevel@tonic-gate #define	CHP_DC_TAG			0x1
9860Sstevel@tonic-gate #define	CHP_DC_SNTAG			0x2
9870Sstevel@tonic-gate #define	PN_DC_DATA_PARITY_SHIFT    	8
9880Sstevel@tonic-gate #define	PN_DC_DATA_PARITY_MASK    	0xff
9890Sstevel@tonic-gate #define	PN_DC_DATA_ALL_PARITY_MASK    	0xffffffff
9900Sstevel@tonic-gate #endif	/* CHEETAH_PLUS || JALAPENO || SERRANO */
9910Sstevel@tonic-gate #define	PN_DC_DATA_PARITY_BIT_SHIFT    	16
9920Sstevel@tonic-gate 
9930Sstevel@tonic-gate /*
9940Sstevel@tonic-gate  * Macros for Cheetah Icache diagnostic accesses.
9950Sstevel@tonic-gate  */
9960Sstevel@tonic-gate 
9970Sstevel@tonic-gate /*
9980Sstevel@tonic-gate  * Icache Index Mask for bits from *AFAR*. Note that the Icache is virtually
9990Sstevel@tonic-gate  * indexed for Panther and physically indexed for other CPUs. For Panther,
10000Sstevel@tonic-gate  * we obtain an index by looking at bits[12:6] of the AFAR PA and we check
10010Sstevel@tonic-gate  * both lines associated with bit 13 = 0 or 1 (total of 8 entries to check).
10020Sstevel@tonic-gate  * For non-Panther CPUs we get our index by just looking at bits[12:5] of
10030Sstevel@tonic-gate  * the AFAR PA (total of 4 entries to check). The Icache index is also
10040Sstevel@tonic-gate  * confusing because we need to shift the virtual address bits left by one
10050Sstevel@tonic-gate  * for the index.
10060Sstevel@tonic-gate  */
10070Sstevel@tonic-gate #define	CH_ICACHE_IDX_MASK		0x01fe0
10080Sstevel@tonic-gate #define	PN_ICACHE_IDX_MASK		0x03fc0
10090Sstevel@tonic-gate #define	PN_ICACHE_VA_IDX_MASK		0x01fc0
10100Sstevel@tonic-gate #define	CH_ICACHE_IDX_SHIFT		1
10110Sstevel@tonic-gate #define	CH_ICACHE_IDX_INCR		0x04000
10120Sstevel@tonic-gate #define	PN_ICACHE_IDX_INCR		0x08000
10130Sstevel@tonic-gate #define	CH_ICACHE_IDX_LIMIT		0x10000
10140Sstevel@tonic-gate #define	PN_ICACHE_IDX_LIMIT		0x20000
10150Sstevel@tonic-gate #define	CH_ICACHE_NWAY			4
10160Sstevel@tonic-gate #define	CH_ICACHE_WAY_MASK		0x0c000
10170Sstevel@tonic-gate #define	CH_ICACHE_WAY_SHIFT		14
10180Sstevel@tonic-gate #define	PN_ICACHE_WAY_MASK		0x18000
10190Sstevel@tonic-gate #define	PN_ICACHE_WAY_SHIFT		15
10200Sstevel@tonic-gate #define	CH_ICTAG_PA			0x00
10210Sstevel@tonic-gate #define	CH_ICTAG_UTAG			0x08
10220Sstevel@tonic-gate #define	CH_ICTAG_UPPER			0x10
10230Sstevel@tonic-gate #define	CH_ICTAG_LOWER			0x30
10240Sstevel@tonic-gate #define	CH_ICTAG_TMASK			0x3f
10250Sstevel@tonic-gate #define	CH_ICPATAG_MASK			INT64_C(0x000007ffffffe000)
10260Sstevel@tonic-gate #define	CH_ICPATAG_LBITS		0xff	/* lower 8 bits undefined */
10270Sstevel@tonic-gate #define	CH_ICPATAG_SHIFT		5
10280Sstevel@tonic-gate #define	CH_ICIDX_TO_WAY(idx)		(((idx) & CH_ICACHE_WAY_MASK) >> \
10290Sstevel@tonic-gate 						CH_ICACHE_WAY_SHIFT)
10300Sstevel@tonic-gate #define	PN_ICIDX_TO_WAY(idx)		(((idx) & PN_ICACHE_WAY_MASK) >> \
10310Sstevel@tonic-gate 						PN_ICACHE_WAY_SHIFT)
10320Sstevel@tonic-gate #define	CH_ICIDX_TO_ADDR(idx)		(((idx) >> CH_ICACHE_IDX_SHIFT) & \
10330Sstevel@tonic-gate 						CH_ICACHE_IDX_MASK)
10340Sstevel@tonic-gate #define	PN_ICIDX_TO_ADDR(idx)		(((idx) >> CH_ICACHE_IDX_SHIFT) & \
10350Sstevel@tonic-gate 						PN_ICACHE_IDX_MASK)
10360Sstevel@tonic-gate #define	CH_ICPATAG_TO_PA(tag)		(((tag) << CH_ICPATAG_SHIFT) & \
10370Sstevel@tonic-gate 						CH_ICPATAG_MASK)
10380Sstevel@tonic-gate #define	CH_ICPATAG_MATCH(tag, pa)	(CH_ICPATAG_TO_PA(tag) == \
10390Sstevel@tonic-gate 						((pa) & CH_ICPATAG_MASK))
10400Sstevel@tonic-gate #define	CH_ICUTAG_MASK			INT64_C(0x00000000001fe000)
10410Sstevel@tonic-gate #define	CH_ICUTAG_TO_UTAG(tag)		(((tag) >> 38) & 0xff)
10420Sstevel@tonic-gate #define	CH_ICUTAG_TO_VA(tag)		(((tag) >> 25) & CH_ICUTAG_MASK)
10430Sstevel@tonic-gate #define	CH_ICSNTAG_MASK			INT64_C(0x000007ffffffe000)
10440Sstevel@tonic-gate #define	CH_ICSNTAG_TO_PA(tag)		(((tag) << 5) & CH_ICSNTAG_MASK)
10450Sstevel@tonic-gate #define	CH_ICLOWER_VALID		INT64_C(0x0004000000000000)
10460Sstevel@tonic-gate #define	CH_ICUPPER_VALID		INT64_C(0x0004000000000000)
10470Sstevel@tonic-gate #define	CH_ICLOWER_TO_VPRED(lower)	(((lower) >> 46) & 0xf)
10480Sstevel@tonic-gate #define	CH_ICUPPER_TO_VPRED(upper)	(((upper) >> 46) & 0xf)
10490Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
10500Sstevel@tonic-gate #define	CH_ICTAG_MATCH(icp, pa)		(((icp->ic_lower | icp->ic_upper) & \
10510Sstevel@tonic-gate 					    CH_ICLOWER_VALID) && \
10520Sstevel@tonic-gate 					    CH_ICPATAG_MATCH(icp->ic_patag, pa))
10530Sstevel@tonic-gate #define	PN_ICUTAG_TO_VA(tag)		((tag >> 24) & PN_ICUTAG_MASK)
10540Sstevel@tonic-gate #else	/* CHEETAH_PLUS */
10550Sstevel@tonic-gate #define	CH_ICTAG_MATCH(icp, pa)		((icp->ic_lower & CH_ICLOWER_VALID) &&\
10560Sstevel@tonic-gate 					    CH_ICPATAG_MATCH(icp->ic_patag, pa))
10570Sstevel@tonic-gate #define	PN_ICUTAG_TO_VA(tag)		0
10580Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
10590Sstevel@tonic-gate 
10600Sstevel@tonic-gate #define	CH_IC_DATA_REG_SIZE		64
10610Sstevel@tonic-gate #define	PN_IC_DATA_REG_SIZE		128
10620Sstevel@tonic-gate #if defined(CHEETAH_PLUS) || defined(JALAPENO) || defined(SERRANO)
10630Sstevel@tonic-gate #define	CHP_IC_IDX(icp)			((icp->ic_idx & 0x3fc0) >> 6)
10640Sstevel@tonic-gate #define	PN_IC_IDX(icp)			((icp->ic_idx & 0x7f80) >> 7)
10650Sstevel@tonic-gate #define	CHP_ICPATAG_MASK		INT64_C(0x000003ffffffe000)
10660Sstevel@tonic-gate #define	CHP_ICSNTAG_MASK		INT64_C(0x000003ffffffe000)
10670Sstevel@tonic-gate #define	CHP_ICUTAG_MASK			INT64_C(0x00000000001fe000)
10680Sstevel@tonic-gate #define	PN_ICUTAG_MASK			INT64_C(0x00000000003fc000)
10690Sstevel@tonic-gate #define	CHP_ICWAY_MASK			INT64_C(0x0000000000003fe0)
10700Sstevel@tonic-gate #define	CHP_ICPATAG_TO_PA(tag)		((tag << 5) & CHP_ICPATAG_MASK)
10710Sstevel@tonic-gate #define	CHP_ICSNTAG_TO_PA(tag)		((tag << 5) & CHP_ICSNTAG_MASK)
10720Sstevel@tonic-gate #define	CHP_ICUTAG_TO_VA(tag)		((tag >> 25) & CHP_ICUTAG_MASK)
10730Sstevel@tonic-gate #define	CHP_ICPATAG_PARMASK		INT64_C(0x0000003fffffff00)
10740Sstevel@tonic-gate #define	CHP_ICSNTAG_PARMASK		INT64_C(0x0000003fffffff00)
10750Sstevel@tonic-gate 
10760Sstevel@tonic-gate /*
10770Sstevel@tonic-gate  * Cheetah+ Icache data parity masks, see Cheetah+ Delta PRM 7.3
10780Sstevel@tonic-gate  * PC-relative instructions have different bits protected by parity.
10790Sstevel@tonic-gate  * Predecode bit 7 is not parity protected and indicates if the instruction
10800Sstevel@tonic-gate  * is PC-relative or not.
10810Sstevel@tonic-gate  */
10820Sstevel@tonic-gate #define	CH_ICDATA_PRED_ISPCREL		INT64_C(0x0000008000000000)
10830Sstevel@tonic-gate #define	CHP_ICDATA_PCREL_PARMASK	INT64_C(0x0000039ffffff800)
10840Sstevel@tonic-gate #define	CHP_ICDATA_NPCREL_PARMASK	INT64_C(0x000003bfffffffff)
10850Sstevel@tonic-gate #define	PN_ICDATA_PARITY_BIT_MASK	INT64_C(0x40000000000)
10860Sstevel@tonic-gate #define	CHP_ICTAG_PARITY(tag)		(tag & CHP_IC_TAG)
10870Sstevel@tonic-gate #define	CHP_ICSNTAG_PARITY(tag)		(tag & CHP_IC_SNTAG)
10880Sstevel@tonic-gate #define	CHP_IC_TAG			0x1
10890Sstevel@tonic-gate #define	CHP_IC_SNTAG			0x2
10900Sstevel@tonic-gate #endif	/* CHEETAH_PLUS || JALAPENO || SERRANO */
10910Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
10920Sstevel@tonic-gate #define	PN_IPB_TAG_ADDR_LINESIZE	0x40
10930Sstevel@tonic-gate #define	PN_IPB_TAG_ADDR_MAX		0x3c0
10940Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
10950Sstevel@tonic-gate 
10960Sstevel@tonic-gate /*
10970Sstevel@tonic-gate  * Macros for Pcache diagnostic accesses.
10980Sstevel@tonic-gate  */
10990Sstevel@tonic-gate #define	CH_PC_WAY_MASK			0x600
11000Sstevel@tonic-gate #define	CH_PC_WAY_SHIFT			9
11010Sstevel@tonic-gate #define	CH_PCIDX_TO_WAY(idx)		(((idx) & CH_PC_WAY_MASK) >> \
11020Sstevel@tonic-gate 						CH_PC_WAY_SHIFT)
11030Sstevel@tonic-gate #define	CH_PC_DATA_REG_SIZE		64
11040Sstevel@tonic-gate #define	CH_PCACHE_NWAY			4
11050Sstevel@tonic-gate #define	PN_PC_PARITY_SHIFT		50
11060Sstevel@tonic-gate #define	PN_PC_PARITY_MASK		0xff
11070Sstevel@tonic-gate #define	PN_PC_PARITY_BITS(status)	\
11080Sstevel@tonic-gate 	(((status) >> PN_PC_PARITY_SHIFT) & PN_PC_PARITY_MASK)
11090Sstevel@tonic-gate #define	CH_PC_IDX_ADR(pcp)		((pcp->pc_idx & 0x1c0) >> 6)
11100Sstevel@tonic-gate #define	CH_PCTAG_ADDR_SHIFT		6
11110Sstevel@tonic-gate #define	CH_PC_PA_MASK			0x7ffffffffc0
11120Sstevel@tonic-gate #define	CH_PCTAG_TO_VA(tag)		((tag) << CH_PCTAG_ADDR_SHIFT)
11130Sstevel@tonic-gate #define	CH_PCSTAG_TO_PA(tag)		(((tag) << CH_PCTAG_ADDR_SHIFT) & \
11140Sstevel@tonic-gate 					    CH_PC_PA_MASK)
11150Sstevel@tonic-gate #define	CH_PCTAG_BNK0_VALID_MASK	0x2000000000000000
11160Sstevel@tonic-gate #define	CH_PCTAG_BNK1_VALID_MASK	0x1000000000000000
11170Sstevel@tonic-gate #define	CH_PCTAG_BNK0_INVALID(tag)	(((tag) & CH_PCTAG_BNK0_VALID_MASK) == \
11180Sstevel@tonic-gate 					    0)
11190Sstevel@tonic-gate #define	CH_PCTAG_BNK1_INVALID(tag)	(((tag) & CH_PCTAG_BNK1_VALID_MASK) == \
11200Sstevel@tonic-gate 					    0)
11210Sstevel@tonic-gate 
11220Sstevel@tonic-gate /*
11230Sstevel@tonic-gate  * CPU Log Out Structure parameters.
11240Sstevel@tonic-gate  * This structure is filled in by the Error Trap handlers and captures the
11250Sstevel@tonic-gate  * Ecache/Dcache/Icache line(s) associated with the AFAR.
11260Sstevel@tonic-gate  * For Cheetah Phase II, this structure is filled in at the TL=0 code.  For
11270Sstevel@tonic-gate  * Cheetah Phase III, this will be filled in at the trap handlers.
11280Sstevel@tonic-gate  */
11290Sstevel@tonic-gate 
11300Sstevel@tonic-gate /*
11310Sstevel@tonic-gate  * We use this to mark the LOGOUT structure as invalid.  Note that
11320Sstevel@tonic-gate  * this cannot be a valid AFAR, as AFAR bits outside of [41:5] should always
11330Sstevel@tonic-gate  * be zero.
11340Sstevel@tonic-gate  */
11350Sstevel@tonic-gate #define	LOGOUT_INVALID_U32	0xecc1ecc1
11360Sstevel@tonic-gate #define	LOGOUT_INVALID_L32	0xecc1ecc1
11370Sstevel@tonic-gate #define	LOGOUT_INVALID		UINT64_C(0xecc1ecc1ecc1ecc1)
11380Sstevel@tonic-gate 
11390Sstevel@tonic-gate /*
11400Sstevel@tonic-gate  * Max number of TLs to support for Fast ECC or Cache Parity Errors
11410Sstevel@tonic-gate  * at TL>0.  Traps are OK from TL=1-2, at TL>=3, we will Red Mode.
11420Sstevel@tonic-gate  */
11430Sstevel@tonic-gate #define	CH_ERR_TL1_TLMAX	2
11440Sstevel@tonic-gate 
11450Sstevel@tonic-gate /*
11460Sstevel@tonic-gate  * Software traps used by TL>0 handlers.
11470Sstevel@tonic-gate  */
11480Sstevel@tonic-gate #define	SWTRAP_0		0	/* Used by Fast ECC */
11490Sstevel@tonic-gate #define	SWTRAP_1		1	/* Used by Dcache Parity */
11500Sstevel@tonic-gate #define	SWTRAP_2		2	/* Used by Icache Parity */
11510Sstevel@tonic-gate 
11520Sstevel@tonic-gate /*
11530Sstevel@tonic-gate  * Bit mask defines for various Cheetah Error conditions.
11540Sstevel@tonic-gate  */
11550Sstevel@tonic-gate #define	CH_ERR_FECC	0x01	/* Data/Event is Fast ECC */
11560Sstevel@tonic-gate #define	CH_ERR_IPE	0x02	/* Data/Event is Icache Parity Error */
11570Sstevel@tonic-gate #define	CH_ERR_DPE	0x04	/* Data/Event is Dcache Parity Error */
11580Sstevel@tonic-gate #define	CH_ERR_PANIC	0x08	/* Fatal error in TL>0 handler */
11590Sstevel@tonic-gate #define	CH_ERR_TL	0x10	/* Error occured at TL>0 */
11600Sstevel@tonic-gate #define	CH_ERR_ME_SHIFT	   8	/* If multiple errors, shift left newest */
11610Sstevel@tonic-gate #define	CH_ERR_ME_FLAGS(x)	((x) >> CH_ERR_ME_SHIFT)
11620Sstevel@tonic-gate 
11630Sstevel@tonic-gate /*
11640Sstevel@tonic-gate  * Defines for Bit8 (CH_ERR_TSTATE_IC_ON) and Bit9 (CH_ERR_TSTATE_DC_ON)
11650Sstevel@tonic-gate  * in %tstate, which is used to remember D$/I$ state on Fast ECC handler
11660Sstevel@tonic-gate  * at TL>0.  Note that DCU_IC=0x1, DCU_DC=0x2.
11670Sstevel@tonic-gate  */
11680Sstevel@tonic-gate #define	CH_ERR_G2_TO_TSTATE_SHFT	10
11690Sstevel@tonic-gate #define	CH_ERR_DCU_TO_TSTATE_SHFT	8
11700Sstevel@tonic-gate #define	CH_ERR_TSTATE_IC_ON	(DCU_IC << CH_ERR_DCU_TO_TSTATE_SHFT)
11710Sstevel@tonic-gate #define	CH_ERR_TSTATE_DC_ON	(DCU_DC << CH_ERR_DCU_TO_TSTATE_SHFT)
11720Sstevel@tonic-gate 
11730Sstevel@tonic-gate /*
11740Sstevel@tonic-gate  * Multiple offset TL>0 handler structure elements
11750Sstevel@tonic-gate  */
11760Sstevel@tonic-gate #define	CH_ERR_TL1_DATA		(CH_ERR_TL1_LOGOUT + CH_CLO_DATA)
11770Sstevel@tonic-gate #define	CH_ERR_TL1_SDW_DATA	(CH_ERR_TL1_LOGOUT + CH_CLO_SDW_DATA)
11780Sstevel@tonic-gate #define	CH_ERR_TL1_NEST_CNT	(CH_ERR_TL1_LOGOUT + CH_CLO_NEST_CNT)
11791321Srscott #define	CH_ERR_TL1_AFAR		(CH_ERR_TL1_DATA + CH_CHD_AFAR)
11800Sstevel@tonic-gate #define	CH_ERR_TL1_AFSR		(CH_ERR_TL1_DATA + CH_CHD_AFSR)
11811321Srscott #define	CH_ERR_TL1_SDW_AFAR	(CH_ERR_TL1_SDW_DATA + CH_CHD_AFAR)
11820Sstevel@tonic-gate #define	CH_ERR_TL1_SDW_AFSR	(CH_ERR_TL1_SDW_DATA + CH_CHD_AFSR)
11830Sstevel@tonic-gate #define	CH_ERR_TL1_SDW_AFSR_EXT	(CH_ERR_TL1_SDW_DATA + CH_CHD_AFSR_EXT)
11840Sstevel@tonic-gate 
11850Sstevel@tonic-gate /*
11860Sstevel@tonic-gate  * Interval for deferred CEEN reenable
11870Sstevel@tonic-gate  */
11880Sstevel@tonic-gate #define	CPU_CEEN_DELAY_SECS		6
11890Sstevel@tonic-gate 
11900Sstevel@tonic-gate /*
11910Sstevel@tonic-gate  * flags for flt_trapped_ce variable
11920Sstevel@tonic-gate  */
11930Sstevel@tonic-gate #define	CE_CEEN_DEFER		0x1	/* no CEEN reenable in trap handler */
11940Sstevel@tonic-gate #define	CE_CEEN_NODEFER		0x2	/* reenable CEEN in handler */
11950Sstevel@tonic-gate #define	CE_CEEN_TIMEOUT		0x4	/* CE caught by timeout */
11960Sstevel@tonic-gate #define	CE_CEEN_TRAPPED		0x8	/* CE caught by trap */
11970Sstevel@tonic-gate 
11980Sstevel@tonic-gate /*
11990Sstevel@tonic-gate  * default value for cpu_ce_not_deferred
12000Sstevel@tonic-gate  */
12010Sstevel@tonic-gate #if defined(JALAPENO) || defined(SERRANO)
12020Sstevel@tonic-gate #define	CPU_CE_NOT_DEFERRED	(C_AFSR_CECC_ERRS & \
12030Sstevel@tonic-gate 		~(C_AFSR_CE | C_AFSR_FRC | C_AFSR_RCE | C_AFSR_EMC))
12040Sstevel@tonic-gate #else /* JALAPENO || SERRANO */
12055219Skm84432 #if defined(CHEETAH_PLUS)
12065219Skm84432 #define	CPU_CE_NOT_DEFERRED	(C_AFSR_CECC_ERRS & \
12075219Skm84432 		~(C_AFSR_CE | C_AFSR_EMC | C_AFSR_THCE))
12085219Skm84432 #else /* CHEETAH_PLUS */
12095219Skm84432 #define	CPU_CE_NOT_DEFERRED	(C_AFSR_CECC_ERRS & \
12105219Skm84432 		~(C_AFSR_CE | C_AFSR_EMC))
12115219Skm84432 #endif /* CHEETAH_PLUS */
12120Sstevel@tonic-gate #endif /* JALAPENO || SERRANO */
12130Sstevel@tonic-gate 
12145219Skm84432 #define	CPU_CE_NOT_DEFERRED_EXT	(C_AFSR_EXT_CECC_ERRS & \
12155219Skm84432 		~(C_AFSR_L3_THCE))
12160Sstevel@tonic-gate 
12170Sstevel@tonic-gate #if defined(CHEETAH_PLUS)
12180Sstevel@tonic-gate 
12190Sstevel@tonic-gate /*
12200Sstevel@tonic-gate  * VA for primary and shadow AFSR/AFAR/AFSR_EXT registers
12210Sstevel@tonic-gate  */
12220Sstevel@tonic-gate #define	ASI_SHADOW_REG_VA	0x8
12230Sstevel@tonic-gate #define	ASI_AFSR_EXT_VA		0x10
12240Sstevel@tonic-gate #define	ASI_SHADOW_AFSR_EXT_VA	0x18
12250Sstevel@tonic-gate 
12260Sstevel@tonic-gate /*
12270Sstevel@tonic-gate  * Bitmask for keeping track of core parking in ECC error handlers.
12280Sstevel@tonic-gate  * We share a register that also saves the DCUCR value so we use
12290Sstevel@tonic-gate  * one of the reserved bit positions of the DCUCR register to keep
12300Sstevel@tonic-gate  * track of whether or not we have parked our sibling core.
12310Sstevel@tonic-gate  */
12320Sstevel@tonic-gate #define	PN_PARKED_OTHER_CORE	0x20
12330Sstevel@tonic-gate #define	PN_BOTH_CORES_RUNNING	0x3
12340Sstevel@tonic-gate 
12350Sstevel@tonic-gate /*
12360Sstevel@tonic-gate  * Panther EMU Activity Status Register Bits.
12370Sstevel@tonic-gate  */
12380Sstevel@tonic-gate #define	ASI_EMU_ACT_STATUS_VA	0x18
12390Sstevel@tonic-gate #define	MCU_ACT_STATUS		INT64_C(0x0000000000000001)
12400Sstevel@tonic-gate #define	SIU_ACT_STATUS		INT64_C(0x0000000000000002)
12410Sstevel@tonic-gate #endif	/* CHEETAH_PLUS */
12420Sstevel@tonic-gate 
12430Sstevel@tonic-gate #define	ASI_CESR_ID_VA		0x40    /* ASI_CESRD_ID per-core registers */
12440Sstevel@tonic-gate 
12450Sstevel@tonic-gate #define	ASR_DISPATCH_CONTROL		%asr18
12460Sstevel@tonic-gate #define	ASR_DISPATCH_CONTROL_BPE	0x20
12470Sstevel@tonic-gate 
12480Sstevel@tonic-gate /*
12490Sstevel@tonic-gate  * Max number of E$ sets logged in ch_diag_data structure
12500Sstevel@tonic-gate  */
12510Sstevel@tonic-gate #define	CHD_EC_DATA_SETS	4	/* max 4 sets of E$ data */
12520Sstevel@tonic-gate 
12530Sstevel@tonic-gate /*
12540Sstevel@tonic-gate  * Definitions for Panther TLB parity handling.
12550Sstevel@tonic-gate  */
12560Sstevel@tonic-gate #define	PN_ITLB_NWAYS		2
12570Sstevel@tonic-gate #define	PN_NUM_512_ITLBS	1
12580Sstevel@tonic-gate #define	PN_DTLB_NWAYS		2
12590Sstevel@tonic-gate #define	PN_NUM_512_DTLBS	2
12600Sstevel@tonic-gate #define	PN_SFSR_PARITY_SHIFT	12
12610Sstevel@tonic-gate #define	PN_ITLB_PGSZ_SHIFT	22
12620Sstevel@tonic-gate #define	PN_ITLB_PGSZ_MASK	(7 << PN_ITLB_PGSZ_SHIFT)
12630Sstevel@tonic-gate #define	PN_DTLB_PGSZ0_SHIFT	16
12640Sstevel@tonic-gate #define	PN_DTLB_PGSZ0_MASK	(7 << PN_DTLB_PGSZ0_SHIFT)
12650Sstevel@tonic-gate #define	PN_DTLB_PGSZ1_SHIFT	19
12660Sstevel@tonic-gate #define	PN_DTLB_PGSZ1_MASK	(7 << PN_DTLB_PGSZ1_SHIFT)
12670Sstevel@tonic-gate #define	PN_DTLB_PGSZ_MASK	(PN_DTLB_PGSZ1_MASK | PN_DTLB_PGSZ0_MASK)
12680Sstevel@tonic-gate #define	PN_DTLB_T512_0		(2 << 16)
12690Sstevel@tonic-gate #define	PN_DTLB_T512_1		(3 << 16)
12700Sstevel@tonic-gate #define	PN_TLO_INFO_IMMU_SHIFT	14
12710Sstevel@tonic-gate #define	PN_TLO_INFO_IMMU	(1 << PN_TLO_INFO_IMMU_SHIFT)
12720Sstevel@tonic-gate #define	PN_TLO_INFO_TL1_SHIFT	13
12730Sstevel@tonic-gate #define	PN_TLO_INFO_TL1		(1 << PN_TLO_INFO_TL1_SHIFT)
12740Sstevel@tonic-gate #define	PN_ITLB_T512		(2 << 16)
12750Sstevel@tonic-gate #define	PN_TLB_ACC_IDX_SHIFT	3
12760Sstevel@tonic-gate #define	PN_TLB_ACC_WAY_BIT	(1 << 11)
12770Sstevel@tonic-gate #define	PN_TLB_DIAGACC_OFFSET	0x40000	/* Diag Acc ASI VA offset */
12780Sstevel@tonic-gate /*
12790Sstevel@tonic-gate  * tag parity = XOR(Size[2:0],Global,VA[63:21],Context[12:0])
12800Sstevel@tonic-gate  * which requires looking at both the tag and the data.
12810Sstevel@tonic-gate  */
12820Sstevel@tonic-gate #define	PN_TLB_TAG_PARITY_TAG_MASK	0xffffffffffe01fff
12830Sstevel@tonic-gate #define	PN_TLB_TAG_PARITY_DATA_MASK	0x6001400000000001
12840Sstevel@tonic-gate /* data parity = XOR(NFO,IE,PA[42:13],CP,CV,E,P,W) */
12850Sstevel@tonic-gate #define	PN_TLB_DATA_PARITY_DATA_MASK	0x180087ffffffe03e
12860Sstevel@tonic-gate 
12870Sstevel@tonic-gate #ifdef _KERNEL
12880Sstevel@tonic-gate 
12890Sstevel@tonic-gate #ifndef	_ASM
12900Sstevel@tonic-gate 
12910Sstevel@tonic-gate #include <sys/kstat.h>
12920Sstevel@tonic-gate 
12930Sstevel@tonic-gate /*
12940Sstevel@tonic-gate  * One Ecache data element, 32 bytes of data, 8 bytes of ECC.
12950Sstevel@tonic-gate  * See Cheetah PRM 10.7.2.
12960Sstevel@tonic-gate  */
12970Sstevel@tonic-gate typedef struct ec_data_elm {
12980Sstevel@tonic-gate 	uint64_t ec_d8[CH_ECACHE_STGREG_NUM];
12990Sstevel@tonic-gate 	uint64_t ec_eccd;	/* EC_data_ECC field */
13000Sstevel@tonic-gate } ec_data_elm_t;
13010Sstevel@tonic-gate 
13020Sstevel@tonic-gate /*
13030Sstevel@tonic-gate  * L2 and L3 cache data captured by cpu log out code.
13040Sstevel@tonic-gate  * See Cheetah PRM 10.7.4.
13050Sstevel@tonic-gate  */
13060Sstevel@tonic-gate typedef struct ch_ec_data {
13070Sstevel@tonic-gate 	uint64_t ec_logflag;	/* Flag indicates if data was logged */
13080Sstevel@tonic-gate 	uint64_t ec_idx;	/* Ecache index */
13090Sstevel@tonic-gate 	uint64_t ec_way;	/* Ecache way */
13100Sstevel@tonic-gate 	uint64_t ec_tag;	/* Ecache Tag */
13110Sstevel@tonic-gate 	uint64_t ec_tag_ecc;	/* Ecache Tag ECC (Cheetah+ only) */
13120Sstevel@tonic-gate 	ec_data_elm_t ec_data[CH_ECACHE_SUBBLK_SIZE/CH_ECACHE_STGREG_SIZE];
13130Sstevel@tonic-gate } ch_ec_data_t;
13140Sstevel@tonic-gate 
13150Sstevel@tonic-gate /*
13160Sstevel@tonic-gate  * Dcache data captured by cpu log out code and get_dcache_dtag.
13170Sstevel@tonic-gate  * See Cheetah PRM 10.6.[1-4].
13180Sstevel@tonic-gate  */
13190Sstevel@tonic-gate typedef struct ch_dc_data {
13200Sstevel@tonic-gate 	uint64_t dc_logflag;	/* Flag indicates if data was logged */
13210Sstevel@tonic-gate 	uint64_t dc_idx;	/* Dcache index */
13220Sstevel@tonic-gate 	uint64_t dc_way;	/* Dcache way */
13230Sstevel@tonic-gate 	uint64_t dc_tag;	/* Tag/Valid Fields */
13240Sstevel@tonic-gate 	uint64_t dc_utag;	/* Microtag */
13250Sstevel@tonic-gate 	uint64_t dc_sntag;	/* Snoop Tag */
13260Sstevel@tonic-gate 	uint64_t dc_data[CH_DC_DATA_REG_SIZE/sizeof (uint64_t)]; /* Data */
13270Sstevel@tonic-gate 	uint64_t dc_pn_data_parity;	/* Data parity bits for Panther */
13280Sstevel@tonic-gate } ch_dc_data_t;
13290Sstevel@tonic-gate 
13300Sstevel@tonic-gate /*
13310Sstevel@tonic-gate  * Icache data captured by cpu log out code and get_icache_dtag.
13320Sstevel@tonic-gate  * See Cheetah PRM 10.4.[1-3].
13330Sstevel@tonic-gate  */
13340Sstevel@tonic-gate typedef struct ch_ic_data {
13350Sstevel@tonic-gate 	uint64_t ic_logflag;	/* Flag indicates if data was logged */
13360Sstevel@tonic-gate 	uint64_t ic_idx;	/* Icache index */
13370Sstevel@tonic-gate 	uint64_t ic_way;	/* Icache way */
13380Sstevel@tonic-gate 	uint64_t ic_patag;	/* Physical address tag */
13390Sstevel@tonic-gate 	uint64_t ic_utag;	/* Microtag */
13400Sstevel@tonic-gate 	uint64_t ic_upper;	/* Upper valid/predict tag */
13410Sstevel@tonic-gate 	uint64_t ic_lower;	/* Lower valid/predict tag */
13420Sstevel@tonic-gate 	uint64_t ic_sntag;	/* Snoop Tag */
13430Sstevel@tonic-gate 	uint64_t ic_data[PN_IC_DATA_REG_SIZE/sizeof (uint64_t)]; /* Data */
13440Sstevel@tonic-gate } ch_ic_data_t;
13450Sstevel@tonic-gate 
13460Sstevel@tonic-gate /*
13470Sstevel@tonic-gate  * Pcache data captured by get_pcache_dtag
13480Sstevel@tonic-gate  */
13490Sstevel@tonic-gate typedef struct ch_pc_data {
13500Sstevel@tonic-gate 	uint64_t pc_logflag;	/* Flag indicates if data was logged */
13510Sstevel@tonic-gate 	uint64_t pc_idx;	/* Pcache index */
13520Sstevel@tonic-gate 	uint64_t pc_way;	/* Pcache way */
13530Sstevel@tonic-gate 	uint64_t pc_status;	/* Pcache status data */
13540Sstevel@tonic-gate 	uint64_t pc_tag;	/* Tag/Valid Fields */
13550Sstevel@tonic-gate 	uint64_t pc_sntag;	/* Snoop Tag */
13560Sstevel@tonic-gate 	uint64_t pc_data[CH_PC_DATA_REG_SIZE/sizeof (uint64_t)]; /* Data */
13570Sstevel@tonic-gate } ch_pc_data_t;
13580Sstevel@tonic-gate 
13590Sstevel@tonic-gate /*
13600Sstevel@tonic-gate  * CPU Error State
13610Sstevel@tonic-gate  */
13620Sstevel@tonic-gate typedef struct ch_cpu_errors {
13630Sstevel@tonic-gate 	uint64_t afsr;		/* AFSR */
13640Sstevel@tonic-gate 	uint64_t afar;		/* AFAR */
13650Sstevel@tonic-gate 	/*
13660Sstevel@tonic-gate 	 * The following registers don't exist on cheetah
13670Sstevel@tonic-gate 	 */
13680Sstevel@tonic-gate 	uint64_t shadow_afsr;	/* Shadow AFSR */
13690Sstevel@tonic-gate 	uint64_t shadow_afar;	/* Shadow AFAR */
13700Sstevel@tonic-gate 	uint64_t afsr_ext;	/* AFSR1_EXT */
13710Sstevel@tonic-gate 	uint64_t shadow_afsr_ext;	/* AFSR2_EXT */
13720Sstevel@tonic-gate 	uint64_t afar2;		/* AFAR2 - Serrano only */
13730Sstevel@tonic-gate } ch_cpu_errors_t;
13740Sstevel@tonic-gate 
13750Sstevel@tonic-gate /*
13760Sstevel@tonic-gate  * CPU logout structures.
13770Sstevel@tonic-gate  * NOTE: These structures should be the same for Cheetah, Cheetah+,
13780Sstevel@tonic-gate  *	 Jaguar, Panther, and Jalapeno since the assembler code relies
13790Sstevel@tonic-gate  *	 on one set of offsets. Panther is the only processor that
13800Sstevel@tonic-gate  *	 uses the chd_l2_data field since it has both L3 and L2 caches.
13810Sstevel@tonic-gate  */
13820Sstevel@tonic-gate typedef struct ch_diag_data {
13830Sstevel@tonic-gate 	uint64_t chd_afar;				/* AFAR */
13840Sstevel@tonic-gate 	uint64_t chd_afsr;				/* AFSR */
13850Sstevel@tonic-gate 	uint64_t chd_afsr_ext;				/* AFSR_EXT */
13860Sstevel@tonic-gate 	uint64_t chd_afar2;			/* AFAR2 - Serrano only */
13870Sstevel@tonic-gate 	ch_ec_data_t chd_ec_data[CHD_EC_DATA_SETS];	/* Ecache data */
13880Sstevel@tonic-gate 	ch_ec_data_t chd_l2_data[PN_L2_NWAYS];		/* L2 cache data */
13890Sstevel@tonic-gate 	ch_dc_data_t chd_dc_data;			/* Dcache data */
13900Sstevel@tonic-gate 	ch_ic_data_t chd_ic_data;			/* Icache data */
13910Sstevel@tonic-gate } ch_diag_data_t;
13920Sstevel@tonic-gate 
13930Sstevel@tonic-gate 
13940Sstevel@tonic-gate /*
13950Sstevel@tonic-gate  * Top level CPU logout structure.
13960Sstevel@tonic-gate  * clo_flags is used to hold information such as trap type, trap level,
13970Sstevel@tonic-gate  * CEEN value, etc that is needed by the individual trap handlers. Not
13980Sstevel@tonic-gate  * all fields in this flag are used by all trap handlers but when they
13990Sstevel@tonic-gate  * are used, here's how they are laid out:
14000Sstevel@tonic-gate  *
14010Sstevel@tonic-gate  * |-------------------------------------------------------|
14020Sstevel@tonic-gate  * |        | trap type | trap level |  |UCEEN| |NCEEN|CEEN|
14030Sstevel@tonic-gate  * |-------------------------------------------------------|
14040Sstevel@tonic-gate  *  63       19       12 11         8      3   2   1    0
14050Sstevel@tonic-gate  *
14060Sstevel@tonic-gate  * Note that the *CEEN bits correspond exactly to the same bit positions
14070Sstevel@tonic-gate  * that are used in the error enable register.
14080Sstevel@tonic-gate  */
14090Sstevel@tonic-gate typedef struct ch_cpu_logout {
14100Sstevel@tonic-gate 	uint64_t clo_flags;		/* Information about this trap */
14110Sstevel@tonic-gate 	uint64_t clo_nest_cnt;		/* To force an upper bound */
14120Sstevel@tonic-gate 	ch_diag_data_t clo_data;	/* Diag data for primary AFAR */
14130Sstevel@tonic-gate 	ch_diag_data_t clo_sdw_data;	/* Diag data for shadow AFAR */
14140Sstevel@tonic-gate } ch_cpu_logout_t;
14150Sstevel@tonic-gate 
14160Sstevel@tonic-gate typedef struct ch_tte_entry {
14170Sstevel@tonic-gate 	uint64_t ch_tte_tag;
14180Sstevel@tonic-gate 	uint64_t ch_tte_data;
14190Sstevel@tonic-gate } ch_tte_entry_t;
14200Sstevel@tonic-gate 
14210Sstevel@tonic-gate /*
14220Sstevel@tonic-gate  * Top level CPU logout structure for TLB parity errors.
14230Sstevel@tonic-gate  *
14240Sstevel@tonic-gate  * tlo_logflag  - Flag indicates if data was logged
14250Sstevel@tonic-gate  * tlo_info	- Used to keep track of a number of values:
14260Sstevel@tonic-gate  *   itlb pgsz	  - Page size of the VA whose lookup in the ITLB caused
14270Sstevel@tonic-gate  *		    the exception (from ASI_IMMU_TAG_ACCESS_EXT.)
14280Sstevel@tonic-gate  *   dtlb pgsz1	  - Page size of the VA whose lookup in the DTLB T512_1
14290Sstevel@tonic-gate  *		    caused the exception (from ASI_DMMU_TAG_ACCESS_EXT.).
14300Sstevel@tonic-gate  *   dtlb pgsz0	  - Page size of the VA whose lookup in the DTLB T512_0
14310Sstevel@tonic-gate  *		    caused the exception (from ASI_DMMU_TAG_ACCESS_EXT.).
14320Sstevel@tonic-gate  *   immu	  - Trap is the result of an ITLB exception if immu == 1.
14330Sstevel@tonic-gate  *		    Otherwise, for DTLB exceptions immu == 0.
14340Sstevel@tonic-gate  *   tl1	  - Set to 1 if the exception occured at TL>0.
14350Sstevel@tonic-gate  *   context	  - Context of the VA whose lookup in the TLB caused the
14360Sstevel@tonic-gate  *		    exception (from ASI_[I|D]MMU_TAG_ACCESS.)
14370Sstevel@tonic-gate  * |---------------------------------------------------------------------|
14380Sstevel@tonic-gate  * |...| itlb pgsz  | dtlb pgsz1 | dtlb pgsz0 |...| immu | tl1 | context |
14390Sstevel@tonic-gate  * |---------------------------------------------------------------------|
14400Sstevel@tonic-gate  *      24        22 21        19 18        16       14    13   12      0
14410Sstevel@tonic-gate  *
14420Sstevel@tonic-gate  * tlo_addr	- VA that cause the MMU exception trap.
14430Sstevel@tonic-gate  * tlo_pc	- PC where the exception occured.
14440Sstevel@tonic-gate  * tlo_itlb_tte	- TTEs that were in the ITLB after the trap at the index
14450Sstevel@tonic-gate  *		  specific to the VA and page size in question.
14460Sstevel@tonic-gate  * tlo_dtlb_tte	- TTEs that were in the DTLB after the trap at the index
14470Sstevel@tonic-gate  *		  specific to the VA and page size in question.
14480Sstevel@tonic-gate  */
14490Sstevel@tonic-gate typedef struct pn_tlb_logout {
14500Sstevel@tonic-gate 	uint64_t tlo_logflag;
14510Sstevel@tonic-gate 	uint64_t tlo_info;
14520Sstevel@tonic-gate 	uint64_t tlo_addr;
14530Sstevel@tonic-gate 	uint64_t tlo_pc;
14540Sstevel@tonic-gate 	ch_tte_entry_t tlo_itlb_tte[PN_ITLB_NWAYS * PN_NUM_512_ITLBS];
14550Sstevel@tonic-gate 	ch_tte_entry_t tlo_dtlb_tte[PN_DTLB_NWAYS * PN_NUM_512_DTLBS];
14560Sstevel@tonic-gate } pn_tlb_logout_t;
14570Sstevel@tonic-gate 
14580Sstevel@tonic-gate #if defined(CPU_IMP_L1_CACHE_PARITY)
14590Sstevel@tonic-gate /*
14600Sstevel@tonic-gate  * Parity error logging structure.
14610Sstevel@tonic-gate  */
14620Sstevel@tonic-gate typedef union ch_l1_parity_log {
14630Sstevel@tonic-gate 	struct {
14640Sstevel@tonic-gate 		int cpl_way;				/* Faulty line way */
14650Sstevel@tonic-gate 		int cpl_off;				/* Faulty line offset */
14660Sstevel@tonic-gate 		int cpl_tag;				/* Faulty tags list */
14670Sstevel@tonic-gate 		int cpl_lcnt;				/* Faulty cache lines */
14680Sstevel@tonic-gate 		ch_dc_data_t cpl_dc[CH_DCACHE_NWAY];	/* D$ data nWays */
14690Sstevel@tonic-gate 		ch_pc_data_t cpl_pc[CH_PCACHE_NWAY];	/* P$ data nWays */
14700Sstevel@tonic-gate 		int cpl_cache;				/* error in D$ or P$? */
14710Sstevel@tonic-gate 	} dpe;	/* D$ parity error */
14720Sstevel@tonic-gate 	struct {
14730Sstevel@tonic-gate 		int cpl_way;				/* Faulty line way */
14740Sstevel@tonic-gate 		int cpl_off;				/* Faulty line offset */
14750Sstevel@tonic-gate 		int cpl_tag;				/* Faulty tags list */
14760Sstevel@tonic-gate 		int cpl_lcnt;				/* Faulty cache lines */
14770Sstevel@tonic-gate 		ch_ic_data_t cpl_ic[CH_ICACHE_NWAY];	/* I$ data nWays */
14780Sstevel@tonic-gate 	} ipe;	/* I$ parity error */
14790Sstevel@tonic-gate } ch_l1_parity_log_t;
14800Sstevel@tonic-gate 
14810Sstevel@tonic-gate #endif	/* CPU_IMP_L1_CACHE_PARITY */
14820Sstevel@tonic-gate 
14830Sstevel@tonic-gate /*
14840Sstevel@tonic-gate  * Error at TL>0 CPU logout data.
14850Sstevel@tonic-gate  *   Needs some extra space to save %g registers and miscellaneous info.
14860Sstevel@tonic-gate  */
14870Sstevel@tonic-gate typedef struct ch_err_tl1_data {
14880Sstevel@tonic-gate 	uint64_t ch_err_tl1_g1;		/* Saved %g1 */
14890Sstevel@tonic-gate 	uint64_t ch_err_tl1_g2;		/* Saved %g2 */
14900Sstevel@tonic-gate 	uint64_t ch_err_tl1_g3;		/* Saved %g3 */
14910Sstevel@tonic-gate 	uint64_t ch_err_tl1_g4;		/* Saved %g4 */
14920Sstevel@tonic-gate 	uint64_t ch_err_tl1_g5;		/* Saved %g5 */
14930Sstevel@tonic-gate 	uint64_t ch_err_tl1_g6;		/* Saved %g6 */
14940Sstevel@tonic-gate 	uint64_t ch_err_tl1_g7;		/* Saved %g7 */
14950Sstevel@tonic-gate 	uint64_t ch_err_tl1_tpc;	/* Trap PC */
14960Sstevel@tonic-gate 	uint64_t ch_err_tl1_flags;	/* miscellaneous flags */
14970Sstevel@tonic-gate 	uint64_t ch_err_tl1_tmp;	/* some handlers may use as tmp */
14980Sstevel@tonic-gate 	ch_cpu_logout_t ch_err_tl1_logout;	/* logout */
14990Sstevel@tonic-gate } ch_err_tl1_data_t;
15000Sstevel@tonic-gate 
15010Sstevel@tonic-gate /* Indices into chsm_outstanding and friends */
15020Sstevel@tonic-gate #define	CACHE_SCRUBBER_INFO_E	0
15030Sstevel@tonic-gate #define	CACHE_SCRUBBER_INFO_D	1
15040Sstevel@tonic-gate #define	CACHE_SCRUBBER_INFO_I	2
15050Sstevel@tonic-gate 
15060Sstevel@tonic-gate /* We define 3 scrubbers: E$, D$, and I$ */
15070Sstevel@tonic-gate #define	CACHE_SCRUBBER_COUNT	3
15080Sstevel@tonic-gate 
15090Sstevel@tonic-gate /*
15100Sstevel@tonic-gate  * The ch_scrub_misc structure contains miscellaneous bookkeeping
15110Sstevel@tonic-gate  * items for scrubbing the I$, D$, and E$.
15120Sstevel@tonic-gate  *
15130Sstevel@tonic-gate  * For a description of the use of chsm_core_state and why it's not needed
15140Sstevel@tonic-gate  * on Jaguar, see the comment above cpu_scrub_cpu_setup() in us3_cheetahplus.c.
15150Sstevel@tonic-gate  */
15160Sstevel@tonic-gate typedef struct ch_scrub_misc {
15170Sstevel@tonic-gate 	uint32_t	chsm_outstanding[CACHE_SCRUBBER_COUNT];
15180Sstevel@tonic-gate 						/* outstanding requests */
15190Sstevel@tonic-gate 	int		chsm_flush_index[CACHE_SCRUBBER_COUNT];
15200Sstevel@tonic-gate 						/* next line to flush */
15210Sstevel@tonic-gate 	int		chsm_enable[CACHE_SCRUBBER_COUNT];
15220Sstevel@tonic-gate 				/* is this scrubber enabled on this core? */
15230Sstevel@tonic-gate 	int		chsm_ecache_nlines;	/* no. of E$ lines */
15240Sstevel@tonic-gate 	int		chsm_ecache_busy;	/* keeps track if cpu busy */
15250Sstevel@tonic-gate 	int		chsm_icache_nlines;	/* no. of I$ lines */
15260Sstevel@tonic-gate 	int		chsm_core_state;	/* which core the scrubber is */
15270Sstevel@tonic-gate 						/* running on (Panther only) */
15280Sstevel@tonic-gate } ch_scrub_misc_t;
15290Sstevel@tonic-gate 
15300Sstevel@tonic-gate /*
15310Sstevel@tonic-gate  * Cheetah module private data structure.  One of these is allocated for
15320Sstevel@tonic-gate  * each valid cpu at setup time and is pointed to by the machcpu
15330Sstevel@tonic-gate  * "cpu_private" pointer.  For Cheetah, we have the miscellaneous scrubber
15340Sstevel@tonic-gate  * variables and cpu log out structures for Fast ECC traps at TL=0,
15350Sstevel@tonic-gate  * Disrupting (correctable) traps and Deferred (asynchronous) traps.  For
15360Sstevel@tonic-gate  * Disrupting traps only one log out structure is needed because we cannot
15370Sstevel@tonic-gate  * get a TL>0 disrupting trap since it obeys IE.  For Deferred traps we
15380Sstevel@tonic-gate  * cannot get a TL>0 because we turn off NCEEN during log out capture.  E$
15390Sstevel@tonic-gate  * set size (E$ size / nways) is saved here to avoid repeated calculations.
15400Sstevel@tonic-gate  * NB: The ch_err_tl1_data_t structures cannot cross a page boundary
15410Sstevel@tonic-gate  *      because we use physical addresses to access them.  We ensure this
15420Sstevel@tonic-gate  *      by allocating them near the front of cheetah_private_t, which is
15430Sstevel@tonic-gate  *      aligned on PAGESIZE (8192) via kmem_cache_create, and by ASSERTing
15440Sstevel@tonic-gate  *	sizeof (chpr_tl1_err_data) <= CH_ECACHE_MAX_LSIZE in the
15450Sstevel@tonic-gate  *	cpu_init_private routines.
15460Sstevel@tonic-gate  * NB:  chpr_icache_size and chpr_icache_linesize need to be at the front
15470Sstevel@tonic-gate  *	of cheetah_private_t because putting them after chpr_tl1_err_data
15480Sstevel@tonic-gate  *	would make their offsets > 4195.
15490Sstevel@tonic-gate  */
15500Sstevel@tonic-gate typedef struct cheetah_private {
15510Sstevel@tonic-gate 	int			chpr_icache_size;
15520Sstevel@tonic-gate 	int			chpr_icache_linesize;
15530Sstevel@tonic-gate 	ch_err_tl1_data_t	chpr_tl1_err_data[CH_ERR_TL1_TLMAX];
15540Sstevel@tonic-gate 	ch_scrub_misc_t		chpr_scrub_misc;
15550Sstevel@tonic-gate 	int			chpr_ec_set_size;
15560Sstevel@tonic-gate 	ch_cpu_logout_t		chpr_fecctl0_logout;
15570Sstevel@tonic-gate 	ch_cpu_logout_t		chpr_cecc_logout;
15580Sstevel@tonic-gate 	ch_cpu_logout_t		chpr_async_logout;
15590Sstevel@tonic-gate 	pn_tlb_logout_t		chpr_tlb_logout;
15600Sstevel@tonic-gate 	uint64_t		chpr_fpras_timestamp[FPRAS_NCOPYOPS];
15610Sstevel@tonic-gate 	hrtime_t		chpr_ceptnr_seltime;
15620Sstevel@tonic-gate 	int			chpr_ceptnr_id;
15630Sstevel@tonic-gate } cheetah_private_t;
15640Sstevel@tonic-gate 
15650Sstevel@tonic-gate #endif /* _ASM */
15660Sstevel@tonic-gate 
15670Sstevel@tonic-gate #endif /* _KERNEL */
15680Sstevel@tonic-gate 
15690Sstevel@tonic-gate #ifdef	__cplusplus
15700Sstevel@tonic-gate }
15710Sstevel@tonic-gate #endif
15720Sstevel@tonic-gate 
15730Sstevel@tonic-gate #endif	/* _SYS_CHEETAHREGS_H */
1574