blob: d3179f38e323dc54491b76c6947b5c1194e0f128 [file] [log] [blame]
Patrick Ventureef3aead2018-09-12 08:53:29 -07001/*
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 Venturecd8dab42019-01-15 19:57:38 -080020#include "manager.hpp"
Patrick Ventureef3aead2018-09-12 08:53:29 -070021#include "process.hpp"
Patrick Venture5100a382018-09-27 10:40:50 -070022#include "utils.hpp"
Patrick Ventureef3aead2018-09-12 08:53:29 -070023
William A. Kennington IIIacebece2019-02-07 15:15:44 -080024#include <ipmid/api.h>
Patrick Ventureef3aead2018-09-12 08:53:29 -070025
26#include <cstdio>
Willy Tu067ece12022-06-16 02:07:06 -070027#include <ipmid/api-types.hpp>
28#include <ipmid/handler.hpp>
William A. Kennington IIIacebece2019-02-07 15:15:44 -080029#include <ipmid/iana.hpp>
30#include <ipmid/oemopenbmc.hpp>
31#include <ipmid/oemrouter.hpp>
Patrick Ventureef3aead2018-09-12 08:53:29 -070032#include <memory>
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070033#include <phosphor-logging/log.hpp>
Willy Tu067ece12022-06-16 02:07:06 -070034#include <span>
Patrick Ventureef3aead2018-09-12 08:53:29 -070035
Patrick Ventureef3aead2018-09-12 08:53:29 -070036namespace blobs
37{
38
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070039using namespace phosphor::logging;
40
Patrick Ventureef3aead2018-09-12 08:53:29 -070041void setupBlobGlobalHandler() __attribute__((constructor));
42
43void setupBlobGlobalHandler()
44{
Patrick Ventureef3aead2018-09-12 08:53:29 -070045 std::fprintf(stderr,
46 "Registering OEM:[%#08X], Cmd:[%#04X] for Blob Commands\n",
Patrick Venturee08863e2018-11-15 14:39:44 -080047 oem::obmcOemNumber, oem::Cmd::blobTransferCmd);
Patrick Ventureef3aead2018-09-12 08:53:29 -070048
Willy Tu067ece12022-06-16 02:07:06 -070049 ipmi::registerOemHandler(
50 ipmi::prioOemBase, oem::obmcOemNumber, oem::Cmd::blobTransferCmd,
51 ::ipmi::Privilege::User,
52 [](ipmi::Context::ptr, uint8_t cmd, const std::vector<uint8_t>& data) {
53 return handleBlobCommand(cmd, data);
54 });
Patrick Ventureef3aead2018-09-12 08:53:29 -070055
Patrick Venture5100a382018-09-27 10:40:50 -070056 /* Install handlers. */
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070057 try
58 {
Patrick Venture8aee0572018-11-28 14:59:23 -080059 loadLibraries(getBlobManager(), BLOB_LIB_PATH);
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070060 }
61 catch (const std::exception& e)
62 {
63 log<level::ERR>("ERROR loading blob handlers",
64 entry("ERROR=%s", e.what()));
65 }
Patrick Ventureef3aead2018-09-12 08:53:29 -070066}
67} // namespace blobs