Willy Tu | a2056e9 | 2021-10-10 13:36:16 -0700 | [diff] [blame] | 1 | // 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 Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 14 | |
Patrick Venture | c87de55 | 2020-05-20 20:25:39 -0700 | [diff] [blame] | 15 | #include "handler_impl.hpp" |
Patrick Venture | eff1f2e | 2020-08-05 08:27:36 -0700 | [diff] [blame] | 16 | #include "ipmi.hpp" |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 17 | |
William A. Kennington III | 2c9e162 | 2019-02-07 15:45:19 -0800 | [diff] [blame] | 18 | #include <ipmid/api.h> |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 19 | |
| 20 | #include <cstdint> |
Patrick Venture | 28557a1 | 2018-09-28 08:56:05 -0700 | [diff] [blame] | 21 | #include <cstdio> |
Patrick Venture | eff1f2e | 2020-08-05 08:27:36 -0700 | [diff] [blame] | 22 | #include <functional> |
Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 23 | #include <ipmid/api-types.hpp> |
| 24 | #include <ipmid/handler.hpp> |
William A. Kennington III | 2c9e162 | 2019-02-07 15:45:19 -0800 | [diff] [blame] | 25 | #include <ipmid/iana.hpp> |
Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 26 | #include <span> |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 27 | |
| 28 | namespace oem |
| 29 | { |
| 30 | namespace google |
| 31 | { |
| 32 | constexpr int sysCmd = 50; |
| 33 | } // namespace google |
| 34 | } // namespace oem |
| 35 | |
| 36 | namespace google |
| 37 | { |
| 38 | namespace ipmi |
| 39 | { |
| 40 | |
Patrick Venture | 96b088a | 2018-11-13 15:02:33 -0800 | [diff] [blame] | 41 | void setupGoogleOemSysCommands() __attribute__((constructor)); |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 42 | |
Patrick Venture | 96b088a | 2018-11-13 15:02:33 -0800 | [diff] [blame] | 43 | void setupGoogleOemSysCommands() |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 44 | { |
William A. Kennington III | 96ad906 | 2020-11-24 21:47:20 -0800 | [diff] [blame] | 45 | static Handler handlerImpl; |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 46 | |
Patrick Venture | ce07ee0 | 2018-09-19 18:09:32 -0700 | [diff] [blame] | 47 | std::fprintf(stderr, |
| 48 | "Registering OEM:[%#08X], Cmd:[%#04X] for Sys Commands\n", |
| 49 | oem::googOemNumber, oem::google::sysCmd); |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 50 | |
Willy Tu | b4e3704 | 2021-10-12 17:12:30 -0700 | [diff] [blame] | 51 | ::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 Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | } // namespace ipmi |
| 61 | } // namespace google |