summaryrefslogtreecommitdiffstats
path: root/sensorhandler.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'sensorhandler.hpp')
-rw-r--r--sensorhandler.hpp67
1 files changed, 24 insertions, 43 deletions
diff --git a/sensorhandler.hpp b/sensorhandler.hpp
index 954a3ed..8780235 100644
--- a/sensorhandler.hpp
+++ b/sensorhandler.hpp
@@ -2,6 +2,7 @@
#include <stdint.h>
+#include <exception>
#include <ipmid/api.hpp>
#include <ipmid/types.hpp>
@@ -38,6 +39,16 @@ enum ipmi_sensor_types
IPMI_SENSOR_TPM = 0xCC,
};
+/** @brief Custom exception for reading sensors that are not funcitonal.
+ */
+struct SensorFunctionalError : public std::exception
+{
+ const char* what() const noexcept
+ {
+ return "Sensor not functional";
+ }
+};
+
#define MAX_DBUS_PATH 128
struct dbus_interface_t
{
@@ -79,11 +90,7 @@ ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
ipmi_data_len_t data_len, ipmi_context_t context);
-ipmi_ret_t ipmi_sen_reserve_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
- ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t data_len,
- ipmi_context_t context);
+ipmi::RspType<uint16_t> ipmiSensorReserveSdr();
static const uint16_t FRU_RECORD_ID_START = 256;
static const uint16_t ENTITY_RECORD_ID_START = 512;
@@ -106,34 +113,6 @@ inline bool get_count(void* req)
return (bool)((uint64_t)(req)&1);
}
} // namespace request
-
-namespace response
-{
-#define SDR_INFO_RESP_SIZE 2
-inline void set_lun_present(int lun, uint8_t* resp)
-{
- *resp |= 1 << lun;
-}
-inline void set_lun_not_present(int lun, uint8_t* resp)
-{
- *resp &= ~(1 << lun);
-}
-inline void set_dynamic_population(uint8_t* resp)
-{
- *resp |= 1 << 7;
-}
-inline void set_static_population(uint8_t* resp)
-{
- *resp &= ~(1 << 7);
-}
-} // namespace response
-
-struct GetSdrInfoResp
-{
- uint8_t count;
- uint8_t luns_and_dynamic_population;
-};
-
} // namespace get_sdr_info
/**
@@ -155,7 +134,7 @@ struct GetSdrReq
namespace request
{
-inline uint8_t get_reservation_id(GetSdrReq* req)
+inline uint16_t get_reservation_id(GetSdrReq* req)
{
return (req->reservation_id_lsb + (req->reservation_id_msb << 8));
};
@@ -665,15 +644,15 @@ namespace sensor
* @param[in] offset - offset number.
* @param[in/out] resp - get sensor reading response.
*/
-inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp)
+inline void setOffset(uint8_t offset, ipmi::sensor::GetSensorResponse* resp)
{
if (offset > 7)
{
- resp->assertOffset8_14 |= 1 << (offset - 8);
+ resp->discreteReadingSensorStates |= 1 << (offset - 8);
}
else
{
- resp->assertOffset0_7 |= 1 << offset;
+ resp->thresholdLevelsStates |= 1 << offset;
}
}
@@ -683,7 +662,7 @@ inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp)
* @param[in] offset - offset number.
* @param[in/out] resp - get sensor reading response.
*/
-inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp)
+inline void setReading(uint8_t value, ipmi::sensor::GetSensorResponse* resp)
{
resp->reading = value;
}
@@ -696,10 +675,10 @@ inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp)
* @param[in/out] resp - get sensor reading response.
*/
inline void setAssertionBytes(uint16_t value,
- ipmi::sensor::GetReadingResponse* resp)
+ ipmi::sensor::GetSensorResponse* resp)
{
- resp->assertOffset0_7 = static_cast<uint8_t>(value & 0x00FF);
- resp->assertOffset8_14 = static_cast<uint8_t>(value >> 8);
+ resp->thresholdLevelsStates = static_cast<uint8_t>(value & 0x00FF);
+ resp->discreteReadingSensorStates = static_cast<uint8_t>(value >> 8);
}
/**
@@ -707,9 +686,11 @@ inline void setAssertionBytes(uint16_t value,
*
* @param[in/out] resp - get sensor reading response.
*/
-inline void enableScanning(ipmi::sensor::GetReadingResponse* resp)
+inline void enableScanning(ipmi::sensor::GetSensorResponse* resp)
{
- resp->operation = 1 << 6;
+ resp->readingOrStateUnavailable = false;
+ resp->scanningEnabled = true;
+ resp->allEventMessagesEnabled = false;
}
} // namespace sensor
OpenPOWER on IntegriCloud