blob: 92dfc6fd479946b2fecc8a9e2f0248973943a4bb [file] [log] [blame]
Tony Lee6c595012019-06-19 10:54:59 +08001#pragma once
2
Tony Lee6c595012019-06-19 10:54:59 +08003#include <sdbusplus/bus.hpp>
Tony Lee6c595012019-06-19 10:54:59 +08004#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
5#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
6#include <xyz/openbmc_project/Sensor/Value/server.hpp>
Potin Lai76f455e2022-09-22 00:11:26 +08007#include <xyz/openbmc_project/State/Decorator/Availability/server.hpp>
Tony Lee6c595012019-06-19 10:54:59 +08008
9namespace phosphor
10{
11namespace nvme
12{
13
14using ValueIface = sdbusplus::xyz::openbmc_project::Sensor::server::Value;
15
16using CriticalInterface =
17 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Critical;
18
19using WarningInterface =
20 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning;
21
Potin Lai76f455e2022-09-22 00:11:26 +080022using AvailabilityInterface =
23 sdbusplus::xyz::openbmc_project::State::Decorator::server::Availability;
24
25using NvmeIfaces =
26 sdbusplus::server::object_t<ValueIface, CriticalInterface, WarningInterface,
27 AvailabilityInterface>;
Tony Lee6c595012019-06-19 10:54:59 +080028
29class NvmeSSD : public NvmeIfaces
30{
31 public:
32 NvmeSSD() = delete;
33 NvmeSSD(const NvmeSSD&) = delete;
34 NvmeSSD& operator=(const NvmeSSD&) = delete;
35 NvmeSSD(NvmeSSD&&) = delete;
36 NvmeSSD& operator=(NvmeSSD&&) = delete;
37 virtual ~NvmeSSD() = default;
38
39 /** @brief Constructs NvmeSSD
40 *
41 * @param[in] bus - Handle to system dbus
42 * @param[in] objPath - The Dbus path of nvme
43 */
Patrick Williams7ce68bc2022-07-22 19:26:55 -050044 NvmeSSD(sdbusplus::bus_t& bus, const char* objPath) :
Tony Lee6c595012019-06-19 10:54:59 +080045 NvmeIfaces(bus, objPath), bus(bus)
46 {
Potin Lai5c4de832022-03-04 13:19:17 +080047 ValueIface::unit(Unit::DegreesC);
Tony Lee6c595012019-06-19 10:54:59 +080048 }
49
50 /** @brief Set sensor value temperature to nvme D-bus */
51 void setSensorValueToDbus(const int8_t value);
52 /** @brief Check if sensor value higher or lower threshold */
53 void checkSensorThreshold();
54 /** @brief Set Sensor Threshold to D-bus at beginning */
55 void setSensorThreshold(int8_t criticalHigh, int8_t criticalLow,
Tony Lee6c595012019-06-19 10:54:59 +080056 int8_t warningHigh, int8_t warningLow);
George Hung831f2042021-05-19 17:02:29 +080057 /** @brief Set Sensor Max/Min value to D-bus at beginning */
58 void setSensorMaxMin(int8_t maxValue, int8_t minValue);
Potin Lai76f455e2022-09-22 00:11:26 +080059 /** @brief Set Sensor Availability to D-bus */
60 void setSensorAvailability(bool avail);
Tony Lee6c595012019-06-19 10:54:59 +080061
62 private:
Patrick Williams7ce68bc2022-07-22 19:26:55 -050063 sdbusplus::bus_t& bus;
Tony Lee6c595012019-06-19 10:54:59 +080064};
65} // namespace nvme
Brandon Kimd5838d12021-05-19 12:51:55 -070066} // namespace phosphor