| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 1 | #pragma once | 
 | 2 |  | 
 | 3 | #include <string> | 
| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> | 
 | 5 | #include <sdbusplus/server/object.hpp> | 
| Vishwanatha Subbanna | 9bb065b | 2017-04-18 14:25:26 +0530 | [diff] [blame] | 6 | #include <org/open_power/OCC/PassThrough/server.hpp> | 
| Vishwanatha Subbanna | 38b08d7 | 2017-04-14 18:12:14 +0530 | [diff] [blame] | 7 | #include "file.hpp" | 
| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 8 |  | 
 | 9 | namespace open_power | 
 | 10 | { | 
 | 11 | namespace occ | 
 | 12 | { | 
| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 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; | 
| Vishwanatha Subbanna | 38b08d7 | 2017-04-14 18:12:14 +0530 | [diff] [blame] | 24 |         ~PassThrough() = default; | 
| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 25 |         PassThrough(const PassThrough&) = delete; | 
 | 26 |         PassThrough& operator=(const PassThrough&) = delete; | 
 | 27 |         PassThrough(PassThrough&&) = default; | 
 | 28 |         PassThrough& operator=(PassThrough&&) = default; | 
| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 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; | 
| Vishwanatha Subbanna | afd21a6 | 2017-04-13 20:17:13 +0530 | [diff] [blame] | 47 |  | 
 | 48 |         /** @brief OCC device path | 
 | 49 |          *  For now, here is the hard-coded mapping until | 
| Vishwanatha Subbanna | 38b08d7 | 2017-04-14 18:12:14 +0530 | [diff] [blame] | 50 |          *  the udev rule is in. | 
| Vishwanatha Subbanna | afd21a6 | 2017-04-13 20:17:13 +0530 | [diff] [blame] | 51 |          *  occ0 --> /dev/occfifo1 | 
 | 52 |          *  occ1 --> /dev/occfifo2 | 
 | 53 |          *  ... | 
 | 54 |          */ | 
| Vishwanatha Subbanna | d13694a | 2017-06-01 15:44:20 +0530 | [diff] [blame] | 55 |         std::string devicePath = "/dev/occ"; | 
| Vishwanatha Subbanna | 38b08d7 | 2017-04-14 18:12:14 +0530 | [diff] [blame] | 56 |  | 
 | 57 |         /** @brief File descriptor manager */ | 
 | 58 |         FileDescriptor fd; | 
 | 59 |  | 
 | 60 |         /** Opens devicePath and returns file descritor */ | 
 | 61 |         int openDevice(); | 
| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 62 | }; | 
 | 63 |  | 
| Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 64 | } // namespace occ | 
 | 65 | } // namespace open_power |