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