diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2017-09-06 19:23:00 +0530 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2017-09-14 18:48:00 +0530 |
commit | 816e92b59fa52dcd997099a81e2f43a3512fca1e (patch) | |
tree | 7329e332662cc0a969fd8234b50bfbbbf2224899 /sensorhandler.h | |
parent | cc941e150007d56b2d7f2fc0c8248e6d74dd659d (diff) | |
download | phosphor-host-ipmid-816e92b59fa52dcd997099a81e2f43a3512fca1e.tar.gz phosphor-host-ipmid-816e92b59fa52dcd997099a81e2f43a3512fca1e.zip |
sensor: Add function to map dbus info to assertion status
Change-Id: I30aae9abd7905ae3299856d798d41e10859fed7f
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'sensorhandler.h')
-rw-r--r-- | sensorhandler.h | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/sensorhandler.h b/sensorhandler.h index 0b4c4e5..576c803 100644 --- a/sensorhandler.h +++ b/sensorhandler.h @@ -2,6 +2,7 @@ #define __HOST_IPMI_SEN_HANDLER_H__ #include <stdint.h> +#include "types.hpp" // IPMI commands for net functions. enum ipmi_netfn_sen_cmds @@ -39,25 +40,6 @@ int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t); int find_openbmc_path(uint8_t , dbus_interface_t *); /** - * @struct SetSensorReadingReq - * - * IPMI Request data for Set Sensor Reading and Event Status Command - */ -struct SetSensorReadingReq -{ - uint8_t number; - uint8_t operation; - uint8_t reading; - uint8_t assertOffset0_7; - uint8_t assertOffset8_14; - uint8_t deassertOffset0_7; - uint8_t deassertOffset8_14; - uint8_t eventData1; - uint8_t eventData2; - uint8_t eventData3; -} __attribute__((packed)); - -/** * Get SDR Info */ @@ -489,4 +471,35 @@ struct SensorDataFullRecord } __attribute__((packed)); } // get_sdr + +namespace ipmi +{ + +namespace sensor +{ + +/** + * @brief Map offset to the corresponding bit in the assertion byte. + * + * The discrete sensors support upto 14 states. 0-7 offsets are stored in one + * byte and offsets 8-14 in the second byte. + * + * @param[in] offset - offset number. + * @param[in/out] resp - get sensor reading response. + */ +inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp) +{ + if (offset > 7) + { + resp->assertOffset8_14 |= 1 << (offset - 8); + } + else + { + resp->assertOffset0_7 |= 1 << offset; + } +} + +} // namespace sensor + +} // namespace ipmi #endif |