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