move files around to create a common convenience library

Problem: plan is to add another blob handler into ipmi-flash
(ipmi-flash-version). This new handler will re-use much of the
ipmi-flash (firmware-handler) code. The common code should be presented
as a convenience library to reduce code duplication.

Solution: move anticipated firmware-handler specific code into the
subdirectory bmc/firmware-handler and leave common code in bmc/.

The end goal is to have version-handler re-use as
much code as possible.

Tested:
rebuilt everything and ran unit tests.

Signed-off-by: Jason Ling <jasonling@google.com>
Change-Id: I2128da629b0ddf27b89f1faee358d1941f1dff38
diff --git a/Makefile.am b/Makefile.am
index e6c85c5..187e221 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,7 @@
 
 if BUILD_BMC_HANDLER
 SUBDIRS += bmc
+SUBDIRS += bmc/firmware-handler
 endif
 
 if BUILD_HOST_TOOL
diff --git a/bmc/Makefile.am b/bmc/Makefile.am
index 993b881..4592bbd 100644
--- a/bmc/Makefile.am
+++ b/bmc/Makefile.am
@@ -1,105 +1,21 @@
 AM_DEFAULT_SOURCE_EXT = .cpp
+noinst_LTLIBRARIES = libbmc_common.la
 
-pkgdatadir = $(datadir)/phosphor-ipmi-flash
-dist_pkgdata_DATA =
-
-# reboot update is only effective for static layout
-# static layout is also possible with a tarball+bmc-code-mgmt
-#
-# the bmc-code-mgmt will reboot for us or if we need to support this
-# variation (via the ApplyTime to immediate) (only currently supported for
-# ubi).
-if ENABLE_STATIC_LAYOUT
-if ENABLE_REBOOT_UPDATE
-dist_pkgdata_DATA += config-static-bmc-reboot.json
-else
-if ENABLE_UPDATE_STATUS
-dist_pkgdata_DATA += config-static-bmc-with-update-status.json
-else
-dist_pkgdata_DATA += config-static-bmc.json
-endif
-endif
-endif
-
-if ENABLE_HOST_BIOS
-dist_pkgdata_DATA += config-bios.json
-endif
-
-if HAVE_SYSTEMD
-systemdsystemunit_DATA = \
-	phosphor-ipmi-flash-bmc-prepare.target \
-	phosphor-ipmi-flash-bmc-verify.target \
-	phosphor-ipmi-flash-bmc-update.target
-if ENABLE_HOST_BIOS
-systemdsystemunit_DATA += \
-	phosphor-ipmi-flash-bios-prepare.target \
-	phosphor-ipmi-flash-bios-verify.target \
-	phosphor-ipmi-flash-bios-update.target
-endif
-endif
-
-noinst_LTLIBRARIES = libfirmwareblob_common.la
-libfirmwareblob_common_la_SOURCES = \
-	buildjson.cpp \
-	fs.cpp \
-	firmware_handler.cpp \
+# shared functionality between firmware and version blob handlers
+libbmc_common_la_SOURCES = \
 	file_handler.cpp \
+	fs.cpp \
 	general_systemd.cpp \
-	lpc_handler.cpp \
 	skip_action.cpp
 
-if ENABLE_ASPEED_LPC
-libfirmwareblob_common_la_SOURCES += lpc_aspeed.cpp
-endif
-
-if ENABLE_NUVOTON_LPC
-libfirmwareblob_common_la_SOURCES += lpc_nuvoton.cpp
-endif
-
-if ENABLE_ASPEED_P2A
-libfirmwareblob_common_la_SOURCES += pci_handler.cpp
-endif
-
-if ENABLE_NUVOTON_P2A_VGA
-libfirmwareblob_common_la_SOURCES += pci_nuvoton_handler.cpp
-endif
-
-if ENABLE_NUVOTON_P2A_MBOX
-libfirmwareblob_common_la_SOURCES += pci_nuvoton_handler.cpp
-endif
-
-if ENABLE_NET_BRIDGE
-libfirmwareblob_common_la_SOURCES += net_handler.cpp
-endif
-
-libfirmwareblob_common_la_CXXFLAGS = \
+libbmc_common_la_CXXFLAGS = \
 	-I$(top_srcdir) \
 	$(SDBUSPLUS_CFLAGS) \
         $(PHOSPHOR_LOGGING_CFLAGS) \
         $(CODE_COVERAGE_CXXFLAGS) \
         -flto
