blob: ef30779650c620a9bb8206857e29d2eab6481df2 [file] [log] [blame]
Chris Austenac4604a2015-10-13 12:43:27 -05001#ifndef __HOST_IPMI_SEN_HANDLER_H__
2#define __HOST_IPMI_SEN_HANDLER_H__
3
Chris Austen0012e9b2015-10-22 01:37:46 -05004#include <stdint.h>
5
Chris Austenac4604a2015-10-13 12:43:27 -05006// IPMI commands for net functions.
7enum ipmi_netfn_sen_cmds
8{
Emily Shafferd06e0e72017-04-05 09:08:57 -07009 IPMI_CMD_GET_SDR_INFO = 0x20,
Chris Austen10ccc0f2015-12-10 18:27:04 -060010 IPMI_CMD_GET_SENSOR_READING = 0x2D,
Emily Shafferd06e0e72017-04-05 09:08:57 -070011 IPMI_CMD_GET_SENSOR_TYPE = 0x2F,
12 IPMI_CMD_SET_SENSOR = 0x30,
Chris Austenac4604a2015-10-13 12:43:27 -050013};
14
Emily Shaffer1fabf222017-04-05 08:53:21 -070015// Discrete sensor types.
16enum ipmi_sensor_types
17{
18 IPMI_SENSOR_TEMP = 0x01,
19 IPMI_SENSOR_VOLTAGE = 0x02,
20 IPMI_SENSOR_CURRENT = 0x03,
21 IPMI_SENSOR_FAN = 0x04,
22};
23
Chris Austen0012e9b2015-10-22 01:37:46 -050024#define MAX_DBUS_PATH 128
25struct dbus_interface_t {
26 uint8_t sensornumber;
27 uint8_t sensortype;
28
29 char bus[MAX_DBUS_PATH];
30 char path[MAX_DBUS_PATH];
31 char interface[MAX_DBUS_PATH];
32};
Tomd700e762016-09-20 18:24:13 +053033
34int set_sensor_dbus_state_s(uint8_t , const char *, const char *);
35int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t);
Emily Shaffer2ae09b92017-04-05 15:09:41 -070036int find_openbmc_path(uint8_t , dbus_interface_t *);
Tom05732372016-09-06 17:21:23 +053037
Tom Josephbe703f72017-03-09 12:34:35 +053038/**
39 * @struct SetSensorReadingReq
40 *
41 * IPMI Request data for Set Sensor Reading and Event Status Command
42 */
43struct SetSensorReadingReq
44{
45 uint8_t number;
46 uint8_t operation;
47 uint8_t reading;
48 uint8_t assertOffset0_7;
49 uint8_t assertOffset8_14;
50 uint8_t deassertOffset0_7;
51 uint8_t deassertOffset8_14;
52 uint8_t eventData1;
53 uint8_t eventData2;
54 uint8_t eventData3;
55} __attribute__((packed));
56
Emily Shafferd06e0e72017-04-05 09:08:57 -070057/**
58 * Get SDR Info
59 */
60
61namespace get_sdr_info
62{
63namespace request
64{
65// Note: for some reason the ipmi_request_t appears to be the
66// raw value for this call.
67inline bool get_count(void* req)
68{
69 return (bool)((uint64_t)(req) & 1);
70}
71} // namespace request
72
73namespace response
74{
75#define SDR_INFO_RESP_SIZE 2
76inline void set_lun_present(int lun, uint8_t* resp)
77{
78 *resp |= 1 << lun;
79}
80inline void set_lun_not_present(int lun, uint8_t* resp)
81{
82 *resp &= ~(1 << lun);
83}
84inline void set_dynamic_population(uint8_t* resp)
85{
86 *resp |= 1 << 7;
87}
88inline void set_static_population(uint8_t* resp)
89{
90 *resp &= ~(1 << 7);
91}
92} // namespace response
93
94struct GetSdrInfoResp
95{
96 uint8_t count;
97 uint8_t luns_and_dynamic_population;
98};
99
100} // namespace get_sdr_info
Chris Austenac4604a2015-10-13 12:43:27 -0500101#endif