blob: da8c617c7e7099e6c0d16ac2b6ce7f772a04191e [file] [log] [blame]
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05001#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
10namespace open_power
11{
12namespace occ
13{
14namespace 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 */
21inline 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 */
30void run();
31
32using 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 */
38class 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 Subbannaafd21a62017-04-13 20:17:13 +053065
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 Kodihalli6b492fb2017-03-18 01:09:28 -050074};
75
76} // namespace pass_through
77} // namespace occ
78} // namespace open_power