-libfirmwareblob_common_la_LDFLAGS = \
+libbmc_common_la_LDFLAGS = \
         $(SDBUSPLUS_LIBS) \
         $(PHOSPHOR_LOGGING_LIBS) \
         $(CODE_COVERAGE_LIBS) \
         -lstdc++fs
-libfirmwareblob_common_la_LIBADD = $(top_builddir)/libfirmware_common.la
-
-libfirmwareblobdir = ${libdir}/ipmid-providers
-libfirmwareblob_LTLIBRARIES = libfirmwareblob.la
-libfirmwareblob_la_SOURCES = main.cpp
-libfirmwareblob_la_LIBADD = libfirmwareblob_common.la
-libfirmwareblob_la_LDFLAGS = \
-	$(SDBUSPLUS_LIBS) \
-	$(PHOSPHOR_LOGGING_LIBS) \
-	$(CODE_COVERAGE_LIBS) \
-	-lstdc++fs \
-	-version-info 0:0:0 -shared
-libfirmwareblob_la_CXXFLAGS = \
-	-I$(top_srcdir) \
-	$(SDBUSPLUS_CFLAGS) \
-	$(PHOSPHOR_LOGGING_CFLAGS) \
-	$(CODE_COVERAGE_CXXFLAGS) \
-	-flto
-
-SUBDIRS = . test
diff --git a/bmc/firmware-handler/Makefile.am b/bmc/firmware-handler/Makefile.am
new file mode 100644
index 0000000..c4fe392
--- /dev/null
+++ b/bmc/firmware-handler/Makefile.am
@@ -0,0 +1,106 @@
+AM_DEFAULT_SOURCE_EXT = .cpp
+
+pkgdatadir = $(datadir)/phosphor-ipmi-flash
+dist_pkgdata_DATA =
+
+# reboot update is only effective for static layout
+# static layout is also possible with a tarball+bmc-code-mgmt
+#
+# the bmc-code-mgmt will reboot for us or if we need to support this
+# variation (via the ApplyTime to immediate) (only currently supported for
+# ubi).
+if ENABLE_STATIC_LAYOUT
+if ENABLE_REBOOT_UPDATE
+dist_pkgdata_DATA += config-static-bmc-reboot.json
+else
+if ENABLE_UPDATE_STATUS
+dist_pkgdata_DATA += config-static-bmc-with-update-status.json
+else
+dist_pkgdata_DATA += config-static-bmc.json
+endif
+endif
+endif
+
+if ENABLE_HOST_BIOS
+dist_pkgdata_DATA += config-bios.json
+endif
+
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = \
+	phosphor-ipmi-flash-bmc-prepare.target \
+	phosphor-ipmi-flash-bmc-verify.target \
+	phosphor-ipmi-flash-bmc-update.target
+if ENABLE_HOST_BIOS
+systemdsystemunit_DATA += \
+	phosphor-ipmi-flash-bios-prepare.target \
+	phosphor-ipmi-flash-bios-verify.target \
+	phosphor-ipmi-flash-bios-update.target
+endif
+endif
+# Convenience libraries that are discarded after build
+noinst_LTLIBRARIES = libfirmwareblob_common.la
+
+# firmware blob handler specific
+libfirmwareblob_common_la_SOURCES = \
+	buildjson.cpp \
+	firmware_handler.cpp \
+	lpc_handler.cpp
+
+if ENABLE_ASPEED_LPC
+libfirmwareblob_common_la_SOURCES += lpc_aspeed.cpp
+endif
+
+if ENABLE_NUVOTON_LPC
+libfirmwareblob_common_la_SOURCES += lpc_nuvoton.cpp
+endif
+
+if ENABLE_ASPEED_P2A
+libfirmwareblob_common_la_SOURCES += pci_handler.cpp
+endif
+
+if ENABLE_NUVOTON_P2A_VGA
+libfirmwareblob_common_la_SOURCES += pci_nuvoton_handler.cpp
+endif
+
+if ENABLE_NUVOTON_P2A_MBOX
+libfirmwareblob_common_la_SOURCES += pci_nuvoton_handler.cpp
+endif
+
+if ENABLE_NET_BRIDGE
+libfirmwareblob_common_la_SOURCES += net_handler.cpp
+endif
+
+libfirmwareblob_common_la_CXXFLAGS = \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/bmc \
+	$(SDBUSPLUS_CFLAGS) \
+        $(PHOSPHOR_LOGGING_CFLAGS) \
+        $(CODE_COVERAGE_CXXFLAGS) \
+        -flto
+libfirmwareblob_common_la_LDFLAGS = \
+        $(SDBUSPLUS_LIBS) \
+        $(PHOSPHOR_LOGGING_LIBS) \
+        $(CODE_COVERAGE_LIBS) \
+        -lstdc++fs
+libfirmwareblob_common_la_LIBADD = $(top_builddir)/libfirmware_common.la
+libfirmwareblob_common_la_LIBADD += $(top_builddir)/bmc/libbmc_common.la
+
+libfirmwareblobdir = ${libdir}/ipmid-providers
+libfirmwareblob_LTLIBRARIES = libfirmwareblob.la
+libfirmwareblob_la_SOURCES = main.cpp
+libfirmwareblob_la_LIBADD = libfirmwareblob_common.la
+libfirmwareblob_la_LDFLAGS = \
+	$(SDBUSPLUS_LIBS) \
+	$(PHOSPHOR_LOGGING_LIBS) \
+	$(CODE_COVERAGE_LIBS) \
+	-lstdc++fs \
+	-version-info 0:0:0 -shared
+libfirmwareblob_la_CXXFLAGS = \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/bmc \
+	$(SDBUSPLUS_CFLAGS) \
+	$(PHOSPHOR_LOGGING_CFLAGS) \
+	$(CODE_COVERAGE_CXXFLAGS) \
+	-flto
+
+SUBDIRS = . test
diff --git a/bmc/buildjson.cpp b/bmc/firmware-handler/buildjson.cpp
similarity index 100%
rename from bmc/buildjson.cpp
rename to bmc/firmware-handler/buildjson.cpp
diff --git a/bmc/buildjson.hpp b/bmc/firmware-handler/buildjson.hpp
similarity index 100%
rename from bmc/buildjson.hpp
rename to bmc/firmware-handler/buildjson.hpp
diff --git a/bmc/config-bios.json.in b/bmc/firmware-handler/config-bios.json.in
similarity index 100%
rename from bmc/config-bios.json.in
rename to bmc/firmware-handler/config-bios.json.in
diff --git a/bmc/config-static-bmc-reboot.json.in b/bmc/firmware-handler/config-static-bmc-reboot.json.in
similarity index 100%
rename from bmc/config-static-bmc-reboot.json.in
rename to bmc/firmware-handler/config-static-bmc-reboot.json.in
diff --git a/bmc/config-static-bmc-with-update-status.json.in b/bmc/firmware-handler/config-static-bmc-with-update-status.json.in
similarity index 100%
rename from bmc/config-static-bmc-with-update-status.json.in
rename to bmc/firmware-handler/config-static-bmc-with-update-status.json.in
diff --git a/bmc/config-static-bmc.json.in b/bmc/firmware-handler/config-static-bmc.json.in
similarity index 100%
rename from bmc/config-static-bmc.json.in
rename to bmc/firmware-handler/config-static-bmc.json.in
diff --git a/bmc/data_handler.hpp b/bmc/firmware-handler/data_handler.hpp
similarity index 100%
rename from bmc/data_handler.hpp
rename to bmc/firmware-handler/data_handler.hpp
diff --git a/bmc/firmware_handler.cpp b/bmc/firmware-handler/firmware_handler.cpp
similarity index 100%
rename from bmc/firmware_handler.cpp
rename to bmc/firmware-handler/firmware_handler.cpp
diff --git a/bmc/firmware_handler.hpp b/bmc/firmware-handler/firmware_handler.hpp
similarity index 98%
rename from bmc/firmware_handler.hpp
rename to bmc/firmware-handler/firmware_handler.hpp
index 91699e6..505f1a7 100644
--- a/bmc/firmware_handler.hpp
+++ b/bmc/firmware-handler/firmware_handler.hpp
@@ -61,7 +61,7 @@
      * Pointer to the correct image handler interface.  (nullptr on hash
      * blob_id)
      */
