]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/machine_check.h
xnu-1228.12.14.tar.gz
[apple/xnu.git] / osfmk / i386 / machine_check.h
1 /*
2 * Copyright (c) 2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 #ifdef KERNEL_PRIVATE
29 #ifndef _I386_MACHINE_CHECK_H_
30 #define _I386_MACHINE_CHECK_H_
31
32 /*
33 * This header defines the machine check architecture for Pentium4 and Xeon.
34 */
35
36 /*
37 * Macro BITS(n,m) returns the number of bits between bit(n) and bit(m),
38 * where (n>m). Macro BIT1(n) is cosmetic and returns 1.
39 */
40 #define BITS(n,m) ((n)-(m)+1)
41 #define BIT1(n) (1)
42
43 /*
44 * IA32 SDM 14.3.1 Machine-Check Global Control MSRs:
45 */
46 #define IA32_MCG_CAP (0x179)
47 typedef union {
48 struct {
49 uint64_t count :BITS(7,0);
50 uint64_t mcg_ctl_p :BIT1(8);
51 uint64_t mcg_ext_p :BIT1(9);
52 uint64_t mcg_ext_corr_err_p :BIT1(10);
53 uint64_t mcg_tes_p :BIT1(11);
54 uint64_t mcg_ecms :BIT1(12);
55 uint64_t mcg_reserved2 :BITS(15,13);
56 uint64_t mcg_ext_cnt :BITS(23,16);
57 } bits;
58 uint64_t u64;
59 } ia32_mcg_cap_t;
60
61 #define IA32_MCG_STATUS (0x17A)
62 typedef union {
63 struct {
64 uint64_t ripv :BIT1(0);
65 uint64_t eipv :BIT1(1);
66 uint64_t mcip :BIT1(2);
67 } bits;
68 uint64_t u64;
69 } ia32_mcg_status_t;
70
71 #define IA32_MCG_CTL (0x17B)
72 typedef uint64_t ia32_mcg_ctl_t;
73 #define IA32_MCG_CTL_ENABLE (0xFFFFFFFFFFFFFFFFULL)
74 #define IA32_MCG_CTL_DISABLE (0x0ULL)
75
76
77 /*
78 * IA32 SDM 14.3.2 Error-Reporting Register Banks:
79 */
80 #define IA32_MCi_CTL(i) (0x400 + 4*(i))
81 #define IA32_MCi_STATUS(i) (0x401 + 4*(i))
82 #define IA32_MCi_ADDR(i) (0x402 + 4*(i))
83 #define IA32_MCi_MISC(i) (0x403 + 4*(i))
84
85 #define IA32_MC0_CTL IA32_MCi_CTL(0)
86 #define IA32_MC0_STATUS IA32_MCi_STATUS(0)
87 #define IA32_MC0_ADDR IA32_MCi_ADDR(0)
88 #define IA32_MC0_MISC IA32_MCi_MISC(0)
89
90 #define IA32_MC1_CTL IA32_MCi_CTL(1)
91 #define IA32_MC1_STATUS IA32_MCi_STATUS(1)
92 #define IA32_MC1_ADDR IA32_MCi_ADDR(1)
93 #define IA32_MC1_MISC IA32_MCi_MISC(1)
94
95 #define IA32_MC2_CTL IA32_MCi_CTL(2)
96 #define IA32_MC2_STATUS IA32_MCi_STATUS(2)
97 #define IA32_MC2_ADDR IA32_MCi_ADDR(2)
98 #define IA32_MC2_MISC IA32_MCi_MISC(2)
99
100 #define IA32_MC3_CTL IA32_MCi_CTL(3)
101 #define IA32_MC3_STATUS IA32_MCi_STATUS(3)
102 #define IA32_MC3_ADDR IA32_MCi_ADDR(3)
103 #define IA32_MC3_MISC IA32_MCi_MISC(3)
104
105 #define IA32_MC4_CTL IA32_MCi_CTL(4)
106 #define IA32_MC4_STATUS IA32_MCi_STATUS(4)
107 #define IA32_MC4_ADDR IA32_MCi_ADDR(4)
108 #define IA32_MC4_MISC IA32_MCi_MISC(4)
109
110 typedef uint64_t ia32_mci_ctl_t;
111 #define IA32_MCi_CTL_EE(j) (0x1ULL << (j))
112 #define IA32_MCi_CTL_ENABLE_ALL (0xFFFFFFFFFFFFFFFFULL)
113
114 typedef union {
115 struct {
116 uint64_t mca_error :BITS(15,0);
117 uint64_t model_specific_error :BITS(31,16);
118 uint64_t other_information :BITS(56,32);
119 uint64_t pcc :BIT1(57);
120 uint64_t addrv :BIT1(58);
121 uint64_t miscv :BIT1(59);
122 uint64_t en :BIT1(60);
123 uint64_t uc :BIT1(61);
124 uint64_t over :BIT1(62);
125 uint64_t val :BIT1(63);
126 } bits;
127 struct { /* Variant if threshold-based error status present: */
128 uint64_t mca_error :BITS(15,0);
129 uint64_t model_specific_error :BITS(31,16);
130 uint64_t other_information :BITS(52,32);
131 uint64_t threshold :BITS(54,53);
132 uint64_t pcc :BIT1(57);
133 uint64_t addrv :BIT1(58);
134 uint64_t miscv :BIT1(59);
135 uint64_t en :BIT1(60);
136 uint64_t uc :BIT1(61);
137 uint64_t over :BIT1(62);
138 uint64_t val :BIT1(63);
139 } bits_tes_p;
140 struct ia32_mc8_specific {
141 uint64_t channel_number :BITS(3,0);
142 uint64_t memory_operation :BITS(6,4);
143 uint64_t unused :BITS(15,7);
144 uint64_t read_ecc :BIT1(16);
145 uint64_t ecc_on_a_scrub :BIT1(17);
146 uint64_t write_parity :BIT1(18);
147 uint64_t redundant_memory :BIT1(19);
148 uint64_t sparing :BIT1(20);
149 uint64_t access_out_of_range :BIT1(21);
150 uint64_t address_parity :BIT1(23);
151 uint64_t byte_enable_parity :BIT1(24);
152 uint64_t reserved :BITS(37,25);
153 uint64_t cor_err_cnt :BITS(52,38);
154 } bits_mc8;
155 uint64_t u64;
156 } ia32_mci_status_t;
157
158 /* Values for threshold_status if mcg_tes_p == 1 and uc == 0 */
159 #define THRESHOLD_STATUS_NO_TRACKING 0
160 #define THRESHOLD_STATUS_GREEN 1
161 #define THRESHOLD_STATUS_YELLOW 2
162 #define THRESHOLD_STATUS_RESERVED 3
163
164 /* MC8 memory operations encoding: */
165 #define MC8_MMM_GENERIC 0
166 #define MC8_MMM_READ 1
167 #define MC8_MMM_WRITE 2
168 #define MC8_MMM_ADDRESS_COMMAND 3
169 #define MC8_MMM_RESERVED 4
170
171 typedef union {
172 struct {
173 uint64_t reserved1 :BITS(15,0);
174 uint64_t dimm :BITS(17,16);
175 uint64_t channel :BITS(19,18);
176 uint64_t reserved2 :BITS(31,20);
177 uint64_t syndrome :BITS(63,32);
178 } bits;
179 uint64_t u64;
180 } ia32_mc8_misc_t;
181
182 typedef uint64_t ia32_mci_addr_t;
183 typedef uint64_t ia32_mci_misc_t;
184
185 #define IA32_MCG_EAX (0x180)
186 #define IA32_MCG_EBX (0x181)
187 #define IA32_MCG_ECX (0x182)
188 #define IA32_MCG_EDX (0x183)
189 #define IA32_MCG_ESI (0x184)
190 #define IA32_MCG_EDI (0x185)
191 #define IA32_MCG_EBP (0x186)
192 #define IA32_MCG_ESP (0x187)
193 #define IA32_MCG_EFLAGS (0x188)
194 #define IA32_MCG_EIP (0x189)
195 #define IA32_MCG_MISC (0x18A)
196
197 #define IA32_MCG_RAX (0x180)
198 #define IA32_MCG_RBX (0x181)
199 #define IA32_MCG_RCX (0x182)
200 #define IA32_MCG_RDX (0x183)
201 #define IA32_MCG_RSI (0x184)
202 #define IA32_MCG_RDI (0x185)
203 #define IA32_MCG_RBP (0x186)
204 #define IA32_MCG_RSP (0x187)
205 #define IA32_MCG_RFLAGS (0x188)
206 #define IA32_MCG_RIP (0x189)
207 #define IA32_MCG_MISC (0x18A)
208 #define IA32_MCG_RESERVED1 (0x18B)
209 #define IA32_MCG_RESERVED2 (0x18C)
210 #define IA32_MCG_RESERVED3 (0x18D)
211 #define IA32_MCG_RESERVED4 (0x18E)
212 #define IA32_MCG_RESERVED5 (0x18F)
213 #define IA32_MCG_R8 (0x190)
214 #define IA32_MCG_R9 (0x191)
215 #define IA32_MCG_R10 (0x192)
216 #define IA32_MCG_R11 (0x193)
217 #define IA32_MCG_R12 (0x194)
218 #define IA32_MCG_R13 (0x195)
219 #define IA32_MCG_R14 (0x196)
220 #define IA32_MCG_R15 (0x197)
221
222 extern void mca_cpu_alloc(cpu_data_t *cdp);
223 extern void mca_cpu_init(void);
224 extern void mca_dump(void);
225 extern void mca_check_save(void);
226 extern boolean_t mca_is_cmci_present(void);
227
228 #endif /* _I386_MACHINE_CHECK_H_ */
229 #endif /* KERNEL_PRIVATE */