blob: b6560f67be189438de56b4b964b5fca4a23736d4 [file] [log] [blame]
Matthew Barth29e9e382020-01-23 13:40:49 -06001#pragma once
2
3#include <interfaces/manager_interface.hpp>
4#include <sdbusplus/bus.hpp>
5#include <sdbusplus/server/object.hpp>
Matthew Barthf2bcf1f2020-01-29 14:42:47 -06006#include <sdeventplus/event.hpp>
Matthew Barth7cbc5532020-01-29 15:13:13 -06007#include <sdeventplus/source/signal.hpp>
Matthew Barthf2bcf1f2020-01-29 14:42:47 -06008#include <sdeventplus/utility/timer.hpp>
Matthew Barth29e9e382020-01-23 13:40:49 -06009
10namespace phosphor::power::regulators
11{
12
13constexpr auto busName = "xyz.openbmc_project.Power.Regulators";
14constexpr auto objPath = "/xyz/openbmc_project/power/regulators/manager";
15
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060016using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
17
Matthew Barth29e9e382020-01-23 13:40:49 -060018using ManagerObject = sdbusplus::server::object::object<
19 phosphor::power::regulators::interface::ManagerInterface>;
20
21class 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 Barthf2bcf1f2020-01-29 14:42:47 -060036 * @param[in] event - the sdevent event
Matthew Barth29e9e382020-01-23 13:40:49 -060037 */
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060038 Manager(sdbusplus::bus::bus& bus, const sdeventplus::Event& event);
Matthew Barth29e9e382020-01-23 13:40:49 -060039
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 Barthf2bcf1f2020-01-29 14:42:47 -060052 /**
53 * @brief Timer expired callback function
54 */
55 void timerExpired();
56
Matthew Barth7cbc5532020-01-29 15:13:13 -060057 /**
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 Barth29e9e382020-01-23 13:40:49 -060067 private:
68 /**
69 * The dbus bus
70 */
71 sdbusplus::bus::bus& bus;
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060072
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 Barth29e9e382020-01-23 13:40:49 -060082};
83
84} // namespace phosphor::power::regulators