blob: 8e58b258424244fab3a746589420fc3c3c35150f [file] [log] [blame]
Patrick Venture9bf5cef2020-08-16 08:59:54 -07001/**
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
Patrick Venture09334bb2020-08-16 12:22:54 -070017#include "control.hpp"
18#include "dbus_mode.hpp"
Patrick Venture9bf5cef2020-08-16 08:59:54 -070019#include "manualcmds.hpp"
20
21#include <ipmid/iana.hpp>
22#include <ipmid/oemopenbmc.hpp>
23#include <ipmid/oemrouter.hpp>
24
25#include <cstdio>
Patrick Venture09334bb2020-08-16 12:22:54 -070026#include <functional>
27#include <memory>
28
29namespace pid_control
30{
31namespace ipmi
32{
33
34ZoneControlIpmiHandler handler(std::make_unique<DbusZoneControl>());
35
36}
37} // namespace pid_control
Patrick Venture9bf5cef2020-08-16 08:59:54 -070038
39void setupGlobalOemFanControl() __attribute__((constructor));
40
41void 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
Patrick Venture09334bb2020-08-16 12:22:54 -070050 using namespace std::placeholders;
Patrick Venture9bf5cef2020-08-16 08:59:54 -070051 router->registerHandler(oem::obmcOemNumber, oem::Cmd::fanManualCmd,
Patrick Venture09334bb2020-08-16 12:22:54 -070052 std::bind(pid_control::ipmi::manualModeControl,
53 &pid_control::ipmi::handler, _1, _2, _3,
54 _4));
Patrick Venture9bf5cef2020-08-16 08:59:54 -070055}