Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <sdbusplus/server/object.hpp> |
| 5 | #include <org/open_power/OCC/Status/server.hpp> |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 6 | #include "occ_events.hpp" |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 7 | #include "occ_device.hpp" |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 8 | namespace open_power |
| 9 | { |
| 10 | namespace occ |
| 11 | { |
| 12 | |
| 13 | namespace Base = sdbusplus::org::open_power::OCC::server; |
| 14 | using Interface = sdbusplus::server::object::object<Base::Status>; |
| 15 | |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame^] | 16 | // OCC status instance. Ex. for "occ0", the instance is 0 |
| 17 | using instanceID = int; |
| 18 | |
| 19 | // IPMI sensor ID for a given OCC instance |
| 20 | using sensorID = uint8_t; |
| 21 | |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 22 | /** @class Status |
| 23 | * @brief Implementation of OCC Active Status |
| 24 | */ |
| 25 | class Status : public Interface |
| 26 | { |
| 27 | public: |
| 28 | Status() = delete; |
| 29 | ~Status() = default; |
| 30 | Status(const Status&) = delete; |
| 31 | Status& operator=(const Status&) = delete; |
| 32 | Status(Status&&) = default; |
| 33 | Status& operator=(Status&&) = default; |
| 34 | |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 35 | /** @brief Constructs the Status object and |
| 36 | * the underlying device object |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 37 | * |
| 38 | * @param[in] bus - DBus bus to attach to |
| 39 | * @param[in] path - DBus object path |
| 40 | */ |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 41 | Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path) |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 42 | : Interface(bus, path), |
| 43 | path(path), |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame^] | 44 | instance(((this->path.back() - '0'))), |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 45 | device(event, |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame^] | 46 | name + std::to_string(instance + 1), |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 47 | std::bind(&Status::deviceErrorHandler, this)) |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 48 | { |
| 49 | // Nothing to do here |
| 50 | } |
| 51 | |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 52 | /** @brief Since we are overriding the setter-occActive but not the |
| 53 | * getter-occActive, we need to have this using in order to |
| 54 | * allow passthrough usage of the getter-occActive |
| 55 | */ |
| 56 | using Base::Status::occActive; |
| 57 | |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 58 | /** @brief SET OccActive to True or False |
| 59 | * |
| 60 | * @param[in] value - Intended value |
| 61 | * |
| 62 | * @return - Updated value of the property |
| 63 | */ |
| 64 | bool occActive(bool value) override; |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 65 | |
| 66 | private: |
| 67 | /** @brief OCC dbus object path */ |
| 68 | std::string path; |
| 69 | |
| 70 | /** @brief occ name prefix */ |
| 71 | std::string name = OCC_NAME; |
| 72 | |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame^] | 73 | /** @brief OCC instance number. Ex, 0,1, etc */ |
| 74 | int instance; |
| 75 | |
| 76 | /** @brief OCC instance to Sensor ID mapping */ |
| 77 | static const std::map<instanceID, sensorID> sensorMap; |
| 78 | |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 79 | /** @brief OCC device object to do bind and unbind */ |
| 80 | Device device; |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 81 | |
| 82 | /** @brief Callback handler when device errors are detected */ |
| 83 | void deviceErrorHandler(); |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | } // namespace occ |
| 87 | } // namespace open_power |