1 /*
2 * UEFI Common Platform Error Record
3 *
4 * Copyright (C) 2010, Intel Corp.
5 * Author: Huang Ying <ying.huang@intel.com>
6 * Ported by: Liu, Jinsong <jinsong.liu@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef LINUX_CPER_H
22 #define LINUX_CPER_H
23
24 #include <xen/types.h>
25 #include <xen/string.h>
26
27 extern unsigned long get_sec(void);
28
29 typedef struct {
30 __u8 b[16];
31 } uuid_le;
32
uuid_le_cmp(const uuid_le u1,const uuid_le u2)33 static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
34 {
35 return memcmp(&u1, &u2, sizeof(uuid_le));
36 }
37
cper_next_record_id(void)38 static inline u64 cper_next_record_id(void)
39 {
40 static u64 record_id;
41
42 if (!record_id)
43 record_id = (u64)get_sec() << 32;
44
45 return ++record_id;
46 }
47
48 #define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
49 ((uuid_le) \
50 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
51 (b) & 0xff, ((b) >> 8) & 0xff, \
52 (c) & 0xff, ((c) >> 8) & 0xff, \
53 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
54
55 /* CPER record signature and the size */
56 #define CPER_SIG_RECORD "CPER"
57 #define CPER_SIG_SIZE 4
58 /* Used in signature_end field in struct cper_record_header */
59 #define CPER_SIG_END 0xffffffff
60
61 /*
62 * CPER record header revision, used in revision field in struct
63 * cper_record_header
64 */
65 #define CPER_RECORD_REV 0x0100
66
67 /*
68 * Severity difinition for error_severity in struct cper_record_header
69 * and section_severity in struct cper_section_descriptor
70 */
71 #define CPER_SER_RECOVERABLE 0x0
72 #define CPER_SER_FATAL 0x1
73 #define CPER_SER_CORRECTED 0x2
74 #define CPER_SER_INFORMATIONAL 0x3
75
76 /*
77 * Notification type used to generate error record, used in
78 * notification_type in struct cper_record_header
79 *
80 * Corrected Machine Check
81 */
82 #define CPER_NOTIFY_CMC \
83 UUID_LE(0x2DCE8BB1, 0xBDD7, 0x450e, 0xB9, 0xAD, 0x9C, 0xF4, \
84 0xEB, 0xD4, 0xF8, 0x90)
85 /* Corrected Platform Error */
86 #define CPER_NOTIFY_CPE \
87 UUID_LE(0x4E292F96, 0xD843, 0x4a55, 0xA8, 0xC2, 0xD4, 0x81, \
88 0xF2, 0x7E, 0xBE, 0xEE)
89 /* Machine Check Exception */
90 #define CPER_NOTIFY_MCE \
91 UUID_LE(0xE8F56FFE, 0x919C, 0x4cc5, 0xBA, 0x88, 0x65, 0xAB, \
92 0xE1, 0x49, 0x13, 0xBB)
93 /* PCI Express Error */
94 #define CPER_NOTIFY_PCIE \
95 UUID_LE(0xCF93C01F, 0x1A16, 0x4dfc, 0xB8, 0xBC, 0x9C, 0x4D, \
96 0xAF, 0x67, 0xC1, 0x04)
97 /* INIT Record (for IPF) */
98 #define CPER_NOTIFY_INIT \
99 UUID_LE(0xCC5263E8, 0x9308, 0x454a, 0x89, 0xD0, 0x34, 0x0B, \
100 0xD3, 0x9B, 0xC9, 0x8E)
101 /* Non-Maskable Interrupt */
102 #define CPER_NOTIFY_NMI \
103 UUID_LE(0x5BAD89FF, 0xB7E6, 0x42c9, 0x81, 0x4A, 0xCF, 0x24, \
104 0x85, 0xD6, 0xE9, 0x8A)
105 /* BOOT Error Record */
106 #define CPER_NOTIFY_BOOT \
107 UUID_LE(0x3D61A466, 0xAB40, 0x409a, 0xA6, 0x98, 0xF3, 0x62, \
108 0xD4, 0x64, 0xB3, 0x8F)
109 /* DMA Remapping Error */
110 #define CPER_NOTIFY_DMAR \
111 UUID_LE(0x667DD791, 0xC6B3, 0x4c27, 0x8A, 0x6B, 0x0F, 0x8E, \
112 0x72, 0x2D, 0xEB, 0x41)
113
114 /*
115 * Flags bits definitions for flags in struct cper_record_header
116 * If set, the error has been recovered
117 */
118 #define CPER_HW_ERROR_FLAGS_RECOVERED 0x1
119 /* If set, the error is for previous boot */
120 #define CPER_HW_ERROR_FLAGS_PREVERR 0x2
121 /* If set, the error is injected for testing */
122 #define CPER_HW_ERROR_FLAGS_SIMULATED 0x4
123
124 /*
125 * CPER section header revision, used in revision field in struct
126 * cper_section_descriptor
127 */
128 #define CPER_SEC_REV 0x0100
129
130 /*
131 * Validation bits difinition for validation_bits in struct
132 * cper_section_descriptor. If set, corresponding fields in struct
133 * cper_section_descriptor contain valid information.
134 *
135 * corresponds fru_id
136 */
137 #define CPER_SEC_VALID_FRU_ID 0x1
138 /* corresponds fru_text */
139 #define CPER_SEC_VALID_FRU_TEXT 0x2
140
141 /*
142 * Flags bits definitions for flags in struct cper_section_descriptor
143 *
144 * If set, the section is associated with the error condition
145 * directly, and should be focused on
146 */
147 #define CPER_SEC_PRIMARY 0x0001
148
149 /*
150 * All tables and structs must be byte-packed to match CPER
151 * specification, since the tables are provided by the system BIOS
152 */
153 #pragma pack(1)
154
155 struct cper_record_header {
156 char signature[CPER_SIG_SIZE]; /* must be CPER_SIG_RECORD */
157 __u16 revision; /* must be CPER_RECORD_REV */
158 __u32 signature_end; /* must be CPER_SIG_END */
159 __u16 section_count;
160 __u32 error_severity;
161 __u32 validation_bits;
162 __u32 record_length;
163 __u64 timestamp;
164 uuid_le platform_id;
165 uuid_le partition_id;
166 uuid_le creator_id;
167 uuid_le notification_type;
168 __u64 record_id;
169 __u32 flags;
170 __u64 persistence_information;
171 __u8 reserved[12]; /* must be zero */
172 };
173
174 struct cper_section_descriptor {
175 __u32 section_offset; /* Offset in bytes of the
176 * section body from the base
177 * of the record header */
178 __u32 section_length;
179 __u16 revision; /* must be CPER_RECORD_REV */
180 __u8 validation_bits;
181 __u8 reserved; /* must be zero */
182 __u32 flags;
183 uuid_le section_type;
184 uuid_le fru_id;
185 __u32 section_severity;
186 __u8 fru_text[20];
187 };
188
189 /* Reset to default packing */
190 #pragma pack()
191
192 #endif
193