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