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" |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 4 | #include "image_handler.hpp" |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 5 | #include "lpc_handler.hpp" |
| 6 | #include "pci_handler.hpp" |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 7 | #include "static_handler.hpp" |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 8 | |
| 9 | #include <blobs-ipmid/manager.hpp> |
Patrick Venture | 192d60f | 2018-11-06 11:11:59 -0800 | [diff] [blame] | 10 | #include <cstdint> |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 11 | #include <memory> |
| 12 | #include <phosphor-logging/log.hpp> |
| 13 | |
| 14 | namespace blobs |
| 15 | { |
| 16 | using namespace phosphor::logging; |
| 17 | |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 18 | namespace |
| 19 | { |
| 20 | StaticLayoutHandler staticLayoutHandler; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 21 | LpcDataHandler lpcDataHandler; |
| 22 | PciDataHandler pciDataHandler; |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 23 | |
| 24 | std::vector<HandlerPack> supportedFirmware = { |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame] | 25 | #ifdef ENABLE_STATIC_LAYOUT |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 26 | {"/flash/image", &staticLayoutHandler}, |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame] | 27 | #endif |
| 28 | }; |
| 29 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 30 | std::vector<DataHandlerPack> supportedTransports = { |
| 31 | {FirmwareBlobHandler::FirmwareUpdateFlags::bt, nullptr}, |
| 32 | #ifdef ENABLE_PCI_BRIDGE |
| 33 | {FirmwareBlobHandler::FirmwareUpdateFlags::p2a, &pciDataHandler}, |
| 34 | #endif |
| 35 | #ifdef ENABLE_LPC_BRIDGE |
| 36 | {FirmwareBlobHandler::FirmwareUpdateFlags::lpc, &lpcDataHandler}, |
| 37 | #endif |
| 38 | }; |
| 39 | |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 40 | } // namespace |
Patrick Venture | 192d60f | 2018-11-06 11:11:59 -0800 | [diff] [blame] | 41 | |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 42 | void setupFirmwareHandler() __attribute__((constructor)); |
| 43 | |
| 44 | void setupFirmwareHandler() |
| 45 | { |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 46 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 47 | supportedFirmware, supportedTransports); |
| 48 | |
| 49 | if (!handler) |
| 50 | { |
| 51 | log<level::ERR>("Firmware Handler has invalid configuration"); |
| 52 | return; |
| 53 | } |
| 54 | |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 55 | auto* manager = getBlobManager(); |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 56 | |
| 57 | if (!manager->registerHandler(std::move(handler))) |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 58 | { |
| 59 | log<level::ERR>("Failed to register Firmware Handler"); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | } // namespace blobs |