1 #pragma once 2 3 #include "occ_command.hpp" 4 #include "utils.hpp" 5 6 #include <fmt/core.h> 7 8 #include <org/open_power/OCC/PassThrough/server.hpp> 9 #include <phosphor-logging/log.hpp> 10 #include <sdbusplus/bus.hpp> 11 #include <sdbusplus/server/object.hpp> 12 13 #include <string> 14 15 namespace open_power 16 { 17 namespace occ 18 { 19 20 using Iface = sdbusplus::server::object::object< 21 sdbusplus::org::open_power::OCC::server::PassThrough>; 22 23 // For waiting on signals 24 namespace sdbusRule = sdbusplus::bus::match::rules; 25 26 /** @class PassThrough 27 * @brief Implements org.open_power.OCC.PassThrough 28 */ 29 class PassThrough : public Iface 30 { 31 public: 32 PassThrough() = delete; 33 ~PassThrough() = default; 34 PassThrough(const PassThrough&) = delete; 35 PassThrough& operator=(const PassThrough&) = delete; 36 PassThrough(PassThrough&&) = default; 37 PassThrough& operator=(PassThrough&&) = default; 38 39 /** @brief Ctor to put pass-through d-bus object on the bus 40 * @param[in] path - Path to attach at 41 */ 42 explicit PassThrough(const char* path); 43 44 /** @brief Pass through command to OCC from dbus 45 * @param[in] command - command to pass-through 46 * @returns OCC response as an array 47 */ 48 std::vector<std::int32_t> send(std::vector<std::int32_t> command) override; 49 50 /** @brief Pass through command to OCC from openpower-occ-control 51 * @param[in] command - command to pass-through 52 * @returns OCC response as an array 53 */ 54 std::vector<std::uint8_t> send(std::vector<std::uint8_t> command); 55 56 private: 57 /** @brief Pass-through occ path on the bus */ 58 std::string path; 59 60 /** @brief OCC device path 61 * For now, here is the hard-coded mapping until 62 * the udev rule is in. 63 * occ0 --> /dev/occ1 64 * occ1 --> /dev/occ2 65 * ... 66 */ 67 std::string devicePath; 68 69 /** @brief OCC instance number */ 70 int occInstance; 71 72 /** @brief Indicates whether or not the OCC is currently active */ 73 bool occActive = false; 74 75 /** @brief Subscribe to OCC Status signal 76 * 77 * Once the OCC status gets to active, only then we will get /dev/occ2 78 * populated and hence need to wait on that before opening that 79 */ 80 sdbusplus::bus::match_t activeStatusSignal; 81 82 /** @brief Object to send commands to the OCC */ 83 OccCommand occCmd; 84 85 /** @brief Callback function on OCC Status change signals 86 * 87 * @param[in] msg - Data associated with subscribed signal 88 */ 89 void activeStatusEvent(sdbusplus::message::message& msg); 90 }; 91 92 } // namespace occ 93 } // namespace open_power 94