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 | |
Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 20 | #include <ipmid/api-types.hpp> |
| 21 | #include <ipmid/handler.hpp> |
William A. Kennington III | 2c9e162 | 2019-02-07 15:45:19 -0800 | [diff] [blame] | 22 | #include <ipmid/iana.hpp> |
Michael Shen | 8d61853 | 2023-10-25 09:14:07 +0000 | [diff] [blame] | 23 | #include <stdplus/print.hpp> |
Patrick Williams | 444b5ea | 2023-05-19 13:56:42 -0500 | [diff] [blame] | 24 | |
| 25 | #include <cstdint> |
| 26 | #include <cstdio> |
| 27 | #include <functional> |
Willy Tu | ff3cd8e | 2021-09-14 22:49:55 -0700 | [diff] [blame] | 28 | #include <span> |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 29 | |
| 30 | namespace oem |
| 31 | { |
| 32 | namespace google |
| 33 | { |
| 34 | constexpr int sysCmd = 50; |
| 35 | } // namespace google |
| 36 | } // namespace oem |
| 37 | |
| 38 | namespace google |
| 39 | { |
| 40 | namespace ipmi |
| 41 | { |
| 42 | |
Patrick Venture | 96b088a | 2018-11-13 15:02:33 -0800 | [diff] [blame] | 43 | void setupGoogleOemSysCommands() __attribute__((constructor)); |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 44 | |
Patrick Venture | 96b088a | 2018-11-13 15:02:33 -0800 | [diff] [blame] | 45 | void setupGoogleOemSysCommands() |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 46 | { |
William A. Kennington III | 96ad906 | 2020-11-24 21:47:20 -0800 | [diff] [blame] | 47 | static Handler handlerImpl; |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 48 | |
Michael Shen | 8d61853 | 2023-10-25 09:14:07 +0000 | [diff] [blame] | 49 | stdplus::print( |
| 50 | stderr, "Registering OEM:[{:#08X}], Cmd:[{:#04X}] for Sys Commands\n", |
| 51 | oem::googOemNumber, oem::google::sysCmd); |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 52 | |
Patrick Williams | 8c0094e | 2024-08-16 15:22:37 -0400 | [diff] [blame] | 53 | ::ipmi::registerOemHandler( |
| 54 | ::ipmi::prioOemBase, oem::googOemNumber, oem::google::sysCmd, |
| 55 | ::ipmi::Privilege::User, |
| 56 | [](::ipmi::Context::ptr ctx, uint8_t cmd, |
| 57 | const std::vector<uint8_t>& data) { |
| 58 | return handleSysCommand(&handlerImpl, ctx, cmd, data); |
| 59 | }); |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | } // namespace ipmi |
| 63 | } // namespace google |