Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <interfaces/manager_interface.hpp> |
| 4 | #include <sdbusplus/bus.hpp> |
| 5 | #include <sdbusplus/server/object.hpp> |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame] | 6 | #include <sdeventplus/event.hpp> |
Matthew Barth | 7cbc553 | 2020-01-29 15:13:13 -0600 | [diff] [blame^] | 7 | #include <sdeventplus/source/signal.hpp> |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame] | 8 | #include <sdeventplus/utility/timer.hpp> |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 9 | |
| 10 | namespace phosphor::power::regulators |
| 11 | { |
| 12 | |
| 13 | constexpr auto busName = "xyz.openbmc_project.Power.Regulators"; |
| 14 | constexpr auto objPath = "/xyz/openbmc_project/power/regulators/manager"; |
| 15 | |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame] | 16 | using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>; |
| 17 | |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 18 | using ManagerObject = sdbusplus::server::object::object< |
| 19 | phosphor::power::regulators::interface::ManagerInterface>; |
| 20 | |
| 21 | class Manager : public ManagerObject |
| 22 | { |
| 23 | public: |
| 24 | Manager() = delete; |
| 25 | Manager(const Manager&) = delete; |
| 26 | Manager(Manager&&) = delete; |
| 27 | Manager& operator=(const Manager&) = delete; |
| 28 | Manager& operator=(Manager&&) = delete; |
| 29 | ~Manager() = default; |
| 30 | |
| 31 | /** |
| 32 | * Constructor |
| 33 | * Creates a manager over the regulators. |
| 34 | * |
| 35 | * @param[in] bus - the dbus bus |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame] | 36 | * @param[in] event - the sdevent event |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 37 | */ |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame] | 38 | Manager(sdbusplus::bus::bus& bus, const sdeventplus::Event& event); |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * @brief Overridden manager object's configure method |
| 42 | */ |
| 43 | void configure() override; |
| 44 | |
| 45 | /** |
| 46 | * @brief Overridden manager object's monitor method |
| 47 | * |
| 48 | * @param[in] enable - Enable or disable regulator monitoring |
| 49 | */ |
| 50 | void monitor(bool enable) override; |
| 51 | |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame] | 52 | /** |
| 53 | * @brief Timer expired callback function |
| 54 | */ |
| 55 | void timerExpired(); |
| 56 | |
Matthew Barth | 7cbc553 | 2020-01-29 15:13:13 -0600 | [diff] [blame^] | 57 | /** |
| 58 | * @brief Callback function to handle receiving a HUP signal |
| 59 | * to reload the configuration data. |
| 60 | * |
| 61 | * @param[in] sigSrc - sd_event_source signal wrapper |
| 62 | * @param[in] sigInfo - signal info on signal fd |
| 63 | */ |
| 64 | void sighupHandler(sdeventplus::source::Signal& sigSrc, |
| 65 | const struct signalfd_siginfo* sigInfo); |
| 66 | |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 67 | private: |
| 68 | /** |
| 69 | * The dbus bus |
| 70 | */ |
| 71 | sdbusplus::bus::bus& bus; |
Matthew Barth | f2bcf1f | 2020-01-29 14:42:47 -0600 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Event to loop on |
| 75 | */ |
| 76 | sdeventplus::Event eventLoop; |
| 77 | |
| 78 | /** |
| 79 | * List of event timers |
| 80 | */ |
| 81 | std::vector<Timer> timers; |
Matthew Barth | 29e9e38 | 2020-01-23 13:40:49 -0600 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | } // namespace phosphor::power::regulators |