xref: /openbmc/phosphor-ipmi-blobs/main.cpp (revision 03fd5b8b9e8fc0eb7f77c1a170fd2c0018ab9e63)
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"
20 #include "manager.hpp"
21 #include "process.hpp"
22 #include "utils.hpp"
23 
24 #include <ipmid/api.h>
25 
26 #include <cstdio>
27 #include <ipmid/iana.hpp>
28 #include <ipmid/oemopenbmc.hpp>
29 #include <ipmid/oemrouter.hpp>
30 #include <memory>
31 #include <phosphor-logging/log.hpp>
32 
33 namespace blobs
34 {
35 
36 using namespace phosphor::logging;
37 
38 void setupBlobGlobalHandler() __attribute__((constructor));
39 
40 void setupBlobGlobalHandler()
41 {
42     oem::Router* oemRouter = oem::mutableRouter();
43     std::fprintf(stderr,
44                  "Registering OEM:[%#08X], Cmd:[%#04X] for Blob Commands\n",
45                  oem::obmcOemNumber, oem::Cmd::blobTransferCmd);
46 
47     oemRouter->registerHandler(oem::obmcOemNumber, oem::Cmd::blobTransferCmd,
48                                handleBlobCommand);
49 
50     /* Install handlers. */
51     try
52     {
53         loadLibraries(getBlobManager(), BLOB_LIB_PATH);
54     }
55     catch (const std::exception& e)
56     {
57         log<level::ERR>("ERROR loading blob handlers",
58                         entry("ERROR=%s", e.what()));
59     }
60 }
61 } // namespace blobs
62