blob: f2f78c750dc74dd8627afca4df48c1d608634b7a [file] [log] [blame]
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05001#pragma once
2
3#include <string>
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05004#include <sdbusplus/bus.hpp>
5#include <sdbusplus/server/object.hpp>
Vishwanatha Subbanna9bb065b2017-04-18 14:25:26 +05306#include <org/open_power/OCC/PassThrough/server.hpp>
Vishwanatha Subbanna38b08d72017-04-14 18:12:14 +05307#include "file.hpp"
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05008
9namespace open_power
10{
11namespace occ
12{
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050013
14using 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 */
20class PassThrough : public Iface
21{
22 public:
23 PassThrough() = delete;
Vishwanatha Subbanna38b08d72017-04-14 18:12:14 +053024 ~PassThrough() = default;
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050025 PassThrough(const PassThrough&) = delete;
26 PassThrough& operator=(const PassThrough&) = delete;
27 PassThrough(PassThrough&&) = default;
28 PassThrough& operator=(PassThrough&&) = default;
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050029
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 Subbannaafd21a62017-04-13 20:17:13 +053047
48 /** @brief OCC device path
49 * For now, here is the hard-coded mapping until
Vishwanatha Subbanna38b08d72017-04-14 18:12:14 +053050 * the udev rule is in.
Vishwanatha Subbannaafd21a62017-04-13 20:17:13 +053051 * occ0 --> /dev/occfifo1
52 * occ1 --> /dev/occfifo2
53 * ...
54 */
Vishwanatha Subbannad13694a2017-06-01 15:44:20 +053055 std::string devicePath = "/dev/occ";
Vishwanatha Subbanna38b08d72017-04-14 18:12:14 +053056
57 /** @brief File descriptor manager */
58 FileDescriptor fd;
59
60 /** Opens devicePath and returns file descritor */
61 int openDevice();
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050062};
63
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050064} // namespace occ
65} // namespace open_power