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 | { |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 17 | namespace |
| 18 | { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 19 | HashFileHandler hashHandler; |
Patrick Venture | a5c5906 | 2018-11-09 12:25:52 -0800 | [diff] [blame] | 20 | StaticLayoutHandler staticLayoutHandler(STATIC_HANDLER_STAGED_NAME); |
Patrick Venture | e772842 | 2018-11-14 20:16:33 -0800 | [diff] [blame] | 21 | |
| 22 | #ifdef ENABLE_LPC_BRIDGE |
| 23 | #if defined(ASPEED_LPC) |
| 24 | LpcDataHandler lpcDataHandler(LpcMapperAspeed::createAspeedMapper()); |
| 25 | #elif defined(NUVOTON_LPC) |
| 26 | LpcDataHandler lpcDataHandler(LpcMapperNuvoton::createNuvotonMapper()); |
| 27 | #else |
| 28 | #error "You must specify a hardware implementation." |
| 29 | #endif |
| 30 | #endif |
| 31 | |
Patrick Venture | b0c84d0 | 2018-11-09 12:00:31 -0800 | [diff] [blame] | 32 | PciDataHandler pciDataHandler(PCI_PHYSICAL_ADDRESS); |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 33 | |
| 34 | std::vector<HandlerPack> supportedFirmware = { |
Patrick Venture | 18235e6 | 2018-11-08 10:21:09 -0800 | [diff] [blame] | 35 | {FirmwareBlobHandler::hashBlobID, &hashHandler}, |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame] | 36 | #ifdef ENABLE_STATIC_LAYOUT |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 37 | {"/flash/image", &staticLayoutHandler}, |
Patrick Venture | 148cd65 | 2018-11-06 10:59:47 -0800 | [diff] [blame] | 38 | #endif |
| 39 | }; |
| 40 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 41 | std::vector<DataHandlerPack> supportedTransports = { |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 42 | {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 43 | #ifdef ENABLE_PCI_BRIDGE |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 44 | {FirmwareBlobHandler::UpdateFlags::p2a, &pciDataHandler}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 45 | #endif |
| 46 | #ifdef ENABLE_LPC_BRIDGE |
Patrick Venture | 05abf7e | 2018-11-09 11:02:56 -0800 | [diff] [blame] | 47 | {FirmwareBlobHandler::UpdateFlags::lpc, &lpcDataHandler}, |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 48 | #endif |
| 49 | }; |
| 50 | |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 51 | } // namespace |
Patrick Venture | 192d60f | 2018-11-06 11:11:59 -0800 | [diff] [blame] | 52 | |
Patrick Venture | 5b451e6 | 2018-11-14 14:20:08 -0800 | [diff] [blame] | 53 | } // namespace blobs |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 54 | |
Patrick Venture | 5b451e6 | 2018-11-14 14:20:08 -0800 | [diff] [blame] | 55 | #ifdef __cplusplus |
| 56 | extern "C" { |
| 57 | #endif |
| 58 | |
| 59 | std::unique_ptr<blobs::GenericBlobInterface> createHandler(); |
| 60 | |
| 61 | #ifdef __cplusplus |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | std::unique_ptr<blobs::GenericBlobInterface> createHandler() |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 66 | { |
Patrick Venture | 5b451e6 | 2018-11-14 14:20:08 -0800 | [diff] [blame] | 67 | using namespace phosphor::logging; |
| 68 | |
| 69 | auto handler = blobs::FirmwareBlobHandler::CreateFirmwareBlobHandler( |
| 70 | blobs::supportedFirmware, blobs::supportedTransports); |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 71 | |
| 72 | if (!handler) |
| 73 | { |
| 74 | log<level::ERR>("Firmware Handler has invalid configuration"); |
Patrick Venture | 5b451e6 | 2018-11-14 14:20:08 -0800 | [diff] [blame] | 75 | return nullptr; |
Patrick Venture | 5285462 | 2018-11-06 12:30:00 -0800 | [diff] [blame] | 76 | } |
| 77 | |
Patrick Venture | 5b451e6 | 2018-11-14 14:20:08 -0800 | [diff] [blame] | 78 | return std::move(handler); |
Patrick Venture | c7ca291 | 2018-11-02 11:38:33 -0700 | [diff] [blame] | 79 | } |