]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/machine_check.h
xnu-1456.1.26.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 #include <stdint.h>
33
34 #include <i386/cpu_data.h>
35
36 /*
37 * This header defines the machine check architecture for Pentium4 and Xeon.
38 */
39
40 /*
41 * Macro BITS(n,m) returns the number of bits between bit(n) and bit(m),
42 * where (n>m). Macro BIT1(n) is cosmetic and returns 1.
43 */
44 #define BITS(n,m) ((n)-(m)+1)
45 #define BIT1(n) (1)
46
47 /*
48 * IA32 SDM 14.3.1 Machine-Check Global Control MSRs:
49 */
50 #define IA32_MCG_CAP (0x179)
51 typedef union {
52 struct {
53 uint64_t count :BITS(7,0);
54 uint64_t mcg_ctl_p :BIT1(8);
55 uint64_t mcg_ext_p :BIT1(9);
56 uint64_t mcg_ext_corr_err_p :BIT1(10);
57 uint64_t mcg_tes_p :BIT1(11);
58 uint64_t mcg_ecms :BIT1(12);
59 uint64_t mcg_reserved2 :BITS(15,13);
60 uint64_t mcg_ext_cnt :BITS(23,16);
61 } bits;
62 uint64_t u64;
63 } ia32_mcg_cap_t;
64
65 #define IA32_MCG_STATUS (0x17A)
66 typedef union {
67 struct {
68 uint64_t ripv :BIT1(0);
69 uint64_t eipv :BIT1(1);
70 uint64_t mcip :BIT1(2);
71 } bits;
72 uint64_t u64;
73 } ia32_mcg_status_t;
74
75 #define IA32_MCG_CTL (0x17B)
76 typedef uint64_t ia32_mcg_ctl_t;
77 #define IA32_MCG_CTL_ENABLE (0xFFFFFFFFFFFFFFFFULL)
78 #define IA32_MCG_CTL_DISABLE (0x0ULL)
79
80
81 /*
82 * IA32 SDM 14.3.2 Error-Reporting Register Banks:
83 */
84 #define IA32_MCi_CTL(i) (0x400 + 4*(i))
85 #define IA32_MCi_STATUS(i) (0x401 + 4*(i))
86 #define IA32_MCi_ADDR(i) (0x402 + 4*(i))
87 #define IA32_MCi_MISC(i) (0x403 + 4*(i))
88
89 #define IA32_MC0_CTL IA32_MCi_CTL(0)
90 #define IA32_MC0_STATUS IA32_MCi_STATUS(0)
91 #define IA32_MC0_ADDR IA32_MCi_ADDR(0)
92 #define IA32_MC0_MISC IA32_MCi_MISC(0)
93
94 #define IA32_MC1_CTL IA32_MCi_CTL(1)
95 #define IA32_MC1_STATUS IA32_MCi_STATUS(1)
96 #define IA32_MC1_ADDR IA32_MCi_ADDR(1)
97 #define IA32_MC1_MISC IA32_MCi_MISC(1)
98
99 #define IA32_MC2_CTL IA32_MCi_CTL(2)
100 #define IA32_MC2_STATUS IA32_MCi_STATUS(2)
101 #define IA32_MC2_ADDR IA32_MCi_ADDR(2)
102 #define IA32_MC2_MISC IA32_MCi_MISC(2)
103
104 #define IA32_MC3_CTL IA32_MCi_CTL(3)
105 #define IA32_MC3_STATUS IA32_MCi_STATUS(3)
106 #define IA32_MC3_ADDR IA32_MCi_ADDR(3)
107 #define IA32_MC3_MISC IA32_MCi_MISC(3)
108
109 #define IA32_MC4_CTL IA32_MCi_CTL(4)
110 #define IA32_MC4_STATUS IA32_MCi_STATUS(4)
111 #define IA32_MC4_ADDR IA32_MCi_ADDR(4)
112 #define IA32_MC4_MISC IA32_MCi_MISC(4)
113
114 typedef uint64_t ia32_mci_ctl_t;
115 #define IA32_MCi_CTL_EE(j) (0x1ULL << (j))
116 #define IA32_MCi_CTL_ENABLE_ALL (0xFFFFFFFFFFFFFFFFULL)
117
118 typedef union {
119 struct {
120 uint64_t mca_error :BITS(15,0);
121 uint64_t model_specific_error :BITS(31,16);
122 uint64_t other_information :BITS(56,32);
123 uint64_t pcc :BIT1(57);
124 uint64_t addrv :BIT1(58);
125 uint64_t miscv :BIT1(59);
126 uint64_t en :BIT1(60);
127 uint64_t uc :BIT1(61);
128 uint64_t over :BIT1(62);
129 uint64_t val :BIT1(63);
130 } bits;
131 struct { /* Variant if threshold-based error status present: */
132 uint64_t mca_error :BITS(15,0);
133 uint64_t model_specific_error :BITS(31,16);
134 uint64_t other_information :BITS(52,32);
135 uint64_t threshold :BITS(54,53);
136 uint64_t pcc :BIT1(57);
137 uint64_t addrv :BIT1(58);
138 uint64_t miscv :BIT1(59);
139 uint64_t en :BIT1(60);
140 uint64_t uc :BIT1(61);
141 uint64_t over :BIT1(62);
142 uint64_t val :BIT1(63);
143 } bits_tes_p;
144 struct ia32_mc8_specific {
145 uint64_t channel_number :BITS(3,0);
146 uint64_t memory_operation :BITS(6,4);
147 uint64_t unused :BITS(15,7);
148 uint64_t read_ecc :BIT1(16);
149 uint64_t ecc_on_a_scrub :BIT1(17);
150 uint64_t write_parity :BIT1(18);
151 uint64_t redundant_memory :BIT1(19);
152 uint64_t sparing :BIT1(20);
153 uint64_t access_out_of_range :BIT1(21);
154 uint64_t address_parity :BIT1(23);
155 uint64_t byte_enable_parity :BIT1(24);
156 uint64_t reserved :BITS(37,25);
157 uint64_t cor_err_cnt :BITS(52,38);
158 } bits_mc8;
159 uint64_t u64;
160 } ia32_mci_status_t;
161
162 /* Values for threshold_status if mcg_tes_p == 1 and uc == 0 */
163 #define THRESHOLD_STATUS_NO_TRACKING 0
164 #define THRESHOLD_STATUS_GREEN 1
165 #define THRESHOLD_STATUS_YELLOW 2
166 #define THRESHOLD_STATUS_RESERVED 3
167
168 /* MC8 memory operations encoding: */
169 #define MC8_MMM_GENERIC 0
170 #define MC8_MMM_READ 1
171 #define MC8_MMM_WRITE 2
172 #define MC8_MMM_ADDRESS_COMMAND 3
173 #define MC8_MMM_RESERVED 4
174 typedef union {
175 struct {
176 uint64_t reserved1 :BITS(15,0);
177 uint64_t dimm :BITS(17,16);
178 uint64_t channel :BITS(19,18);
179 uint64_t reserved2 :BITS(31,20);
180 uint64_t syndrome :BITS(63,32);
181 } bits;
182 uint64_t u64;
183 } ia32_mc8_misc_t;
184
185 typedef uint64_t ia32_mci_addr_t;
186 typedef uint64_t ia32_mci_misc_t;
187
188 #define IA32_MCG_EAX (0x180)
189 #define IA32_MCG_EBX (0x181)
190 #define IA32_MCG_ECX (0x182)
191 #define IA32_MCG_EDX (0x183)
192 #define IA32_MCG_ESI (0x184)
193 #define IA32_MCG_EDI (0x185)
194 #define IA32_MCG_EBP (0x186)
195 #define IA32_MCG_ESP (0x187)
196 #define IA32_MCG_EFLAGS (0x188)
197 #define IA32_MCG_EIP (0x189)
198 #define IA32_MCG_MISC (0x18A)
199
200 #define IA32_MCG_RAX (0x180)
201 #define IA32_MCG_RBX (0x181)
202 #define IA32_MCG_RCX (0x182)
203 #define IA32_MCG_RDX (0x183)
204 #define IA32_MCG_RSI (0x184)
205 #define IA32_MCG_RDI (0x185)
206 #define IA32_MCG_RBP (0x186)
207 #define IA32_MCG_RSP (0x187)
208 #define IA32_MCG_RFLAGS (0x188)
209 #define IA32_MCG_RIP (0x189)
210 #define IA32_MCG_MISC (0x18A)
211 #define IA32_MCG_RESERVED1 (0x18B)
212 #define IA32_MCG_RESERVED2 (0x18C)
213 #define IA32_MCG_RESERVED3 (0x18D)
214 #define IA32_MCG_RESERVED4 (0x18E)
215 #define IA32_MCG_RESERVED5 (0x18F)
216 #define IA32_MCG_R8 (0x190)
217 #define IA32_MCG_R9 (0x191)
218 #define IA32_MCG_R10 (0x192)
219 #define IA32_MCG_R11 (0x193)
220 #define IA32_MCG_R12 (0x194)
221 #define IA32_MCG_R13 (0x195)
222 #define IA32_MCG_R14 (0x196)
223 #define IA32_MCG_R15 (0x197)
224
225 extern void mca_cpu_alloc(cpu_data_t *cdp);
226 extern void mca_cpu_init(void);
227 extern void mca_dump(void);
228 extern void mca_check_save(void);
229 extern boolean_t mca_is_cmci_present(void);
230
231 #endif /* _I386_MACHINE_CHECK_H_ */
232 #endif /* KERNEL_PRIVATE */