blob: 7daceb99dca82f6d1c4d30bfb84ba5811158823f [file] [log] [blame]
Patrick Venture148cd652018-11-06 10:59:47 -08001#include "config.h"
2
Patrick Venture64919ec2018-11-15 11:52:07 -08003#include "file_handler.hpp"
Patrick Venturec7ca2912018-11-02 11:38:33 -07004#include "firmware_handler.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08005#include "image_handler.hpp"
Patrick Venture1cde5f92018-11-07 08:26:47 -08006#include "lpc_handler.hpp"
7#include "pci_handler.hpp"
Patrick Venturec7ca2912018-11-02 11:38:33 -07008
9#include <blobs-ipmid/manager.hpp>
Patrick Venture192d60f2018-11-06 11:11:59 -080010#include <cstdint>
Patrick Venturec7ca2912018-11-02 11:38:33 -070011#include <memory>
12#include <phosphor-logging/log.hpp>
13
14namespace blobs
15{
Patrick Venturea78e39f2018-11-06 18:37:06 -080016namespace
17{
Patrick Venture64919ec2018-11-15 11:52:07 -080018FileHandler hashHandler(HASH_FILENAME);
Patrick Venture7753d942018-11-15 13:15:36 -080019FileHandler staticLayoutHandler(STATIC_HANDLER_STAGED_NAME);
Patrick Venturee7728422018-11-14 20:16:33 -080020
21#ifdef ENABLE_LPC_BRIDGE
22#if defined(ASPEED_LPC)
Patrick Venture002916a2018-11-15 10:38:07 -080023LpcDataHandler lpcDataHandler(MAPPED_ADDRESS,
24 LpcMapperAspeed::createAspeedMapper());
Patrick Venturee7728422018-11-14 20:16:33 -080025#elif defined(NUVOTON_LPC)
Patrick Venture002916a2018-11-15 10:38:07 -080026LpcDataHandler lpcDataHandler(MAPPED_ADDRESS,
27 LpcMapperNuvoton::createNuvotonMapper());
Patrick Venturee7728422018-11-14 20:16:33 -080028#else
29#error "You must specify a hardware implementation."
30#endif
31#endif
32
Patrick Venture002916a2018-11-15 10:38:07 -080033PciDataHandler pciDataHandler(MAPPED_ADDRESS);
Patrick Venturea78e39f2018-11-06 18:37:06 -080034
35std::vector<HandlerPack> supportedFirmware = {
Patrick Venture18235e62018-11-08 10:21:09 -080036 {FirmwareBlobHandler::hashBlobID, &hashHandler},
Patrick Venture148cd652018-11-06 10:59:47 -080037#ifdef ENABLE_STATIC_LAYOUT
Patrick Venturea78e39f2018-11-06 18:37:06 -080038 {"/flash/image", &staticLayoutHandler},
Patrick Venture148cd652018-11-06 10:59:47 -080039#endif
40};
41
Patrick Venture1cde5f92018-11-07 08:26:47 -080042std::vector<DataHandlerPack> supportedTransports = {
Patrick Venture05abf7e2018-11-09 11:02:56 -080043 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080044#ifdef ENABLE_PCI_BRIDGE
Patrick Venture05abf7e2018-11-09 11:02:56 -080045 {FirmwareBlobHandler::UpdateFlags::p2a, &pciDataHandler},
Patrick Venture1cde5f92018-11-07 08:26:47 -080046#endif
47#ifdef ENABLE_LPC_BRIDGE
Patrick Venture05abf7e2018-11-09 11:02:56 -080048 {FirmwareBlobHandler::UpdateFlags::lpc, &lpcDataHandler},
Patrick Venture1cde5f92018-11-07 08:26:47 -080049#endif
50};
51
Patrick Venturea78e39f2018-11-06 18:37:06 -080052} // namespace
Patrick Venture192d60f2018-11-06 11:11:59 -080053
Patrick Venture5b451e62018-11-14 14:20:08 -080054} // namespace blobs
Patrick Venturec7ca2912018-11-02 11:38:33 -070055
Patrick Venture5b451e62018-11-14 14:20:08 -080056extern "C" {
Patrick Venture5b451e62018-11-14 14:20:08 -080057std::unique_ptr<blobs::GenericBlobInterface> createHandler();
Patrick Venture5b451e62018-11-14 14:20:08 -080058}
Patrick Venture5b451e62018-11-14 14:20:08 -080059
60std::unique_ptr<blobs::GenericBlobInterface> createHandler()
Patrick Venturec7ca2912018-11-02 11:38:33 -070061{
Patrick Venture5b451e62018-11-14 14:20:08 -080062 using namespace phosphor::logging;
63
64 auto handler = blobs::FirmwareBlobHandler::CreateFirmwareBlobHandler(
65 blobs::supportedFirmware, blobs::supportedTransports);
Patrick Venture52854622018-11-06 12:30:00 -080066
67 if (!handler)
68 {
69 log<level::ERR>("Firmware Handler has invalid configuration");
Patrick Venture5b451e62018-11-14 14:20:08 -080070 return nullptr;
Patrick Venture52854622018-11-06 12:30:00 -080071 }
72
Patrick Venture5b451e62018-11-14 14:20:08 -080073 return std::move(handler);
Patrick Venturec7ca2912018-11-02 11:38:33 -070074}