main: Add empty implementation
Add empty implementation of blob handler. Boiler-plate with all methods
returning false.
Change-Id: Id7c004262c1402a18753a6d84cddecf3d1bdbf5d
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..afed099
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,10 @@
+AM_DEFAULT_SOURCE_EXT = .cpp
+
+libfirmwareblobdir = ${libdir}/ipmid-providers
+libfirmwareblob_LTLIBRARIES = libfirmwareblob.la
+libfirmwareblob_la_SOURCES = main.cpp \
+ firmware_handler.cpp
+libfirmwareblob_la_LDFLAGS = $(PHOSPHOR_LOGGING_LIBS) \
+ -version-info 0:0:0 -shared
+libfirmwareblob_la_CXXFLAGS = $(PHOSPHOR_LOGGING_CFLAGS) \
+ -flto
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..b022138
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,58 @@
+# Initialization
+AC_PREREQ([2.69])
+AC_INIT([phosphor-ipmi-flash], [0.1], [https://github.com/openbmc/phosphor-ipmi-flash/issues])
+AC_LANG([C++])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
+AM_SILENT_RULES([yes])
+
+# Checks for programs.
+AC_PROG_CXX
+AM_PROG_AR
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+
+# Checks for typedefs, structures, and compiler characteristics.
+AX_CXX_COMPILE_STDCXX_17([noext])
+AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
+
+# Checks for library functions.
+LT_INIT # Required for systemd linking
+
+# Checks for libraries.
+PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],, [AC_MSG_ERROR([Could not find phosphor-logging...openbmc/phosphor-logging package required])])
+AC_CHECK_HEADER([blobs-ipmid], [AC_MSG_ERROR(["phosphor-ipmi-blobs required and not found."])])
+AX_PTHREAD([], [AC_MSG_ERROR(["pthread required and not found"])])
+
+# Check/set gtest specific functions.
+PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
+PKG_CHECK_MODULES([GMOCK], [gmock], [], [AC_MSG_NOTICE([gmock not found, tests will not build])])
+PKG_CHECK_MODULES([GTEST_MAIN], [gtest_main], [], [AC_MSG_NOTICE([gtest_main not found, tests will not build])])
+
+# Add --enable-oe-sdk flag to configure script
+AC_ARG_ENABLE([oe-sdk],
+ AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
+)
+
+# Check for OECORE_TARGET_SYSROOT in the environment.
+AC_ARG_VAR(OECORE_TARGET_SYSROOT,
+ [Path to the OE SDK SYSROOT])
+
+# Configure OESDK_TESTCASE_FLAGS environment variable, which will be later
+# used in test/Makefile.am
+AS_IF([test "x$enable_oe_sdk" == "xyes"],
+ AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
+ AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
+ )
+ AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
+ [
+ testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
+ testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
+ testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
+ ]
+ AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
+)
+
+# Create configured output
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
new file mode 100644
index 0000000..97ebf76
--- /dev/null
+++ b/firmware_handler.cpp
@@ -0,0 +1,60 @@
+#include "firmware_handler.hpp"
+
+namespace blobs
+{
+
+bool FirmwareBlobHandler::canHandleBlob(const std::string& path)
+{
+ return false;
+}
+std::vector<std::string> FirmwareBlobHandler::getBlobIds()
+{
+ return {};
+}
+bool FirmwareBlobHandler::deleteBlob(const std::string& path)
+{
+ return false;
+}
+bool FirmwareBlobHandler::stat(const std::string& path, struct BlobMeta* meta)
+{
+ return false;
+}
+bool FirmwareBlobHandler::open(uint16_t session, uint16_t flags,
+ const std::string& path)
+{
+ return false;
+}
+std::vector<uint8_t> FirmwareBlobHandler::read(uint16_t session,
+ uint32_t offset,
+ uint32_t requestedSize)
+{
+ return {};
+}
+bool FirmwareBlobHandler::write(uint16_t session, uint32_t offset,
+ const std::vector<uint8_t>& data)
+{
+ return false;
+}
+bool FirmwareBlobHandler::writeMeta(uint16_t session, uint32_t offset,
+ const std::vector<uint8_t>& data)
+{
+ return false;
+}
+bool FirmwareBlobHandler::commit(uint16_t session,
+ const std::vector<uint8_t>& data)
+{
+ return false;
+}
+bool FirmwareBlobHandler::close(uint16_t session)
+{
+ return false;
+}
+bool FirmwareBlobHandler::stat(uint16_t session, struct BlobMeta* meta)
+{
+ return false;
+}
+bool FirmwareBlobHandler::expire(uint16_t session)
+{
+ return false;
+}
+} // namespace blobs
diff --git a/firmware_handler.hpp b/firmware_handler.hpp
new file mode 100644
index 0000000..1ba57c1
--- /dev/null
+++ b/firmware_handler.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <blobs-ipmid/blobs.hpp>
+
+namespace blobs
+{
+
+/**
+ * Register only one firmware blob handler that will manage all sessions.
+ */
+class FirmwareBlobHandler : public GenericBlobInterface
+{
+ public:
+ FirmwareBlobHandler() = default;
+ ~FirmwareBlobHandler() = default;
+ FirmwareBlobHandler(const FirmwareBlobHandler&) = default;
+ FirmwareBlobHandler& operator=(const FirmwareBlobHandler&) = default;
+ FirmwareBlobHandler(FirmwareBlobHandler&&) = default;
+ FirmwareBlobHandler& operator=(FirmwareBlobHandler&&) = default;
+
+ bool canHandleBlob(const std::string& path) override;
+ std::vector<std::string> getBlobIds() override;
+ bool deleteBlob(const std::string& path) override;
+ bool stat(const std::string& path, struct BlobMeta* meta) override;
+ bool open(uint16_t session, uint16_t flags,
+ const std::string& path) override;
+ std::vector<uint8_t> read(uint16_t session, uint32_t offset,
+ uint32_t requestedSize) override;
+ bool write(uint16_t session, uint32_t offset,
+ const std::vector<uint8_t>& data) override;
+ bool writeMeta(uint16_t session, uint32_t offset,
+ const std::vector<uint8_t>& data) override;
+ bool commit(uint16_t session, const std::vector<uint8_t>& data) override;
+ bool close(uint16_t session) override;
+ bool stat(uint16_t session, struct BlobMeta* meta) override;
+ bool expire(uint16_t session) override;
+};
+
+} // namespace blobs
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..127d37b
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,22 @@
+#include "firmware_handler.hpp"
+
+#include <blobs-ipmid/manager.hpp>
+#include <memory>
+#include <phosphor-logging/log.hpp>
+
+namespace blobs
+{
+using namespace phosphor::logging;
+
+void setupFirmwareHandler() __attribute__((constructor));
+
+void setupFirmwareHandler()
+{
+ auto* manager = getBlobManager();
+ if (!manager->registerHandler(std::make_unique<FirmwareBlobHandler>()))
+ {
+ log<level::ERR>("Failed to register Firmware Handler");
+ }
+}
+
+} // namespace blobs