blob: 061c15f92a9a5fdb53828b72431aa2688efec4f9 [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
Willy Tuff3cd8e2021-09-14 22:49:55 -070020#include <ipmid/api-types.hpp>
21#include <ipmid/handler.hpp>
William A. Kennington III2c9e1622019-02-07 15:45:19 -080022#include <ipmid/iana.hpp>
Patrick Williams444b5ea2023-05-19 13:56:42 -050023
24#include <cstdint>
25#include <cstdio>
26#include <functional>
Willy Tuff3cd8e2021-09-14 22:49:55 -070027#include <span>
Patrick Venture4d49ae62018-09-17 11:35:32 -070028
29namespace oem
30{
31namespace google
32{
33constexpr int sysCmd = 50;
34} // namespace google
35} // namespace oem
36
37namespace google
38{
39namespace ipmi
40{
41
Patrick Venture96b088a2018-11-13 15:02:33 -080042void setupGoogleOemSysCommands() __attribute__((constructor));
Patrick Venture4d49ae62018-09-17 11:35:32 -070043
Patrick Venture96b088a2018-11-13 15:02:33 -080044void setupGoogleOemSysCommands()
Patrick Venture4d49ae62018-09-17 11:35:32 -070045{
William A. Kennington III96ad9062020-11-24 21:47:20 -080046 static Handler handlerImpl;
Patrick Venture4d49ae62018-09-17 11:35:32 -070047
Patrick Venturece07ee02018-09-19 18:09:32 -070048 std::fprintf(stderr,
49 "Registering OEM:[%#08X], Cmd:[%#04X] for Sys Commands\n",
50 oem::googOemNumber, oem::google::sysCmd);
Patrick Venture4d49ae62018-09-17 11:35:32 -070051
Willy Tub4e37042021-10-12 17:12:30 -070052 ::ipmi::registerOemHandler(::ipmi::prioOemBase, oem::googOemNumber,
53 oem::google::sysCmd, ::ipmi::Privilege::User,
54 [](::ipmi::Context::ptr ctx, uint8_t cmd,
55 const std::vector<uint8_t>& data) {
Patrick Williams444b5ea2023-05-19 13:56:42 -050056 return handleSysCommand(&handlerImpl, ctx, cmd, data);
57 });
Patrick Venture4d49ae62018-09-17 11:35:32 -070058}
59
60} // namespace ipmi
61} // namespace google