Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 4 | #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 Lai | 76f455e | 2022-09-22 00:11:26 +0800 | [diff] [blame] | 7 | #include <xyz/openbmc_project/State/Decorator/Availability/server.hpp> |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 8 | |
| 9 | namespace phosphor |
| 10 | { |
| 11 | namespace nvme |
| 12 | { |
| 13 | |
| 14 | using ValueIface = sdbusplus::xyz::openbmc_project::Sensor::server::Value; |
| 15 | |
| 16 | using CriticalInterface = |
| 17 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Critical; |
| 18 | |
| 19 | using WarningInterface = |
| 20 | sdbusplus::xyz::openbmc_project::Sensor::Threshold::server::Warning; |
| 21 | |
Potin Lai | 76f455e | 2022-09-22 00:11:26 +0800 | [diff] [blame] | 22 | using AvailabilityInterface = |
| 23 | sdbusplus::xyz::openbmc_project::State::Decorator::server::Availability; |
| 24 | |
| 25 | using NvmeIfaces = |
| 26 | sdbusplus::server::object_t<ValueIface, CriticalInterface, WarningInterface, |
| 27 | AvailabilityInterface>; |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 28 | |
| 29 | class 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 Williams | 7ce68bc | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 44 | NvmeSSD(sdbusplus::bus_t& bus, const char* objPath) : |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 45 | NvmeIfaces(bus, objPath), bus(bus) |
| 46 | { |
Potin Lai | 5c4de83 | 2022-03-04 13:19:17 +0800 | [diff] [blame] | 47 | ValueIface::unit(Unit::DegreesC); |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 48 | } |
| 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 Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 56 | int8_t warningHigh, int8_t warningLow); |
George Hung | 831f204 | 2021-05-19 17:02:29 +0800 | [diff] [blame] | 57 | /** @brief Set Sensor Max/Min value to D-bus at beginning */ |
| 58 | void setSensorMaxMin(int8_t maxValue, int8_t minValue); |
Potin Lai | 76f455e | 2022-09-22 00:11:26 +0800 | [diff] [blame] | 59 | /** @brief Set Sensor Availability to D-bus */ |
| 60 | void setSensorAvailability(bool avail); |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 61 | |
| 62 | private: |
Patrick Williams | 7ce68bc | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 63 | sdbusplus::bus_t& bus; |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 64 | }; |
| 65 | } // namespace nvme |
Brandon Kim | d5838d1 | 2021-05-19 12:51:55 -0700 | [diff] [blame] | 66 | } // namespace phosphor |