blob: 05864c1ae177aee90889099e54ab4f91e9213218 [file] [log] [blame]
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05001#include <memory>
Deepak Kodihalli02ba9ec2017-03-18 02:57:43 -05002#include <algorithm>
3#include <phosphor-logging/log.hpp>
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05004#include "occ_pass_through.hpp"
5#include "occ_finder.hpp"
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05006namespace open_power
7{
8namespace occ
9{
10namespace pass_through
11{
12
13void run()
14{
15 auto bus = sdbusplus::bus::new_default();
16 sdbusplus::server::manager::manager objManager(bus,
17 OCC_PASS_THROUGH_ROOT);
18
19 std::vector<std::unique_ptr<PassThrough>> objects;
20 auto occs = open_power::occ::finder::get();
21
22 for (const auto& occ : occs)
23 {
24 auto occPassThrough = object(occ);
25 objects.emplace_back(
26 std::make_unique<PassThrough>(bus, occPassThrough.c_str()));
27 }
28 bus.request_name(OCC_PASS_THROUGH_BUSNAME);
29
30 while (true)
31 {
32 bus.process_discard();
33 bus.wait();
34 }
35}
36
37PassThrough::PassThrough(
38 sdbusplus::bus::bus& bus,
39 const char* path) :
40 Iface(bus, path),
41 path(path)
42{
Vishwanatha Subbannaafd21a62017-04-13 20:17:13 +053043 devicePath.append(std::to_string((this->path.back() - '0') + 1));
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050044}
45
46std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
47{
Deepak Kodihalli02ba9ec2017-03-18 02:57:43 -050048 std::string msg = "Pass through to OCC ";
49 msg += path;
50
51 std::string cmd;
52 std::for_each(command.cbegin(), command.cend(),
53 [&cmd](const auto& c)
54 {
55 cmd += std::to_string(c);
56 cmd += ',';
57 });
58 if (!cmd.empty())
59 {
60 // Remove trailing ','
61 cmd.pop_back();
62 }
63
64 using namespace phosphor::logging;
65 log<level::INFO>(msg.c_str(), entry("COMMAND=%s", cmd.c_str()));
66
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050067 return {};
68}
69
70} // namespace pass_through
71} // namespace occ
72} // namespace open_power