blob: ab51a1dd7ae8f8f360a298a947d4f2d9163ba0cc [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";
Matthew Barth23a5e592020-01-30 13:11:08 -060015constexpr auto sysDbusObj = "/xyz/openbmc_project/inventory";
16constexpr auto sysDbusPath = "/xyz/openbmc_project/inventory/system";
17constexpr auto sysDbusIntf = "xyz.openbmc_project.Inventory.Item.System";
18constexpr auto sysDbusProp = "Identifier";
Matthew Barth29e9e382020-01-23 13:40:49 -060019
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060020using Timer = sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>;
21
Matthew Barth29e9e382020-01-23 13:40:49 -060022using ManagerObject = sdbusplus::server::object::object<
23 phosphor::power::regulators::interface::ManagerInterface>;
24
25class 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 Barthf2bcf1f2020-01-29 14:42:47 -060040 * @param[in] event - the sdevent event
Matthew Barth29e9e382020-01-23 13:40:49 -060041 */
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060042 Manager(sdbusplus::bus::bus& bus, const sdeventplus::Event& event);
Matthew Barth29e9e382020-01-23 13:40:49 -060043
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 Barthf2bcf1f2020-01-29 14:42:47 -060056 /**
57 * @brief Timer expired callback function
58 */
59 void timerExpired();
60
Matthew Barth7cbc5532020-01-29 15:13:13 -060061 /**
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 Barth29e9e382020-01-23 13:40:49 -060071 private:
72 /**
73 * The dbus bus
74 */
75 sdbusplus::bus::bus& bus;
Matthew Barthf2bcf1f2020-01-29 14:42:47 -060076
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 Barth29e9e382020-01-23 13:40:49 -060086};
87
88} // namespace phosphor::power::regulators