blob: 534f5773e82ad0f4743bda98993e3583be1911a4 [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
Patrick Williams5d82f472022-07-22 19:26:53 -050020 : public sdbusplus::server::object_t<
Andrew Geisslerc7021b82021-04-28 15:22:35 -050021 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 */
Patrick Williams5d82f472022-07-22 19:26:53 -050030 Host(sdbusplus::bus_t& bus, const char* objPath) :
31 sdbusplus::server::object_t<
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. */
Patrick Williams5d82f472022-07-22 19:26:53 -050053 sdbusplus::bus_t& 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