Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
William A. Kennington III | 822eaf6 | 2019-02-12 15:20:06 -0800 | [diff] [blame] | 3 | #include <ipmid-host/cmd-utils.hpp> |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 4 | #include <org/open_power/Control/Host/server.hpp> |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 5 | #include <sdbusplus/bus.hpp> |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 6 | namespace open_power |
| 7 | { |
| 8 | namespace host |
| 9 | { |
| 10 | namespace command |
| 11 | { |
| 12 | |
| 13 | namespace Base = sdbusplus::org::open_power::Control::server; |
| 14 | using IpmiCmdData = phosphor::host::command::IpmiCmdData; |
| 15 | |
| 16 | /** @class Host |
| 17 | * @brief OpenBMC control host interface implementation. |
| 18 | * @details A concrete implementation for org.open_power.Control.Host |
| 19 | * DBus API. |
| 20 | */ |
Patrick Williams | a0a221f | 2022-07-22 19:26:53 -0500 | [diff] [blame^] | 21 | class Host : public sdbusplus::server::object_t<Base::Host> |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 22 | { |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 23 | public: |
| 24 | /** @brief Constructs Host Control Interface |
| 25 | * |
| 26 | * @param[in] bus - The Dbus bus object |
| 27 | * @param[in] objPath - The Dbus object path |
| 28 | */ |
Patrick Williams | a0a221f | 2022-07-22 19:26:53 -0500 | [diff] [blame^] | 29 | Host(sdbusplus::bus_t& bus, const char* objPath) : |
| 30 | sdbusplus::server::object_t<Base::Host>(bus, objPath), bus(bus) |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 31 | { |
| 32 | // Nothing to do |
| 33 | } |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 34 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 35 | /** @brief Sends input command to host |
| 36 | * Note that the command will be queued in a FIFO if |
| 37 | * other commands to the host have yet to be run |
| 38 | * |
| 39 | * @param[in] command - Input command to execute |
| 40 | * @param[in] data - Data associated with the command |
| 41 | */ |
Patrick Williams | 6195010 | 2020-05-13 17:49:58 -0500 | [diff] [blame] | 42 | void execute(Command command, std::variant<uint8_t> data) override; |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 43 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 44 | private: |
| 45 | /** @brief sdbusplus DBus bus connection. */ |
Patrick Williams | a0a221f | 2022-07-22 19:26:53 -0500 | [diff] [blame^] | 46 | sdbusplus::bus_t& bus; |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 47 | |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 48 | /** @brief Callback function to be invoked by command manager |
| 49 | * |
| 50 | * @detail Conveys the status of the last Host bound command. |
| 51 | * Depending on the status, a CommandComplete or |
| 52 | * CommandFailure signal would be sent |
| 53 | * |
| 54 | * @param[in] cmd - IPMI command and data sent to Host |
| 55 | * @param[in] status - Success or Failure |
| 56 | */ |
| 57 | void commandStatusHandler(IpmiCmdData cmd, bool status); |
Vishwanatha Subbanna | 0765506 | 2017-07-14 20:31:57 +0530 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace command |
| 61 | } // namespace host |
Patrick Venture | 02261c0 | 2018-10-31 15:16:23 -0700 | [diff] [blame] | 62 | } // namespace open_power |