blob: ec0f53b441319e21a3117bdd5d4e37873abbbeee [file] [log] [blame]
Patrick Venture148cd652018-11-06 10:59:47 -08001#include "config.h"
2
Patrick Venturec7ca2912018-11-02 11:38:33 -07003#include "firmware_handler.hpp"
4
5#include <blobs-ipmid/manager.hpp>
Patrick Venture192d60f2018-11-06 11:11:59 -08006#include <cstdint>
Patrick Venturec7ca2912018-11-02 11:38:33 -07007#include <memory>
8#include <phosphor-logging/log.hpp>
9
10namespace blobs
11{
12using namespace phosphor::logging;
13
Patrick Venture148cd652018-11-06 10:59:47 -080014std::vector<std::string> supportedFirmware = {
Patrick Venture148cd652018-11-06 10:59:47 -080015#ifdef ENABLE_STATIC_LAYOUT
16 "/flash/image",
17#endif
18};
19
Patrick Venture192d60f2018-11-06 11:11:59 -080020std::uint32_t supportedTransports =
21 static_cast<std::uint32_t>(FirmwareUpdateFlags::bt);
22
Patrick Venturec7ca2912018-11-02 11:38:33 -070023void setupFirmwareHandler() __attribute__((constructor));
24
25void setupFirmwareHandler()
26{
Patrick Venture192d60f2018-11-06 11:11:59 -080027#ifdef ENABLE_PCI_BRIDGE
28 supportedTransports |= static_cast<std::uint32_t>(FirmwareUpdateFlags::p2a);
29#endif
30#ifdef ENABLE_LPC_BRIDGE
31 supportedTransports |= static_cast<std::uint32_t>(FirmwareUpdateFlags::lpc);
32#endif
33
Patrick Venture52854622018-11-06 12:30:00 -080034 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
35 supportedFirmware, supportedTransports);
36
37 if (!handler)
38 {
39 log<level::ERR>("Firmware Handler has invalid configuration");
40 return;
41 }
42
Patrick Venturec7ca2912018-11-02 11:38:33 -070043 auto* manager = getBlobManager();
Patrick Venture52854622018-11-06 12:30:00 -080044
45 if (!manager->registerHandler(std::move(handler)))
Patrick Venturec7ca2912018-11-02 11:38:33 -070046 {
47 log<level::ERR>("Failed to register Firmware Handler");
48 }
49}
50
51} // namespace blobs