Enable firmware transport mechanisms

build: Allow configuring transport mechanisms
firmware: Support receiving this currently unused information.

Change-Id: If6d83ef5fe00eabd7fd7fc932a579657c0b0a0ab
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/configure.ac b/configure.ac
index 09fceb3..8af2813 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,18 @@
     AX_APPEND_COMPILE_FLAGS([-DENABLE_STATIC_LAYOUT], [CXXFLAGS])
 ])
 # Enable P2A, and or LPC (block-transfer is always enabled).
+AC_ARG_ENABLE([pci-bridge],
+    AS_HELP_STRING([--enable-pci-bridge],
+                   [Enable pci-bridge transport mechanism]))
+AS_IF([test "x$enable_pci_bridge" = "xyes"], [
+    AX_APPEND_COMPILE_FLAGS([-DENABLE_PCI_BRIDGE], [CXXFLAGS])
+])
+AC_ARG_ENABLE([lpc-bridge],
+    AS_HELP_STRING([--enable-lpc-bridge],
+                   [Enable lpc-bridge transport mechanism]))
+AS_IF([test "x$enable_lpc_bridge" = "xyes"], [
+    AX_APPEND_COMPILE_FLAGS([-DENABLE_LPC_BRIDGE], [CXXFLAGS])
+])
 
 # Check/set gtest specific functions.
 PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 89c7891..0e26ab2 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -1,5 +1,6 @@
 #include "firmware_handler.hpp"
 
+#include <cstdint>
 #include <memory>
 #include <string>
 #include <vector>
@@ -9,9 +10,9 @@
 
 std::unique_ptr<GenericBlobInterface>
     FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        const std::vector<std::string>& firmwares)
+        const std::vector<std::string>& firmwares, std::uint32_t transports)
 {
-    return std::make_unique<FirmwareBlobHandler>(firmwares);
+    return std::make_unique<FirmwareBlobHandler>(firmwares, transports);
 }
 
 bool FirmwareBlobHandler::canHandleBlob(const std::string& path)
diff --git a/firmware_handler.hpp b/firmware_handler.hpp
index b206f56..f9a8983 100644
--- a/firmware_handler.hpp
+++ b/firmware_handler.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <blobs-ipmid/blobs.hpp>
+#include <cstdint>
 #include <memory>
 #include <string>
 #include <vector>
@@ -22,10 +23,13 @@
 {
   public:
     static std::unique_ptr<GenericBlobInterface>
-        CreateFirmwareBlobHandler(const std::vector<std::string>& firmwares);
+        CreateFirmwareBlobHandler(const std::vector<std::string>& firmwares,
+                                  std::uint32_t transports);
 
-    explicit FirmwareBlobHandler(const std::vector<std::string>& firmwares) :
-        baseFirmwares(firmwares)
+    FirmwareBlobHandler(const std::vector<std::string>& firmwares,
+                        std::uint32_t transports) :
+        baseFirmwares(firmwares),
+        transports(transports)
     {
     }
     ~FirmwareBlobHandler() = default;
@@ -53,6 +57,7 @@
 
   private:
     std::vector<std::string> baseFirmwares;
+    std::uint32_t transports;
 };
 
 } // namespace blobs
diff --git a/main.cpp b/main.cpp
index 0ec159f..4012a0e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -3,6 +3,7 @@
 #include "firmware_handler.hpp"
 
 #include <blobs-ipmid/manager.hpp>
+#include <cstdint>
 #include <memory>
 #include <phosphor-logging/log.hpp>
 
@@ -17,13 +18,24 @@
 #endif
 };
 
+std::uint32_t supportedTransports =
+    static_cast<std::uint32_t>(FirmwareUpdateFlags::bt);
+
 void setupFirmwareHandler() __attribute__((constructor));
 
 void setupFirmwareHandler()
 {
+#ifdef ENABLE_PCI_BRIDGE
+    supportedTransports |= static_cast<std::uint32_t>(FirmwareUpdateFlags::p2a);
+#endif
+#ifdef ENABLE_LPC_BRIDGE
+    supportedTransports |= static_cast<std::uint32_t>(FirmwareUpdateFlags::lpc);
+#endif
+
     auto* manager = getBlobManager();
     if (!manager->registerHandler(
-            FirmwareBlobHandler::CreateFirmwareBlobHandler(supportedFirmware)))
+            FirmwareBlobHandler::CreateFirmwareBlobHandler(
+                supportedFirmware, supportedTransports)))
     {
         log<level::ERR>("Failed to register Firmware Handler");
     }