-    ImageHandlerInterface* imageHandler;
+    ipmi_flash::ImageHandlerInterface* imageHandler;
 
     /** The flags used to open the session. */
     std::uint16_t flags;
diff --git a/bmc/lpc_aspeed.cpp b/bmc/firmware-handler/lpc_aspeed.cpp
similarity index 100%
rename from bmc/lpc_aspeed.cpp
rename to bmc/firmware-handler/lpc_aspeed.cpp
diff --git a/bmc/lpc_aspeed.hpp b/bmc/firmware-handler/lpc_aspeed.hpp
similarity index 100%
rename from bmc/lpc_aspeed.hpp
rename to bmc/firmware-handler/lpc_aspeed.hpp
diff --git a/bmc/lpc_handler.cpp b/bmc/firmware-handler/lpc_handler.cpp
similarity index 100%
rename from bmc/lpc_handler.cpp
rename to bmc/firmware-handler/lpc_handler.cpp
diff --git a/bmc/lpc_handler.hpp b/bmc/firmware-handler/lpc_handler.hpp
similarity index 100%
rename from bmc/lpc_handler.hpp
rename to bmc/firmware-handler/lpc_handler.hpp
diff --git a/bmc/lpc_nuvoton.cpp b/bmc/firmware-handler/lpc_nuvoton.cpp
similarity index 100%
rename from bmc/lpc_nuvoton.cpp
rename to bmc/firmware-handler/lpc_nuvoton.cpp
diff --git a/bmc/lpc_nuvoton.hpp b/bmc/firmware-handler/lpc_nuvoton.hpp
similarity index 100%
rename from bmc/lpc_nuvoton.hpp
rename to bmc/firmware-handler/lpc_nuvoton.hpp
diff --git a/bmc/main.cpp b/bmc/firmware-handler/main.cpp
similarity index 100%
rename from bmc/main.cpp
rename to bmc/firmware-handler/main.cpp
diff --git a/bmc/mapper_errors.hpp b/bmc/firmware-handler/mapper_errors.hpp
similarity index 100%
rename from bmc/mapper_errors.hpp
rename to bmc/firmware-handler/mapper_errors.hpp
diff --git a/bmc/net_handler.cpp b/bmc/firmware-handler/net_handler.cpp
similarity index 100%
rename from bmc/net_handler.cpp
rename to bmc/firmware-handler/net_handler.cpp
diff --git a/bmc/net_handler.hpp b/bmc/firmware-handler/net_handler.hpp
similarity index 100%
rename from bmc/net_handler.hpp
rename to bmc/firmware-handler/net_handler.hpp
diff --git a/bmc/pci_handler.cpp b/bmc/firmware-handler/pci_handler.cpp
similarity index 100%
rename from bmc/pci_handler.cpp
rename to bmc/firmware-handler/pci_handler.cpp
diff --git a/bmc/pci_handler.hpp b/bmc/firmware-handler/pci_handler.hpp
similarity index 100%
rename from bmc/pci_handler.hpp
rename to bmc/firmware-handler/pci_handler.hpp
diff --git a/bmc/pci_nuvoton_handler.cpp b/bmc/firmware-handler/pci_nuvoton_handler.cpp
similarity index 100%
rename from bmc/pci_nuvoton_handler.cpp
rename to bmc/firmware-handler/pci_nuvoton_handler.cpp
diff --git a/bmc/phosphor-ipmi-flash-bios-prepare.target.in b/bmc/firmware-handler/phosphor-ipmi-flash-bios-prepare.target.in
similarity index 100%
rename from bmc/phosphor-ipmi-flash-bios-prepare.target.in
rename to bmc/firmware-handler/phosphor-ipmi-flash-bios-prepare.target.in
diff --git a/bmc/phosphor-ipmi-flash-bios-update.target.in b/bmc/firmware-handler/phosphor-ipmi-flash-bios-update.target.in
similarity index 100%
rename from bmc/phosphor-ipmi-flash-bios-update.target.in
rename to bmc/firmware-handler/phosphor-ipmi-flash-bios-update.target.in
diff --git a/bmc/phosphor-ipmi-flash-bios-verify.target.in b/bmc/firmware-handler/phosphor-ipmi-flash-bios-verify.target.in
similarity index 100%
rename from bmc/phosphor-ipmi-flash-bios-verify.target.in
rename to bmc/firmware-handler/phosphor-ipmi-flash-bios-verify.target.in
diff --git a/bmc/phosphor-ipmi-flash-bmc-prepare.target.in b/bmc/firmware-handler/phosphor-ipmi-flash-bmc-prepare.target.in
similarity index 100%
rename from bmc/phosphor-ipmi-flash-bmc-prepare.target.in
rename to bmc/firmware-handler/phosphor-ipmi-flash-bmc-prepare.target.in
diff --git a/bmc/phosphor-ipmi-flash-bmc-update.target.in b/bmc/firmware-handler/phosphor-ipmi-flash-bmc-update.target.in
similarity index 100%
rename from bmc/phosphor-ipmi-flash-bmc-update.target.in
rename to bmc/firmware-handler/phosphor-ipmi-flash-bmc-update.target.in
diff --git a/bmc/phosphor-ipmi-flash-bmc-verify.target.in b/bmc/firmware-handler/phosphor-ipmi-flash-bmc-verify.target.in
similarity index 100%
rename from bmc/phosphor-ipmi-flash-bmc-verify.target.in
rename to bmc/firmware-handler/phosphor-ipmi-flash-bmc-verify.target.in
diff --git a/bmc/test/Makefile.am b/bmc/firmware-handler/test/Makefile.am
similarity index 67%
rename from bmc/test/Makefile.am
rename to bmc/firmware-handler/test/Makefile.am
index cbac3eb..bf818fd 100644
--- a/bmc/test/Makefile.am
+++ b/bmc/firmware-handler/test/Makefile.am
@@ -4,6 +4,7 @@
 	-I$(top_srcdir)/ \
 	-I$(top_srcdir)/tools/ \
 	-I$(top_srcdir)/bmc/ \
