1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 #include <sdbusplus/server/object.hpp>
5 #include <xyz/openbmc_project/Ipmi/Internal/SoftPowerOff/server.hpp>
6 namespace phosphor
7 {
8 namespace ipmi
9 {
10 
11 namespace Base = sdbusplus::xyz::openbmc_project::Ipmi::Internal::server;
12 
13 /** @class SoftPowerOff
14  *  @brief Responsible for coordinating Host SoftPowerOff operation
15  */
16 class SoftPowerOff : public sdbusplus::server::object::object<
17                      Base::SoftPowerOff>
18 {
19     public:
20         /** @brief Constructs SoftPowerOff object.
21          *
22          *  @param[in] bus      - system dbus handler
23          *  @param[in] objPath  - The Dbus path that hosts SoftPowerOff function
24          */
25         SoftPowerOff(sdbusplus::bus::bus& bus,
26                      const char* objPath) :
27             sdbusplus::server::object::object<
28                 Base::SoftPowerOff>(bus, objPath),
29                 bus(bus)
30         {
31             // 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();
36         }
37 
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;
57 };
58 } // namespace ipmi
59 } // namespace phosphor
60