blob: 64d279e50d107f86af6ca68907999ad2138e4c11 [file] [log] [blame]
Tony Lee6c595012019-06-19 10:54:59 +08001#pragma once
2
3#include "config.h"
4
5#include <sdbusplus/bus.hpp>
6#include <sdbusplus/server.hpp>
7#include <sdeventplus/clock.hpp>
8#include <sdeventplus/event.hpp>
9#include <sdeventplus/utility/timer.hpp>
10#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
11#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
12#include <xyz/openbmc_project/Sensor/Value/server.hpp>
13
14namespace phosphor
15{
16namespace nvme
17{
18
19using ValueIface = sdbusplus::xyz::openbmc_project::Sensor::server::Value;
20
21using CriticalInterface =
22 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Critical;
23
24using WarningInterface =
25 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning;
26
27using NvmeIfaces =
28 sdbusplus::server::object::object<ValueIface, CriticalInterface,
29 WarningInterface>;
30
31class NvmeSSD : public NvmeIfaces
32{
33 public:
34 NvmeSSD() = delete;
35 NvmeSSD(const NvmeSSD&) = delete;
36 NvmeSSD& operator=(const NvmeSSD&) = delete;
37 NvmeSSD(NvmeSSD&&) = delete;
38 NvmeSSD& operator=(NvmeSSD&&) = delete;
39 virtual ~NvmeSSD() = default;
40
41 /** @brief Constructs NvmeSSD
42 *
43 * @param[in] bus - Handle to system dbus
44 * @param[in] objPath - The Dbus path of nvme
45 */
46 NvmeSSD(sdbusplus::bus::bus& bus, const char* objPath) :
47 NvmeIfaces(bus, objPath), bus(bus)
48 {
49 }
50
51 /** @brief Set sensor value temperature to nvme D-bus */
52 void setSensorValueToDbus(const int8_t value);
53 /** @brief Check if sensor value higher or lower threshold */
54 void checkSensorThreshold();
55 /** @brief Set Sensor Threshold to D-bus at beginning */
56 void setSensorThreshold(int8_t criticalHigh, int8_t criticalLow,
Tony Lee6c595012019-06-19 10:54:59 +080057 int8_t warningHigh, int8_t warningLow);
George Hung831f2042021-05-19 17:02:29 +080058 /** @brief Set Sensor Max/Min value to D-bus at beginning */
59 void setSensorMaxMin(int8_t maxValue, int8_t minValue);
Tony Lee6c595012019-06-19 10:54:59 +080060
61 private:
62 sdbusplus::bus::bus& bus;
63};
64} // namespace nvme
65} // namespace phosphor