blob: 93d3770734723d3812bdf1ee18081bb1ace6c61c [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 Venturea78e39f2018-11-06 18:37:06 -08004#include "image_handler.hpp"
Patrick Venture1cde5f92018-11-07 08:26:47 -08005#include "lpc_handler.hpp"
6#include "pci_handler.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08007#include "static_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{
16using namespace phosphor::logging;
17
Patrick Venturea78e39f2018-11-06 18:37:06 -080018namespace
19{
20StaticLayoutHandler staticLayoutHandler;
Patrick Venture1cde5f92018-11-07 08:26:47 -080021LpcDataHandler lpcDataHandler;
22PciDataHandler pciDataHandler;
Patrick Venturea78e39f2018-11-06 18:37:06 -080023
24std::vector<HandlerPack> supportedFirmware = {
Patrick Venture148cd652018-11-06 10:59:47 -080025#ifdef ENABLE_STATIC_LAYOUT
Patrick Venturea78e39f2018-11-06 18:37:06 -080026 {"/flash/image", &staticLayoutHandler},
Patrick Venture148cd652018-11-06 10:59:47 -080027#endif
28};
29
Patrick Venture1cde5f92018-11-07 08:26:47 -080030std::vector<DataHandlerPack> supportedTransports = {
31 {FirmwareBlobHandler::FirmwareUpdateFlags::bt, nullptr},
32#ifdef ENABLE_PCI_BRIDGE
33 {FirmwareBlobHandler::FirmwareUpdateFlags::p2a, &pciDataHandler},
34#endif
35#ifdef ENABLE_LPC_BRIDGE
36 {FirmwareBlobHandler::FirmwareUpdateFlags::lpc, &lpcDataHandler},
37#endif
38};
39
Patrick Venturea78e39f2018-11-06 18:37:06 -080040} // namespace
Patrick Venture192d60f2018-11-06 11:11:59 -080041
Patrick Venturec7ca2912018-11-02 11:38:33 -070042void setupFirmwareHandler() __attribute__((constructor));
43
44void setupFirmwareHandler()
45{
Patrick Venture52854622018-11-06 12:30:00 -080046 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
47 supportedFirmware, supportedTransports);
48
49 if (!handler)
50 {
51 log<level::ERR>("Firmware Handler has invalid configuration");
52 return;
53 }
54
Patrick Venturec7ca2912018-11-02 11:38:33 -070055 auto* manager = getBlobManager();
Patrick Venture52854622018-11-06 12:30:00 -080056
57 if (!manager->registerHandler(std::move(handler)))
Patrick Venturec7ca2912018-11-02 11:38:33 -070058 {
59 log<level::ERR>("Failed to register Firmware Handler");
60 }
61}
62
63} // namespace blobs