blob: 09d0990533e8074f3cb1a36e0f4671028342d5cf [file] [log] [blame]
Willy Tua2056e92021-10-10 13:36:16 -07001// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
Patrick Venture4d49ae62018-09-17 11:35:32 -070014
Patrick Venturec87de552020-05-20 20:25:39 -070015#include "handler_impl.hpp"
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070016#include "ipmi.hpp"
Patrick Venture4d49ae62018-09-17 11:35:32 -070017
William A. Kennington III2c9e1622019-02-07 15:45:19 -080018#include <ipmid/api.h>
Patrick Venture4d49ae62018-09-17 11:35:32 -070019
20#include <cstdint>
Patrick Venture28557a12018-09-28 08:56:05 -070021#include <cstdio>
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070022#include <functional>
William A. Kennington III2c9e1622019-02-07 15:45:19 -080023#include <ipmid/iana.hpp>
24#include <ipmid/oemrouter.hpp>
Patrick Venture4d49ae62018-09-17 11:35:32 -070025
26namespace oem
27{
28namespace google
29{
30constexpr int sysCmd = 50;
31} // namespace google
32} // namespace oem
33
34namespace google
35{
36namespace ipmi
37{
38
Patrick Venture96b088a2018-11-13 15:02:33 -080039void setupGoogleOemSysCommands() __attribute__((constructor));
Patrick Venture4d49ae62018-09-17 11:35:32 -070040
Patrick Venture96b088a2018-11-13 15:02:33 -080041void setupGoogleOemSysCommands()
Patrick Venture4d49ae62018-09-17 11:35:32 -070042{
William A. Kennington III96ad9062020-11-24 21:47:20 -080043 static Handler handlerImpl;
Patrick Venture4d49ae62018-09-17 11:35:32 -070044 oem::Router* oemRouter = oem::mutableRouter();
45
Patrick Venturece07ee02018-09-19 18:09:32 -070046 std::fprintf(stderr,
47 "Registering OEM:[%#08X], Cmd:[%#04X] for Sys Commands\n",
48 oem::googOemNumber, oem::google::sysCmd);
Patrick Venture4d49ae62018-09-17 11:35:32 -070049
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070050 using namespace std::placeholders;
51 oemRouter->registerHandler(
52 oem::googOemNumber, oem::google::sysCmd,
53 std::bind(handleSysCommand, &handlerImpl, _1, _2, _3, _4));
Patrick Venture4d49ae62018-09-17 11:35:32 -070054}
55
56} // namespace ipmi
57} // namespace google