Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | #include <vector> |
| 5 | #include <sdbusplus/bus.hpp> |
| 6 | #include <sdbusplus/server/object.hpp> |
| 7 | #include "org/open_power/OCC/PassThrough/server.hpp" |
| 8 | #include "config.h" |
| 9 | |
| 10 | namespace open_power |
| 11 | { |
| 12 | namespace occ |
| 13 | { |
| 14 | namespace pass_through |
| 15 | { |
| 16 | |
| 17 | /** @brief Make occ pass-through d-bus object pathname |
| 18 | * @param[in] occ - occ name |
| 19 | * @returns occ pass-through path |
| 20 | */ |
| 21 | inline auto object(const std::string& occ) |
| 22 | { |
| 23 | return std::string(OCC_PASS_THROUGH_ROOT) + |
| 24 | '/' + |
| 25 | occ; |
| 26 | } |
| 27 | |
| 28 | /** @brief Put occ pass through objects on the bus |
| 29 | */ |
| 30 | void run(); |
| 31 | |
| 32 | using Iface = sdbusplus::server::object::object< |
| 33 | sdbusplus::org::open_power::OCC::server::PassThrough>; |
| 34 | |
| 35 | /** @class PassThrough |
| 36 | * @brief Implements org.open_power.OCC.PassThrough |
| 37 | */ |
| 38 | class PassThrough : public Iface |
| 39 | { |
| 40 | public: |
| 41 | PassThrough() = delete; |
| 42 | PassThrough(const PassThrough&) = delete; |
| 43 | PassThrough& operator=(const PassThrough&) = delete; |
| 44 | PassThrough(PassThrough&&) = default; |
| 45 | PassThrough& operator=(PassThrough&&) = default; |
| 46 | ~PassThrough() = default; |
| 47 | |
| 48 | /** @brief Ctor to put pass-through d-bus object on the bus |
| 49 | * @param[in] bus - Bus to attach to |
| 50 | * @param[in] path - Path to attach at |
| 51 | */ |
| 52 | PassThrough(sdbusplus::bus::bus& bus, |
| 53 | const char* path); |
| 54 | |
| 55 | /** @brief Pass through command to OCC |
| 56 | * @param[in] command - command to pass-through |
| 57 | * @returns OCC response as an array |
| 58 | */ |
| 59 | std::vector<std::int32_t> |
| 60 | send(std::vector<std::int32_t> command) override; |
| 61 | |
| 62 | private: |
| 63 | /** @brief Pass-through occ path on the bus */ |
| 64 | std::string path; |
Vishwanatha Subbanna | afd21a6 | 2017-04-13 20:17:13 +0530 | [diff] [blame^] | 65 | |
| 66 | /** @brief OCC device path |
| 67 | * For now, here is the hard-coded mapping until |
| 68 | * the udev rule is in |
| 69 | * occ0 --> /dev/occfifo1 |
| 70 | * occ1 --> /dev/occfifo2 |
| 71 | * ... |
| 72 | */ |
| 73 | std::string devicePath = "/dev/occfifo"; |
Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | } // namespace pass_through |
| 77 | } // namespace occ |
| 78 | } // namespace open_power |