From bcb76886797f6c85c4052a72c07156f398c3e142 Mon Sep 17 00:00:00 2001 From: Vishwanatha Subbanna Date: Wed, 25 Jan 2017 16:29:43 +0530 Subject: Add timer skeleton This patchset creates the timer infrastructure that is then used by soft power off object on user requests. Change-Id: I6f7a5c161999fda89471f453c24725efddac65b9 Signed-off-by: Vishwanatha Subbanna --- softoff/softoff.hpp | 54 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'softoff/softoff.hpp') diff --git a/softoff/softoff.hpp b/softoff/softoff.hpp index dcb4b18..06f3861 100644 --- a/softoff/softoff.hpp +++ b/softoff/softoff.hpp @@ -3,6 +3,7 @@ #include #include #include +#include "timer.hpp" namespace phosphor { namespace ipmi @@ -19,15 +20,22 @@ class SoftPowerOff : public sdbusplus::server::object::object< public: /** @brief Constructs SoftPowerOff object. * - * @param[in] bus - system dbus handler - * @param[in] objPath - The Dbus path that hosts SoftPowerOff function + * @param[in] bus - system dbus handler + * @param[in] event - sd_event handler + * @param[in] objPath - The Dbus path hosting SoftPowerOff function */ SoftPowerOff(sdbusplus::bus::bus& bus, + sd_event* event, const char* objPath) : sdbusplus::server::object::object< - Base::SoftPowerOff>(bus, objPath), - bus(bus) + Base::SoftPowerOff>(bus, objPath, false), + bus(bus), + timer(event) { + // Need to announce since we may get the response + // very quickly on SMS_ATN + emit_object_added(); + // The whole purpose of this application is to send SMS_ATTN // and watch for the soft power off to go through. We need the // interface added signal emitted before we send SMS_ATN just to @@ -35,12 +43,43 @@ class SoftPowerOff : public sdbusplus::server::object::object< sendSMSAttn(); } + /** @brief Tells if the objective of this application is completed */ + inline auto isCompleted() + { + return completed; + } + + /** @brief Tells if the referenced timer is expired or not */ + inline auto isTimerExpired() + { + return timer.isExpired(); + } + private: + // Need this to send SMS_ATTN + // TODO : Switch over to using mapper service in a different patch + static constexpr auto HOST_IPMI_BUS = "org.openbmc.HostIpmi"; + static constexpr auto HOST_IPMI_OBJ = "/org/openbmc/HostIpmi/1"; + static constexpr auto HOST_IPMI_INTF = "org.openbmc.HostIpmi"; + + /* @brief sdbusplus handle */ + sdbusplus::bus::bus& bus; + + /** @brief Reference to Timer object */ + Timer timer; + + /** @brief Marks the end of life of this application. + * + * This is set to true if host gives appropriate responses + * for the sequence of commands. + */ + bool completed = false; + /** @brief Sends SMS_ATN to host to initiate soft power off process. * - * After sending the SMS_ATN, starts a watchdog timer for 30 + * After sending the SMS_ATN, starts a timer for 30 * seconds and expects a initial response from the host. - * After receiving the initial response, starts another watchdog + * After receiving the initial response, starts another * timer for 30 minutes to let host do a clean shutdown of * partitions. When the second response is received from the * host, it indicates that BMC can do a power off. @@ -51,9 +90,6 @@ class SoftPowerOff : public sdbusplus::server::object::object< * being thrown */ void sendSMSAttn(); - - /* @brief sdbusplus handle */ - sdbusplus::bus::bus& bus; }; } // namespace ipmi } // namespace phosphor -- cgit v1.2.1