blob: e90969beb991f79f2aec3d82a5110720f42980ca [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>
William A. Kennington IIIacebece2019-02-07 15:15:44 -080027#include <ipmid/iana.hpp>
28#include <ipmid/oemopenbmc.hpp>
29#include <ipmid/oemrouter.hpp>
Patrick Ventureef3aead2018-09-12 08:53:29 -070030#include <memory>
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070031#include <phosphor-logging/log.hpp>
Patrick Ventureef3aead2018-09-12 08:53:29 -070032
Patrick Ventureef3aead2018-09-12 08:53:29 -070033namespace blobs
34{
35
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070036using namespace phosphor::logging;
37
Patrick Ventureef3aead2018-09-12 08:53:29 -070038void setupBlobGlobalHandler() __attribute__((constructor));
39
40void setupBlobGlobalHandler()
41{
42 oem::Router* oemRouter = oem::mutableRouter();
43 std::fprintf(stderr,
44 "Registering OEM:[%#08X], Cmd:[%#04X] for Blob Commands\n",
Patrick Venturee08863e2018-11-15 14:39:44 -080045 oem::obmcOemNumber, oem::Cmd::blobTransferCmd);
Patrick Ventureef3aead2018-09-12 08:53:29 -070046
Patrick Venturee08863e2018-11-15 14:39:44 -080047 oemRouter->registerHandler(oem::obmcOemNumber, oem::Cmd::blobTransferCmd,
Patrick Ventureef3aead2018-09-12 08:53:29 -070048 handleBlobCommand);
49
Patrick Venture5100a382018-09-27 10:40:50 -070050 /* Install handlers. */
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070051 try
52 {
Patrick Venture8aee0572018-11-28 14:59:23 -080053 loadLibraries(getBlobManager(), BLOB_LIB_PATH);
Benjamin Fair1c4d3d32018-10-19 17:22:53 -070054 }
55 catch (const std::exception& e)
56 {
57 log<level::ERR>("ERROR loading blob handlers",
58 entry("ERROR=%s", e.what()));
59 }
Patrick Ventureef3aead2018-09-12 08:53:29 -070060}
61} // namespace blobs