Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 3 | #include "firmware_handler.hpp" |
| 4 | |
| 5 | #include <blobs-ipmid/manager.hpp> |
Patrick Venture | 192d60f | 2018-11-06 11:11:59 -0800 | [diff] [blame] | 6 | #include <cstdint> |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 7 | #include <memory> |
| 8 | #include <phosphor-logging/log.hpp> |
| 9 | |
| 10 | namespace blobs |
| 11 | { |
| 12 | using namespace phosphor::logging; |
| 13 | |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame] | 14 | std::vector<std::string> supportedFirmware = { |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame] | 15 | #ifdef ENABLE_STATIC_LAYOUT |
| 16 | "/flash/image", |
| 17 | #endif |
| 18 | }; |
| 19 | |
Patrick Venture | 192d60f | 2018-11-06 11:11:59 -0800 | [diff] [blame] | 20 | std::uint32_t supportedTransports = |
| 21 | static_cast<std::uint32_t>(FirmwareUpdateFlags::bt); |
| 22 | |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 23 | void setupFirmwareHandler() __attribute__((constructor)); |
| 24 | |
| 25 | void setupFirmwareHandler() |
| 26 | { |
Patrick Venture | 192d60f | 2018-11-06 11:11:59 -0800 | [diff] [blame] | 27 | #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 Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame^] | 34 | 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 Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 43 | auto* manager = getBlobManager(); |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame^] | 44 | |
| 45 | if (!manager->registerHandler(std::move(handler))) |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 46 | { |
| 47 | log<level::ERR>("Failed to register Firmware Handler"); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | } // namespace blobs |