+	-I$(top_srcdir)/bmc/firmware-handler \
 	$(GTEST_CFLAGS) \
 	$(GMOCK_CFLAGS) \
 	$(CODE_COVERAGE_CPPFLAGS)
@@ -48,67 +49,67 @@
 TESTS = $(check_PROGRAMS)
 
 firmware_handler_unittest_SOURCES = firmware_handler_unittest.cpp
-firmware_handler_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_handler_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_stat_unittest_SOURCES = firmware_stat_unittest.cpp
-firmware_stat_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_stat_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_canhandle_unittest_SOURCES = firmware_canhandle_unittest.cpp
-firmware_canhandle_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_canhandle_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_write_unittest_SOURCES = firmware_write_unittest.cpp
-firmware_write_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_write_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_writemeta_unittest_SOURCES = firmware_writemeta_unittest.cpp
-firmware_writemeta_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_writemeta_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_open_unittest_SOURCES = firmware_open_unittest.cpp
-firmware_open_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_open_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_close_unittest_SOURCES = firmware_close_unittest.cpp
-firmware_close_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_close_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_sessionstat_unittest_SOURCES = firmware_sessionstat_unittest.cpp
-firmware_sessionstat_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_sessionstat_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_commit_unittest_SOURCES = firmware_commit_unittest.cpp
-firmware_commit_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_commit_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 file_handler_unittest_SOURCES = file_handler_unittest.cpp
-file_handler_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la -lstdc++fs
+file_handler_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la -lstdc++fs
 
 firmware_state_notyetstarted_unittest_SOURCES = firmware_state_notyetstarted_unittest.cpp
