blob: 69d9c045075d1562f73604b481e678b24c93a107 [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>
Michael Shen8d618532023-10-25 09:14:07 +000023#include <stdplus/print.hpp>
Patrick Williams444b5ea2023-05-19 13:56:42 -050024
25#include <cstdint>
26#include <cstdio>
27#include <functional>
Willy Tuff3cd8e2021-09-14 22:49:55 -070028#include <span>
Patrick Venture4d49ae62018-09-17 11:35:32 -070029
30namespace oem
31{
32namespace google
33{
34constexpr int sysCmd = 50;
35} // namespace google
36} // namespace oem
37
38namespace google
39{
40namespace ipmi
41{
42
Patrick Venture96b088a2018-11-13 15:02:33 -080043void setupGoogleOemSysCommands() __attribute__((constructor));
Patrick Venture4d49ae62018-09-17 11:35:32 -070044
Patrick Venture96b088a2018-11-13 15:02:33 -080045void setupGoogleOemSysCommands()
Patrick Venture4d49ae62018-09-17 11:35:32 -070046{
William A. Kennington III96ad9062020-11-24 21:47:20 -080047 static Handler handlerImpl;
Patrick Venture4d49ae62018-09-17 11:35:32 -070048
Michael Shen8d618532023-10-25 09:14:07 +000049 stdplus::print(
50 stderr, "Registering OEM:[{:#08X}], Cmd:[{:#04X}] for Sys Commands\n",
51 oem::googOemNumber, oem::google::sysCmd);
Patrick Venture4d49ae62018-09-17 11:35:32 -070052
Willy Tub4e37042021-10-12 17:12:30 -070053 ::ipmi::registerOemHandler(::ipmi::prioOemBase, oem::googOemNumber,
54 oem::google::sysCmd, ::ipmi::Privilege::User,
55 [](::ipmi::Context::ptr ctx, uint8_t cmd,
56 const std::vector<uint8_t>& data) {
Patrick Williams444b5ea2023-05-19 13:56:42 -050057 return handleSysCommand(&handlerImpl, ctx, cmd, data);
58 });
Patrick Venture4d49ae62018-09-17 11:35:32 -070059}
60
61} // namespace ipmi
62} // namespace google