OpenBIC
OpenSource Bridge-IC
sdr.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SDR_H
18#define SDR_H
19
20#include <stdbool.h>
21#include <stdint.h>
22
23/* SDR definition follow IPMI specification V2 */
24
25#define IPMI_SDR_VER_15 0x51
26
27#define IPMI_SDR_FULL_SENSOR 0x01
28#define IPMI_SDR_COMPACT_SENSOR 0x02
29#define IPMI_SDR_EVENT_ONLY 0x03
30
31#define IPMI_SDR_HEADER_LEN 5
32#define IPMI_SDR_FULL_SENSOR_MIN_LEN 43
33#define IPMI_SDR_COMPACT_SENSOR_MIN_LEN 27
34#define IPMI_SDR_EVENT_SENSOR_MIN_LEN 12
35#define IPMI_SDR_FRU_SENSOR_MIN_LEN 11
36#define IPMI_SDR_MC_SENSOR_MIN_LEN 11
37
38/* Entity IDs, see IPMI spec 43.14, table 43-13 */
39#define IPMI_SDR_ENTITY_ID_OTHER 0x01
40#define IPMI_SDR_ENTITY_ID_UNKNOWN 0x02
41#define IPMI_SDR_ENTITY_ID_PROCESSOR 0x03
42#define IPMI_SDR_ENTITY_ID_DISK 0x04
43#define IPMI_SDR_ENTITY_ID_SYS_MGT_MOD 0x06
44#define IPMI_SDR_ENTITY_ID_SYS_BOARD 0x07
45#define IPMI_SDR_ENTITY_ID_MEM_MODULE 0x08
46#define IPMI_SDR_ENTITY_ID_POWER_SUPPLY 0x0A
47#define IPMI_SDR_ENTITY_ID_ADDIN_CARD 0x0B
48#define IPMI_SDR_ENTITY_ID_FRONT_PANEL 0x0C
49#define IPMI_SDR_ENTITY_ID_BACK_PANEL 0x0D
50#define IPMI_SDR_ENTITY_ID_POWER_SYSTEM_BOARD 0x0E
51#define IPMI_SDR_ENTITY_ID_BACKPLANE 0x0F
52#define IPMI_SDR_ENTITY_ID_INTERNAL_EXPANSION_BOARD 0x10
53#define IPMI_SDR_ENTITY_ID_OTHER_SYSTEM_BOARD 0x11
54#define IPMI_SDR_ENTITY_ID_PROCESSOR_BOARD 0x12
55#define IPMI_SDR_ENTITY_ID_POWER_UNIT 0x13
56#define IPMI_SDR_ENTITY_ID_POWER_MODULE 0x14
57#define IPMI_SDR_ENTITY_ID_PDB 0x15
58#define IPMI_SDR_ENTITY_ID_CHASSIS_BACK_PANEL_BOARD 0x16
59#define IPMI_SDR_ENTITY_ID_SYS_CHASSIS 0x17
60#define IPMI_SDR_ENTITY_ID_FAN_DEVICE 0x1D
61#define IPMI_SDR_ENTITY_ID_MEMORY 0x20
62#define IPMI_SDR_ENTITY_ID_SYS_FW 0x22
63#define IPMI_SDR_ENTITY_ID_OS 0x23
64#define IPMI_SDR_ENTITY_ID_SYS_BUS 0x24
65#define IPMI_SDR_ENTITY_ID_BATTERY 0x28
66#define IPMI_SDR_ENTITY_ID_IO_MODULE 0x2C
67#define IPMI_SDR_ENTITY_ID_PROCESSOR_IO 0x2D
68#define IPMI_SDR_ENTITY_ID_MC_FW 0x2E
69#define IPMI_SDR_ENTITY_ID_PCI_BUS 0x30
70#define IPMI_SDR_ENTITY_ID_PCIE_BUS 0x31
71#define IPMI_SDR_ENTITY_ID_SCSI_BUS 0x32
72#define IPMI_SDR_ENTITY_ID_SATA_BUS 0x33
73#define IPMI_SDR_ENTITY_ID_FSB 0x34
74#define IPMI_SDR_ENTITY_ID_AIR_INLET 0x37
75#define IPMI_SDR_ENTITY_ID_PROCESSOR_DCMI 0x41
76#define IPMI_SDR_ENTITY_ID_SYS_BOARD_DCMI 0x42
77
78/* sensor type, see IPMI spec 42.2, table 42-3 */
79#define IPMI_SDR_SENSOR_TYPE_TEMPERATURE 0x01
80#define IPMI_SDR_SENSOR_TYPE_VOLTAGE 0x02
81#define IPMI_SDR_SENSOR_TYPE_CURRENT 0x03
82#define IPMI_SDR_SENSOR_TYPE_FAN 0x04
83#define IPMI_SDR_SENSOR_TYPE_PHY_SECURITY 0x05
84#define IPMI_SDR_SENSOR_TYPE_SECURITY_VIO 0x06
85#define IPMI_SDR_SENSOR_TYPE_PROCESSOR 0x07
86#define IPMI_SDR_SENSOR_TYPE_POWER_SUPPLY 0x08
87#define IPMI_SDR_SENSOR_TYPE_POWER_UNIT 0x09
88#define IPMI_SDR_SENSOR_TYPE_OTHER_UNIT_BASE 0x0B
89#define IPMI_SDR_SENSOR_TYPE_MEMORY 0x0C
90#define IPMI_SDR_SENSOR_TYPE_SYS_FW 0x0F
91#define IPMI_SDR_SENSOR_TYPE_EVENT_LOG 0x10
92#define IPMI_SDR_SENSOR_TYPE_SYS_EVENT 0x12
93#define IPMI_SDR_SENSOR_TYPE_CRITICAL_INT 0x13
94#define IPMI_SDR_SENSOR_TYPE_BUTTON 0x14
95#define IPMI_SDR_SENSOR_TYPE_BOOT_ERR 0x1E
96#define IPMI_SDR_SENSOR_TYPE_WATCHDOG2 0x23
97#define IPMI_SDR_SENSOR_TYPE_MANGE_HEALTH 0x28
98#define IPMI_SDR_SENSOR_TYPE_OEM 0xC0
99
100/* string type, see IPMI spec 43.15 */
101#define IPMI_SDR_STRING_TYPE_BCD 0x40
102#define IPMI_SDR_STRING_TYPE_ASCII_6 0x80
103#define IPMI_SDR_STRING_TYPE_ASCII_8 0xC0
104
105/* sensor unit type, see IPMI spec 43.17, table 43-15 */
106#define IPMI_SENSOR_UNIT_UNSPECIFIED 0x00
107#define IPMI_SENSOR_UNIT_DEGREE_C 0x01
108#define IPMI_SENSOR_UNIT_DEGREE_F 0x02
109#define IPMI_SENSOR_UNIT_DEGREE_K 0x03
110#define IPMI_SENSOR_UNIT_VOL 0x04
111#define IPMI_SENSOR_UNIT_AMP 0x05
112#define IPMI_SENSOR_UNIT_WATT 0x06
113#define IPMI_SENSOR_UNIT_RPM 0x12
114
115/* sensor initial, see IPMI spec 43.1, Full Sensor Record, byte 11 */
116#define IPMI_SDR_SENSOR_INIT_SETTABLE 0x80 /* bit 7 */
117#define IPMI_SDR_SENSOR_INIT_SCAN 0x40 /* bit 6 */
118#define IPMI_SDR_SENSOR_INIT_EVENT 0x20 /* bit 5 */
119#define IPMI_SDR_SENSOR_INIT_THRESHOLD 0x10 /* bit 4 */
120#define IPMI_SDR_SENSOR_INIT_HYSTERESIS 0x08 /* bit 3 */
121#define IPMI_SDR_SENSOR_INIT_TYPE 0x04 /* bit 2 */
122#define IPMI_SDR_SENSOR_INIT_DEF_EVENT 0x02 /* bit 1 */
123#define IPMI_SDR_SENSOR_INIT_DEF_SCAN 0x01 /* bit 0 */
124
125/* sensor capabilities, see IPMI spec 43.1, Full Sensor Record, byte 12 */
126#define IPMI_SDR_SENSOR_CAP_IGNORE 0x80 /* bit 7 */
127#define IPMI_SDR_SENSOR_CAP_AUTO_RE_ARM 0x40 /* bit 6 */
128#define IPMI_SDR_SENSOR_CAP_MANUAL_REARM 0x00 /* bit 6 */
129#define IPMI_SDR_SENSOR_CAP_HYSTERESIS_NO 0x00 /* bits[5:4], 00 */
130#define IPMI_SDR_SENSOR_CAP_HYSTERESIS_RO 0x10 /* bits[5:4], 01 */
131#define IPMI_SDR_SENSOR_CAP_HYSTERESIS_RW 0x20 /* bits[5:4], 10 */
132#define IPMI_SDR_SENSOR_CAP_HYSTERESIS_FIX 0x30 /* bits[5:4], 11 */
133#define IPMI_SDR_SENSOR_CAP_THRESHOLD_NO 0x00 /* bits[3:2], 00 */
134#define IPMI_SDR_SENSOR_CAP_THRESHOLD_RO 0x04 /* bits[3:2], 01 */
135#define IPMI_SDR_SENSOR_CAP_THRESHOLD_RW 0x08 /* bits[3:2], 10 */
136#define IPMI_SDR_SENSOR_CAP_THRESHOLD_FIX 0x0C /* bits[3:2], 11 */
137#define IPMI_SDR_SENSOR_CAP_EVENT_CTRL_BIT 0x00 /* bits[1:0], 00 */
138#define IPMI_SDR_SENSOR_CAP_EVENT_CTRL_ENTIRE 0x01 /* bits[1:0], 01 */
139#define IPMI_SDR_SENSOR_CAP_EVENT_CTRL_GLOBAL 0x02 /* bits[1:0], 10 */
140#define IPMI_SDR_SENSOR_CAP_EVENT_CTRL_NO 0x03 /* bits[1:0], 11 */
141
142/* event/reading type, see IPMI spec 42.1, table 42-1 */
143#define IPMI_SDR_EVENT_TYPE_THRESHOLD 0x01
144#define IPMI_SDR_EVENT_TYPE_USAGE 0x02
145#define IPMI_SDR_EVENT_TYPE_DEAS_ASSE 0x03
146#define IPMI_SDR_EVENT_TYPE_LIMIT_EXCEED 0x05
147#define IPMI_SDR_EVENT_TYPE_PERFORMANCE 0x06
148#define IPMI_SDR_EVENT_TYPE_SEVERITY 0x07
149#define IPMI_SDR_EVENT_TYPE_PRESENT 0x08
150#define IPMI_SDR_EVENT_TYPE_EN_DIS 0x09
151#define IPMI_SDR_EVENT_TYPE_DIS_REDUNDANCY 0x0B
152#define IPMI_SDR_EVENT_TYPE_SENSOR_SPEC 0x6F
153
154/* assertion event mask / lower threshold reading mask */
155#define IPMI_SDR_ASSERT_MASK_LNCT_LO 0x01 /* bit 0 */
156#define IPMI_SDR_ASSERT_MASK_LNCT_HI 0x02 /* bit 1 */
157#define IPMI_SDR_ASSERT_MASK_LCT_LO 0x04 /* bit 2 */
158#define IPMI_SDR_ASSERT_MASK_LCT_HI 0x08 /* bit 3 */
159#define IPMI_SDR_ASSERT_MASK_LNRT_LO 0x10 /* bit 4 */
160#define IPMI_SDR_ASSERT_MASK_LNRT_HI 0x20 /* bit 5 */
161#define IPMI_SDR_ASSERT_MASK_UNCT_LO 0x40 /* bit 6 */
162#define IPMI_SDR_ASSERT_MASK_UNCT_HI 0x80 /* bit 7 */
163
164#define IPMI_SDR_ASSERT_MASK_UCT_LO 0x01 /* bit 8 */
165#define IPMI_SDR_ASSERT_MASK_UCT_HI 0x02 /* bit 9 */
166#define IPMI_SDR_ASSERT_MASK_UNRT_LO 0x04 /* bit 10 */
167#define IPMI_SDR_ASSERT_MASK_UNRT_HI 0x08 /* bit 11 */
168#define IPMI_SDR_CMP_RETURN_LNCT 0x10 /* bit 12 */
169#define IPMI_SDR_CMP_RETURN_LCT 0x20 /* bit 13 */
170#define IPMI_SDR_CMP_RETURN_LNRT 0x40 /* bit 14 */
171
172/* deassertion event mask / upper threshold reading mask */
173#define IPMI_SDR_DEASSERT_MASK_LNCT_LO 0x01 /* bit 0 */
174#define IPMI_SDR_DEASSERT_MASK_LNCT_HI 0x02 /* bit 1 */
175#define IPMI_SDR_DEASSERT_MASK_LCT_LO 0x04 /* bit 2 */
176#define IPMI_SDR_DEASSERT_MASK_LCT_HI 0x08 /* bit 3 */
177#define IPMI_SDR_DEASSERT_MASK_LNRT_LO 0x10 /* bit 4 */
178#define IPMI_SDR_DEASSERT_MASK_LNRT_HI 0x20 /* bit 5 */
179#define IPMI_SDR_DEASSERT_MASK_UNCT_LO 0x40 /* bit 6 */
180#define IPMI_SDR_DEASSERT_MASK_UNCT_HI 0x80 /* bit 7 */
181
182#define IPMI_SDR_DEASSERT_MASK_UCT_LO 0x01 /* bit 8 */
183#define IPMI_SDR_DEASSERT_MASK_UCT_HI 0x02 /* bit 9 */
184#define IPMI_SDR_DEASSERT_MASK_UNRT_LO 0x04 /* bit 10 */
185#define IPMI_SDR_DEASSERT_MASK_UNRT_HI 0x08 /* bit 11 */
186#define IPMI_SDR_CMP_RETURN_UNCT 0x10 /* bit 12 */
187#define IPMI_SDR_CMP_RETURN_UCT 0x20 /* bit 13 */
188#define IPMI_SDR_CMP_RETURN_UNRT 0x40 /* bit 14 */
189
190/* settable/readable threshold moask */
191#define IPMI_SDR_LNCT_READABLE 0x01 /* bit 0 */
192#define IPMI_SDR_LCT_READABLE 0x02 /* bit 1 */
193#define IPMI_SDR_LNRT_READABLE 0x04 /* bit 2 */
194#define IPMI_SDR_UNCT_READABLE 0x08 /* bit 3 */
195#define IPMI_SDR_UCT_READABLE 0x10 /* bit 4 */
196#define IPMI_SDR_UNRT_READABLE 0x20 /* bit 5 */
197
198#define IPMI_SDR_LNCT_SETTABLE 0x01 /* bit 8 */
199#define IPMI_SDR_LCT_SETTABLE 0x02 /* bit 9 */
200#define IPMI_SDR_LNRT_SETTABLE 0x04 /* bit 10 */
201#define IPMI_SDR_UNCT_SETTABLE 0x08 /* bit 11 */
202#define IPMI_SDR_UCT_SETTABLE 0x10 /* bit 12 */
203#define IPMI_SDR_UNRT_SETTABLE 0x20 /* bit 13 */
204
205/* linearization */
206#define IPMI_SDR_LINEAR_LINEAR 0x00
207#define IPMI_SDR_LINEAR_LN 0x01
208#define IPMI_SDR_LINEAR_LOG10 0x02
209#define IPMI_SDR_LINEAR_LOG2 0x03
210#define IPMI_SDR_LINEAR_EXP 0x04
211#define IPMI_SDR_LINEAR_EXP10 0x05
212#define IPMI_SDR_LINEAR_EXP2 0x06
213#define IPMI_SDR_LINEAR_1_X 0x07
214#define IPMI_SDR_LINEAR_SQR 0x08
215#define IPMI_SDR_LINEAR_CUBE 0x09
216#define IPMI_SDR_LINEAR_SQRT 0x0A
217#define IPMI_SDR_LINEAR_CUBE_1 0x0B
218
219#define IPMI_NOR_READING_SPEC 0x01
220#define IPMI_NOR_MAX_SPEC 0x02
221#define IPMI_NOR_MIN_SPEC 0x04
222
223/* sensor direction */
224#define IPMI_SDR_SENSOR_DIREC_NO 0x00
225#define IPMI_SDR_SENSOR_DIREC_IN 0x40
226#define IPMI_SDR_SENSOR_DIREC_OUT 0x80
227
228/* ID string instance modifier type */
229#define IPMI_ID_STR_MODIFIER_NUM 0x00
230#define IPMI_ID_STR_MODIFIER_ALPHA 0x10
231
232/* ID entity instance sharing */
233#define IPMI_ENTIFY_INSTANCE_SHARE_SAME 0x00
234#define IPMI_ENTIFY_INSTANCE_SHARE_INC 0x80
235
236/* generic offset for IPMI_SDR_EVENT_TYPE_PRESENT */
237#define IPMI_SDR_EVENT_TYPE_ABS_PRES_ABSENT 0x01
238#define IPMI_SDR_EVENT_TYPE_ABS_PRES_PRESENT 0x02
239
240/* generic offset for IPMI_SDR_EVENT_TYPE_DEAS_ASSE */
241#define IPMI_SDR_EVENT_TYPE_STATE_DEASSERT 0x01
242#define IPMI_SDR_EVENT_TYPE_STATE_ASSERT 0x02
243
244/* generic offset for IPMI_SDR_EVENT_TYPE_DIS_REDUNDANCY */
245#define IPMI_SDR_EVENT_TYPE_FULL_REDUNDANCY 0x01
246#define IPMI_SDR_EVENT_TYPE_REDUNDANCY_LOST 0x02
247
248/* generic offset for IPMI_SDR_EVENT_TYPE_EN_DIS */
249#define IPMI_SDR_EVENT_TYPE_EN_DIS_DISABLE 0x01
250#define IPMI_SDR_EVENT_TYPE_EN_DIS_ENABLE 0x02
251
252/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_PROCESSOR */
253#define IPMI_SDR_SENSOR_SPEC_EVENT_PROCESSOR_IERR 0x01 /* bit 0 */
254#define IPMI_SDR_SENSOR_SPEC_EVENT_PROCESSOR_THERMAL_TRIP 0x02 /* bit 1 */
255#define IPMI_SDR_SENSOR_SPEC_EVENT_PROCESSOR_FRB1 0x04 /* bit 2 */
256#define IPMI_SDR_SENSOR_SPEC_EVENT_PROCESSOR_FRB2 0x08 /* bit 3 */
257#define IPMI_SDR_SENSOR_SPEC_EVENT_PROCESSOR_FRB3 0x10 /* bit 4 */
258#define IPMI_SDR_SENSOR_SPEC_EVENT_PROCESSOR_PRESENCE 0x80 /* bit 7 */
259#define IPMI_SDR_SENSOR_SPEC_EVENT_PROCESSOR_MCERR 0x08 /* bit 11 */ // Jerry130827
260
261/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_MEMORY */
262#define IPMI_SDR_SENSOR_SPEC_EVENT_MEMORY_CORRECT_ECC 0x01 /* bit 0 */
263#define IPMI_SDR_SENSOR_SPEC_EVENT_MEMORY_UNCORRECT_ECC 0x02 /* bit 1 */
264#define IPMI_SDR_SENSOR_SPEC_EVENT_MEMORY_PARITY 0x04 /* bit 2 */
265#define IPMI_SDR_SENSOR_SPEC_EVENT_MEMORY_ECC_LOG_LIMIT_REACH 0x20 /* bit 6*/ // brenden130924
266
267/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_POWER_SUPPLY */
268#define IPMI_SDR_EVENT_POWER_SUPPLY_PRESENCE 0x01 /* bit 0 */
269#define IPMI_SDR_EVENT_POWER_SUPPLY_FAILURE 0x02 /* bit 1 */
270#define IPMI_SDR_EVENT_POWER_SUPPLY_PRE_FAILURE 0x04 /* bit 2 */
271#define IPMI_SDR_EVENT_POWER_SUPPLY_INPUT_LOST 0x08 /* bit 3 */
272
273/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_POWER_UNIT */
274#define IPMI_SDR_SENSOR_SPEC_EVENT_POWER_UNIT_POWER_OFF 0x01 /* bit 0 */
275#define IPMI_SDR_SENSOR_SPEC_EVENT_POWER_UNIT_POWER_CYCLE 0x02 /* bit 1 */
276#define IPMI_SDR_SENSOR_SPEC_EVENT_POWER_UNIT_AC_LOST 0x10 /* bit 4 */
277
278/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_CRITICAL_INT */
279#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_FP_NMI 0x01 /* bit 0 */
280#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_SW_NMI 0x08 /* bit 3 */
281#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_PERR 0x10 /* bit 4 */
282#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_SERR 0x20 /* bit 5 */
283#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_NCERR 0x80 /* bit 7 */
284#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_NFERR 0x01 /* bit 8 */
285#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_FATAL_NMI 0x02 /* bit 9 */
286#define IPMI_SDR_SENSOR_SPEC_EVENT_CRITICAL_INT_FERR 0x04 /* bit 10 */
287
288/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_BUTTON */
289#define IPMI_SDR_SENSOR_SPEC_EVENT_BTN_POWER 0x01 /* bit 0 */
290#define IPMI_SDR_SENSOR_SPEC_EVENT_BTN_SELLP 0x02 /* bit 1 */
291#define IPMI_SDR_SENSOR_SPEC_EVENT_BTN_RESET 0x04 /* bit 2 */
292
293/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_WATCHDOG2 */
294#define IPMI_SDR_SENSOR_SPEC_EVENT_WDT2_EXPIRE 0x01 /* bit 0 */
295#define IPMI_SDR_SENSOR_SPEC_EVENT_WDT2_RESET 0x02 /* bit 1 */
296#define IPMI_SDR_SENSOR_SPEC_EVENT_WDT2_DOWN 0x04 /* bit 2 */
297#define IPMI_SDR_SENSOR_SPEC_EVENT_WDT2_CYCLE 0x08 /* bit 3 */
298#define IPMI_SDR_SENSOR_SPEC_EVENT_WDT2_INT 0x01 /* bit 8 */
299
300/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_BOOT_ERR */
301#define IPMI_SDR_SENSOR_SPEC_EVENT_BOOT_ERR_NO_MEDIA 0x01 /* bit 0 */
302#define IPMI_SDR_SENSOR_SPEC_EVENT_BOOT_ERR_NON_BOOTABLE 0x02 /* bit 1 */
303#define IPMI_SDR_SENSOR_SPEC_EVENT_BOOT_ERR_PXE_NO 0x04 /* bit 2 */
304#define IPMI_SDR_SENSOR_SPEC_EVENT_BOOT_ERR_INVALID_SECTOR 0x08 /* bit 3 */
305#define IPMI_SDR_SENSOR_SPEC_EVENT_BOOT_ERR_TIMEOUT 0x10 /* bit 4 */
306
307/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_SYS_FW */
308#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_FW_POST_ERR 0x01 /* bit 0 */
309#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_FW_HANG 0x02 /* bit 1 */
310#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_FW_PROGRESS 0x04 /* bit 2 */
311
312/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_EVENT_LOG */
313#define IPMI_SDR_SENSOR_SPEC_EVENT_LOG_MEM_ERR_DIS 0x01 /* bit 0 */
314#define IPMI_SDR_SENSOR_SPEC_EVENT_LOG_TYPE_DIS 0x02 /* bit 1 */
315#define IPMI_SDR_SENSOR_SPEC_EVENT_LOG_CLEAR 0x04 /* bit 2 */
316#define IPMI_SDR_SENSOR_SPEC_EVENT_LOG_ALL_DIS 0x08 /* bit 3 */
317#define IPMI_SDR_SENSOR_SPEC_EVENT_LOG_SEL_FULL 0x10 /* bit 4 */
318#define IPMI_SDR_SENSOR_SPEC_EVENT_LOG_SEL_ALMOST_FULL 0x20 /* bit 5 */
319
320/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_SYS_EVENT */
321#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_EVENT_RECONFIG 0x01 /* bit 0 */
322#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_EVENT_OEM 0x02 /* bit 1 */
323#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_EVENT_HW_FAIL 0x04 /* bit 2 */
324#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_EVENT_ADD_AUXI 0x08 /* bit 3 */
325#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_EVENT_PEF 0x10 /* bit 4 */
326#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_EVENT_CLOCK 0x20 /* bit 5 */
327
328/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_PHY_SECURITY */
329#define IPMI_SDR_SENSOR_SPEC_EVENT_PHYSICAL_SECURITY_CHASSIS 0x01 /* bit 0 */
330
331/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_MANAGEMENT */ // Jerry130723 SEL BMC Watchdog timeout
332#define IPMI_SDR_SENSOR_SPEC_EVENT_MANAGEMENT_UNAVAILABLE 0x08 /* bit 3 */
333
334/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_CPU_DIMM_HOT */
335#define IPMI_SDR_SENSOR_SPEC_EVENT_CPU_HOT 0x01 /* bit 0 */
336#define IPMI_SDR_SENSOR_SPEC_EVENT_DIMM_HOT 0x02 /* bit 1 */
337
338/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_CPU_DIMM_VR_HOT */
339#define IPMI_SDR_SENSOR_SPEC_EVENT_CPU_VR_HOT 0x01 /* bit 0 */
340#define IPMI_SDR_SENSOR_SPEC_EVENT_DIMM_AB_VR_HOT 0x02 /* bit 1 */
341#define IPMI_SDR_SENSOR_SPEC_EVENT_DIMM_DE_VR_HOT 0x04 /* bit 2 */
342
343/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_SYS_STA */
344#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_THERMAL_TRIP 0x01 /* bit 0 */
345#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_FIVR_FAULT 0x02 /* bit 1 */
346#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_THROTTLE 0x04 /* bit 2 */
347#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_PCHHOT 0x08 /* bit 3 */
348#define IPMI_SDR_SENSOR_SPEC_EVENT_FM_THROT 0x10 /* bit 4 */
349#define IPMI_SDR_SENSOR_SPEC_EVENT_FAST_THROT 0x20 /* bit 5 */
350#define IPMI_SDR_SENSOR_SPEC_EVENT_PMBUS_ALERT 0x40 /* bit 6 */
351
352/* sensor-specific offset for IPMI_SDR_SENSOR_TYPE_SYS_BOOT_STA */
353#define IPMI_SDR_SENSOR_SPEC_EVENT_SLP_S4 0x01 /* bit 0 */
354#define IPMI_SDR_SENSOR_SPEC_EVENT_SLP_S3 0x02 /* bit 1 */
355#define IPMI_SDR_SENSOR_SPEC_EVENT_PCH_PWROK 0x04 /* bit 2 */
356#define IPMI_SDR_SENSOR_SPEC_EVENT_SYS_PWROK 0x08 /* bit 3 */
357#define IPMI_SDR_SENSOR_SPEC_EVENT_PLTRST 0x10 /* bit 4 */
358#define IPMI_SDR_SENSOR_SPEC_EVENT_POST_CLT 0x20 /* bit 5 */
359
360#define SDR_END_ID 0xFFFF
361#define SDR_INVALID_ID 0xFFFE
362#define MAX_SDR_SENSOR_NAME_LEN 32
363
367};
368
369typedef struct _SDR_Full_sensor_ {
370 /*** sensor record header ***/
371 uint8_t record_id_h; /* Record ID high byte */
372 uint8_t record_id_l; /* Record ID low byte */
373 uint8_t sdr_ver; /* SDR version */
374 uint8_t record_type; /* Record type */
375 uint8_t record_len; /* Record length */
376
377 /*** record key bytes ***/
378 uint8_t owner_id; /* 8 bit owner ID */
379 uint8_t owner_lun; /* [7:4] channel number, [3:2] LUN for write/read FRU commands, [1:0] sensor owner LUN */
380 uint8_t sensor_num; /* unique sensor number */
381
382 /*** record body bytes ***/
383 uint8_t entity_id; /* physical entity */
384 uint8_t entity_instance; /* instance number for entity */
385 uint8_t sensor_init; /* report how this sensor coms up on deivce power up or cold reset */
386 uint8_t sensor_capabilities; /* [6] auto re-arm support, [5:4] hysteresis support, [3:2] threshold access, [1:0] event message control support */
387 uint8_t sensor_type; /* sensor type, e.g. temperature, voltage, etc. */
388 uint8_t evt_read_type; /* event/Reading Type code */
389 uint8_t assert_evt_mask; /* assertion event mask */
390 uint8_t lower_thres_read_mask; /* low threshold reading mask */
391 uint8_t deassert_evt_mask; /* deassertion event mask */
392 uint8_t upper_thres_read_mask; /* upper threshold read mask */
393 uint8_t discrete_read_mask; /* discrete sensor read mask */
394 uint8_t discrete_thres_read_mask; /* [15:8] settable threshold mask, [7:0] readable threshold mask */
398 uint8_t linear;
399 uint8_t M;
400 uint8_t M_tolerance;
401 uint8_t B;
402 uint8_t B_accuracy;
403 uint8_t accuracy;
404 uint8_t RexpBexp; /* [7:4] R exp 4 bits, 2's completment, signed, [3:0] B exp 4 bits, 2's completment, signed */
407 uint8_t normal_max;
408 uint8_t normal_min;
411 uint8_t UNRT;
412 uint8_t UCT;
413 uint8_t UNCT;
414 uint8_t LNRT;
415 uint8_t LCT;
416 uint8_t LNCT;
419 uint8_t reserved0;
420 uint8_t reserved1;
421 uint8_t OEM;
422 uint8_t ID_len;
425
426typedef struct _SDR_INFO_ {
427 uint16_t start_ID;
428 uint16_t last_ID;
429 uint16_t current_ID;
431
432enum {
439 /* Follow the section 36.3 of IPMI spec,
440 * there are three parameters for sensor reading conversion formula.
441 * M: Signed integer constant multiplier
442 * B: Signed additive "offset"
443 * R: Signed Exponent
444 */
448};
449
450extern uint8_t sdr_count;
451extern bool is_sdr_not_init;
452// Mapping sensor number to sdr config index
453extern uint8_t sdr_index_map[];
455extern uint8_t sensor_config_size;
456extern const int negative_ten_power[16];
457#define SDR_M(sensor_num) \
458 (((full_sdr_table[sdr_index_map[sensor_num]].M_tolerance & 0xC0) << 2) | \
459 full_sdr_table[sdr_index_map[sensor_num]].M)
460#define SDR_R(sensor_num) ((full_sdr_table[sdr_index_map[sensor_num]].RexpBexp >> 4) & 0x0F)
461#define SDR_Rexp(sensor_num) negative_ten_power[SDR_R(sensor_num)]
462
463static inline uint8_t round_add(uint8_t sensor_num, int val)
464{
465 return (SDR_R(sensor_num) > 0) ?
466 (((negative_ten_power[((SDR_R(sensor_num) + 1) & 0xF)] * val) % 10) > 5 ?
467 1 :
468 0) :
469 0;
470}
471
472uint16_t SDR_get_record_ID(uint16_t current_ID);
473bool SDR_check_record_ID(uint16_t current_ID);
474uint16_t SDR_get_RSV_ID(uint8_t rsv_table_index);
475bool SDR_RSV_ID_check(uint16_t ID, uint8_t rsv_table_index);
476uint8_t sdr_init(void);
480void change_sensor_threshold(uint8_t sensor_num, uint8_t threshold_type, uint8_t change_value);
481void change_sensor_mbr(uint8_t sensor_num, uint8_t mbr_type, uint16_t change_value);
482uint8_t plat_get_sdr_size();
483void load_sdr_table(void);
484
485#endif
uint32_t val
Definition: plat_util.c:40
bool SDR_check_record_ID(uint16_t current_ID)
Definition: sdr.c:58
bool SDR_RSV_ID_check(uint16_t ID, uint8_t rsv_table_index)
Definition: sdr.c:72
void change_sensor_threshold(uint8_t sensor_num, uint8_t threshold_type, uint8_t change_value)
Definition: sdr.c:127
const int negative_ten_power[16]
Definition: sensor.c:61
struct _SDR_Full_sensor_ SDR_Full_sensor
#define MAX_SDR_SENSOR_NAME_LEN
Definition: sdr.h:362
uint16_t SDR_get_RSV_ID(uint8_t rsv_table_index)
Definition: sdr.c:67
uint8_t plat_get_sdr_size()
Definition: sdr.c:239
void pal_fix_full_sdr_table(void)
SDR_Full_sensor * full_sdr_table
Definition: sdr.c:36
uint8_t sdr_index_map[]
Definition: sensor.c:54
void load_sdr_table(void)
Definition: sdr.c:244
rsv_table_index
Definition: sdr.h:364
@ RSV_TABLE_INDEX_0
Definition: sdr.h:365
@ RSV_TABLE_INDEX_1
Definition: sdr.h:366
@ THRESHOLD_LNC
Definition: sdr.h:438
@ MBR_R
Definition: sdr.h:447
@ THRESHOLD_LCR
Definition: sdr.h:437
@ THRESHOLD_UNC
Definition: sdr.h:435
@ THRESHOLD_LNR
Definition: sdr.h:436
@ THRESHOLD_UNR
Definition: sdr.h:433
@ MBR_M
Definition: sdr.h:445
@ THRESHOLD_UCR
Definition: sdr.h:434
@ MBR_B
Definition: sdr.h:446
uint8_t sdr_count
Definition: sdr.c:39
bool check_sdr_num_exist(uint8_t sensor_num)
uint16_t SDR_get_record_ID(uint16_t current_ID)
Definition: sdr.c:47
uint8_t sdr_init(void)
Definition: sdr.c:204
void change_sensor_mbr(uint8_t sensor_num, uint8_t mbr_type, uint16_t change_value)
Definition: sdr.c:165
struct _SDR_INFO_ SDR_INFO
#define SDR_R(sensor_num)
Definition: sdr.h:460
uint8_t sensor_config_size
Definition: sdr.c:38
bool is_sdr_not_init
Definition: sdr.c:31
void add_full_sdr_table(SDR_Full_sensor add_item)
Definition: sdr.c:101
uint8_t sensor_num
Definition: storage_handler.h:6
Definition: sdr.h:369
uint8_t ID_len
Definition: sdr.h:422
uint8_t record_id_h
Definition: sdr.h:371
uint8_t owner_id
Definition: sdr.h:378
uint8_t deassert_evt_mask
Definition: sdr.h:391
uint8_t normal_min
Definition: sdr.h:408
uint8_t lower_thres_read_mask
Definition: sdr.h:390
uint8_t entity_instance
Definition: sdr.h:384
uint8_t positive_going_thres
Definition: sdr.h:417
uint8_t sensor_capabilities
Definition: sdr.h:386
uint8_t sensor_unit3
Definition: sdr.h:397
uint8_t UNCT
Definition: sdr.h:413
uint8_t UCT
Definition: sdr.h:412
uint8_t upper_thres_read_mask
Definition: sdr.h:392
uint8_t OEM
Definition: sdr.h:421
uint8_t nominal_read
Definition: sdr.h:406
uint8_t sensor_unit1
Definition: sdr.h:395
uint8_t analog_char_flag
Definition: sdr.h:405
uint8_t ID_str[MAX_SDR_SENSOR_NAME_LEN]
Definition: sdr.h:423
uint8_t sensor_max_read
Definition: sdr.h:409
uint8_t discrete_read_mask
Definition: sdr.h:393
uint8_t sensor_init
Definition: sdr.h:385
uint8_t accuracy
Definition: sdr.h:403
uint8_t normal_max
Definition: sdr.h:407
uint8_t discrete_thres_read_mask
Definition: sdr.h:394
uint8_t B_accuracy
Definition: sdr.h:402
uint8_t negative_going_thres
Definition: sdr.h:418
uint8_t record_len
Definition: sdr.h:375
uint8_t UNRT
Definition: sdr.h:411
uint8_t reserved1
Definition: sdr.h:420
uint8_t sensor_num
Definition: sdr.h:380
uint8_t record_id_l
Definition: sdr.h:372
uint8_t LCT
Definition: sdr.h:415
uint8_t sensor_unit2
Definition: sdr.h:396
uint8_t sdr_ver
Definition: sdr.h:373
uint8_t M
Definition: sdr.h:399
uint8_t assert_evt_mask
Definition: sdr.h:389
uint8_t owner_lun
Definition: sdr.h:379
uint8_t LNCT
Definition: sdr.h:416
uint8_t sensor_type
Definition: sdr.h:387
uint8_t LNRT
Definition: sdr.h:414
uint8_t RexpBexp
Definition: sdr.h:404
uint8_t linear
Definition: sdr.h:398
uint8_t record_type
Definition: sdr.h:374
uint8_t entity_id
Definition: sdr.h:383
uint8_t reserved0
Definition: sdr.h:419
uint8_t sensor_min_read
Definition: sdr.h:410
uint8_t M_tolerance
Definition: sdr.h:400
uint8_t B
Definition: sdr.h:401
uint8_t evt_read_type
Definition: sdr.h:388
Definition: sdr.h:426
uint16_t last_ID
Definition: sdr.h:428
uint16_t current_ID
Definition: sdr.h:429
uint16_t start_ID
Definition: sdr.h:427