blob: 3cfc21fd64102f4aa10bafa8948cefef40e55547 [file] [log] [blame]
#include "config.h"
#include "firmware_handler.hpp"
#include "hash_handler.hpp"
#include "image_handler.hpp"
#include "lpc_handler.hpp"
#include "pci_handler.hpp"
#include "static_handler.hpp"
#include <blobs-ipmid/manager.hpp>
#include <cstdint>
#include <memory>
#include <phosphor-logging/log.hpp>
namespace blobs
{
using namespace phosphor::logging;
namespace
{
HashFileHandler hashHandler;
StaticLayoutHandler staticLayoutHandler(STATIC_HANDLER_STAGED_NAME);
LpcDataHandler lpcDataHandler;
PciDataHandler pciDataHandler(PCI_PHYSICAL_ADDRESS);
std::vector<HandlerPack> supportedFirmware = {
{FirmwareBlobHandler::hashBlobID, &hashHandler},
#ifdef ENABLE_STATIC_LAYOUT
{"/flash/image", &staticLayoutHandler},
#endif
};
std::vector<DataHandlerPack> supportedTransports = {
{FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
#ifdef ENABLE_PCI_BRIDGE
{FirmwareBlobHandler::UpdateFlags::p2a, &pciDataHandler},
#endif
#ifdef ENABLE_LPC_BRIDGE
{FirmwareBlobHandler::UpdateFlags::lpc, &lpcDataHandler},
#endif
};
} // namespace
void setupFirmwareHandler() __attribute__((constructor));
void setupFirmwareHandler()
{
auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
supportedFirmware, supportedTransports);
if (!handler)
{
log<level::ERR>("Firmware Handler has invalid configuration");
return;
}
auto* manager = getBlobManager();
if (!manager->registerHandler(std::move(handler)))
{
log<level::ERR>("Failed to register Firmware Handler");
}
}
} // namespace blobs