blob: e903e1c82a49282a7b3b041867bb77e92a56683a [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>
Willy Tuff3cd8e2021-09-14 22:49:55 -070023#include <ipmid/api-types.hpp>
24#include <ipmid/handler.hpp>
William A. Kennington III2c9e1622019-02-07 15:45:19 -080025#include <ipmid/iana.hpp>
Willy Tuff3cd8e2021-09-14 22:49:55 -070026#include <span>
Patrick Venture4d49ae62018-09-17 11:35:32 -070027
28namespace oem
29{
30namespace google
31{
32constexpr int sysCmd = 50;
33} // namespace google
34} // namespace oem
35
36namespace google
37{
38namespace ipmi
39{
40
Patrick Venture96b088a2018-11-13 15:02:33 -080041void setupGoogleOemSysCommands() __attribute__((constructor));
Patrick Venture4d49ae62018-09-17 11:35:32 -070042
Patrick Venture96b088a2018-11-13 15:02:33 -080043void setupGoogleOemSysCommands()
Patrick Venture4d49ae62018-09-17 11:35:32 -070044{
William A. Kennington III96ad9062020-11-24 21:47:20 -080045 static Handler handlerImpl;
Patrick Venture4d49ae62018-09-17 11:35:32 -070046
Patrick Venturece07ee02018-09-19 18:09:32 -070047 std::fprintf(stderr,
48 "Registering OEM:[%#08X], Cmd:[%#04X] for Sys Commands\n",
49 oem::googOemNumber, oem::google::sysCmd);
Patrick Venture4d49ae62018-09-17 11:35:32 -070050
Willy Tub4e37042021-10-12 17:12:30 -070051 ::ipmi::registerOemHandler(::ipmi::prioOemBase, oem::googOemNumber,
52 oem::google::sysCmd, ::ipmi::Privilege::User,
53 [](::ipmi::Context::ptr ctx, uint8_t cmd,
54 const std::vector<uint8_t>& data) {
55 return handleSysCommand(&handlerImpl, ctx,
56 cmd, data);
57 });
Patrick Venture4d49ae62018-09-17 11:35:32 -070058}
59
60} // namespace ipmi
61} // namespace google