-firmware_state_notyetstarted_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_notyetstarted_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_uploadinprogress_unittest_SOURCES = firmware_state_uploadinprogress_unittest.cpp
-firmware_state_uploadinprogress_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_uploadinprogress_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_verificationpending_unittest_SOURCES = firmware_state_verificationpending_unittest.cpp
-firmware_state_verificationpending_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_verificationpending_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_verificationstarted_unittest_SOURCES = firmware_state_verificationstarted_unittest.cpp
-firmware_state_verificationstarted_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_verificationstarted_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_verificationcompleted_unittest_SOURCES = firmware_state_verificationcompleted_unittest.cpp
-firmware_state_verificationcompleted_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_verificationcompleted_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_updatepending_unittest_SOURCES = firmware_state_updatepending_unittest.cpp
-firmware_state_updatepending_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_updatepending_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_updatestarted_unittest_SOURCES = firmware_state_updatestarted_unittest.cpp
-firmware_state_updatestarted_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_updatestarted_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_updatecompleted_unittest_SOURCES = firmware_state_updatecompleted_unittest.cpp
-firmware_state_updatecompleted_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_updatecompleted_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_state_notyetstarted_tarball_unittest_SOURCES = firmware_state_notyetstarted_tarball_unittest.cpp
-firmware_state_notyetstarted_tarball_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_state_notyetstarted_tarball_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_multiplebundle_unittest_SOURCES = firmware_multiplebundle_unittest.cpp
-firmware_multiplebundle_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_multiplebundle_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_json_unittest_SOURCES = firmware_json_unittest.cpp
-firmware_json_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_json_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
 
 firmware_skip_unittest_SOURCES = firmware_skip_unittest.cpp
