Patrick Venture | ef3aead | 2018-09-12 08:53:29 -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 | |
| 17 | #include "config.h" |
| 18 | |
| 19 | #include "ipmi.hpp" |
Patrick Venture | cd8dab4 | 2019-01-15 19:57:38 -0800 | [diff] [blame] | 20 | #include "manager.hpp" |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 21 | #include "process.hpp" |
Patrick Venture | 5100a38 | 2018-09-27 10:40:50 -0700 | [diff] [blame] | 22 | #include "utils.hpp" |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 23 | |
William A. Kennington III | acebece | 2019-02-07 15:15:44 -0800 | [diff] [blame] | 24 | #include <ipmid/api.h> |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 25 | |
| 26 | #include <cstdio> |
Willy Tu | 88ca532 | 2022-06-14 01:18:53 -0700 | [diff] [blame^] | 27 | #include <functional> |
William A. Kennington III | acebece | 2019-02-07 15:15:44 -0800 | [diff] [blame] | 28 | #include <ipmid/iana.hpp> |
| 29 | #include <ipmid/oemopenbmc.hpp> |
| 30 | #include <ipmid/oemrouter.hpp> |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 31 | #include <memory> |
Benjamin Fair | 1c4d3d3 | 2018-10-19 17:22:53 -0700 | [diff] [blame] | 32 | #include <phosphor-logging/log.hpp> |
Willy Tu | 88ca532 | 2022-06-14 01:18:53 -0700 | [diff] [blame^] | 33 | #include <user_channel/channel_layer.hpp> |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 34 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 35 | namespace blobs |
| 36 | { |
| 37 | |
Benjamin Fair | 1c4d3d3 | 2018-10-19 17:22:53 -0700 | [diff] [blame] | 38 | using namespace phosphor::logging; |
| 39 | |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 40 | void setupBlobGlobalHandler() __attribute__((constructor)); |
| 41 | |
| 42 | void setupBlobGlobalHandler() |
| 43 | { |
| 44 | oem::Router* oemRouter = oem::mutableRouter(); |
| 45 | std::fprintf(stderr, |
| 46 | "Registering OEM:[%#08X], Cmd:[%#04X] for Blob Commands\n", |
Patrick Venture | e08863e | 2018-11-15 14:39:44 -0800 | [diff] [blame] | 47 | oem::obmcOemNumber, oem::Cmd::blobTransferCmd); |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 48 | |
Willy Tu | 88ca532 | 2022-06-14 01:18:53 -0700 | [diff] [blame^] | 49 | oemRouter->registerHandler( |
| 50 | oem::obmcOemNumber, oem::Cmd::blobTransferCmd, |
| 51 | std::bind_front(handleBlobCommand, |
| 52 | // Get current IPMI channel and get the max transfer |
| 53 | // size (assuming that it |
| 54 | // does not change). |
| 55 | ipmi::getChannelMaxTransferSize(ipmi::currentChNum))); |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 56 | |
Patrick Venture | 5100a38 | 2018-09-27 10:40:50 -0700 | [diff] [blame] | 57 | /* Install handlers. */ |
Benjamin Fair | 1c4d3d3 | 2018-10-19 17:22:53 -0700 | [diff] [blame] | 58 | try |
| 59 | { |
Patrick Venture | 8aee057 | 2018-11-28 14:59:23 -0800 | [diff] [blame] | 60 | loadLibraries(getBlobManager(), BLOB_LIB_PATH); |
Benjamin Fair | 1c4d3d3 | 2018-10-19 17:22:53 -0700 | [diff] [blame] | 61 | } |
| 62 | catch (const std::exception& e) |
| 63 | { |
| 64 | log<level::ERR>("ERROR loading blob handlers", |
| 65 | entry("ERROR=%s", e.what())); |
| 66 | } |
Patrick Venture | ef3aead | 2018-09-12 08:53:29 -0700 | [diff] [blame] | 67 | } |
| 68 | } // namespace blobs |