summaryrefslogtreecommitdiffstats
path: root/softoff/softoff.hpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-01-25 16:29:43 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-03-24 21:26:16 +0000
commitbcb76886797f6c85c4052a72c07156f398c3e142 (patch)
tree82efbe75847bc27c87099b91dbb2202ee26085cf /softoff/softoff.hpp
parent7cc9d716a4880c14f6a7882c25d920ce7cd77cd4 (diff)
downloadphosphor-host-ipmid-bcb76886797f6c85c4052a72c07156f398c3e142.tar.gz
phosphor-host-ipmid-bcb76886797f6c85c4052a72c07156f398c3e142.zip
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 <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'softoff/softoff.hpp')
-rw-r--r--softoff/softoff.hpp54
1 files changed, 45 insertions, 9 deletions
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 <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <xyz/openbmc_project/Ipmi/Internal/SoftPowerOff/server.hpp>
+#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
OpenPOWER on IntegriCloud