-firmware_skip_unittest_LDADD = $(top_builddir)/bmc/libfirmwareblob_common.la
+firmware_skip_unittest_LDADD = $(top_builddir)/bmc/firmware-handler/libfirmwareblob_common.la
diff --git a/bmc/test/crc_mock.hpp b/bmc/firmware-handler/test/crc_mock.hpp
similarity index 100%
rename from bmc/test/crc_mock.hpp
rename to bmc/firmware-handler/test/crc_mock.hpp
diff --git a/bmc/test/data_mock.hpp b/bmc/firmware-handler/test/data_mock.hpp
similarity index 100%
rename from bmc/test/data_mock.hpp
rename to bmc/firmware-handler/test/data_mock.hpp
diff --git a/bmc/test/file_handler_unittest.cpp b/bmc/firmware-handler/test/file_handler_unittest.cpp
similarity index 100%
rename from bmc/test/file_handler_unittest.cpp
rename to bmc/firmware-handler/test/file_handler_unittest.cpp
diff --git a/bmc/test/firmware_canhandle_unittest.cpp b/bmc/firmware-handler/test/firmware_canhandle_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_canhandle_unittest.cpp
rename to bmc/firmware-handler/test/firmware_canhandle_unittest.cpp
diff --git a/bmc/test/firmware_close_unittest.cpp b/bmc/firmware-handler/test/firmware_close_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_close_unittest.cpp
rename to bmc/firmware-handler/test/firmware_close_unittest.cpp
diff --git a/bmc/test/firmware_commit_unittest.cpp b/bmc/firmware-handler/test/firmware_commit_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_commit_unittest.cpp
rename to bmc/firmware-handler/test/firmware_commit_unittest.cpp
diff --git a/bmc/test/firmware_handler_unittest.cpp b/bmc/firmware-handler/test/firmware_handler_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_handler_unittest.cpp
rename to bmc/firmware-handler/test/firmware_handler_unittest.cpp
diff --git a/bmc/test/firmware_json_unittest.cpp b/bmc/firmware-handler/test/firmware_json_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_json_unittest.cpp
rename to bmc/firmware-handler/test/firmware_json_unittest.cpp
diff --git a/bmc/test/firmware_multiplebundle_unittest.cpp b/bmc/firmware-handler/test/firmware_multiplebundle_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_multiplebundle_unittest.cpp
rename to bmc/firmware-handler/test/firmware_multiplebundle_unittest.cpp
diff --git a/bmc/test/firmware_open_unittest.cpp b/bmc/firmware-handler/test/firmware_open_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_open_unittest.cpp
rename to bmc/firmware-handler/test/firmware_open_unittest.cpp
diff --git a/bmc/test/firmware_sessionstat_unittest.cpp b/bmc/firmware-handler/test/firmware_sessionstat_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_sessionstat_unittest.cpp
rename to bmc/firmware-handler/test/firmware_sessionstat_unittest.cpp
diff --git a/bmc/test/firmware_skip_unittest.cpp b/bmc/firmware-handler/test/firmware_skip_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_skip_unittest.cpp
rename to bmc/firmware-handler/test/firmware_skip_unittest.cpp
diff --git a/bmc/test/firmware_stat_unittest.cpp b/bmc/firmware-handler/test/firmware_stat_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_stat_unittest.cpp
rename to bmc/firmware-handler/test/firmware_stat_unittest.cpp
diff --git a/bmc/test/firmware_state_notyetstarted_tarball_unittest.cpp b/bmc/firmware-handler/test/firmware_state_notyetstarted_tarball_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_notyetstarted_tarball_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_notyetstarted_tarball_unittest.cpp
diff --git a/bmc/test/firmware_state_notyetstarted_unittest.cpp b/bmc/firmware-handler/test/firmware_state_notyetstarted_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_notyetstarted_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_notyetstarted_unittest.cpp
diff --git a/bmc/test/firmware_state_updatecompleted_unittest.cpp b/bmc/firmware-handler/test/firmware_state_updatecompleted_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_updatecompleted_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_updatecompleted_unittest.cpp
diff --git a/bmc/test/firmware_state_updatepending_unittest.cpp b/bmc/firmware-handler/test/firmware_state_updatepending_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_updatepending_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_updatepending_unittest.cpp
diff --git a/bmc/test/firmware_state_updatestarted_unittest.cpp b/bmc/firmware-handler/test/firmware_state_updatestarted_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_updatestarted_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_updatestarted_unittest.cpp
diff --git a/bmc/test/firmware_state_uploadinprogress_unittest.cpp b/bmc/firmware-handler/test/firmware_state_uploadinprogress_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_uploadinprogress_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_uploadinprogress_unittest.cpp
diff --git a/bmc/test/firmware_state_verificationcompleted_unittest.cpp b/bmc/firmware-handler/test/firmware_state_verificationcompleted_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_verificationcompleted_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_verificationcompleted_unittest.cpp
diff --git a/bmc/test/firmware_state_verificationpending_unittest.cpp b/bmc/firmware-handler/test/firmware_state_verificationpending_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_verificationpending_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_verificationpending_unittest.cpp
diff --git a/bmc/test/firmware_state_verificationstarted_unittest.cpp b/bmc/firmware-handler/test/firmware_state_verificationstarted_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_state_verificationstarted_unittest.cpp
rename to bmc/firmware-handler/test/firmware_state_verificationstarted_unittest.cpp
diff --git a/bmc/test/firmware_unittest.hpp b/bmc/firmware-handler/test/firmware_unittest.hpp
similarity index 100%
rename from bmc/test/firmware_unittest.hpp
rename to bmc/firmware-handler/test/firmware_unittest.hpp
diff --git a/bmc/test/firmware_write_unittest.cpp b/bmc/firmware-handler/test/firmware_write_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_write_unittest.cpp
rename to bmc/firmware-handler/test/firmware_write_unittest.cpp
diff --git a/bmc/test/firmware_writemeta_unittest.cpp b/bmc/firmware-handler/test/firmware_writemeta_unittest.cpp
similarity index 100%
rename from bmc/test/firmware_writemeta_unittest.cpp
rename to bmc/firmware-handler/test/firmware_writemeta_unittest.cpp
diff --git a/bmc/test/image_mock.hpp b/bmc/firmware-handler/test/image_mock.hpp
similarity index 100%
rename from bmc/test/image_mock.hpp
rename to bmc/firmware-handler/test/image_mock.hpp
diff --git a/bmc/test/triggerable_mock.hpp b/bmc/firmware-handler/test/triggerable_mock.hpp
similarity index 100%
rename from bmc/test/triggerable_mock.hpp
rename to bmc/firmware-handler/test/triggerable_mock.hpp
diff --git a/bmc/test/window_mapper_mock.hpp b/bmc/firmware-handler/test/window_mapper_mock.hpp
similarity index 100%
rename from bmc/test/window_mapper_mock.hpp
rename to bmc/firmware-handler/test/window_mapper_mock.hpp
diff --git a/bmc/window_hw_interface.hpp b/bmc/firmware-handler/window_hw_interface.hpp
similarity index 100%
rename from bmc/window_hw_interface.hpp
rename to bmc/firmware-handler/window_hw_interface.hpp
diff --git a/bmc/image_handler.hpp b/bmc/image_handler.hpp
index a25a74a..c024ec9 100644
--- a/bmc/image_handler.hpp
+++ b/bmc/image_handler.hpp
@@ -1,7 +1,7 @@
 #pragma once
 
 #include <cstdint>
