1 /**
2 * Copyright 2017 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "control.hpp"
18 #include "dbus_mode.hpp"
19 #include "manualcmds.hpp"
20
21 #include <ipmid/iana.hpp>
22 #include <ipmid/oemopenbmc.hpp>
23 #include <ipmid/oemrouter.hpp>
24
25 #include <cstdio>
26 #include <functional>
27 #include <memory>
28
29 namespace pid_control
30 {
31 namespace ipmi
32 {
33
34 ZoneControlIpmiHandler handler(std::make_unique<DbusZoneControl>());
35
36 }
37 } // namespace pid_control
38
39 void setupGlobalOemFanControl() __attribute__((constructor));
40
setupGlobalOemFanControl()41 void setupGlobalOemFanControl()
42 {
43 oem::Router* router = oem::mutableRouter();
44
45 std::fprintf(
46 stderr,
47 "Registering OEM:[%#08X], Cmd:[%#04X] for Manual Zone Control\n",
48 oem::obmcOemNumber, oem::Cmd::fanManualCmd);
49
50 using namespace std::placeholders;
51 router->registerHandler(
52 oem::obmcOemNumber, oem::Cmd::fanManualCmd,
53 std::bind(pid_control::ipmi::manualModeControl,
54 &pid_control::ipmi::handler, _1, _2, _3, _4));
55 }
56