Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Patrick Venture | c87de55 | 2020-05-20 20:25:39 -0700 | [diff] [blame] | 17 | #include "handler_impl.hpp" |
Patrick Venture | eff1f2e | 2020-08-05 08:27:36 -0700 | [diff] [blame] | 18 | #include "ipmi.hpp" |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 19 | |
William A. Kennington III | 2c9e162 | 2019-02-07 15:45:19 -0800 | [diff] [blame] | 20 | #include <ipmid/api.h> |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 21 | |
| 22 | #include <cstdint> |
Patrick Venture | 28557a1 | 2018-09-28 08:56:05 -0700 | [diff] [blame] | 23 | #include <cstdio> |
Patrick Venture | eff1f2e | 2020-08-05 08:27:36 -0700 | [diff] [blame] | 24 | #include <functional> |
William A. Kennington III | 2c9e162 | 2019-02-07 15:45:19 -0800 | [diff] [blame] | 25 | #include <ipmid/iana.hpp> |
| 26 | #include <ipmid/oemrouter.hpp> |
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 | oem::Router* oemRouter = oem::mutableRouter(); |
| 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 | |
Patrick Venture | eff1f2e | 2020-08-05 08:27:36 -0700 | [diff] [blame] | 52 | using namespace std::placeholders; |
| 53 | oemRouter->registerHandler( |
| 54 | oem::googOemNumber, oem::google::sysCmd, |
| 55 | std::bind(handleSysCommand, &handlerImpl, _1, _2, _3, _4)); |
Patrick Venture | 4d49ae6 | 2018-09-17 11:35:32 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | } // namespace ipmi |
| 59 | } // namespace google |