xref: /onnv-gate/usr/src/uts/intel/sys/mca_x86.h (revision 5254:38162db71c7d)
11414Scindi /*
21414Scindi  * CDDL HEADER START
31414Scindi  *
41414Scindi  * The contents of this file are subject to the terms of the
5*5254Sgavinm  * Common Development and Distribution License (the "License").
6*5254Sgavinm  * You may not use this file except in compliance with the License.
71414Scindi  *
81414Scindi  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91414Scindi  * or http://www.opensolaris.org/os/licensing.
101414Scindi  * See the License for the specific language governing permissions
111414Scindi  * and limitations under the License.
121414Scindi  *
131414Scindi  * When distributing Covered Code, include this CDDL HEADER in each
141414Scindi  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151414Scindi  * If applicable, add the following below this CDDL HEADER, with the
161414Scindi  * fields enclosed by brackets "[]" replaced with your own identifying
171414Scindi  * information: Portions Copyright [yyyy] [name of copyright owner]
181414Scindi  *
191414Scindi  * CDDL HEADER END
201414Scindi  *
21*5254Sgavinm  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
221414Scindi  * Use is subject to license terms.
231414Scindi  */
241414Scindi 
251414Scindi #ifndef _SYS_MCA_X86_H
261414Scindi #define	_SYS_MCA_X86_H
271414Scindi 
281414Scindi #pragma ident	"%Z%%M%	%I%	%E% SMI"
291414Scindi 
301414Scindi /*
311414Scindi  * Constants for the Memory Check Architecture as implemented on generic x86
321414Scindi  * CPUs.
331414Scindi  */
341414Scindi 
35*5254Sgavinm #include <sys/types.h>
36*5254Sgavinm #include <sys/isa_defs.h>
37*5254Sgavinm 
381414Scindi #ifdef __cplusplus
391414Scindi extern "C" {
401414Scindi #endif
411414Scindi 
421414Scindi /*
43*5254Sgavinm  * Architectural MSRs from the IA-32 Software Developer's Manual - IA32_MSR_*
441414Scindi  */
451414Scindi #define	IA32_MSR_MCG_CAP		0x179
461414Scindi #define	IA32_MSR_MCG_STATUS		0x17a
471414Scindi #define	IA32_MSR_MCG_CTL		0x17b
481414Scindi 
491414Scindi #define	MCG_CAP_CTL_P			0x00000100ULL
501414Scindi #define	MCG_CAP_EXT_P			0x00000200ULL
51*5254Sgavinm #define	MCG_CAP_TES_P			0x00000800ULL
52*5254Sgavinm 
53*5254Sgavinm #define	MCG_CAP_COUNT_MASK		0x000000ffULL
54*5254Sgavinm #define	MCG_CAP_COUNT(cap) ((cap) & MCG_CAP_COUNT_MASK)
55*5254Sgavinm 
561414Scindi #define	MCG_CAP_EXT_CNT_MASK		0x00ff0000ULL
571414Scindi #define	MCG_CAP_EXT_CNT_SHIFT		16
58*5254Sgavinm #define	MCG_CAP_EXT_CNT(cap) \
59*5254Sgavinm 	(((cap) & MCG_CAP_EXT_CNT_MASK) >> MCG_CAP_EXT_CNT_SHIFT)
601414Scindi 
611414Scindi #define	MCG_STATUS_RIPV			0x01
621414Scindi #define	MCG_STATUS_EIPV			0x02
631414Scindi #define	MCG_STATUS_MCIP			0x04
641414Scindi 
65*5254Sgavinm /*
66*5254Sgavinm  * There are as many error detector "banks" as indicated by
67*5254Sgavinm  * IA32_MSR_MCG_CAP.COUNT.  Each bank has a minimum of 3 associated
68*5254Sgavinm  * registers (MCi_CTL, MCi_STATUS, and MCi_ADDR) and some banks
69*5254Sgavinm  * may implement a fourth (MCi_MISC) which should only be read
70*5254Sgavinm  * when MCi_STATUS.MISCV indicates that it exists and has valid data.
71*5254Sgavinm  *
72*5254Sgavinm  * The first bank features at MSR offsets 0x400 to 0x403, the next at
73*5254Sgavinm  * 0x404 to 0x407, and so on.  Current processors implement up to 6
74*5254Sgavinm  * banks (sixth one at 0x414 to 0x417).
75*5254Sgavinm  *
76*5254Sgavinm  * It is, sadly, not the case that the i'th set of 4 registers starting
77*5254Sgavinm  * at 0x400 corresponds to MCi_{CTL,STATUS,ADDR,MISC} - for some Intel
78*5254Sgavinm  * processors, for example, the order is 0/1/2/4/3.  Nonetheless, we can
79*5254Sgavinm  * still iterate through the banks and read all telemetry - there'll just
80*5254Sgavinm  * be some potential confusion as to which processor unit a bank is
81*5254Sgavinm  * associated with.  Error reports should seek to disambiguate.
82*5254Sgavinm  *
83*5254Sgavinm  * IA32_MSR_MC(i, which) calculates the MSR address for th i'th bank
84*5254Sgavinm  * of registers (not for MCi_*, as above) and one of CTL, STATUS, ADDR, MISC
85*5254Sgavinm  */
861414Scindi 
87*5254Sgavinm #define	_IA32_MSR_MC0_CTL		0x400ULL /* first/base reg */
88*5254Sgavinm #define	_IA32_MSR_OFFSET_CTL		0x0	/* offset within a bank */
89*5254Sgavinm #define	_IA32_MSR_OFFSET_STATUS		0x1	/* offset within a bank */
90*5254Sgavinm #define	_IA32_MSR_OFFSET_ADDR		0x2	/* offset within a bank */
91*5254Sgavinm #define	_IA32_MSR_OFFSET_MISC		0x3	/* offset within a bank */
92*5254Sgavinm 
93*5254Sgavinm 
94*5254Sgavinm #define	IA32_MSR_MC(i, which) \
95*5254Sgavinm 	(_IA32_MSR_MC0_CTL + (i) * 4 + _IA32_MSR_OFFSET_##which)
96*5254Sgavinm 
97*5254Sgavinm /*
98*5254Sgavinm  * IA32_MSR_MCG_CAP.MCG_EXT_P indicates that a processor implements
99*5254Sgavinm  * a set of extended machine-check registers starting at MSR 0x180;
100*5254Sgavinm  * when that is set, IA32_MSR_MCG_CAP.MCG_EXT_CNT indicates how
101*5254Sgavinm  * many of these extended registers (addresses 0x180, 0x181, ...)
102*5254Sgavinm  * are present.  Which registers are present depends on whether support
103*5254Sgavinm  * for 64-bit architecture is present.
104*5254Sgavinm  */
105*5254Sgavinm 
106*5254Sgavinm #define	_IA32_MCG_RAX			0x180ULL /* first/base extended reg */
107*5254Sgavinm 
108*5254Sgavinm #define	IA32_MSR_EXT(i)	(_IA32_MCG_RAX + (i))
1091414Scindi 
110*5254Sgavinm #ifdef _BIT_FIELDS_LTOH
111*5254Sgavinm typedef union mca_x86_mcistatus {
112*5254Sgavinm 	uint64_t _val64;
113*5254Sgavinm 	struct {
114*5254Sgavinm 		/*
115*5254Sgavinm 		 * Lower 32 bits of MCi_STATUS
116*5254Sgavinm 		 */
117*5254Sgavinm 		struct {
118*5254Sgavinm 			uint32_t _errcode:16;		/* <15:0> */
119*5254Sgavinm 			uint32_t _ms_errcode:16;	/* <31:16> */
120*5254Sgavinm 		} _mcis_lo;
121*5254Sgavinm 		/*
122*5254Sgavinm 		 * Upper 32 bits of MCi_STATUS
123*5254Sgavinm 		 */
124*5254Sgavinm 		union {
125*5254Sgavinm 			/*
126*5254Sgavinm 			 * If IA32_MCG_CAP.MCG_TES_P is set then <54:53>
127*5254Sgavinm 			 * and <56:55> are architectural.
128*5254Sgavinm 			 */
129*5254Sgavinm 			struct {
130*5254Sgavinm 				uint32_t _otherinfo:21;		/* <52:32> */
131*5254Sgavinm 				uint32_t _tbes:2;		/* <54:53> */
132*5254Sgavinm 				uint32_t _reserved:2;		/* <56:55> */
133*5254Sgavinm 				uint32_t _pcc:1;		/* <57> */
134*5254Sgavinm 				uint32_t _addrv:1;		/* <58> */
135*5254Sgavinm 				uint32_t _miscv:1;		/* <59> */
136*5254Sgavinm 				uint32_t _en:1;			/* <60> */
137*5254Sgavinm 				uint32_t _uc:1;			/* <61> */
138*5254Sgavinm 				uint32_t _over:1;		/* <62> */
139*5254Sgavinm 				uint32_t _val:1;		/* <63> */
140*5254Sgavinm 			} _mcis_hi_tes_p;
141*5254Sgavinm 			/*
142*5254Sgavinm 			 * If IA32_MCG_CAP.MCG_TES_P is clear then <56:53>
143*5254Sgavinm 			 * are model-specific.
144*5254Sgavinm 			 */
145*5254Sgavinm 			struct {
146*5254Sgavinm 				uint32_t _otherinfo:25;		/* <56:32> */
147*5254Sgavinm 				uint32_t _pcc:1;		/* <57> */
148*5254Sgavinm 				uint32_t _addrv:1;		/* <58> */
149*5254Sgavinm 				uint32_t _miscv:1;		/* <59> */
150*5254Sgavinm 				uint32_t _en:1;			/* <60> */
151*5254Sgavinm 				uint32_t _uc:1;			/* <61> */
152*5254Sgavinm 				uint32_t _over:1;		/* <62> */
153*5254Sgavinm 				uint32_t _val:1;		/* <63> */
154*5254Sgavinm 			} _mcis_hi_tes_np;
155*5254Sgavinm 		} _mcis_hi;
156*5254Sgavinm 	} _mcis_hilo;
157*5254Sgavinm } mca_x86_mcistatus_t;
1581414Scindi 
159*5254Sgavinm #define	mcistatus_errcode	_mcis_hilo._mcis_lo._errcode
160*5254Sgavinm #define	mcistatus_mserrcode	_mcis_hilo._mcis_lo._ms_errcode
161*5254Sgavinm #define	mcistatus_pcc	_mcis_hilo._mcis_hi._mcis_hi_tes_np._pcc
162*5254Sgavinm #define	mcistatus_addrv	_mcis_hilo._mcis_hi._mcis_hi_tes_np._addrv
163*5254Sgavinm #define	mcistatus_miscv	_mcis_hilo._mcis_hi._mcis_hi_tes_np._miscv
164*5254Sgavinm #define	mcistatus_en	_mcis_hilo._mcis_hi._mcis_hi_tes_np._en
165*5254Sgavinm #define	mcistatus_uc	_mcis_hilo._mcis_hi._mcis_hi_tes_np._uc
166*5254Sgavinm #define	mcistatus_over	_mcis_hilo._mcis_hi._mcis_hi_tes_np._over
167*5254Sgavinm #define	mcistatus_val	_mcis_hilo._mcis_hi._mcis_hi_tes_np._val
168*5254Sgavinm 
169*5254Sgavinm /*
170*5254Sgavinm  * The consumer must check for TES_P before using these.
171*5254Sgavinm  */
172*5254Sgavinm #define	mcistatus_tbes	_mcis_hilo._mcis_hi._mcis_hi_tes_p._tbes
173*5254Sgavinm #define	mcistatus_reserved \
174*5254Sgavinm 	_mcis_hilo._mcis_hi._mcis_hi_tes_p._reserved
175*5254Sgavinm #define	mcistatus_otherinfo_tes_p \
176*5254Sgavinm 	_mcis_hilo._mcis_hi._mcis_hi_tes_p._otherinfo
177*5254Sgavinm #define	mcistatus_otherinfo_tes_np \
178*5254Sgavinm 	_mcis_hilo._mcis_hi._mcis_hi_tes_np._otherinfo
179*5254Sgavinm 
180*5254Sgavinm #endif /* _BIT_FIELDS_LTOH */
1811414Scindi 
1821414Scindi #define	MSR_MC_STATUS_VAL		0x8000000000000000ULL
183*5254Sgavinm #define	MSR_MC_STATUS_OVER		0x4000000000000000ULL
1841414Scindi #define	MSR_MC_STATUS_UC		0x2000000000000000ULL
1851414Scindi #define	MSR_MC_STATUS_EN		0x1000000000000000ULL
1861414Scindi #define	MSR_MC_STATUS_MISCV		0x0800000000000000ULL
1871414Scindi #define	MSR_MC_STATUS_ADDRV		0x0400000000000000ULL
1881414Scindi #define	MSR_MC_STATUS_PCC		0x0200000000000000ULL
189*5254Sgavinm #define	MSR_MC_STATUS_RESERVED_MASK	0x0180000000000000ULL
190*5254Sgavinm #define	MSR_MC_STATUS_TBES_MASK		0x0060000000000000ULL
191*5254Sgavinm #define	MSR_MC_STATUS_TBES_SHIFT	53
1921414Scindi #define	MSR_MC_STATUS_MSERR_MASK	0x00000000ffff0000ULL
1931414Scindi #define	MSR_MC_STATUS_MSERR_SHIFT	16
1941414Scindi #define	MSR_MC_STATUS_MCAERR_MASK	0x000000000000ffffULL
1951414Scindi 
1961414Scindi /*
197*5254Sgavinm  * Macros to extract error code and model-specific error code.
198*5254Sgavinm  */
199*5254Sgavinm #define	MCAX86_ERRCODE(stat)		((stat) & MSR_MC_STATUS_MCAERR_MASK)
200*5254Sgavinm #define	MCAX86_MSERRCODE(stat) \
201*5254Sgavinm 	(((stat) & MSR_MC_STATUS_MSERR_MASK) >> MSR_MC_STATUS_MSERR_SHIFT)
202*5254Sgavinm 
203*5254Sgavinm /*
204*5254Sgavinm  * Macro to extract threshold based error state (if MCG_CAP.TES_P)
205*5254Sgavinm  */
206*5254Sgavinm #define	MCAX86_TBES_VALUE(stat) \
207*5254Sgavinm 	(((stat) & MSR_MC_STATUS_TBES_MASK) >> MSR_MC_STATUS_TBES_SHIFT)
208*5254Sgavinm 
209*5254Sgavinm /*
210*5254Sgavinm  * Bit definitions for the architectural error code.
2111414Scindi  */
212*5254Sgavinm 
213*5254Sgavinm #define	MCAX86_ERRCODE_TT_MASK		0x000c
214*5254Sgavinm #define	MCAX86_ERRCODE_TT_SHIFT		2
215*5254Sgavinm #define	MCAX86_ERRCODE_TT_INSTR		0x0
216*5254Sgavinm #define	MCAX86_ERRCODE_TT_DATA		0x1
217*5254Sgavinm #define	MCAX86_ERRCODE_TT_GEN		0x2
218*5254Sgavinm #define	MCAX86_ERRCODE_TT(code) \
219*5254Sgavinm 	(((code) & MCAX86_ERRCODE_TT_MASK) >> MCAX86_ERRCODE_TT_SHIFT)
220*5254Sgavinm 
221*5254Sgavinm #define	MCAX86_ERRCODE_LL_MASK		0x0003
222*5254Sgavinm #define	MCAX86_ERRCODE_LL_SHIFT		0
223*5254Sgavinm #define	MCAX86_ERRCODE_LL_L0		0x0
224*5254Sgavinm #define	MCAX86_ERRCODE_LL_L1		0x1
225*5254Sgavinm #define	MCAX86_ERRCODE_LL_L2		0x2
226*5254Sgavinm #define	MCAX86_ERRCODE_LL_LG		0x3
227*5254Sgavinm #define	MCAX86_ERRCODE_LL(code) \
228*5254Sgavinm 	((code) & MCAX86_ERRCODE_LL_MASK)
229*5254Sgavinm 
230*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_MASK	0x00f0
231*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_SHIFT	4
232*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_ERR		0x0
233*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_RD		0x1
234*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_WR		0x2
235*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_DRD		0x3
236*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_DWR		0x4
237*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_IRD		0x5
238*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_PREFETCH	0x6
239*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_EVICT	0x7
240*5254Sgavinm #define	MCAX86_ERRCODE_RRRR_SNOOP	0x8
241*5254Sgavinm #define	MCAX86_ERRCODE_RRRR(code) \
242*5254Sgavinm 	(((code) & MCAX86_ERRCODE_RRRR_MASK) >> MCAX86_ERRCODE_RRRR_SHIFT)
2431414Scindi 
244*5254Sgavinm #define	MCAX86_ERRCODE_PP_MASK		0x0600
245*5254Sgavinm #define	MCAX86_ERRCODE_PP_SHIFT		9
246*5254Sgavinm #define	MCAX86_ERRCODE_PP_SRC		0x0
247*5254Sgavinm #define	MCAX86_ERRCODE_PP_RES		0x1
248*5254Sgavinm #define	MCAX86_ERRCODE_PP_OBS		0x2
249*5254Sgavinm #define	MCAX86_ERRCODE_PP_GEN		0x3
250*5254Sgavinm #define	MCAX86_ERRCODE_PP(code) \
251*5254Sgavinm 	(((code) & MCAX86_ERRCODE_PP_MASK) >> MCAX86_ERRCODE_PP_SHIFT)
252*5254Sgavinm 
253*5254Sgavinm #define	MCAX86_ERRCODE_II_MASK		0x000c
254*5254Sgavinm #define	MCAX86_ERRCODE_II_SHIFT		2
255*5254Sgavinm #define	MCAX86_ERRCODE_II_MEM		0x0
256*5254Sgavinm #define	MCAX86_ERRCODE_II_IO		0x2
257*5254Sgavinm #define	MCAX86_ERRCODE_II_GEN		0x3
258*5254Sgavinm #define	MCAX86_ERRCODE_II(code) \
259*5254Sgavinm 	(((code) & MCAX86_ERRCODE_II_MASK) >> MCAX86_ERRCODE_II_SHIFT)
260*5254Sgavinm 
261*5254Sgavinm #define	MCAX86_ERRCODE_T_MASK		0x0100
262*5254Sgavinm #define	MCAX86_ERRCODE_T_SHIFT		8
263*5254Sgavinm #define	MCAX86_ERRCODE_T_NONE		0x0
264*5254Sgavinm #define	MCAX86_ERRCODE_T_TIMEOUT	0x1
265*5254Sgavinm #define	MCAX86_ERRCODE_T(code) \
266*5254Sgavinm 	(((code) & MCAX86_ERRCODE_T_MASK) >> MCAX86_ERRCODE_T_SHIFT)
267*5254Sgavinm 
268*5254Sgavinm /*
269*5254Sgavinm  * Simple error encoding.  MASKON are bits that must be set for a match
270*5254Sgavinm  * at the same time bits indicated by MASKOFF are clear.
271*5254Sgavinm  */
272*5254Sgavinm #define	MCAX86_SIMPLE_UNCLASSIFIED_MASKON		0x0001
273*5254Sgavinm #define	MCAX86_SIMPLE_UNCLASSIFIED_MASKOFF		0xfffe
274*5254Sgavinm 
275*5254Sgavinm #define	MCAX86_SIMPLE_MC_CODE_PARITY_MASKON		0x0002
276*5254Sgavinm #define	MCAX86_SIMPLE_MC_CODE_PARITY_MASKOFF		0xfffd
277*5254Sgavinm 
278*5254Sgavinm #define	MCAX86_SIMPLE_EXTERNAL_MASKON			0x0003
279*5254Sgavinm #define	MCAX86_SIMPLE_EXTERNAL_MASKOFF			0xfffc
280*5254Sgavinm 
281*5254Sgavinm #define	MCAX86_SIMPLE_FRC_MASKON			0x0004
282*5254Sgavinm #define	MCAX86_SIMPLE_FRC_MASKOFF			0xfffb
283*5254Sgavinm 
284*5254Sgavinm #define	MCAX86_SIMPLE_INTERNAL_TIMER_MASKON		0x0400
285*5254Sgavinm #define	MCAX86_SIMPLE_INTERNAL_TIMER_MASKOFF		0xfbff
2861414Scindi 
287*5254Sgavinm #define	MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON	0x0400
288*5254Sgavinm #define	MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKOFF	0xf800
289*5254Sgavinm #define	MCAX86_SIMPLE_INTERNAL_UNCLASS_VALUE_MASK	0x03ff
290*5254Sgavinm 
291*5254Sgavinm /*
292*5254Sgavinm  * Macros to make an internal unclassified error code, and to test if
293*5254Sgavinm  * a given code is internal unclassified.
294*5254Sgavinm  */
295*5254Sgavinm #define	MCAX86_MKERRCODE_INTERNAL_UNCLASS(val) \
296*5254Sgavinm 	(MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON | \
297*5254Sgavinm 	((val) & MCAX86_SIMPLE_INTERNAL_UNCLASS_VALUE_MASK))
298*5254Sgavinm #define	MCAX86_ERRCODE_ISSIMPLE_INTERNAL_UNCLASS(code) \
299*5254Sgavinm 	(((code) & MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON) == \
300*5254Sgavinm 	MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKON && \
301*5254Sgavinm 	((code) & MCAX86_SIMPLE_INTERNAL_UNCLASS_MASK_MASKOFF) == 0 && \
302*5254Sgavinm 	((code) & MCAX86_SIMPLE_INTERNAL_UNCLASS_VALUE_MASK) != 0)
303*5254Sgavinm 
304*5254Sgavinm /*
305*5254Sgavinm  * Is the given error code a simple error encoding?
306*5254Sgavinm  */
307*5254Sgavinm #define	MCAX86_ERRCODE_ISSIMPLE(code) \
308*5254Sgavinm 	((code) >= MCAX86_SIMPLE_UNCLASSIFIED_MASKON && \
309*5254Sgavinm 	(code) <= MCAX86_SIMPLE_FRC_MASKON || \
310*5254Sgavinm 	(code) == MCAX86_SIMPLE_INTERNAL_TIMER_MASKON || \
311*5254Sgavinm 	MCAX86_ERRCODE_ISSIMPLE_INTERNAL_UNCLASS(code))
312*5254Sgavinm 
313*5254Sgavinm /*
314*5254Sgavinm  * Compound error encoding.  We always ignore the 'F' bit (which indicates
315*5254Sgavinm  * "correction report filtering") in classifying the error type.
316*5254Sgavinm  */
317*5254Sgavinm #define	MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON		0x000c
318*5254Sgavinm #define	MCAX86_COMPOUND_GENERIC_MEMHIER_MASKOFF		0xeff0
319*5254Sgavinm 
320*5254Sgavinm #define	MCAX86_COMPOUND_TLB_MASKON			0x0010
321*5254Sgavinm #define	MCAX86_COMPOUND_TLB_MASKOFF			0xefe0
322*5254Sgavinm 
323*5254Sgavinm #define	MCAX86_COMPOUND_MEMHIER_MASKON			0x0100
324*5254Sgavinm #define	MCAX86_COMPOUND_MEMHIER_MASKOFF			0xee00
325*5254Sgavinm 
326*5254Sgavinm #define	MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON		0x0800
327*5254Sgavinm #define	MCAX86_COMPOUND_BUS_INTERCONNECT_MASKOFF	0xe000
3281414Scindi 
329*5254Sgavinm /*
330*5254Sgavinm  * Macros to make compound error codes and to test for each type.
331*5254Sgavinm  */
332*5254Sgavinm #define	MCAX86_MKERRCODE_GENERIC_MEMHIER(ll) \
333*5254Sgavinm 	(MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON | \
334*5254Sgavinm 	((ll) & MCAX86_ERRCODE_LL_MASK))
335*5254Sgavinm #define	MCAX86_ERRCODE_ISGENERIC_MEMHIER(code) \
336*5254Sgavinm 	(((code) & MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON) == \
337*5254Sgavinm 	MCAX86_COMPOUND_GENERIC_MEMHIER_MASKON && \
338*5254Sgavinm 	((code) & MCAX86_COMPOUND_GENERIC_MEMHIER_MASKOFF) == 0)
339*5254Sgavinm 
340*5254Sgavinm #define	MCAX86_MKERRCODE_TLB(tt, ll) \
341*5254Sgavinm 	(MCAX86_COMPOUND_TLB_MASKON | \
342*5254Sgavinm 	((tt) << MCAX86_ERRCODE_TT_SHIFT & MCAX86_ERRCODE_TT_MASK) | \
343*5254Sgavinm 	((ll) & MCAX86_ERRCODE_LL_MASK))
344*5254Sgavinm #define	MCAX86_ERRCODE_ISTLB(code) \
345*5254Sgavinm 	(((code) & MCAX86_COMPOUND_TLB_MASKON) == \
346*5254Sgavinm 	MCAX86_COMPOUND_TLB_MASKON && \
347*5254Sgavinm 	((code) & MCAX86_COMPOUND_TLB_MASKOFF) == 0)
3481414Scindi 
349*5254Sgavinm #define	MCAX86_MKERRCODE_MEMHIER(rrrr, tt, ll) \
350*5254Sgavinm 	(MCAX86_COMPOUND_MEMHIER_MASKON | \
351*5254Sgavinm 	((rrrr) << MCAX86_ERRCODE_RRRR_SHIFT & MCAX86_ERRCODE_RRRR_MASK) | \
352*5254Sgavinm 	((tt) << MCAX86_ERRCODE_TT_SHIFT & MCAX86_ERRCODE_TT_MASK) | \
353*5254Sgavinm 	((ll) & MCAX86_ERRCODE_LL_MASK))
354*5254Sgavinm #define	MCAX86_ERRCODE_ISMEMHIER(code) \
355*5254Sgavinm 	(((code) & MCAX86_COMPOUND_MEMHIER_MASKON) == \
356*5254Sgavinm 	MCAX86_COMPOUND_MEMHIER_MASKON && \
357*5254Sgavinm 	((code) & MCAX86_COMPOUND_MEMHIER_MASKOFF) == 0)
358*5254Sgavinm 
359*5254Sgavinm #define	MCAX86_MKERRCODE_BUS_INTERCONNECT(pp, t, rrrr, ii, ll) \
360*5254Sgavinm 	(MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON | \
361*5254Sgavinm 	((pp) << MCAX86_ERRCODE_PP_SHIFT & MCAX86_ERRCODE_PP_MASK) | \
362*5254Sgavinm 	((t) << MCAX86_ERRCODE_T_SHIFT & MCAX86_ERRCODE_T_MASK) | \
363*5254Sgavinm 	((rrrr) << MCAX86_ERRCODE_RRRR_SHIFT & MCAX86_ERRCODE_RRRR_MASK) | \
364*5254Sgavinm 	((ii) << MCAX86_ERRCODE_II_SHIFT & MCAX86_ERRCODE_II_MASK) | \
365*5254Sgavinm 	((ll) & MCAX86_ERRCODE_LL_MASK))
366*5254Sgavinm #define	MCAX86_ERRCODE_ISBUS_INTERCONNECT(code) \
367*5254Sgavinm 	(((code) & MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON) == \
368*5254Sgavinm 	MCAX86_COMPOUND_BUS_INTERCONNECT_MASKON && \
369*5254Sgavinm 	((code) & MCAX86_COMPOUND_BUS_INTERCONNECT_MASKOFF) == 0)
370*5254Sgavinm 
371*5254Sgavinm #define	MCAX86_ERRCODE_ISCOMPOUND(code) \
372*5254Sgavinm 	(MCAX86_ERRCODE_ISGENERIC_MEMHIER(code) || \
373*5254Sgavinm 	MCAX86_ERRCODE_ISTLB(code) || \
374*5254Sgavinm 	MCAX86_ERRCODE_ISMEMHIER(code) \
375*5254Sgavinm 	MCAX86_ERRCODE_ISBUS_INTERCONNECT(code))
376*5254Sgavinm 
377*5254Sgavinm #define	MCAX86_ERRCODE_UNKNOWN(code) \
378*5254Sgavinm 	(!MCAX86_ERRCODE_ISSIMPLE(code) && !MCAX86_ERRCODE_ISCOMPOUND(code))
3791414Scindi 
3801414Scindi #ifdef __cplusplus
3811414Scindi }
3821414Scindi #endif
3831414Scindi 
3841414Scindi #endif /* _SYS_MCA_X86_H */
385