1 #pragma once 2 3 #include <string> 4 #include <sdbusplus/bus.hpp> 5 #include <sdbusplus/server/object.hpp> 6 #include <org/open_power/OCC/PassThrough/server.hpp> 7 #include "file.hpp" 8 9 namespace open_power 10 { 11 namespace occ 12 { 13 14 using Iface = sdbusplus::server::object::object< 15 sdbusplus::org::open_power::OCC::server::PassThrough>; 16 17 /** @class PassThrough 18 * @brief Implements org.open_power.OCC.PassThrough 19 */ 20 class PassThrough : public Iface 21 { 22 public: 23 PassThrough() = delete; 24 ~PassThrough() = default; 25 PassThrough(const PassThrough&) = delete; 26 PassThrough& operator=(const PassThrough&) = delete; 27 PassThrough(PassThrough&&) = default; 28 PassThrough& operator=(PassThrough&&) = default; 29 30 /** @brief Ctor to put pass-through d-bus object on the bus 31 * @param[in] bus - Bus to attach to 32 * @param[in] path - Path to attach at 33 */ 34 PassThrough(sdbusplus::bus::bus& bus, 35 const char* path); 36 37 /** @brief Pass through command to OCC 38 * @param[in] command - command to pass-through 39 * @returns OCC response as an array 40 */ 41 std::vector<std::int32_t> 42 send(std::vector<std::int32_t> command) override; 43 44 private: 45 /** @brief Pass-through occ path on the bus */ 46 std::string path; 47 48 /** @brief OCC device path 49 * For now, here is the hard-coded mapping until 50 * the udev rule is in. 51 * occ0 --> /dev/occfifo1 52 * occ1 --> /dev/occfifo2 53 * ... 54 */ 55 std::string devicePath = "/dev/occ"; 56 57 /** @brief File descriptor manager */ 58 FileDescriptor fd; 59 60 /** Opens devicePath and returns file descritor */ 61 int openDevice(); 62 }; 63 64 } // namespace occ 65 } // namespace open_power 66