blob: 056ffe97cefc25e2e6e88fa8ed628380bae260ae [file] [log] [blame]
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -05001#pragma once
2
Patrick Venture0b02be92018-08-31 11:55:55 -07003#include <host-cmd-manager.hpp>
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -05004#include <sdbusplus/bus.hpp>
Andrew Geisslerc7021b82021-04-28 15:22:35 -05005#include <xyz/openbmc_project/Condition/HostFirmware/server.hpp>
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -05006#include <xyz/openbmc_project/Control/Host/server.hpp>
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -05007namespace phosphor
8{
9namespace host
10{
Vishwanatha Subbanna3eb117a2017-07-12 16:13:49 +053011namespace command
12{
Andrew Geissler12866372017-03-21 22:58:28 -050013
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -050014/** @class Host
Andrew Geisslerc7021b82021-04-28 15:22:35 -050015 * @brief OpenBMC control and condition host interface implementation.
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -050016 * @details A concrete implementation for xyz.openbmc_project.Control.Host
Andrew Geisslerc7021b82021-04-28 15:22:35 -050017 * and xyz.openbmc_project.Condition.HostFirmware DBus API's.
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -050018 */
Andrew Geisslerc7021b82021-04-28 15:22:35 -050019class Host
20 : public sdbusplus::server::object::object<
21 sdbusplus::xyz::openbmc_project::Control::server::Host,
22 sdbusplus::xyz::openbmc_project::Condition::server::HostFirmware>
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -050023{
Patrick Venture0b02be92018-08-31 11:55:55 -070024 public:
Andrew Geisslerc7021b82021-04-28 15:22:35 -050025 /** @brief Constructs Host Control and Condition Interfaces
Patrick Venture0b02be92018-08-31 11:55:55 -070026 *
27 * @param[in] bus - The Dbus bus object
28 * @param[in] objPath - The Dbus object path
29 */
30 Host(sdbusplus::bus::bus& bus, const char* objPath) :
31 sdbusplus::server::object::object<
Andrew Geisslerc7021b82021-04-28 15:22:35 -050032 sdbusplus::xyz::openbmc_project::Control::server::Host,
33 sdbusplus::xyz::openbmc_project::Condition::server::HostFirmware>(
34 bus, objPath),
Patrick Venture0b02be92018-08-31 11:55:55 -070035 bus(bus)
36 {
37 // Nothing to do
38 }
Andrew Geissler62817fa92017-03-20 14:20:49 -050039
Patrick Venture0b02be92018-08-31 11:55:55 -070040 /** @brief Send input command to host
41 * Note that the command will be queued in a FIFO if
42 * other commands to the host have yet to be run
43 *
44 * @param[in] command - Input command to execute
45 */
46 void execute(Command command) override;
Andrew Geissler1b9d4e52017-03-21 15:04:05 -050047
Andrew Geisslerc7021b82021-04-28 15:22:35 -050048 /** @brief Override reads to CurrentFirmwareCondition */
49 FirmwareCondition currentFirmwareCondition() const override;
50
Patrick Venture0b02be92018-08-31 11:55:55 -070051 private:
52 /** @brief sdbusplus DBus bus connection. */
53 sdbusplus::bus::bus& bus;
Andrew Geissler12866372017-03-21 22:58:28 -050054
Patrick Venture0b02be92018-08-31 11:55:55 -070055 /** @brief Callback function to be invoked by command manager
56 *
57 * @detail Conveys the status of the last Host bound command.
58 * Depending on the status, a CommandComplete or
59 * CommandFailure signal would be sent
60 *
61 * @param[in] cmd - IPMI command and data sent to Host
62 * @param[in] status - Success or Failure
63 */
64 void commandStatusHandler(IpmiCmdData cmd, bool status);
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -050065};
66
Vishwanatha Subbanna3eb117a2017-07-12 16:13:49 +053067} // namespace command
Andrew Geisslerdd2c6fd2017-03-16 15:53:20 -050068} // namespace host
69} // namespace phosphor