xref: /titanic_50/usr/src/uts/intel/io/intel_nb5000/nb5000.h (revision b5a2d8455dfa3190fc977c4bec53e91c99012767)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _NB5000_H
28 #define	_NB5000_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/cpu_module.h>
35 
36 #define	NB_5000_MAX_MEM_CONTROLLERS	2
37 #define	NB_MAX_DIMMS_PER_CHANNEL	(nb_chipset == INTEL_NB_5100 ? 3 : \
38 	(nb_chipset == INTEL_NB_7300 ? 8 : 4))
39 #define	NB_MAX_CHANNELS_PER_BRANCH	2
40 #define	NB_5100_RANKS_PER_CHANNEL	6
41 #define	NB_MEM_BRANCH_SELECT \
42 	(nb_chipset == INTEL_NB_5400 || nb_chipset == INTEL_NB_5100 ? 2 : 3)
43 #define	NB_MAX_MEM_BRANCH_SELECT	3
44 #define	NB_MEM_RANK_SELECT		(nb_chipset == INTEL_NB_7300 ? 7 : 5)
45 #define	NB_MAX_MEM_RANK_SELECT		7
46 #define	NB_RANKS_IN_SELECT		4
47 #define	NB_PCI_DEV			10
48 
49 #define	NB_PCI_NFUNC	4
50 
51 #define	DOCMD_PEX_MASK	0x00
52 #define	DOCMD_5400_PEX_MASK	0x000
53 #define	DOCMD_PEX	0xf0
54 #define	DOCMD_5400_PEX	0xff0
55 
56 #define	SPD_BUSY	0x1000
57 #define	SPD_BUS_ERROR	0x2000
58 #define	SPD_READ_DATA_VALID	0x8000
59 #define	SPD_EEPROM_WRITE	0xa8000000
60 #define	SPD_ADDR(slave, addr) ((((slave) & 7) << 24) | (((addr) & 0xff) << 16))
61 
62 #define	MC_MIRROR	0x10000
63 #define	MC_PATROL_SCRUB	0x80
64 #define	MC_DEMAND_SCRUB	0x40
65 
66 #define	MCA_SCHDIMM	0x4000
67 
68 #define	TLOW_MAX	0x100000000ULL
69 
70 #define	MTR_PRESENT(mtr) \
71 	((mtr) & (nb_chipset == INTEL_NB_5400 || nb_chipset == INTEL_NB_5100 ? \
72 	0x0400 : 0x0100))
73 #define	MTR_ETHROTTLE(mtr) \
74 	((mtr) & (nb_chipset == INTEL_NB_5400 || nb_chipset == INTEL_NB_5100 ? \
75 	? 0x0200 : 0x0080))
76 #define	MTR_WIDTH(mtr) \
77 	((mtr) & (nb_chipset == INTEL_NB_5400 || nb_chipset == INTEL_NB_5100 ? \
78 	0x0100 : 0x0040) ? 8 : 4)
79 #define	MTR_NUMBANK(mtr) \
80 	((mtr) & (nb_chipset == INTEL_NB_5400 || nb_chipset == INTEL_NB_5100 ? \
81 	0x0040 : 0x0020) ? 8 : 4)
82 #define	MTR_NUMRANK(mtr) (nb_chipset == INTEL_NB_5100 ? 1 : \
83 	(((mtr) & (nb_chipset == INTEL_NB_5400 ? 0x0020 : 0x0010)) ? 2 : 1))
84 #define	MTR_NUMROW(mtr) ((((mtr) >> 2) & 3) + 13)
85 #define	MTR_NUMCOL(mtr) (((mtr) & 3) + 10)
86 
87 #define	MTR_DIMMSIZE(mtr) 	((1ULL << (MTR_NUMCOL(mtr) + MTR_NUMROW(mtr))) \
88 	* MTR_NUMRANK(mtr) * MTR_NUMBANK(mtr) * MTR_WIDTH(mtr))
89 #define	DIMMSIZE(nrow, ncol, nrank, nbank, width) \
90 	((1ULL << ((ncol) + (nrow))) * (nrank) * (nbank) * (width))
91 #define	MTR_DDR2_DIMMSIZE(mtr, nrank) \
92 	((1ULL << (MTR_NUMCOL(mtr) + MTR_NUMROW(mtr))) \
93 	* (nrank) * MTR_NUMBANK(mtr) * MTR_WIDTH(mtr))
94 
95 /* FERR_GLOBAL and NERR_GLOBAL */
96 #define	GE_FERR_FSB3_FATAL	0x800000000ULL	/* FSB3 Fatal Error */
97 #define	GE_FERR_FSB2_FATAL	0x400000000ULL	/* FSB2 Fatal Error */
98 #define	GE_FERR_FSB3_NF	0x200000000ULL	/* FSB3 Non-Fatal Error */
99 #define	GE_FERR_FSB2_NF	0x100000000ULL	/* FSB2 Non-Fatal Error */
100 
101 #define	GE_INT_FATAL	0x80000000	/* North Bridge Internal Error */
102 #define	GE_DMA_FATAL	0x40000000	/* DMA engine Fatal Error */
103 #define	GE_FSB1_FATAL	0x20000000	/* FSB1 Fatal Error */
104 #define	GE_FSB0_FATAL	0x10000000	/* FSB0 Fatal Error */
105 #define	GE_FERR_FBD_FATAL	0x08000000	/* FBD channel Fatal Error */
106 #define	GE_FERR_FBD3_FATAL	0x08000000	/* FBD3 channel Fatal Error */
107 #define	GE_FERR_FBD2_FATAL	0x04000000	/* FBD2 channel Fatal Error */
108 #define	GE_FERR_FBD1_FATAL	0x02000000	/* FBD1 channel Fatal Error */
109 #define	GE_FERR_FBD0_FATAL	0x01000000	/* FBD0 channel Fatal Error */
110 #define	GE_FERR_THERMAL_FATAL	0x04000000	/* Thermal Fatal Error */
111 #define	GE_PCIEX9_FATAL	0x02000000	/* PCI Express device 9 Fatal Error */
112 #define	GE_PCIEX8_FATAL	0x01000000	/* PCI Express device 8 Fatal Error */
113 #define	GE_PCIEX7_FATAL	0x00800000	/* PCI Express device 7 Fatal Error */
114 #define	GE_PCIEX6_FATAL	0x00400000	/* PCI Express device 6 Fatal Error */
115 #define	GE_PCIEX5_FATAL	0x00200000	/* PCI Express device 5 Fatal Error */
116 #define	GE_PCIEX4_FATAL	0x00100000	/* PCI Express device 4 Fatal Error */
117 #define	GE_PCIEX3_FATAL	0x00080000	/* PCI Express device 3 Fatal Error */
118 #define	GE_PCIEX2_FATAL	0x00040000	/* PCI Express device 2 Fatal Error */
119 #define	GE_PCIEX1_FATAL	0x00020000	/* PCI Express device 1 Fatal Error */
120 #define	GE_ESI_FATAL	0x00010000	/* ESI Fatal Error */
121 #define	GE_INT_NF	0x00008000	/* North Bridge Internal Error */
122 #define	GE_DMA_NF	0x00004000	/* DMA engine Non-Fatal Error */
123 #define	GE_FSB1_NF	0x00002000	/* FSB1 Non-Fatal Error */
124 #define	GE_FSB0_NF	0x00001000	/* FSB0 Non-Fatal Error */
125 #define	GE_FERR_FBD3_NF	0x00000800	/* FBD channel 3 Non-Fatal Error */
126 #define	GE_FERR_FBD2_NF	0x00000400	/* FBD channel 2 Non-Fatal Error */
127 #define	GE_FERR_FBD1_NF	0x00000200	/* FBD channel 1 Non-Fatal Error */
128 #define	GE_FERR_FBD0_NF	0x00000100	/* FBD channel 0 Non-Fatal Error */
129 #define	GE_FERR_FBD_NF	0x00000800	/* FBD channel Non-Fatal Error */
130 #define	GE_FERR_MEM1_NF	0x00000200	/* DDR channel 1 Non-Fatal Error */
131 #define	GE_FERR_MEM0_NF	0x00000100	/* DDR channel 0 Non-Fatal Error */
132 #define	GE_FERR_THERMAL_NF 0x00000400	/* Thermal Non-Fatal Error */
133 #define	GE_PCIEX9_NF	0x00000200	/* PCI Express dev 9 Non-Fatal Error */
134 #define	GE_PCIEX8_NF	0x00000100	/* PCI Express dev 8 Non-Fatal Error */
135 #define	GE_PCIEX7_NF	0x00000080	/* PCI Express dev 7 Non-Fatal Error */
136 #define	GE_PCIEX6_NF	0x00000040	/* PCI Express dev 6 Non-Fatal Error */
137 #define	GE_PCIEX5_NF	0x00000020	/* PCI Express dev 5 Non-Fatal Error */
138 #define	GE_PCIEX4_NF	0x00000010	/* PCI Express dev 4 Non-Fatal Error */
139 #define	GE_PCIEX3_NF	0x00000008	/* PCI Express dev 3 Non-Fatal Error */
140 #define	GE_PCIEX2_NF	0x00000004	/* PCI Express dev 2 Non-Fatal Error */
141 #define	GE_PCIEX1_NF	0x00000002	/* PCI Express dev 1 Non-Fatal Error */
142 #define	GE_ESI_NF	0x00000001	/* ESI Non-Fatal Error */
143 
144 #define	GE_NERR_FSB2_FATAL	0x08000000 /* FSB2 Fatal Error */
145 #define	GE_NERR_FSB3_FATAL	0x04000000 /* FSB3 Fatal Error */
146 #define	GE_NERR_FBD_FATAL	(nb_chipset == INTEL_NB_5100 ? 0 : 0x01000000)
147 					/* FBD channel Fatal Error */
148 #define	GE_NERR_FSB2_NF		0x00000800 /* FSB2 Non-Fatal Error */
149 #define	GE_NERR_FSB3_NF		0x00000400 /* FSB3 Non-Fatal Error */
150 #define	GE_NERR_FBD_NF		(nb_chipset == INTEL_NB_5100 ? 0 : 0x00000100)
151 					/* FBD channel Non-Fatal Error */
152 #define	GE_NERR_MEM_NF		(nb_chipset == INTEL_NB_5100 ? 0x00000100 : 0)
153 					/* DDR channel0,1 Non-Fatal Error */
154 #define	ERR_FAT_FSB_F9		0x20	/* F9Msk FSB Protocol */
155 #define	ERR_FAT_FSB_F2		0x08	/* F2Msk Unsupported Bus Transaction */
156 #define	ERR_FAT_FSB_F1		0x01 	/* F1Msk Request/Address Parity */
157 
158 #define	ERR_NF_FSB_F7		0x04	/* F7Msk Detected MCERR */
159 #define	ERR_NF_FSB_F8		0x02	/* F8Msk B-INIT */
160 #define	ERR_NF_FSB_F6		0x01	/* F6Msk Data Parity */
161 
162 #define	EMASK_FSB_F1		0x0001 	/* F1Msk Request/Address Parity */
163 #define	EMASK_FSB_F2		0x0002	/* F2Msk Unsupported Bus Transaction */
164 #define	EMASK_FSB_F6		0x0020	/* F6Msk Data Parity */
165 #define	EMASK_FSB_F7		0x0040	/* F7Msk Detected MCERR */
166 #define	EMASK_FSB_F8		0x0080	/* F8Msk B-INIT */
167 #define	EMASK_FSB_F9		0x0100	/* F9Msk FSB Protocol */
168 
169 #define	EMASK_FSB_FATAL		(EMASK_FSB_F1 | EMASK_FSB_F2 | EMASK_FSB_F9)
170 #define	EMASK_FSB_NF		(EMASK_FSB_F6 | EMASK_FSB_F7 | EMASK_FSB_F8)
171 
172 #define	ERR_FBD_CH_SHIFT	28 /* channel index in fat_fbd and nf_fbd */
173 
174 #define	ERR_FAT_FBD_M23	0x00400000	/* M23Err Non-Redundant Fast Reset */
175 					/* Timeout */
176 #define	ERR_FAT_FBD_M3	0x00000004	/* M3Err >Tmid thermal event with */
177 					/* intelligent throttling disabled */
178 #define	ERR_FAT_FBD_M2	0x00000002	/* M2Err memory or FBD configuration */
179 					/* CRC read error */
180 #define	ERR_FAT_FBD_M1	0x00000001	/* M1Err memory write error on */
181 					/* non-redundant retry or FBD */
182 					/* configuration write error on retry */
183 #define	ERR_FAT_FBD_MASK 0x007fffff
184 
185 #define	ERR_NF_FBD_M29	0x02000000	/* M29Err DIMM-Isolation Completed */
186 #define	ERR_NF_FBD_M28	0x01000000	/* M28Err DIMM-Spare Copy Completed */
187 #define	ERR_NF_FBD_M27	0x00800000	/* M27Err DIMM-Spare Copy Initiated */
188 #define	ERR_NF_FBD_M26	0x00400000	/* M26Err Redundant Fast Reset */
189 					/* Timeout */
190 #define	ERR_NF_FBD_M25	0x00200000	/* M25Err Memory write error on */
191 #define	ERR_NF_FBD_M24	0x00100000	/* M24Err refresh error */
192 					/* redundant retry */
193 #define	ERR_NF_FBD_M22	0x00040000	/* M22Err SPD protocol */
194 #define	ERR_NF_FBD_M21	0x00020000	/* M21Err FBD Northbound parity on */
195 					/* FBD sync status */
196 #define	ERR_NF_FBD_M20	0x00010000	/* M20Err Correctable patrol data ECC */
197 #define	ERR_NF_FBD_M19	0x00008000	/* M19Err Correctasble resilver or */
198 					/* spare-copy data ECC */
199 #define	ERR_NF_FBD_M18	0x00004000	/* M18Err Correctable Mirrored demand */
200 					/* data ECC */
201 #define	ERR_NF_FBD_M17	0x00002000	/* M17Err Correctable Non-mirrored */
202 					/* demand data ECC */
203 #define	ERR_NF_FBD_M16	0x00001000	/* M16Err channel failed over */
204 #define	ERR_NF_FBD_M15	0x00000800	/* M15Err Memory or FBD configuration */
205 					/* CRC read error */
206 #define	ERR_NF_FBD_M14	0x00000400	/* M14Err FBD configuration write */
207 					/* error on first attempt */
208 #define	ERR_NF_FBD_M13	0x00000200	/* M13Err Memory write error on first */
209 					/* attempt */
210 #define	ERR_NF_FBD_M12	0x00000100	/* M12Err Non-Aliased uncorrectable */
211 					/* patrol data ECC */
212 #define	ERR_NF_FBD_M11	0x00000080	/* M11Err Non-Aliased uncorrectable */
213 					/* resilver or spare copy data ECC */
214 #define	ERR_NF_FBD_M10	0x00000040	/* M10Err Non-Aliased uncorrectable */
215 					/* mirrored demand data ECC */
216 #define	ERR_NF_FBD_M9	0x00000020	/* M9Err Non-Aliased uncorrectable */
217 					/* non-mirrored demand data ECC */
218 #define	ERR_NF_FBD_M8	0x00000010	/* M8Err Aliased uncorrectable */
219 					/* patrol data ECC */
220 #define	ERR_NF_FBD_M7	0x00000008	/* M7Err Aliased uncorrectable */
221 					/* resilver or spare copy data ECC */
222 #define	ERR_NF_FBD_M6	0x00000004	/* M6Err Aliased uncorrectable */
223 					/* mirrored demand data ECC */
224 #define	ERR_NF_FBD_M5	0x00000002	/* M5Err Aliased uncorrectable */
225 					/* non-mirrored demand data ECC */
226 #define	ERR_NF_FBD_M4	0x00000001	/* M4Err uncorrectable data ECC on */
227 					/* replay */
228 
229 #define	ERR_DEFAULT_NF_FBD_MASK	0x01ffffff
230 #define	ERR_5000_NF_FBD_MASK	(ERR_NF_FBD_M28|ERR_NF_FBD_M27|ERR_NF_FBD_M22| \
231     ERR_NF_FBD_M21|ERR_NF_FBD_M20|ERR_NF_FBD_M19|ERR_NF_FBD_M18| \
232     ERR_NF_FBD_M17|ERR_NF_FBD_M15|ERR_NF_FBD_M14|ERR_NF_FBD_M13| \
233     ERR_NF_FBD_M12|ERR_NF_FBD_M11|ERR_NF_FBD_M10|ERR_NF_FBD_M9|ERR_NF_FBD_M8| \
234     ERR_NF_FBD_M7|ERR_NF_FBD_M6|ERR_NF_FBD_M5|ERR_NF_FBD_M4)
235 #define	ERR_5400_NF_FBD_MASK	(ERR_NF_FBD_M29|ERR_NF_FBD_M28|ERR_NF_FBD_M27| \
236     ERR_NF_FBD_M26|ERR_NF_FBD_M25|ERR_NF_FBD_M24|ERR_NF_FBD_M22| \
237     ERR_NF_FBD_M21|ERR_NF_FBD_M20|ERR_NF_FBD_M19|ERR_NF_FBD_M18| \
238     ERR_NF_FBD_M17|ERR_NF_FBD_M16|ERR_NF_FBD_M15|ERR_NF_FBD_M14| \
239     ERR_NF_FBD_M13|ERR_NF_FBD_M12|ERR_NF_FBD_M11|ERR_NF_FBD_M10| \
240     ERR_NF_FBD_M9|ERR_NF_FBD_M8|ERR_NF_FBD_M7|ERR_NF_FBD_M6|ERR_NF_FBD_M5| \
241     ERR_NF_FBD_M4)
242 #define	ERR_7300_NF_FBD_MASK	(ERR_NF_FBD_M28|ERR_NF_FBD_M27|ERR_NF_FBD_M26| \
243     ERR_NF_FBD_M25|ERR_NF_FBD_M22|ERR_NF_FBD_M21|ERR_NF_FBD_M20| \
244     ERR_NF_FBD_M19|ERR_NF_FBD_M18|ERR_NF_FBD_M17|ERR_NF_FBD_M15| \
245     ERR_NF_FBD_M14|ERR_NF_FBD_M13|ERR_NF_FBD_M12|ERR_NF_FBD_M11| \
246     ERR_NF_FBD_M10|ERR_NF_FBD_M9|ERR_NF_FBD_M8|ERR_NF_FBD_M7|ERR_NF_FBD_M6| \
247     ERR_NF_FBD_M5|ERR_NF_FBD_M4)
248 
249 /* Bitmask of the FB-DIMM non-fatal errors */
250 #define	ERR_NF_FBD_MASK ( \
251 	(nb_chipset == INTEL_NB_5000P || nb_chipset == INTEL_NB_5000V || \
252 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000Z) ? \
253 	ERR_5000_NF_FBD_MASK : \
254 	nb_chipset == INTEL_NB_5400 ? ERR_5400_NF_FBD_MASK : \
255 	nb_chipset == INTEL_NB_7300 ? ERR_7300_NF_FBD_MASK : \
256 	ERR_DEFAULT_NF_FBD_MASK)
257 
258 #define	ERR_NF_FBD_ECC_UE	(ERR_NF_FBD_M12|ERR_NF_FBD_M11|ERR_NF_FBD_M10| \
259     ERR_NF_FBD_M9|ERR_NF_FBD_M8|ERR_NF_FBD_M7|ERR_NF_FBD_M6|ERR_NF_FBD_M5| \
260     ERR_NF_FBD_M4)
261 #define	ERR_NF_FBD_MA	(ERR_NF_FBD_M14)
262 #define	ERR_NF_FBD_ECC_CE	(ERR_NF_FBD_M20|ERR_NF_FBD_M19|ERR_NF_FBD_M18| \
263     ERR_NF_FBD_M17|ERR_NF_FBD_M15|ERR_NF_FBD_M21)
264 #define	ERR_NF_FBD_SPARE (ERR_NF_FBD_M28|ERR_NF_FBD_M27)
265 
266 #define	EMASK_FBD_M29	0x10000000	/* M29Err DIMM-Isolation Completed */
267 #define	EMASK_FBD_M28	0x08000000	/* M28Err DIMM-Spare Copy Completed */
268 #define	EMASK_FBD_M27	0x04000000	/* M27Err DIMM-Spare Copy Initiated */
269 #define	EMASK_FBD_M26	0x02000000	/* M26Err Redundant Fast Reset */
270 					/* Timeout */
271 #define	EMASK_FBD_M25	0x01000000	/* M25Err Memory write error on */
272 					/* redundant retry */
273 #define	EMASK_FBD_M24	0x00800000	/* M24Err refresh error */
274 #define	EMASK_FBD_M23	0x00400000	/* M23Err Non-Redundant Fast Reset */
275 					/* Timeout */
276 #define	EMASK_FBD_M22	0x00200000	/* M22Err SPD protocol */
277 #define	EMASK_FBD_M21	0x00100000	/* M21Err FBD Northbound parity on */
278 					/* FBD sync status */
279 #define	EMASK_FBD_M20	0x00080000	/* M20Err Correctable patrol data ECC */
280 #define	EMASK_FBD_M19	0x00040000	/* M19Err Correctasble resilver or */
281 					/* spare-copy data ECC */
282 #define	EMASK_FBD_M18	0x00020000	/* M18Err Correctable Mirrored demand */
283 					/* data ECC */
284 #define	EMASK_FBD_M17	0x00010000	/* M17Err Correctable Non-mirrored */
285 					/* demand data ECC */
286 #define	EMASK_FBD_M16	0x00008000	/* M16Err channel failed over */
287 #define	EMASK_FBD_M15	0x00004000	/* M15Err Memory or FBD configuration */
288 					/* CRC read error */
289 #define	EMASK_FBD_M14	0x00002000	/* M14Err FBD configuration write */
290 					/* error on first attempt */
291 #define	EMASK_FBD_M13	0x00001000	/* M13Err Memory write error on first */
292 					/* attempt */
293 #define	EMASK_FBD_M12	0x00000800	/* M12Err Non-Aliased uncorrectable */
294 					/* patrol data ECC */
295 #define	EMASK_FBD_M11	0x00000400	/* M11Err Non-Aliased uncorrectable */
296 					/* resilver or spare copy data ECC */
297 #define	EMASK_FBD_M10	0x00000200	/* M10Err Non-Aliased uncorrectable */
298 					/* mirrored demand data ECC */
299 #define	EMASK_FBD_M9	0x00000100	/* M9Err Non-Aliased uncorrectable */
300 					/* non-mirrored demand data ECC */
301 #define	EMASK_FBD_M8	0x00000080	/* M8Err Aliased uncorrectable */
302 					/* patrol data ECC */
303 #define	EMASK_FBD_M7	0x00000040	/* M7Err Aliased uncorrectable */
304 					/* resilver or spare copy data ECC */
305 #define	EMASK_FBD_M6	0x00000020	/* M6Err Aliased uncorrectable */
306 					/* mirrored demand data ECC */
307 #define	EMASK_FBD_M5	0x00000010	/* M5Err Aliased uncorrectable */
308 					/* non-mirrored demand data ECC */
309 #define	EMASK_FBD_M4	0x00000008	/* M4Err uncorrectable data ECC on */
310 					/* replay */
311 #define	EMASK_FBD_M3	0x00000004	/* M3Err >Tmid thermal event with */
312 					/* intelligent throttling disabled */
313 #define	EMASK_FBD_M2	0x00000002	/* M2Err memory or FBD configuration */
314 					/* CRC read error */
315 #define	EMASK_FBD_M1	0x00000001	/* M1Err memory write error on */
316 					/* non-redundant retry or FBD */
317 					/* configuration write error on retry */
318 /* MCH 7300 errata 34 (reserved mask bits) */
319 #define	EMASK_5000_FBD_RES	(EMASK_FBD_M24|EMASK_FBD_M16)
320 #define	EMASK_FBD_RES	(nb_chipset == INTEL_NB_5400 ? 0 : EMASK_5000_FBD_RES)
321 
322 #define	EMASK_FBD_FATAL	(EMASK_FBD_M23|EMASK_FBD_M3|EMASK_FBD_M2|EMASK_FBD_M1)
323 #define	EMASK_FBD_NF (EMASK_FBD_M28|EMASK_FBD_M27|EMASK_FBD_M26|EMASK_FBD_M25| \
324 	EMASK_FBD_M22|EMASK_FBD_M21|EMASK_FBD_M20|EMASK_FBD_M19|EMASK_FBD_M18| \
325 	EMASK_FBD_M17|EMASK_FBD_M15|EMASK_FBD_M14|EMASK_FBD_M13|EMASK_FBD_M12| \
326 	EMASK_FBD_M11|EMASK_FBD_M10|EMASK_FBD_M9|EMASK_FBD_M8|EMASK_FBD_M7| \
327 	EMASK_FBD_M6|EMASK_FBD_M5|EMASK_FBD_M4)
328 #define	EMASK_5400_FBD_FATAL	(EMASK_FBD_M23|EMASK_FBD_M2|EMASK_FBD_M1)
329 #define	EMASK_5400_FBD_NF (EMASK_FBD_M29|EMASK_FBD_M28|EMASK_FBD_M27| \
330 	EMASK_FBD_M26|EMASK_FBD_M25|EMASK_FBD_M24|EMASK_FBD_M22|EMASK_FBD_M21| \
331 	EMASK_FBD_M20|EMASK_FBD_M19|EMASK_FBD_M18|EMASK_FBD_M17|EMASK_FBD_M16| \
332 	EMASK_FBD_M15|EMASK_FBD_M14|EMASK_FBD_M13|EMASK_FBD_M12| \
333 	EMASK_FBD_M11|EMASK_FBD_M10|EMASK_FBD_M9|EMASK_FBD_M8|EMASK_FBD_M7| \
334 	EMASK_FBD_M6|EMASK_FBD_M5|EMASK_FBD_M4)
335 
336 /* FERR_NF_MEM: MC First non-fatal errors */
337 #define	ERR_MEM_CH_SHIFT	28	/* channel index in nf_mem */
338 
339 #define	ERR_NF_MEM_M21	0x00200000	/* M21Err Spare Copy Completed */
340 #define	ERR_NF_MEM_M20	0x00100000	/* M20Err Spare Copy Initiated */
341 #define	ERR_NF_MEM_M18	0x00040000	/* M18Err SPD protocal */
342 #define	ERR_NF_MEM_M16	0x00010000	/* M16Err Correctable Patrol Data ECC */
343 #define	ERR_NF_MEM_M15	0x00008000	/* M15Err Correctable Spare-copy ECC */
344 #define	ERR_NF_MEM_M14	0x00004000	/* M14Err Correctable demand data ECC */
345 #define	ERR_NF_MEM_M12	0x00001000	/* M12Err non-aliased ue Patrol ECC */
346 #define	ERR_NF_MEM_M11	0x00000800	/* M11Err non-aliased ue  Spare-copy */
347 #define	ERR_NF_MEM_M10	0x00000400	/* M10Err non-aliased ue demand data */
348 #define	ERR_NF_MEM_M6	0x00000040	/* M6Err aliased ue Patrol Data ECC */
349 #define	ERR_NF_MEM_M5	0x00000020	/* M5Err aliased ue Spare-copy ECC */
350 #define	ERR_NF_MEM_M4	0x00000010	/* M4Err aliased ue demand data ECC */
351 #define	ERR_NF_MEM_M1	0x00000002	/* M1Err ue data ECC on replay */
352 
353 #define	ERR_NF_MEM_MASK 0x0003fffff
354 #define	ERR_NF_MEM_ECC_UE	(ERR_NF_MEM_M12|ERR_NF_MEM_M11|ERR_NF_MEM_M10| \
355     ERR_NF_MEM_M6|ERR_NF_MEM_M5|ERR_NF_MEM_M4|ERR_NF_MEM_M1)
356 #define	ERR_NF_MEM_ECC_CE	(ERR_NF_MEM_M16|ERR_NF_MEM_M15|ERR_NF_MEM_M14)
357 #define	ERR_NF_MEM_SPARE	(ERR_NF_MEM_M21|ERR_NF_MEM_M20)
358 
359 #define	EMASK_MEM_M21	ERR_NF_MEM_M21
360 #define	EMASK_MEM_M20	ERR_NF_MEM_M20
361 #define	EMASK_MEM_M18	ERR_NF_MEM_M18
362 #define	EMASK_MEM_M16	ERR_NF_MEM_M16
363 #define	EMASK_MEM_M15	ERR_NF_MEM_M15
364 #define	EMASK_MEM_M14	ERR_NF_MEM_M14
365 #define	EMASK_MEM_M12	ERR_NF_MEM_M12
366 #define	EMASK_MEM_M11	ERR_NF_MEM_M11
367 #define	EMASK_MEM_M10	ERR_NF_MEM_M10
368 #define	EMASK_MEM_M6	ERR_NF_MEM_M6
369 #define	EMASK_MEM_M5	ERR_NF_MEM_M5
370 #define	EMASK_MEM_M4	ERR_NF_MEM_M4
371 #define	EMASK_MEM_M1	ERR_NF_MEM_M1
372 
373 #define	EMASK_MEM_NF (EMASK_FBD_M21|EMASK_FBD_M20|EMASK_FBD_M18|EMASK_FBD_M16| \
374 	EMASK_FBD_M15|EMASK_FBD_M14|EMASK_FBD_M12|EMASK_FBD_M11|EMASK_FBD_M10| \
375 	EMASK_MEM_M6|EMASK_MEM_M5|EMASK_MEM_M4|EMASK_MEM_M1)
376 
377 #define	ERR_INT_ALL	(nb_chipset == INTEL_NB_5400 ? 0xffffffff : 0xff)
378 
379 #define	ERR_FAT_INT_B14	0x0400	/* B14Msk SF Scrub DBE */
380 #define	ERR_FAT_INT_B12	0x0100	/* B12Msk Parity Protected register */
381 #define	ERR_FAT_INT_B25	0x0080	/* B25Msk illegal HISMM/TSEG access */
382 #define	ERR_FAT_INT_B23	0x0040	/* B23Msk Vt Unaffiliated port error */
383 #define	ERR_FAT_INT_B21	0x0020	/* B21Msk illegal way */
384 #define	ERR_FAT_INT_B7	0x0010	/* B7Msk Multiple ECC error in any of */
385 					/* the ways during SF lookup */
386 #define	ERR_FAT_INT_B4	0x08	/* B4Msk Virtual pin port error */
387 #define	ERR_FAT_INT_B3	0x04	/* B3Msk Coherency violation error for EWB */
388 #define	ERR_FAT_INT_B2	0x02	/* B2Msk Multi-tag hit SF */
389 #define	ERR_FAT_INT_B1	0x01	/* B1Msk DM parity error */
390 
391 #define	ERR_NF_INT_B27	0x4000	/* B27Msk Request received when in S1 */
392 #define	ERR_NF_INT_B24	0x2000	/* B24Msk DFXERR */
393 #define	ERR_NF_INT_B19	0x1000	/* B19Msk scrub SBE (SF) */
394 #define	ERR_NF_INT_B18	0x0800	/* B18Msk perfmon task completion */
395 #define	ERR_NF_INT_B17	0x0400	/* B17Msk JTAG/TAP error status */
396 #define	ERR_NF_INT_B16	0x0200	/* B16Msk SMBus error status */
397 #define	ERR_NF_INT_B22	0x0080	/* B22Msk Victim ROM parity */
398 #define	ERR_NF_INT_B20	0x0040	/* B20Msk Configuration write abort */
399 #define	ERR_NF_INT_B11	0x0020	/* B11Msk Victim Ram parity error */
400 #define	ERR_NF_INT_B10	0x0010	/* B10Msk DM Parity */
401 #define	ERR_NF_INT_B9	0x0008	/* B9Msk illeagl access */
402 #define	ERR_NF_INT_B8	0x0004	/* B8Msk SF Coherency Error for BIL */
403 #define	ERR_NF_INT_B6	0x0002	/* B6Msk Single ECC error on SF lookup */
404 #define	ERR_NF_INT_B5	0x0001	/* B5Msk Address Map error */
405 
406 #define	NERR_NF_5400_INT_B26	0x0004	/* B26Msk Illeagl Access to */
407 				/* non-coherent address space */
408 
409 #define	EMASK_INT_RES	0x02000000	/* Do not change */
410 #define	EMASK_INT_B25	0x01000000	/* B25Msk illegal HISMM/TSEG access */
411 #define	EMASK_INT_B23	0x00400000	/* B23Msk Vt Unaffiliated port error */
412 #define	EMASK_INT_B22	0x00200000	/* B22Msk Victim ROM parity */
413 #define	EMASK_INT_B21	0x00100000	/* B21Msk illegal way */
414 #define	EMASK_INT_B20	0x00080000	/* B20Msk Configuration write abort  */
415 #define	EMASK_INT_B19	0x00040000	/* B19Msk Scrub SBE */
416 #define	EMASK_INT_B14	0x00002000	/* B14Msk Scrub DBE */
417 #define	EMASK_INT_B12	0x00000800	/* B12Msk Parity Protected */
418 #define	EMASK_INT_B11	0x00000400	/* B11Msk Victim Ram parity error */
419 #define	EMASK_INT_B10	0x00000200	/* B10Msk DM Parity */
420 #define	EMASK_INT_B9	0x00000100	/* B9Msk Illegal Accesss */
421 
422 #define	EMASK_INT_B8	0x80	/* B8Msk SF Coherency Error for BIL */
423 #define	EMASK_INT_B7	0x40	/* B7Msk Multiple ECC error in any of */
424 				/* the ways during SF lookup */
425 #define	EMASK_INT_B6	0x20	/* B6Msk Single ECC error on SF lookup */
426 #define	EMASK_INT_B5	0x10	/* B5Msk Address Map error */
427 #define	EMASK_INT_B4	0x08	/* B4Msk Virtual pin port error */
428 #define	EMASK_INT_B3	0x04	/* B3Msk Coherency violation error for EWB */
429 #define	EMASK_INT_B2	0x02	/* B2Msk Multi-tag hit SF */
430 #define	EMASK_INT_B1	0x01	/* B1Msk DM parity error */
431 
432 /* MCH 5000 errata 2 */
433 #define	EMASK_INT_5000	EMASK_INT_B1
434 /* MCH 7300 errata 17 & 20 */
435 #define	EMASK_INT_7300	(EMASK_INT_B3|EMASK_INT_B1)
436 /* MCH 7300 errata 17,20 & 21 */
437 #define	EMASK_INT_7300_STEP_0	(EMASK_INT_B7|EMASK_INT_B3|EMASK_INT_B1)
438 #define	EMASK_INT_5400 0
439 
440 #define	EMASK_INT_FATAL (EMASK_INT_B7|EMASK_INT_B4|EMASK_INT_B3|EMASK_INT_B2| \
441 	EMASK_INT_B1)
442 #define	EMASK_INT_NF	(EMASK_INT_B8|EMASK_INT_B6|EMASK_INT_B5)
443 #define	GE_FBD_FATAL ((nb_chipset == INTEL_NB_5400) ? GE_FERR_FBD_FATAL : \
444 	(nb_chipset == INTEL_NB_5100) ? 0 : \
445 	(GE_FERR_FBD0_FATAL|GE_FERR_FBD1_FATAL|GE_FERR_FBD2_FATAL| \
446 	GE_FERR_FBD3_FATAL))
447 #define	GE_FBD_NF ((nb_chipset == INTEL_NB_5400) ? GE_FERR_FBD_NF : \
448 	(nb_chipset == INTEL_NB_5100) ? 0 : \
449 	(GE_FERR_FBD0_NF|GE_FERR_FBD1_NF|GE_FERR_FBD2_NF|GE_FERR_FBD3_NF))
450 #define	GE_MEM_NF	((nb_chipset == INTEL_NB_5100) ? \
451 	(GE_FERR_MEM0_NF|GE_FERR_MEM1_NF) : 0)
452 
453 #define	EMASK_UNCOR_PEX_IO18	0x00200000	/* ESI Reset timeout */
454 #define	EMASK_UNCOR_PEX_IO2	0x00100000	/* Received an unsupported */
455 						/* request */
456 #define	EMASK_UNCOR_PEX_IO9	0x00040000	/* Malformed TLP Status */
457 #define	EMASK_UNCOR_PEX_IO10	0x00020000	/* Received buffer overflow */
458 #define	EMASK_UNCOR_PEX_IO8	0x00010000	/* unexpected completion */
459 #define	EMASK_UNCOR_PEX_IO7	0x00008000	/* completion abort */
460 #define	EMASK_UNCOR_PEX_IO6	0x00004000	/* completion timeout */
461 #define	EMASK_UNCOR_PEX_IO5	0x00002000	/* flow control protocol */
462 #define	EMASK_UNCOR_PEX_IO4	0x00001000	/* poisoned TLP */
463 #define	EMASK_UNCOR_PEX_IO19	0x00000020	/* surprise link down */
464 #define	EMASK_UNCOR_PEX_IO0	0x00000010	/* data link protocol */
465 #define	EMASK_UNCOR_PEX_IO3	0x00000001	/* training error */
466 
467 #define	EMASK_COR_PEX_IO20	0x00002000	/* Advisory Non Fatal */
468 #define	EMASK_COR_PEX_IO16	0x00001000	/* replay timer timeout */
469 #define	EMASK_COR_PEX_IO15	0x00000100	/* replay num pollover */
470 #define	EMASK_COR_PEX_IO14	0x00000080	/* bad DLLP */
471 #define	EMASK_COR_PEX_IO13	0x00000040	/* bad TLP */
472 #define	EMASK_COR_PEX_IO12	0x00000001	/* receiver error mask */
473 
474 #define	EMASK_RP_PEX_IO1	0x00000004	/* fatal message detect */
475 #define	EMASK_RP_PEX_IO11	0x00000002	/* uncorrectable message */
476 #define	EMASK_RP_PEX_IO17	0x00000001	/* correctable message */
477 
478 #define	EMASK_UNIT_PEX_IO33	0x00002000	/* Link autonomous BW change */
479 #define	EMASK_UNIT_PEX_IO32	0x00001000	/* Received CA Posted Req */
480 #define	EMASK_UNIT_PEX_IO31	0x00000800	/* Received UR Posted Req */
481 #define	EMASK_UNIT_PEX_IO30	0x00000400	/* VT-d internal HW */
482 #define	EMASK_UNIT_PEX_IO29	0x00000200	/* MSI address */
483 #define	EMASK_UNIT_PEX_IO28	0x00000100	/* Link BW change */
484 #define	EMASK_UNIT_PEX_IO27	0x00000080	/* stop & scream */
485 #define	EMASK_UNIT_PEX_IO26	0x00000040	/* Received CA response */
486 #define	EMASK_UNIT_PEX_IO25	0x00000020	/* Received UR response */
487 #define	EMASK_UNIT_PEX_IO24	0x00000010	/* Outbound poisoned data */
488 #define	EMASK_UNIT_PEX_IO23	0x00000008	/* VTd fault */
489 #define	EMASK_UNIT_PEX_IO22	0x00000004	/* internal header/ctl parity */
490 #define	EMASK_UNIT_PEX_IO18	0x00000002	/* ESI reset timeout */
491 #define	EMASK_UNIT_PEX_VPP	0x00000001	/* correctable message detect */
492 
493 #define	PEX_5400_FAT_IO32	0x00800000	/* Received CA Posted Request */
494 #define	PEX_5400_FAT_IO31	0x00400000	/* Received UR Posted Request */
495 #define	PEX_5400_FAT_IO30	0x00200000	/* VT-d Internal HW */
496 #define	PEX_5400_FAT_IO29	0x00100000	/* MSI Address */
497 #define	PEX_5400_FAT_IO27	0x00040000	/* Stop & Scream */
498 #define	PEX_5400_FAT_IO26	0x00020000	/* Received CA Response */
499 #define	PEX_5400_FAT_IO25	0x00010000	/* Received UR Response */
500 #define	PEX_5400_FAT_IO24	0x00008000	/* Outbound poisoned TLP */
501 #define	PEX_5400_FAT_IO23	0x00004000	/* VT-d Fault */
502 #define	PEX_5400_FAT_IO22	0x00002000	/* Internal Header/Control */
503 						/* Parity */
504 #define	PEX_5400_FAT_IO18	0x00001000	/* ESI reset timeout */
505 #define	PEX_5400_FAT_IO1	0x00000400	/* received fatal error msg */
506 #define	PEX_5400_FAT_IO2	0x00000200	/* received unsupported req  */
507 #define	PEX_5400_FAT_IO9	0x00000100	/* malformed TLP */
508 #define	PEX_5400_FAT_IO10	0x00000080	/* receiver buffer overflow */
509 #define	PEX_5400_FAT_IO8	0x00000040	/* unexpected completion */
510 #define	PEX_5400_FAT_IO7	0x00000020	/* completer abort */
511 #define	PEX_5400_FAT_IO6	0x00000010	/* completion timeout */
512 #define	PEX_5400_FAT_IO5	0x00000008	/* flow control protocol */
513 #define	PEX_5400_FAT_IO4	0x00000004	/* poisoned TLP */
514 #define	PEX_5400_FAT_IO19	0x00000002	/* surprise link down */
515 #define	PEX_5400_FAT_IO0	0x00000001	/* data link layer protocol */
516 #define	PEX_FAT_IO19	0x00001000	/* surprise link down */
517 #define	PEX_FAT_IO18	0x00000800	/* ESI reset timeout */
518 #define	PEX_FAT_IO9	0x00000400	/* malformed TLP */
519 #define	PEX_FAT_IO10	0x00000200	/* receiver buffer overflow */
520 #define	PEX_FAT_IO8	0x00000100	/* unexpected completion */
521 #define	PEX_FAT_IO7	0x00000080	/* completer abort */
522 #define	PEX_FAT_IO6	0x00000040	/* completion timeout */
523 #define	PEX_FAT_IO5	0x00000020	/* flow control protocol */
524 #define	PEX_FAT_IO4	0x00000010	/* poisoned TLP */
525 #define	PEX_FAT_IO3	0x00000008	/* training error */
526 #define	PEX_FAT_IO2	0x00000004	/* received unsupported req  */
527 #define	PEX_FAT_IO1	0x00000002	/* received fatal error message */
528 #define	PEX_FAT_IO0	0x00000001	/* data link layer protocol */
529 
530 #define	PEX_5400_NF_IO33	0x20000000	/* link autonomous bandwidth */
531 						/* change (correctable) */
532 #define	PEX_5400_NF_IO32	0x10000000	/* Received CA Posted Request */
533 #define	PEX_5400_NF_IO31	0x08000000	/* Received UR Posted Request */
534 #define	PEX_5400_NF_IO30	0x04000000	/* VT-d Internal HW */
535 #define	PEX_5400_NF_IO29	0x02000000	/* MSI Address */
536 #define	PEX_5400_NF_IO28	0x01000000	/* Link bandwidth change */
537 #define	PEX_5400_NF_IO27	0x00800000	/* Stop & Scream */
538 #define	PEX_5400_NF_IO26	0x00400000	/* Received CA Response */
539 #define	PEX_5400_NF_IO25	0x00200000	/* Received UR Response */
540 #define	PEX_5400_NF_IO24	0x00100000	/* Outbound poisoned TLP */
541 #define	PEX_5400_NF_IO23	0x00080000	/* VT-d Fault */
542 #define	PEX_5400_NF_IO11	0x00040000	/* received non fatal err msg */
543 #define	PEX_5400_NF_IO17	0x00020000 	/* rec correctable error msg */
544 #define	PEX_5400_NF_IO2		0x00008000	/* Received unsupported req */
545 #define	PEX_5400_NF_IO9		0x00004000	/* Malformed TLP */
546 #define	PEX_5400_NF_IO10	0x00002000	/* Received buffer overflow */
547 #define	PEX_5400_NF_IO8		0x00001000	/* unexpected completion err */
548 #define	PEX_5400_NF_IO7		0x00000800	/* completion abort */
549 #define	PEX_5400_NF_IO6		0x00000400	/* completion timeout */
550 #define	PEX_5400_NF_IO5		0x00000200	/* flow control protocol */
551 #define	PEX_5400_NF_IO4		0x00000100	/* poisoned TLP */
552 #define	PEX_5400_NF_IO19	0x00000080	/* surprise link down */
553 #define	PEX_5400_NF_IO0		0x00000040	/* data link layer protocol */
554 #define	PEX_5400_NF_IO20	0x00000020	/* Advisory Non Fatel */
555 #define	PEX_5400_NF_IO16	0x00000010	/* replay timer timeout */
556 #define	PEX_5400_NF_IO15	0x00000008	/* replay num pollover */
557 #define	PEX_5400_NF_IO14	0x00000004	/* bad DLLP */
558 #define	PEX_5400_NF_IO13	0x00000002	/* bad TLP */
559 #define	PEX_5400_NF_IO12	0x00000001	/* receiver error mask */
560 #define	PEX_NF_IO19	0x00020000	/* surprise link down */
561 #define	PEX_NF_IO17	0x00010000	/* received correctable error message */
562 #define	PEX_NF_IO16	0x00008000	/* replay timer timeout */
563 #define	PEX_NF_IO15	0x00004000	/* replay num pollover */
564 #define	PEX_NF_IO14	0x00002000	/* bad DLLP */
565 #define	PEX_NF_IO13	0x00001000	/* bad TLP */
566 #define	PEX_NF_IO12	0x00000800	/* receiver error mask */
567 #define	PEX_NF_IO11	0x00000400	/* received non fatal error message */
568 #define	PEX_NF_IO10	0x00000200	/* Received buffer overflow */
569 #define	PEX_NF_IO9	0x00000100	/* Malformed TLP */
570 #define	PEX_NF_IO8	0x00000080
571 #define	PEX_NF_IO7	0x00000040
572 #define	PEX_NF_IO6	0x00000020	/* completion timeout */
573 #define	PEX_NF_IO5	0x00000010	/* flow control protocol */
574 #define	PEX_NF_IO4	0x00000008	/* poisoned TLP */
575 #define	PEX_NF_IO3	0x00000004
576 #define	PEX_NF_IO2	0x00000002
577 #define	PEX_NF_IO0	0x00000001	/* data link layer protocol */
578 
579 #define	ERR_FAT_TH2	0x02	/* >tmid thermal event */
580 #define	ERR_FAT_TH1	0x01	/* Catastrophic on-die thermal event */
581 
582 #define	ERR_NF_TH5	0x10	/* timeout on cooling update */
583 #define	ERR_NF_TH4	0x08	/* TSMAX update */
584 #define	ERR_NF_TH3	0x04	/* on-die throttling event */
585 
586 #define	EMASK_TH5	0x0010 	/* TH5Msk timeout on cooling update */
587 #define	EMASK_TH4	0x0008 	/* TH4Msk TSMAX update */
588 #define	EMASK_TH3	0x0004 	/* TH3Msk on-die throttling event */
589 #define	EMASK_TH2	0x0002 	/* TH2Msk >tmid thermal event */
590 #define	EMASK_TH1	0x0001 	/* TH1Msk Catastrophic on-die thermal event */
591 
592 #define	GE_FERR_FSB(ferr) ( \
593 	((ferr) & (GE_FSB0_FATAL|GE_FSB0_NF)) ? 0 : \
594 	((ferr) & (GE_FSB1_FATAL|GE_FSB1_NF)) ? 1 : \
595 	(nb_chipset == INTEL_NB_7300) && \
596 	((ferr) & (GE_FERR_FSB2_FATAL|GE_FERR_FSB2_NF)) ? 2 : \
597 	(nb_chipset == INTEL_NB_7300) && \
598 	((ferr) & (GE_FERR_FSB3_FATAL|GE_FERR_FSB3_NF)) ? 3 : \
599 	-1)
600 
601 #define	GE_NERR_TO_FERR_FSB(nerr) \
602 	((((nerr) & GE_NERR_FSB3_FATAL) ? GE_FERR_FSB3_FATAL : 0) | \
603 	(((nerr) & GE_NERR_FSB2_FATAL) ? GE_FERR_FSB2_FATAL : 0) | \
604 	(((nerr) & GE_FSB1_FATAL) ? GE_FSB1_FATAL : 0) | \
605 	(((nerr) & GE_FSB0_FATAL) ? GE_FSB0_FATAL : 0) | \
606 	(((nerr) & GE_NERR_FSB3_NF) ? GE_FERR_FSB3_NF : 0) | \
607 	(((nerr) & GE_NERR_FSB2_NF) ? GE_FERR_FSB2_NF : 0) | \
608 	(((nerr) & GE_FSB1_NF) ? GE_FSB1_NF : 0) | \
609 	(((nerr) & GE_FSB0_NF) ? GE_FSB0_NF : 0))
610 
611 #define	GE_ERR_PEX(ferr) ( \
612 	((ferr) & (GE_ESI_FATAL|GE_ESI_NF)) ? 0 : \
613 	((nb_chipset == INTEL_NB_7300 || nb_chipset == INTEL_NB_5400) && \
614 	((ferr) & (GE_PCIEX1_FATAL|GE_PCIEX1_NF))) ? 1 : \
615 	((ferr) & (GE_PCIEX2_FATAL|GE_PCIEX2_NF)) ? 2 : \
616 	((ferr) & (GE_PCIEX3_FATAL|GE_PCIEX3_NF)) ? 3 : \
617 	((ferr) & (GE_PCIEX4_FATAL|GE_PCIEX4_NF)) ? 4 : \
618 	((ferr) & (GE_PCIEX5_FATAL|GE_PCIEX5_NF)) ? 5 : \
619 	((ferr) & (GE_PCIEX6_FATAL|GE_PCIEX6_NF)) ? 6 : \
620 	((ferr) & (GE_PCIEX7_FATAL|GE_PCIEX7_NF)) ? 7 : \
621 	(nb_chipset == INTEL_NB_5400) && \
622 	((ferr) & (GE_PCIEX8_FATAL|GE_PCIEX8_NF)) ? 8 : \
623 	((ferr) & (GE_PCIEX9_FATAL|GE_PCIEX9_NF)) ? 9 : \
624 	-1)
625 
626 #define	GE_FERR_FATAL	((nb_chipset == INTEL_NB_7300) ? \
627 	(GE_INT_FATAL|GE_DMA_FATAL|GE_FERR_FSB3_FATAL|GE_FERR_FSB2_FATAL| \
628 	GE_FSB1_FATAL|GE_FSB0_FATAL|GE_FBD_FATAL|GE_PCIEX7_FATAL| \
629 	GE_PCIEX6_FATAL| GE_PCIEX5_FATAL|GE_PCIEX4_FATAL|GE_PCIEX3_FATAL| \
630 	GE_PCIEX2_FATAL| GE_ESI_FATAL) :  \
631 	(GE_INT_FATAL|GE_DMA_FATAL|GE_FSB1_FATAL|GE_FSB0_FATAL|GE_FBD_FATAL| \
632 	GE_PCIEX7_FATAL|GE_PCIEX6_FATAL|GE_PCIEX5_FATAL|GE_PCIEX4_FATAL| \
633 	GE_PCIEX3_FATAL|GE_PCIEX2_FATAL|GE_ESI_FATAL))
634 
635 #define	GE_NERR_FATAL	((nb_chipset == INTEL_NB_7300) ? \
636 	(GE_INT_FATAL|GE_DMA_FATAL|GE_NERR_FSB3_FATAL|GE_NERR_FSB2_FATAL| \
637 	GE_FSB1_FATAL|GE_FSB0_FATAL|GE_FBD_FATAL|GE_PCIEX7_FATAL| \
638 	GE_PCIEX6_FATAL|GE_PCIEX5_FATAL|GE_PCIEX4_FATAL|GE_PCIEX3_FATAL| \
639 	GE_PCIEX2_FATALGE_ESI_FATAL) :  \
640 	(GE_INT_FATAL|GE_DMA_FATAL|GE_FSB1_FATAL|GE_FSB0_FATAL|GE_FBD_FATAL| \
641 	GE_PCIEX7_FATAL|GE_PCIEX6_FATAL|GE_PCIEX5_FATAL|GE_PCIEX4_FATAL| \
642 	GE_PCIEX3_FATAL|GE_PCIEX2_FATAL|GE_ESI_FATAL))
643 
644 #define	GE_PCIEX_FATAL	(GE_ESI_FATAL|GE_PCIEX1_FATAL|GE_PCIEX2_FATAL| \
645 	GE_PCIEX3_FATAL|GE_PCIEX4_FATAL|GE_PCIEX5_FATAL|GE_PCIEX6_FATAL| \
646 	GE_PCIEX7_FATAL)
647 #define	GE_PCIEX_NF	(GE_ESI_NF|GE_PCIEX1_NF|GE_PCIEX2_NF|GE_PCIEX3_NF| \
648 	GE_PCIEX4_NF|GE_PCIEX5_NF|GE_PCIEX6_NF|GE_PCIEX7_NF)
649 #define	GE_FERR_FSB_FATAL	((nb_chipset == INTEL_NB_7300) ? \
650 	(GE_FSB0_FATAL|GE_FSB1_FATAL|GE_FERR_FSB2_FATAL|GE_FERR_FSB3_FATAL) : \
651 	(GE_FSB0_FATAL|GE_FSB1_FATAL))
652 #define	GE_NERR_FSB_FATAL	((nb_chipset == INTEL_NB_7300) ? \
653 	(GE_FSB0_FATAL|GE_FSB1_FATAL|GE_NERR_FSB2_FATAL|GE_NERR_FSB3_FATAL) : \
654 	(GE_FSB0_FATAL|GE_FSB1_FATAL))
655 #define	GE_FERR_FSB_NF	((nb_chipset == INTEL_NB_7300) ? \
656 	(GE_FSB0_NF|GE_FSB1_NF|GE_FERR_FSB2_NF|GE_FERR_FSB3_NF) : \
657 	(GE_FSB0_NF|GE_FSB1_NF))
658 #define	GE_NERR_FSB_NF	((nb_chipset == INTEL_NB_7300) ? \
659 	(GE_FSB0_NF|GE_FSB1_NF|GE_NERR_FSB2_NF|GE_NERR_FSB3_NF) : \
660 	(GE_FSB0_NF|GE_FSB1_NF))
661 
662 #define	FERR_FBD_CHANNEL(reg)	((reg)>>28 & 3)
663 
664 #define	NB5000_STEPPING()	nb_pci_getw(0, 0, 0, 8, 0)
665 
666 #define	FERR_GLOBAL_RD()	((nb_chipset == INTEL_NB_7300) ? \
667 				    ((uint64_t)nb_pci_getl(0, 16, 2, \
668 				    0x48, 0) << 32) | nb_pci_getl(0, 16, 2, \
669 				    0x40, 0) : \
670 				    (uint64_t)nb_pci_getl(0, 16, 2, 0x40, 0))
671 #define	NERR_GLOBAL_RD()	nb_pci_getl(0, 16, 2, 0x44, 0)
672 #define	FERR_FAT_FSB_RD(fsb, ip)	((nb_chipset == INTEL_NB_7300) ? \
673 	nb_pci_getb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc0 : 0x40, ip) : \
674 	nb_pci_getb(0, 16, 0, fsb ? 0x480 : 0x180, ip))
675 #define	FERR_NF_FSB_RD(fsb, ip)	((nb_chipset == INTEL_NB_7300) ? \
676 	nb_pci_getb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc1 : 0x41, ip) : \
677 	nb_pci_getb(0, 16, 0, fsb ? 0x481 : 0x181, ip))
678 #define	NERR_FAT_FSB_RD(fsb, ip) ((nb_chipset == INTEL_NB_7300) ? \
679 	nb_pci_getb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc2 : 0x42, ip) : \
680 	nb_pci_getb(0, 16, 0, fsb ? 0x482 : 0x182, ip))
681 #define	NERR_NF_FSB_RD(fsb, ip) ((nb_chipset == INTEL_NB_7300) ? \
682 	nb_pci_getb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc3 : 0x43, ip) : \
683 	nb_pci_getb(0, 16, 0, fsb ? 0x483 : 0x183, ip))
684 
685 #define	NRECFSB_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
686 	nb_pci_getl(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc4 : 0x44, 0) : \
687 	nb_pci_getl(0, 16, 0, fsb ? 0x484 : 0x184, 0))
688 #define	NRECFSB_WR(fsb)	\
689 	if (nb_chipset == INTEL_NB_7300) { \
690 		nb_pci_putl(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc4 : 0x44, \
691 		    0); \
692 	} else { \
693 		nb_pci_putl(0, 16, 0, fsb ? 0x484 : 0x184, 0); \
694 	}
695 #define	RECFSB_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
696 	nb_pci_getl(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc8 : 0x48, 0) : \
697 	nb_pci_getl(0, 16, 0, fsb ? 0x488 : 0x188, 0))
698 #define	RECFSB_WR(fsb) \
699 	if (nb_chipset == INTEL_NB_7300) { \
700 		nb_pci_putl(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc8 : 0x48, \
701 		    0); \
702 	} else { \
703 		nb_pci_putl(0, 16, 0, fsb ? 0x488 : 0x188, 0); \
704 	}
705 #define	NRECADDR_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
706 	((uint64_t)(nb_pci_getb(0, 17, (fsb & 2) ? 3 : 0, \
707 	(fsb & 1) ? 0xd0 : 0x50, 0)) << 32) | \
708 	nb_pci_getl(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xcc : 0x4c, 0) : \
709 	((uint64_t)(nb_pci_getb(0, 16, 0, fsb ? 0x490 : 0x190, 0)) << 32) | \
710 	nb_pci_getl(0, 16, 0, fsb ? 0x48c : 0x18c, 0))
711 #define	NRECADDR_WR(fsb) \
712 	if (nb_chipset == INTEL_NB_7300) { \
713 		nb_pci_putb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xd0 : 0x50, \
714 		    0); \
715 		nb_pci_putl(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xcc : 0x4c, \
716 		    0); \
717 	} else { \
718 		nb_pci_putb(0, 16, 0, fsb ? 0x490 : 0x190, 0); \
719 		nb_pci_putl(0, 16, 0, fsb ? 0x48c : 0x18c, 0); \
720 	}
721 #define	EMASK_FSB_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
722 	nb_pci_getw(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xd2 : 0x52, 0) : \
723 	nb_pci_getw(0, 16, 0, fsb ? 0x492 : 0x192, 0))
724 #define	ERR0_FSB_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
725 	nb_pci_getw(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xd4 : 0x54, 0) : \
726 	nb_pci_getw(0, 16, 0, fsb ? 0x494 : 0x194, 0))
727 #define	ERR1_FSB_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
728 	nb_pci_getw(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xd6 : 0x56, 0) : \
729 	nb_pci_getw(0, 16, 0, fsb ? 0x496 : 0x196, 0))
730 #define	ERR2_FSB_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
731 	nb_pci_getw(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xd8 : 0x58, 0) : \
732 	nb_pci_getw(0, 16, 0, fsb ? 0x498 : 0x198, 0))
733 #define	MCERR_FSB_RD(fsb)	((nb_chipset == INTEL_NB_7300) ? \
734 	nb_pci_getw(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xda : 0x5a, 0) : \
735 	nb_pci_getw(0, 16, 0, fsb ? 0x49a : 0x19a, 0))
736 
737 #define	FERR_GLOBAL_WR(val) \
738 	if (nb_chipset == INTEL_NB_7300) \
739 	{ \
740 		    nb_pci_putl(0, 16, 2, 0x48, (uint32_t)(val >> 32)); \
741 		    nb_pci_putl(0, 16, 2, 0x40, (uint32_t)val); \
742 	} else { \
743 		    nb_pci_putl(0, 16, 2, 0x40, (uint32_t)val); \
744 	}
745 #define	NERR_GLOBAL_WR(val)	nb_pci_putl(0, 16, 2, 0x44, val)
746 #define	FERR_FAT_FSB_WR(fsb, val)	((nb_chipset == INTEL_NB_7300) ? \
747 	nb_pci_putb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc0 : 0x40, val) : \
748 	nb_pci_putb(0, 16, 0, fsb ? 0x480 : 0x180, val))
749 #define	FERR_NF_FSB_WR(fsb, val)	((nb_chipset == INTEL_NB_7300) ? \
750 	nb_pci_putb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc1 : 0x41, val) : \
751 	nb_pci_putb(0, 16, 0, fsb ? 0x481 : 0x181, val))
752 #define	NERR_FAT_FSB_WR(fsb, val)	((nb_chipset == INTEL_NB_7300) ? \
753 	nb_pci_putb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc2 : 0x42, val) : \
754 	nb_pci_putb(0, 16, 0, fsb ? 0x482 : 0x182, val))
755 #define	NERR_NF_FSB_WR(fsb, val)	((nb_chipset == INTEL_NB_7300) ? \
756 	nb_pci_putb(0, 17, (fsb & 2) ? 3 : 0, (fsb & 1) ? 0xc3 : 0x43, val) : \
757 	nb_pci_putb(0, 16, 0, fsb ? 0x483 : 0x183, val))
758 #define	EMASK_FSB_WR(fsb, val) \
759 	{ \
760 		if (nb_chipset == INTEL_NB_7300) \
761 			nb_pci_putw(0, 17, ((fsb) & 2) ? 3 : 0, \
762 			    ((fsb) & 1) ? 0xd2 : 0x52, val); \
763 		else \
764 			nb_pci_putw(0, 16, 0, fsb ? 0x492 : 0x192, val); \
765 	}
766 #define	ERR0_FSB_WR(fsb, val) \
767 	{ \
768 		if (nb_chipset == INTEL_NB_7300) \
769 			nb_pci_putw(0, 17, (fsb & 2) ? 3 : 0, \
770 			    (fsb & 1) ? 0xd4 : 0x54, val); \
771 		else \
772 			nb_pci_putw(0, 16, 0, fsb ? 0x494 : 0x194, val); \
773 	}
774 #define	ERR1_FSB_WR(fsb, val) \
775 	{ \
776 		if (nb_chipset == INTEL_NB_7300) \
777 			nb_pci_putw(0, 17, (fsb & 2) ? 3 : 0, \
778 			    (fsb & 1) ? 0xd6 : 0x56, val); \
779 		else \
780 			nb_pci_putw(0, 16, 0, fsb ? 0x496 : 0x196, val); \
781 	}
782 #define	ERR2_FSB_WR(fsb, val) \
783 	{ \
784 		if (nb_chipset == INTEL_NB_7300) \
785 			nb_pci_putw(0, 17, (fsb & 2) ? 3 : 0, \
786 			    (fsb & 1) ? 0xd8 : 0x58, val); \
787 		else \
788 			nb_pci_putw(0, 16, 0, fsb ? 0x498 : 0x198, val); \
789 	}
790 #define	MCERR_FSB_WR(fsb, val) \
791 	{ \
792 		if (nb_chipset == INTEL_NB_7300) \
793 			nb_pci_putw(0, 17, (fsb & 2) ? 3 : 0, \
794 			    (fsb & 1) ? 0xda : 0x5a, val); \
795 		else \
796 			nb_pci_putw(0, 16, 0, fsb ? 0x49a : 0x19a, val); \
797 	}
798 
799 #define	NRECSF_RD()	(nb_chipset == INTEL_NB_5000X || \
800 	nb_chipset == INTEL_NB_7300) ? ((uint64_t)( \
801 	nb_pci_getl(0, 16, 2, 0xb4, 0)) << 32) | \
802 	nb_pci_getl(0, 16, 2, 0xb0, 0) : 0LL
803 #define	RECSF_RD()	(nb_chipset == INTEL_NB_5000X || \
804 	nb_chipset == INTEL_NB_7300) ? ((uint64_t)( \
805 	nb_pci_getl(0, 16, 2, 0xbc, 0)) << 32) | \
806 	nb_pci_getl(0, 16, 2, 0xb8, 0) : 0LL
807 
808 #define	NRECSF_WR()	if (nb_chipset == INTEL_NB_5000X || \
809 	nb_chipset == INTEL_NB_7300) { \
810 		nb_pci_putl(0, 16, 2, 0xbc, 0); \
811 		nb_pci_putl(0, 16, 2, 0xb0, 0); \
812 	}
813 #define	RECSF_WR()	if (nb_chipset == INTEL_NB_5000X || \
814 	nb_chipset == INTEL_NB_7300) { \
815 		nb_pci_putl(0, 16, 2, 0xbc, 0); \
816 		nb_pci_putl(0, 16, 2, 0xb8, 0); \
817 	}
818 
819 #define	FERR_FAT_INT_RD(ip)	(((nb_chipset == INTEL_NB_5400) ? \
820 	((uint16_t)nb_pci_getb(0, 16, 2, 0xc1, ip) << 8) : (uint16_t)0) | \
821 	nb_pci_getb(0, 16, 2, 0xc0, ip))
822 #define	FERR_NF_INT_RD(ip)	((nb_chipset == INTEL_NB_5400) ? \
823 	((uint16_t)nb_pci_getb(0, 16, 2, 0xc3, ip) << 8) | \
824 	nb_pci_getb(0, 16, 2, 0xc2, ip) : \
825 	(uint16_t)nb_pci_getb(0, 16, 2, 0xc1, ip))
826 #define	NERR_FAT_INT_RD(ip)	((nb_chipset == INTEL_NB_5400) ? \
827 	((uint16_t)nb_pci_getb(0, 16, 2, 0xc5, ip) << 8) | \
828 	nb_pci_getb(0, 16, 2, 0xc4, ip) : \
829 	(uint16_t)nb_pci_getb(0, 16, 2, 0xc2, ip))
830 #define	NERR_NF_INT_RD(ip)	((nb_chipset == INTEL_NB_5400) ? \
831 	((uint16_t)nb_pci_getb(0, 16, 2, 0xc7, ip) << 8) | \
832 	nb_pci_getb(0, 16, 2, 0xc6, ip) : \
833 	(uint16_t)nb_pci_getb(0, 16, 2, 0xc3, ip))
834 #define	EMASK_INT_RD()		((nb_chipset == INTEL_NB_5400) ? \
835 	nb_pci_getl(0, 16, 2, 0xd0, 0) : nb_pci_getb(0, 16, 2, 0xcc, 0))
836 #define	ERR0_INT_RD()		((nb_chipset == INTEL_NB_5400) ? \
837 	nb_pci_getl(0, 16, 2, 0xd4, 0) : nb_pci_getb(0, 16, 2, 0xd0, 0))
838 #define	ERR1_INT_RD()		((nb_chipset == INTEL_NB_5400) ? \
839 	nb_pci_getl(0, 16, 2, 0xd8, 0) : nb_pci_getb(0, 16, 2, 0xd1, 0))
840 #define	ERR2_INT_RD()		((nb_chipset == INTEL_NB_5400) ? \
841 	nb_pci_getl(0, 16, 2, 0xdc, 0) : nb_pci_getb(0, 16, 2, 0xd2, 0))
842 #define	MCERR_INT_RD()		((nb_chipset == INTEL_NB_5400) ? \
843 	nb_pci_getl(0, 16, 2, 0xe0, 0) : nb_pci_getb(0, 16, 2, 0xd3, 0))
844 
845 #define	FERR_FAT_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
846 					nb_pci_putb(0, 16, 2, 0xc0,  \
847 					    val & 0xff); \
848 					nb_pci_putb(0, 16, 2, 0xc1, val >> 8); \
849 				} else { \
850 					nb_pci_putb(0, 16, 2, 0xc0, val); \
851 				}
852 #define	FERR_NF_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
853 					nb_pci_putb(0, 16, 2, 0xc2,  \
854 					    val & 0xff); \
855 					nb_pci_putb(0, 16, 2, 0xc3, val >> 8); \
856 				} else { \
857 					nb_pci_putb(0, 16, 2, 0xc1, val); \
858 				}
859 #define	NERR_FAT_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
860 					nb_pci_putb(0, 16, 2, 0xc4,  \
861 					    val & 0xff); \
862 					nb_pci_putb(0, 16, 2, 0xc5, val >> 8); \
863 				} else { \
864 					nb_pci_putb(0, 16, 2, 0xc2, val); \
865 				}
866 #define	NERR_NF_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
867 					nb_pci_putb(0, 16, 2, 0xc6,  \
868 					    val & 0xff); \
869 					nb_pci_putb(0, 16, 2, 0xc7, val >> 8); \
870 				} else { \
871 					nb_pci_putb(0, 16, 2, 0xc3, val); \
872 				}
873 #define	EMASK_5000_INT_WR(val)	nb_pci_putb(0, 16, 2, 0xcc, val)
874 #define	EMASK_5400_INT_WR(val)	nb_pci_putl(0, 16, 2, 0xd0, val)
875 #define	EMASK_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
876 					EMASK_5400_INT_WR(val); \
877 				} else { \
878 					EMASK_5000_INT_WR(val); \
879 				}
880 #define	ERR0_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
881 					nb_pci_putl(0, 16, 2, 0xd4, val); \
882 				} else { \
883 					nb_pci_putb(0, 16, 2, 0xd0, val); \
884 				}
885 #define	ERR1_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
886 					nb_pci_putl(0, 16, 2, 0xd8, val); \
887 				} else { \
888 					nb_pci_putb(0, 16, 2, 0xd1, val); \
889 				}
890 #define	ERR2_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
891 					nb_pci_putl(0, 16, 2, 0xdc, val); \
892 				} else { \
893 					nb_pci_putb(0, 16, 2, 0xd2, val); \
894 				}
895 #define	MCERR_INT_WR(val)	if (nb_chipset == INTEL_NB_5400) { \
896 					nb_pci_putl(0, 16, 2, 0xe0, val); \
897 				} else { \
898 					nb_pci_putb(0, 16, 2, 0xd3, val); \
899 				}
900 
901 #define	NRECINT_RD()		nb_pci_getl(0, 16, 2, \
902 	nb_chipset == INTEL_NB_5400 ? 0xc8 : 0xc4, 0)
903 #define	RECINT_RD()		nb_pci_getl(0, 16, 2, \
904 	nb_chipset == INTEL_NB_5400 ? 0xcc : 0xc8, 0)
905 
906 #define	NRECINT_WR()		nb_pci_putl(0, 16, 2, \
907 	nb_chipset == INTEL_NB_5400 ? 0xc8 : 0xc4, 0)
908 #define	RECINT_WR()		nb_pci_putl(0, 16, 2, \
909 	nb_chipset == INTEL_NB_5400 ? 0xcc : 0xc8, 0)
910 
911 
912 #define	FERR_FAT_FBD_RD(ip)	nb_pci_getl(0, 16, 1, 0x98, ip)
913 #define	NERR_FAT_FBD_RD(ip)	nb_pci_getl(0, 16, 1, 0x9c, ip)
914 #define	FERR_NF_FBD_RD(ip)	nb_pci_getl(0, 16, 1, 0xa0, ip)
915 #define	NERR_NF_FBD_RD(ip)	nb_pci_getl(0, 16, 1, 0xa4, ip)
916 #define	EMASK_FBD_RD()		nb_pci_getl(0, 16, 1, 0xa8, 0)
917 #define	ERR0_FBD_RD()		nb_pci_getl(0, 16, 1, 0xac, 0)
918 #define	ERR1_FBD_RD()		nb_pci_getl(0, 16, 1, 0xb0, 0)
919 #define	ERR2_FBD_RD()		nb_pci_getl(0, 16, 1, 0xb4, 0)
920 #define	MCERR_FBD_RD()		nb_pci_getl(0, 16, 1, 0xb8, 0)
921 
922 #define	FERR_FAT_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0x98, val)
923 #define	NERR_FAT_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0x9c, val)
924 #define	FERR_NF_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0xa0, val)
925 #define	NERR_NF_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0xa4, val)
926 #define	EMASK_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0xa8, val)
927 #define	ERR0_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0xac, val)
928 #define	ERR1_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0xb0, val)
929 #define	ERR2_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0xb4, val)
930 #define	MCERR_FBD_WR(val)	nb_pci_putl(0, 16, 1, 0xb8, val)
931 
932 #define	NRECMEMA_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
933 	nb_pci_getw(0, (branch) ? 22 : 21, 1, 0xbe, 0) : \
934 	nb_pci_getw(0, 16, 1, 0xbe, 0))
935 #define	NRECMEMB_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
936 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xc0, 0) : \
937 	nb_pci_getl(0, 16, 1, 0xc0, 0))
938 #define	NRECFGLOG_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
939 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0x74, 0) : \
940 	nb_pci_getl(0, 16, 1, 0xc4, 0))
941 #define	NRECFBDA_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
942 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xc4, 0) : \
943 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xc4 : 0xc8, 0))
944 #define	NRECFBDB_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
945 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xc8, 0) : \
946 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xc8 : 0xcc, 0))
947 #define	NRECFBDC_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
948 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xcc, 0) : \
949 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xcc : 0xd0, 0))
950 #define	NRECFBDD_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
951 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xd0, 0) : \
952 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xd0 : 0xd4, 0))
953 #define	NRECFBDE_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
954 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xd4, 0) : \
955 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xd4 : 0xd8, 0))
956 #define	NRECFBDF_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
957 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xd8, 0) : \
958 	nb_chipset == INTEL_NB_7300 ? nb_pci_getw(0, 16, 1, 0xd8, 0) : 0)
959 #define	REDMEMB_RD()	(nb_chipset == INTEL_NB_5400 ? \
960 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0x7c, 0) : \
961 	nb_pci_getl(0, 16, 1, 0x7c, 0))
962 #define	RECMEMA_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
963 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xe0, 0) & 0xffffff : \
964 	nb_pci_getw(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xe0 : 0xe2, 0))
965 #define	RECMEMB_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
966 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xe4, 0) : \
967 	nb_pci_getl(0, 16, 1, 0xe4, 0))
968 #define	RECFGLOG_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
969 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0x78, 0) : \
970 	nb_chipset == INTEL_NB_7300 ?  nb_pci_getl(0, 16, 1, 0x78, 0) : \
971 	nb_pci_getl(0, 16, 1, 0xe8, 0))
972 #define	RECFBDA_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
973 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xe8, 0) : \
974 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xe8 : 0xec, 0))
975 #define	RECFBDB_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
976 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xec, 0) : \
977 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xec : 0xf0, 0))
978 #define	RECFBDC_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
979 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xf0, 0) : \
980 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xf0 : 0xf4, 0))
981 #define	RECFBDD_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
982 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xf4, 0) : \
983 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xf4 : 0xf8, 0))
984 #define	RECFBDE_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
985 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xf8, 0) : \
986 	nb_pci_getl(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xf8 : 0xfc, 0))
987 #define	RECFBDF_RD(branch)	(nb_chipset == INTEL_NB_5400 ? \
988 	nb_pci_getl(0, (branch) ? 22 : 21, 1, 0xfc, 0) : \
989 	nb_chipset == INTEL_NB_7300 ? nb_pci_getw(0, 16, 1, 0xfc, 0) : 0)
990 #define	NRECMEMA_WR(branch)	(nb_chipset == INTEL_NB_5400 ? \
991 	nb_pci_putw(0, (branch) ? 22 : 21, 1, 0xbe, 0) : \
992 	nb_pci_putw(0, 16, 1, 0xbe, 0))
993 #define	NRECMEMB_WR(branch)	(nb_chipset == INTEL_NB_5400 ? \
994 	nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xc0, 0) : \
995 	nb_pci_putl(0, 16, 1, 0xc0, 0))
996 #define	NRECFGLOG_WR(branch) \
997 	if (nb_chipset == INTEL_NB_5400) \
998 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0x74, 0); \
999 	else if (nb_chipset == INTEL_NB_7300) \
1000 		nb_pci_putl(0, 16, 1, 0x74, 0); \
1001 	else \
1002 		nb_pci_putl(0, 16, 1, 0xc4, 0)
1003 #define	NRECFBDA_WR(branch) \
1004 	if (nb_chipset == INTEL_NB_5400) \
1005 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xc4, 0); \
1006 	else if (nb_chipset == INTEL_NB_7300) \
1007 		nb_pci_putl(0, 16, 1, 0xc4, 0); \
1008 	else \
1009 		nb_pci_putl(0, 16, 1, 0xc8, 0)
1010 #define	NRECFBDB_WR(branch) \
1011 	if (nb_chipset == INTEL_NB_5400) \
1012 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xc8, 0); \
1013 	else if (nb_chipset == INTEL_NB_7300) \
1014 		nb_pci_putl(0, 16, 1, 0xc8, 0); \
1015 	else \
1016 		nb_pci_putl(0, 16, 1, 0xcc, 0)
1017 #define	NRECFBDC_WR(branch) \
1018 	if (nb_chipset == INTEL_NB_5400) \
1019 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xcc, 0); \
1020 	else if (nb_chipset == INTEL_NB_7300) \
1021 		nb_pci_putl(0, 16, 1, 0xcc, 0); \
1022 	else \
1023 		nb_pci_putl(0, 16, 1, 0xd0, 0)
1024 #define	NRECFBDD_WR(branch) \
1025 	if (nb_chipset == INTEL_NB_5400) \
1026 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xd0, 0); \
1027 	else if (nb_chipset == INTEL_NB_7300) \
1028 		nb_pci_putl(0, 16, 1, 0xd0, 0); \
1029 	else \
1030 		nb_pci_putl(0, 16, 1, 0xd4, 0)
1031 #define	NRECFBDE_WR(branch) \
1032 	if (nb_chipset == INTEL_NB_5400) \
1033 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xd4, 0); \
1034 	else if (nb_chipset == INTEL_NB_7300) \
1035 		nb_pci_putl(0, 16, 1, 0xd4, 0); \
1036 	else \
1037 		nb_pci_putl(0, 16, 1, 0xd8, 0)
1038 #define	NRECFBDF_WR(branch) \
1039 	if (nb_chipset == INTEL_NB_5400) \
1040 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xd8, 0); \
1041 	else if (nb_chipset == INTEL_NB_7300) \
1042 		nb_pci_putw(0, 16, 1, 0xd8, 0);
1043 #define	REDMEMB_WR(branch) \
1044 	if (nb_chipset == INTEL_NB_5400) \
1045 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0x7c, 0); \
1046 	else \
1047 		nb_pci_putl(0, 16, 1, 0x7c, 0)
1048 #define	RECMEMA_WR(branch) \
1049 	if (nb_chipset == INTEL_NB_5400) \
1050 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xe0, 0); \
1051 	else \
1052 		nb_pci_putw(0, 16, 1, nb_chipset == INTEL_NB_7300 ? 0xe0 : \
1053 		    0xe2, 0)
1054 #define	RECMEMB_WR(branch) \
1055 	if (nb_chipset == INTEL_NB_5400) \
1056 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xe4, 0); \
1057 	else \
1058 		nb_pci_putl(0, 16, 1, 0xe4, 0)
1059 #define	RECFGLOG_WR(branch) \
1060 	if (nb_chipset == INTEL_NB_5400) \
1061 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0x78, 0); \
1062 	else if (nb_chipset == INTEL_NB_7300) \
1063 		nb_pci_putl(0, 16, 1, 0x78, 0); \
1064 	else \
1065 		nb_pci_putl(0, 16, 1, 0xe8, 0)
1066 #define	RECFBDA_WR(branch) \
1067 	if (nb_chipset == INTEL_NB_5400) \
1068 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xe8, 0); \
1069 	else if (nb_chipset == INTEL_NB_7300) \
1070 		nb_pci_putl(0, 16, 1, 0xe8, 0); \
1071 	else \
1072 		nb_pci_putl(0, 16, 1, 0xec, 0)
1073 #define	RECFBDB_WR(branch) \
1074 	if (nb_chipset == INTEL_NB_5400) \
1075 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xec, 0); \
1076 	else if (nb_chipset == INTEL_NB_7300) \
1077 		nb_pci_putl(0, 16, 1, 0xec, 0); \
1078 	else \
1079 		nb_pci_putl(0, 16, 1, 0xf0, 0)
1080 #define	RECFBDC_WR(branch) \
1081 	if (nb_chipset == INTEL_NB_5400) \
1082 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xf0, 0); \
1083 	else if (nb_chipset == INTEL_NB_7300) \
1084 		nb_pci_putl(0, 16, 1, 0xf0, 0); \
1085 	else \
1086 		nb_pci_putl(0, 16, 1, 0xf4, 0)
1087 #define	RECFBDD_WR(branch) \
1088 	if (nb_chipset == INTEL_NB_5400) \
1089 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xf4, 0); \
1090 	else if (nb_chipset == INTEL_NB_7300) \
1091 		nb_pci_putl(0, 16, 1, 0xf4, 0); \
1092 	else \
1093 		nb_pci_putl(0, 16, 1, 0xf8, 0)
1094 #define	RECFBDE_WR(branch) \
1095 	if (nb_chipset == INTEL_NB_5400) \
1096 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xf8, 0); \
1097 	else if (nb_chipset == INTEL_NB_7300) \
1098 		nb_pci_putl(0, 16, 1, 0xf8, 0); \
1099 	else \
1100 		nb_pci_putl(0, 16, 1, 0xfc, 0)
1101 #define	RECFBDF_WR(branch) \
1102 	if (nb_chipset == INTEL_NB_5400) \
1103 		nb_pci_putl(0, (branch) ? 22 : 21, 1, 0xfc, 0); \
1104 	else if (nb_chipset == INTEL_NB_7300) \
1105 		nb_pci_putw(0, 16, 1, 0xf8, 0); \
1106 
1107 #define	FERR_NF_MEM_RD(ip)	nb_pci_getl(0, 16, 1, 0xa0, ip)
1108 #define	NERR_NF_MEM_RD(ip)	nb_pci_getl(0, 16, 1, 0xa4, ip)
1109 #define	EMASK_MEM_RD()		nb_pci_getl(0, 16, 1, 0xa8, 0)
1110 #define	ERR0_MEM_RD()		nb_pci_getl(0, 16, 1, 0xac, 0)
1111 #define	ERR1_MEM_RD()		nb_pci_getl(0, 16, 1, 0xb0, 0)
1112 #define	ERR2_MEM_RD()		nb_pci_getl(0, 16, 1, 0xb4, 0)
1113 #define	MCERR_MEM_RD()		nb_pci_getl(0, 16, 1, 0xb8, 0)
1114 #define	FERR_NF_MEM_WR(val)	\
1115 	nb_pci_putl(0, 16, 1, 0xa0, (val))
1116 #define	NERR_NF_MEM_WR(val)	\
1117 	nb_pci_putl(0, 16, 1, 0xa4, (val))
1118 #define	EMASK_MEM_WR(val)	\
1119 	nb_pci_putl(0, 16, 1, 0xa8, (val))
1120 #define	ERR0_MEM_WR(val)	\
1121 	nb_pci_putl(0, 16, 1, 0xac, (val))
1122 #define	ERR1_MEM_WR(val)	\
1123 	nb_pci_putl(0, 16, 1, 0xb0, (val))
1124 #define	ERR2_MEM_WR(val)	\
1125 	nb_pci_putl(0, 16, 1, 0xb4, (val))
1126 #define	MCERR_MEM_WR(val)	\
1127 	nb_pci_putl(0, 16, 1, 0xb8, (val))
1128 #define	VALIDLOG_RD(branch)	\
1129 	nb_pci_getl(0, (branch) ? 22 : 21, 0, 0x18c, 0)
1130 #define	MEM_NRECMEMA_RD(branch) \
1131 	nb_pci_getl(0, (branch) ? 22 : 21, 0, 0x190, 0)
1132 #define	MEM_NRECMEMB_RD(branch) \
1133 	nb_pci_getl(0, (branch) ? 22 : 21, 0, 0x194, 0)
1134 #define	MEM_REDMEMA_RD(branch) \
1135 	nb_pci_getl(0, (branch) ? 22 : 21, 0, 0x198, 0)
1136 #define	MEM_REDMEMB_RD(branch) \
1137 	nb_pci_getl(0, (branch) ? 22 : 21, 0, 0x19c, 0)
1138 #define	MEM_RECMEMA_RD(branch) \
1139 	nb_pci_getl(0, (branch) ? 22 : 21, 0, 0x1a0, 0)
1140 #define	MEM_RECMEMB_RD(branch) \
1141 	nb_pci_getl(0, (branch) ? 22 : 21, 0, 0x1a4, 0)
1142 #define	MEM_CERRCNT_RD(branch) nb_pci_getl(0, 21, 0, 0x180, 0)
1143 #define	MEM_CERRCNT_EXT_RD(branch) nb_pci_getw(0, 21, 0, 0x184, 0)
1144 #define	MEM_NRECMEMA_WR(branch) \
1145 	nb_pci_putl(0, (branch) ? 22 : 21, 0, 0x190, 0)
1146 #define	MEM_NRECMEMB_WR(branch) \
1147 	nb_pci_putl(0, (branch) ? 22 : 21, 0, 0x194, 0)
1148 #define	MEM_REDMEMA_WR(branch) \
1149 	nb_pci_putl(0, (branch) ? 22 : 21, 0, 0x198, 0)
1150 #define	MEM_REDMEMB_WR(branch) \
1151 	nb_pci_putl(0, (branch) ? 22 : 21, 0, 0x19c, 0)
1152 #define	MEM_RECMEMA_WR(branch) \
1153 	nb_pci_putl(0, (branch) ? 22 : 21, 0, 0x1a0, 0)
1154 #define	MEM_RECMEMB_WR(branch) \
1155 	nb_pci_putl(0, (branch) ? 22 : 21, 0, 0x1a4, 0)
1156 
1157 #define	MC_RD()		nb_pci_getl(0, 16, 1, 0x40, 0)
1158 #define	MC_WR(val)	nb_pci_putl(0, 16, 1, 0x40, val)
1159 #define	MCA_RD()	nb_pci_getl(0, 16, 1, 0x58, 0)
1160 #define	TOLM_RD()	nb_pci_getw(0, 16, 1, 0x6c, 0)
1161 
1162 #define	MTR_5100_RD(channel, rank) ((rank) < 4 ? \
1163 	nb_pci_getw(0, (channel) == 0 ? 21 : 22, 0, 0x154 + ((rank) * 2), 0) : \
1164 	nb_pci_getw(0, (channel) == 0 ? 21 : 22, 0, 0x1b0 + (((rank) & 3) * 2),\
1165 	0))
1166 
1167 #define	MTR_RD(branch, dimm) (nb_chipset == INTEL_NB_5100 ? \
1168 	MTR_5100_RD(branch, dimm) : \
1169 	nb_chipset == INTEL_NB_5400 ? \
1170 	nb_pci_getw(0, (branch) == 0 ? 21 : 22, 0, 0x80 + dimm * 2, 0) : \
1171 	((branch) == 0) ? \
1172 	nb_pci_getw(0, 21, 0, \
1173 	dimm >= 4 ? 0x82 + (dimm & 3) * 4 : 0x80 + dimm * 4, 0) : \
1174 	(nb_number_memory_controllers == 2) ? \
1175 	nb_pci_getw(0, 22, 0, \
1176 	dimm >= 4 ? 0x82 + (dimm & 3) * 4 : 0x80 + dimm * 4, 0) : 0)
1177 #define	MIR_RD(reg)	nb_pci_getw(0, 16, 1, 0x80 + ((reg)*4), 0)
1178 
1179 #define	DMIR_RD(branch, reg) \
1180 	nb_chipset == INTEL_NB_5100 ? \
1181 	nb_pci_getl(0, ((branch) == 0) ? 21 : 22, 0, 0x15c + ((reg)*4), 0) : \
1182 	((branch) == 0) ? nb_pci_getl(0, 21, 0, 0x90 + ((reg)*4), 0) : \
1183 	(nb_number_memory_controllers == 2) ? \
1184 	nb_pci_getl(0, 22, 0, 0x90 + ((reg)*4), 0) : 0
1185 
1186 #define	SPCPC_RD(branch) (nb_chipset == INTEL_NB_5000P || \
1187 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1188 	nb_chipset == INTEL_NB_5000Z ? \
1189 	(((branch) == 0) ? \
1190 	(uint32_t)nb_pci_getb(0, 21, 0, 0x40, 0) : \
1191 	    (nb_number_memory_controllers == 2) ? \
1192 	    (uint32_t)nb_pci_getb(0, 22, 0, 0x40, 0) : 0) : \
1193 	nb_pci_getl(0, ((branch) == 0) ? 21 : 22, 0, 0x40, 0))
1194 
1195 #define	SPCPC_SPARE_ENABLE (nb_chipset == INTEL_NB_5000P || \
1196 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1197 	nb_chipset == INTEL_NB_5000Z ? 1 : 0x20)
1198 #define	SPCPC_SPRANK(spcpc) (nb_chipset == INTEL_NB_5000P || \
1199 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1200 	nb_chipset == INTEL_NB_5000Z ? \
1201 	(((spcpc) >> 1) & 7) : ((spcpc) & 0xf))
1202 
1203 #define	SPCPS_RD(branch) ((branch) == 0) ? \
1204 	nb_pci_getb(0, 21, 0, nb_chipset == INTEL_NB_5000P || \
1205 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1206 	nb_chipset == INTEL_NB_5000Z ? 0x41 : 0x43, 0) : \
1207 	(nb_number_memory_controllers == 2) ? \
1208 	nb_pci_getb(0, 22, 0, nb_chipset == INTEL_NB_5000P || \
1209 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1210 	nb_chipset == INTEL_NB_5000Z ? 0x41 : 0x43, 0) : 0
1211 
1212 #define	SPCPS_WR(branch) \
1213 	if ((branch) == 0) { \
1214 		nb_pci_putb(0, 21, 0, nb_chipset == INTEL_NB_5000P || \
1215 		    nb_chipset == INTEL_NB_5000X || \
1216 		    nb_chipset == INTEL_NB_5000V || \
1217 		    nb_chipset == INTEL_NB_5000Z ? 0x41 : 0x43, 0); \
1218 	} else if (nb_number_memory_controllers == 2) { \
1219 		nb_pci_putb(0, 22, 0, nb_chipset == INTEL_NB_5000P || \
1220 		    nb_chipset == INTEL_NB_5000X || \
1221 		    nb_chipset == INTEL_NB_5000V || \
1222 		    nb_chipset == INTEL_NB_5000Z ? 0x41 : 0x43, 0); \
1223 	}
1224 
1225 #define	SPCPS_SPARE_DEPLOYED (nb_chipset == INTEL_NB_5000P || \
1226 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1227 	nb_chipset == INTEL_NB_5000Z ? 0x11 : 0x60)
1228 #define	SPCPS_FAILED_RANK(spcps) (nb_chipset == INTEL_NB_5000P || \
1229 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1230 	nb_chipset == INTEL_NB_5000Z ? (((spcps) >> 1) & 7) : ((spcps) & 0xf))
1231 
1232 #define	UERRCNT_RD(branch) ((branch) == 0) ? \
1233 	nb_pci_getl(0, 21, 0, 0xa4, 0) : \
1234 	(nb_number_memory_controllers == 2) ? \
1235 	nb_pci_getl(0, 22, 0, 0xa4, 0) : 0
1236 #define	CERRCNT_RD(branch) ((branch) == 0) ? \
1237 	nb_pci_getl(0, 21, 0, 0xa8, 0) : \
1238 	(nb_number_memory_controllers == 2) ? \
1239 	nb_pci_getl(0, 22, 0, 0xa8, 0) : 0
1240 #define	CERRCNTA_RD(branch, channel) \
1241 	nb_pci_getl(0, branch == 0 ? 21 : 22, 0, \
1242 	(channel & 1) == 0 ? 0xe0 : 0xf0, 0)
1243 #define	CERRCNTB_RD(branch, channel) \
1244 	nb_pci_getl(0, branch == 0 ? 21 : 22, 0, \
1245 	(channel & 1) == 0 ? 0xe4 : 0xf4, 0)
1246 #define	CERRCNTC_RD(branch, channel) \
1247 	(nb_chipset == INTEL_NB_7300 ? \
1248 	nb_pci_getl(0, branch == 0 ? 21 : 22, 0, \
1249 	(channel & 1) == 0 ? 0xe8 : 0xf8, 0) : 0)
1250 #define	CERRCNTD_RD(branch, channel) \
1251 	(nb_chipset == INTEL_NB_7300 ? \
1252 	nb_pci_getl(0, branch == 0 ? 21 : 22, 0, \
1253 	(channel & 1) == 0 ? 0xec : 0xfc, 0) : 0)
1254 #define	BADRAMA_RD(branch) ((branch) == 0) ? \
1255 	nb_pci_getl(0, 21, 0, 0xac, 0) : \
1256 	(nb_number_memory_controllers == 2) ? \
1257 	nb_pci_getl(0, 22, 0, 0xac, 0) : 0
1258 #define	BADRAMB_RD(branch) ((branch) == 0) ? \
1259 	nb_pci_getw(0, 21, 0, 0xb0, 0) : \
1260 	(nb_number_memory_controllers == 2) ? \
1261 	nb_pci_getw(0, 22, 0, 0xb0, 0) : 0
1262 #define	BADCNT_RD(branch) ((branch) == 0) ? \
1263 	nb_pci_getl(0, 21, 0, 0xb4, 0) : \
1264 	(nb_number_memory_controllers == 2) ? \
1265 	nb_pci_getl(0, 22, 0, 0xb4, 0) : 0
1266 
1267 #define	UERRCNT_WR(branch, val)	((branch) == 0) ? \
1268 	nb_pci_putl(0, 21, 0, 0xa4, val) : \
1269 	(nb_number_memory_controllers == 2) ? \
1270 	nb_pci_putl(0, 22, 0, 0xa4, val) \
1271 					: 0
1272 #define	CERRCNT_WR(branch, val)	((branch) == 0) ? \
1273 	nb_pci_putl(0, 21, 0, 0xa8, val) : \
1274 	(nb_number_memory_controllers == 2) ? \
1275 	nb_pci_putl(0, 22, 0, 0xa8, val) : 0
1276 #define	BADRAMA_WR(branch, val)	((branch) == 0) ? \
1277 	nb_pci_putl(0, 21, 0, 0xac, val) : \
1278 	(nb_number_memory_controllers == 2) ? \
1279 	nb_pci_putl(0, 22, 0, 0xac, val) : 0
1280 #define	BADRAMB_WR(branch, val)	((branch) == 0) ? \
1281 	nb_pci_putw(0, 21, 0, 0xb0, val) : \
1282 	(nb_number_memory_controllers == 2) ? \
1283 	nb_pci_putw(0, 22, 0, 0xb0) : 0
1284 #define	BADCNT_WR(branch, val) ((branch) == 0) ? \
1285 	nb_pci_putl(0, 21, 0, 0xb4, val) : \
1286 	(nb_number_memory_controllers == 2) ? \
1287 	nb_pci_putl(0, 22, 0, 0xb4, val) : 0
1288 
1289 #define	SPD_RD(branch, channel) \
1290 	nb_chipset == INTEL_NB_5100 ? nb_pci_getw(0, 16, 1, 0x48, 0) : \
1291 	((branch) == 0) ? \
1292 	nb_pci_getw(0, 21, 0, 0x74 + ((channel) * 2), 0) : \
1293 	(nb_number_memory_controllers == 2) ? \
1294 	nb_pci_getw(0, 22, 0, 0x74 + ((channel) * 2), 0) : 0
1295 #define	SPDCMDRD(branch, channel) ((branch) == 0) ? \
1296 	nb_pci_getl(0, 21, 0, 0x78 + ((channel) * 4), 0) : \
1297 	(nb_number_memory_controllers == 2) ? \
1298 	nb_pci_getl(0, 22, 0, 0x78 + ((channel) * 4), 0) : 0
1299 
1300 #define	SPDCMD1_1_WR(val)	nb_pci_putl(0, 21, 0, 0x7c, val)
1301 #define	SPDCMD_WR(branch, channel, val)	\
1302 	if (nb_chipset == INTEL_NB_5100) \
1303 	nb_pci_putl(0, 16, 1, 0x4c, val); \
1304 	else if ((branch) == 0) \
1305 	nb_pci_putl(0, 21, 0, 0x78 + ((channel) * 4), val); \
1306 	else if (nb_number_memory_controllers == 2) \
1307 	nb_pci_putl(0, 22, 0, 0x78 + ((channel) * 4), val)
1308 
1309 #define	UNCERRSTS_RD(pex)		nb_pci_getl(0, pex, 0, 0x104, 0)
1310 #define	UNCERRMSK_RD(pex) nb_pci_getl(0, pex, 0, 0x108, 0)
1311 #define	PEX_FAT_FERR_ESI_RD()	nb_pci_getl(0, 0, 0, 0x154, 0)
1312 #define	PEX_FAT_NERR_ESI_RD()	nb_pci_getl(0, 0, 0, 0x15c, 0)
1313 #define	PEX_NF_FERR_ESI_RD()	nb_pci_getl(0, 0, 0, 0x158, 0)
1314 #define	PEX_NF_NERR_ESI_RD()	nb_pci_getl(0, 0, 0, 0x160, 0)
1315 #define	PEX_ERR_DOCMD_RD(pex)	((nb_chipset == INTEL_NB_5400) ? \
1316     nb_pci_getw(0, pex, 0, 0x144, 0) : nb_pci_getl(0, pex, 0, 0x144, 0))
1317 #define	PEX_ERR_PIN_MASK_RD(pex)	nb_pci_getw(0, pex, 0, 0x146, 0)
1318 #define	EMASK_UNCOR_PEX_RD(pex)	nb_pci_getl(0, pex, 0, 0x148, 0)
1319 #define	EMASK_COR_PEX_RD(pex)	nb_pci_getl(0, pex, 0, 0x14c, 0)
1320 #define	EMASK_RP_PEX_RD(pex)	nb_pci_getl(0, pex, 0, 0x150, 0)
1321 
1322 #define	UNCERRSTS_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x104, val)
1323 #define	UNCERRMSK_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x108, val)
1324 #define	PEX_FAT_FERR_ESI_WR(val) nb_pci_putl(0, 0, 0, 0x154, val)
1325 #define	PEX_FAT_NERR_ESI_WR(val) nb_pci_putl(0, 0, 0, 0x15c, val)
1326 #define	PEX_NF_FERR_ESI_WR(val)	nb_pci_putl(0, 0, 0, 0x158, val)
1327 #define	PEX_NF_NERR_ESI_WR(val)	nb_pci_putl(0, 0, 0, 0x160, val)
1328 #define	PEX_ERR_DOCMD_WR(pex, val)	((nb_chipset == INTEL_NB_5400) ? \
1329     nb_pci_putw(0, pex, 0, 0x144, val) : nb_pci_putl(0, pex, 0, 0x144, val))
1330 #define	PEX_ERR_PIN_MASK_WR(pex, val)	nb_pci_putw(0, pex, 0, 0x146, val)
1331 #define	EMASK_UNCOR_PEX_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x148, val)
1332 #define	EMASK_COR_PEX_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x14c, val)
1333 #define	EMASK_RP_PEX_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x150, val)
1334 
1335 #define	PEX_FAT_FERR_RD(pex, ip)	nb_pci_getl(0, pex, 0, 0x154, ip)
1336 #define	PEX_FAT_NERR_RD(pex, ip)	nb_pci_getl(0, pex, 0, 0x15c, ip)
1337 #define	PEX_NF_FERR_RD(pex, ip)	nb_pci_getl(0, pex, 0, 0x158, ip)
1338 #define	PEX_NF_NERR_RD(pex, ip)	nb_pci_getl(0, pex, 0, 0x160, ip)
1339 #define	UNCERRSEV_RD(pex)	nb_pci_getl(0, pex, 0, 0x10c, 0)
1340 #define	CORERRSTS_RD(pex)	nb_pci_getl(0, pex, 0, 0x110, 0)
1341 #define	RPERRSTS_RD(pex)	nb_pci_getl(0, pex, 0, 0x130, 0)
1342 #define	RPERRSID_RD(pex)	nb_pci_getl(0, pex, 0, 0x134, 0)
1343 #define	AERRCAPCTRL_RD(pex)	nb_pci_getl(0, pex, 0, 0x118, 0)
1344 #define	PEXDEVSTS_RD(pex)	nb_pci_getw(0, pex, 0, 0x76, 0)
1345 #define	PEXROOTCTL_RD(pex)	nb_pci_getw(0, pex, 0, 0x88, 0)
1346 
1347 #define	PEX_FAT_FERR_WR(pex, val) nb_pci_putl(0, pex, 0, 0x154, val)
1348 #define	PEX_FAT_NERR_WR(pex, val) nb_pci_putl(0, pex, 0, 0x15c, val)
1349 #define	PEX_NF_FERR_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x158, val)
1350 #define	PEX_NF_NERR_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x160, val)
1351 #define	CORERRSTS_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x110, val)
1352 #define	UNCERRSEV_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x10c, val)
1353 #define	RPERRSTS_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x130, val)
1354 #define	PEXDEVSTS_WR(pex, val)	nb_pci_putl(0, pex, 0, 0x76, val)
1355 #define	PEXROOTCTL_WR(pex, val)	nb_pci_putw(0, pex, 0, 0x88, val)
1356 
1357 #define	PCISTS_RD(ip)		nb_pci_getw(0, 8, 0, 0x6, ip)
1358 #define	PCIDEVSTS_RD()		nb_pci_getw(0, 8, 0, 0x76, 0)
1359 #define	PCISTS_WR(val)		nb_pci_putw(0, 8, 0, 0x6, val)
1360 #define	PCIDEVSTS_WR(val)	nb_pci_putw(0, 8, 0, 0x76, val)
1361 
1362 #define	RANK_MASK	(nb_chipset != INTEL_NB_7300 ? 7 : 0xf)
1363 #define	CAS_MASK	(nb_chipset == INTEL_NB_5000P || \
1364 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1365 	nb_chipset == INTEL_NB_5000Z ? 0xfff : 0x1fff)
1366 #define	RAS_MASK	(nb_chipset == INTEL_NB_5000P || \
1367 	nb_chipset == INTEL_NB_5000X || nb_chipset == INTEL_NB_5000V || \
1368 	nb_chipset == INTEL_NB_5000Z ? 0x7fff : 0xffff)
1369 #define	BANK_MASK	7
1370 
1371 #define	DMIR_RANKS(dmir, rank0, rank1, rank2, rank3) \
1372 	if (nb_chipset == INTEL_NB_5000P || nb_chipset == INTEL_NB_5000X || \
1373 	    nb_chipset == INTEL_NB_5000V || nb_chipset == INTEL_NB_5000Z || \
1374 	    nb_chipset == INTEL_NB_5100) { \
1375 		rank0 = (dmir) & 3; \
1376 		rank1 = ((dmir) >> 3) & 3; \
1377 		rank2 = ((dmir) >> 6) & 3; \
1378 		rank3 = ((dmir) >> 9) & 3; \
1379 	} else { \
1380 		rank0 = (dmir) & 0xf; \
1381 		rank1 = ((dmir) >> 4) & 0xf; \
1382 		rank2 = ((dmir) >> 8) & 0xf; \
1383 		rank3 = ((dmir) >> 12) & 0xf; \
1384 	}
1385 
1386 #define	FERR_FAT_THR_RD(ip)	nb_pci_getb(0, 16, 2, 0xf0, ip)
1387 #define	FERR_NF_THR_RD(ip)	nb_pci_getb(0, 16, 2, 0xf1, ip)
1388 #define	NERR_FAT_THR_RD(ip)	nb_pci_getb(0, 16, 2, 0xf2, ip)
1389 #define	NERR_NF_THR_RD(ip)	nb_pci_getb(0, 16, 2, 0xf3, ip)
1390 #define	EMASK_THR_RD(ip)	nb_pci_getw(0, 16, 2, 0xf6, ip)
1391 #define	ERR0_THR_RD(ip)		nb_pci_getw(0, 16, 2, 0xf8, ip)
1392 #define	ERR1_THR_RD(ip)		nb_pci_getw(0, 16, 2, 0xfa, ip)
1393 #define	ERR2_THR_RD(ip)		nb_pci_getw(0, 16, 2, 0xfc, ip)
1394 #define	MCERR_THR_RD(ip)	nb_pci_getw(0, 16, 2, 0xfe, ip)
1395 #define	CTSTS_RD()		nb_pci_getb(0, 16, 4, 0xee, 0)
1396 #define	THRTSTS_RD()		nb_pci_getw(0, 16, 3, 0x68, 0)
1397 
1398 #define	FERR_FAT_THR_WR(val)	nb_pci_putb(0, 16, 2, 0xf0, val)
1399 #define	FERR_NF_THR_WR(val)	nb_pci_putb(0, 16, 2, 0xf1, val)
1400 #define	NERR_FAT_THR_WR(val)	nb_pci_putb(0, 16, 2, 0xf2, val)
1401 #define	NERR_NF_THR_WR(val)	nb_pci_putb(0, 16, 2, 0xf3, val)
1402 #define	EMASK_THR_WR(val)	nb_pci_putw(0, 16, 2, 0xf6, val)
1403 #define	ERR0_THR_WR(val)	nb_pci_putw(0, 16, 2, 0xf8, val)
1404 #define	ERR1_THR_WR(val)	nb_pci_putw(0, 16, 2, 0xfa, val)
1405 #define	ERR2_THR_WR(val)	nb_pci_putw(0, 16, 2, 0xfc, val)
1406 #define	MCERR_THR_WR(val)	nb_pci_putw(0, 16, 2, 0xfe, val)
1407 #define	CTSTS_WR(val)		nb_pci_putb(0, 16, 4, 0xee, val)
1408 #define	THRTSTS_WR(val)		nb_pci_putw(0, 16, 3, 0x68, val)
1409 
1410 #define	ERR_FAT_THR_F2	0x02	/* >tnid thermal event with intelligent */
1411 				/* throttling disabled */
1412 #define	ERR_FAT_THR_F1	0x01	/* catastrophic on-die thermal event */
1413 
1414 #define	ERR_NF_THR_F5	0x10	/* deadman timeout on cooling update */
1415 #define	ERR_NF_THR_F4	0x08	/* TSMAX Updated */
1416 #define	ERR_NF_THR_F3	0x04	/* On-die throttling event */
1417 
1418 #define	EMASK_THR_FATAL	(ERR_FAT_THR_F2|ERR_FAT_THR_F1)
1419 #define	EMASK_THR_NF	(ERR_NF_THR_F5|ERR_NF_THR_F4|ERR_NF_THR_F3)
1420 
1421 #define	EMASK_THR_F5	0x0010	/* deadman timeout on cooling update */
1422 #define	EMASK_THR_F4	0x0008	/* TSMAX Updated */
1423 #define	EMASK_THR_F3	0x0004	/* On-die throttling event */
1424 #define	EMASK_THR_F2	0x0002	/* >tnid thermal event with intelligent */
1425 				/* throttling disabled */
1426 #define	EMASK_THR_F1	0x0001	/* catastrophic on-die thermal event */
1427 
1428 /* dimm type */
1429 #define	SPD_MEM_TYPE	2
1430 #define	SPD_DDR2	8
1431 #define	SPD_FBDIMM	9
1432 
1433 #ifdef __cplusplus
1434 }
1435 #endif
1436 
1437 #endif /* _NB5000_H */
1438