-#include <functional>
+#include <fstream>
 #include <memory>
 #include <string>
 #include <vector>
diff --git a/configure.ac b/configure.ac
index 0ed6517..837180d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -639,17 +639,18 @@
 
 # Create configured output
 AC_CONFIG_FILES([Makefile])
-AC_CONFIG_FILES([bmc/Makefile bmc/test/Makefile])
+AC_CONFIG_FILES([bmc/Makefile])
+AC_CONFIG_FILES([bmc/firmware-handler/Makefile bmc/firmware-handler/test/Makefile])
 AC_CONFIG_FILES([tools/Makefile tools/test/Makefile])
 AC_CONFIG_FILES([cleanup/Makefile cleanup/test/Makefile])
-AC_CONFIG_FILES([bmc/phosphor-ipmi-flash-bmc-prepare.target])
-AC_CONFIG_FILES([bmc/phosphor-ipmi-flash-bmc-verify.target])
-AC_CONFIG_FILES([bmc/phosphor-ipmi-flash-bmc-update.target])
-AC_CONFIG_FILES([bmc/phosphor-ipmi-flash-bios-prepare.target])
-AC_CONFIG_FILES([bmc/phosphor-ipmi-flash-bios-verify.target])
-AC_CONFIG_FILES([bmc/phosphor-ipmi-flash-bios-update.target])
-AC_CONFIG_FILES([bmc/config-static-bmc-reboot.json])
-AC_CONFIG_FILES([bmc/config-static-bmc.json])
-AC_CONFIG_FILES([bmc/config-static-bmc-with-update-status.json])
-AC_CONFIG_FILES([bmc/config-bios.json])
+AC_CONFIG_FILES([bmc/firmware-handler/phosphor-ipmi-flash-bmc-prepare.target])
+AC_CONFIG_FILES([bmc/firmware-handler/phosphor-ipmi-flash-bmc-verify.target])
+AC_CONFIG_FILES([bmc/firmware-handler/phosphor-ipmi-flash-bmc-update.target])
+AC_CONFIG_FILES([bmc/firmware-handler/phosphor-ipmi-flash-bios-prepare.target])
+AC_CONFIG_FILES([bmc/firmware-handler/phosphor-ipmi-flash-bios-verify.target])
+AC_CONFIG_FILES([bmc/firmware-handler/phosphor-ipmi-flash-bios-update.target])
+AC_CONFIG_FILES([bmc/firmware-handler/config-static-bmc-reboot.json])
+AC_CONFIG_FILES([bmc/firmware-handler/config-static-bmc.json])
+AC_CONFIG_FILES([bmc/firmware-handler/config-static-bmc-with-update-status.json])
+AC_CONFIG_FILES([bmc/firmware-handler/config-bios.json])
 AC_OUTPUT