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