blob: dcb4b18c16c8f3df3fa2ce3c177ffee22d7eea4d [file] [log] [blame]
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +05301#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server/object.hpp>
5#include <xyz/openbmc_project/Ipmi/Internal/SoftPowerOff/server.hpp>
6namespace phosphor
7{
8namespace ipmi
9{
10
11namespace Base = sdbusplus::xyz::openbmc_project::Ipmi::Internal::server;
12
13/** @class SoftPowerOff
14 * @brief Responsible for coordinating Host SoftPowerOff operation
15 */
16class SoftPowerOff : public sdbusplus::server::object::object<
17 Base::SoftPowerOff>
18{
19 public:
20 /** @brief Constructs SoftPowerOff object.
21 *
Vishwanatha Subbanna7cc9d712017-01-24 18:48:40 +053022 * @param[in] bus - system dbus handler
23 * @param[in] objPath - The Dbus path that hosts SoftPowerOff function
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053024 */
25 SoftPowerOff(sdbusplus::bus::bus& bus,
26 const char* objPath) :
Vishwanatha Subbanna7cc9d712017-01-24 18:48:40 +053027 sdbusplus::server::object::object<
28 Base::SoftPowerOff>(bus, objPath),
29 bus(bus)
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053030 {
Vishwanatha Subbanna7cc9d712017-01-24 18:48:40 +053031 // The whole purpose of this application is to send SMS_ATTN
32 // and watch for the soft power off to go through. We need the
33 // interface added signal emitted before we send SMS_ATN just to
34 // attend to lightning fast response from host
35 sendSMSAttn();
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053036 }
Vishwanatha Subbanna7cc9d712017-01-24 18:48:40 +053037
38 private:
39 /** @brief Sends SMS_ATN to host to initiate soft power off process.
40 *
41 * After sending the SMS_ATN, starts a watchdog timer for 30
42 * seconds and expects a initial response from the host.
43 * After receiving the initial response, starts another watchdog
44 * timer for 30 minutes to let host do a clean shutdown of
45 * partitions. When the second response is received from the
46 * host, it indicates that BMC can do a power off.
47 * If BMC fails to get any response, then a hard power off would
48 * be forced.
49 *
50 * @return - Does not return anything. Error will result in exception
51 * being thrown
52 */
53 void sendSMSAttn();
54
55 /* @brief sdbusplus handle */
56 sdbusplus::bus::bus& bus;
Vishwanatha Subbanna506aa0f2017-01-24 14:58:25 +053057};
58} // namespace ipmi
59} // namespace phosphor