xref: /openbmc/phosphor-pid-control/ipmi/main_ipmi.cpp (revision f8b6e55147148c3cfb42327ff267197a460b411c)
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 "dbus_mode.hpp"
18 #include "manualcmds.hpp"
19 
20 #include <ipmid/iana.hpp>
21 #include <ipmid/oemopenbmc.hpp>
22 #include <ipmid/oemrouter.hpp>
23 
24 #include <cstdio>
25 #include <functional>
26 #include <memory>
27 
28 namespace pid_control
29 {
30 namespace ipmi
31 {
32 
33 ZoneControlIpmiHandler handler(std::make_unique<DbusZoneControl>());
34 
35 }
36 } // namespace pid_control
37 
38 void setupGlobalOemFanControl() __attribute__((constructor));
39 
40 void setupGlobalOemFanControl()
41 {
42     oem::Router* router = oem::mutableRouter();
43 
44     std::fprintf(
45         stderr,
46         "Registering OEM:[%#08X], Cmd:[%#04X] for Manual Zone Control\n",
47         oem::obmcOemNumber, oem::Cmd::fanManualCmd);
48 
49     router->registerHandler(
50         oem::obmcOemNumber, oem::Cmd::fanManualCmd,
51         std::bind_front(pid_control::ipmi::manualModeControl,
52                         &pid_control::ipmi::handler));
53 }
54