blob: 5304c502c0dea0a3ba893508cd76f0a8a5cbb9ee [file] [log] [blame]
Patrick Venture148cd652018-11-06 10:59:47 -08001#include "config.h"
2
Patrick Venturec7ca2912018-11-02 11:38:33 -07003#include "firmware_handler.hpp"
Patrick Venture18235e62018-11-08 10:21:09 -08004#include "hash_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 Venturea78e39f2018-11-06 18:37:06 -08008#include "static_handler.hpp"
Patrick Venturec7ca2912018-11-02 11:38:33 -07009
10#include <blobs-ipmid/manager.hpp>
Patrick Venture192d60f2018-11-06 11:11:59 -080011#include <cstdint>
Patrick Venturec7ca2912018-11-02 11:38:33 -070012#include <memory>
13#include <phosphor-logging/log.hpp>
14
15namespace blobs
16{
17using namespace phosphor::logging;
18
Patrick Venturea78e39f2018-11-06 18:37:06 -080019namespace
20{
Patrick Venture18235e62018-11-08 10:21:09 -080021HashFileHandler hashHandler;
Patrick Venturea78e39f2018-11-06 18:37:06 -080022StaticLayoutHandler staticLayoutHandler;
Patrick Venture1cde5f92018-11-07 08:26:47 -080023LpcDataHandler lpcDataHandler;
24PciDataHandler pciDataHandler;
Patrick Venturea78e39f2018-11-06 18:37:06 -080025
26std::vector<HandlerPack> supportedFirmware = {
Patrick Venture18235e62018-11-08 10:21:09 -080027 {FirmwareBlobHandler::hashBlobID, &hashHandler},
Patrick Venture148cd652018-11-06 10:59:47 -080028#ifdef ENABLE_STATIC_LAYOUT
Patrick Venturea78e39f2018-11-06 18:37:06 -080029 {"/flash/image", &staticLayoutHandler},
Patrick Venture148cd652018-11-06 10:59:47 -080030#endif
31};
32
Patrick Venture1cde5f92018-11-07 08:26:47 -080033std::vector<DataHandlerPack> supportedTransports = {
Patrick Venture05abf7e2018-11-09 11:02:56 -080034 {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
Patrick Venture1cde5f92018-11-07 08:26:47 -080035#ifdef ENABLE_PCI_BRIDGE
Patrick Venture05abf7e2018-11-09 11:02:56 -080036 {FirmwareBlobHandler::UpdateFlags::p2a, &pciDataHandler},
Patrick Venture1cde5f92018-11-07 08:26:47 -080037#endif
38#ifdef ENABLE_LPC_BRIDGE
Patrick Venture05abf7e2018-11-09 11:02:56 -080039 {FirmwareBlobHandler::UpdateFlags::lpc, &lpcDataHandler},
Patrick Venture1cde5f92018-11-07 08:26:47 -080040#endif
41};
42
Patrick Venturea78e39f2018-11-06 18:37:06 -080043} // namespace
Patrick Venture192d60f2018-11-06 11:11:59 -080044
Patrick Venturec7ca2912018-11-02 11:38:33 -070045void setupFirmwareHandler() __attribute__((constructor));
46
47void setupFirmwareHandler()
48{
Patrick Venture52854622018-11-06 12:30:00 -080049 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 Venturec7ca2912018-11-02 11:38:33 -070058 auto* manager = getBlobManager();
Patrick Venture52854622018-11-06 12:30:00 -080059
60 if (!manager->registerHandler(std::move(handler)))
Patrick Venturec7ca2912018-11-02 11:38:33 -070061 {
62 log<level::ERR>("Failed to register Firmware Handler");
63 }
64}
65
66} // namespace blobs