fw update: common code
new daemons to implement the flow as described in
https://github.com/openbmc/docs/blob/master/designs/code-update.md
- common/
common code folder
- common update flow
- base class for the device specific update daemons
The new daemons are all following the generic template of Code Updater
daemon as outlined in the design.
The idea is that they are separate daemons (per device, as outlined in
the design) but share all the code that's not device specific.
Tested: next patch in series
Change-Id: If2438b8506aceb8c5313ec13a0bf7cb68f3cc279
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/common/include/software_manager.hpp b/common/include/software_manager.hpp
new file mode 100644
index 0000000..7cc2e6a
--- /dev/null
+++ b/common/include/software_manager.hpp
@@ -0,0 +1,70 @@
+#pragma once
+
+#include "device.hpp"
+
+#include <boost/asio/steady_timer.hpp>
+#include <phosphor-logging/lg2.hpp>
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/asio/object_server.hpp>
+#include <sdbusplus/async/context.hpp>
+#include <sdbusplus/timer.hpp>
+
+#include <string>
+
+using namespace phosphor::software::config;
+using namespace phosphor::software::device;
+
+namespace phosphor::software::manager
+{
+
+// This is the base class for the code updater
+// Every code updater can inherit from this
+class SoftwareManager
+{
+ public:
+ SoftwareManager(sdbusplus::async::context& ctx,
+ const std::string& serviceNameSuffix);
+
+ // Fetches initial configuration from dbus and initializes devices.
+ // This should be called once by a code updater at startup.
+ // @param configurationInterfaces the dbus interfaces from which to fetch
+ // configuration
+ sdbusplus::async::task<> initDevices(
+ const std::vector<std::string>& configurationInterfaces);
+
+ // Map of EM config object path to device.
+ std::map<sdbusplus::message::object_path, std::unique_ptr<Device>> devices;
+
+ protected:
+ // This function receives a dbus name and object path for a single device,
+ // which was configured.
+ // The component code updater overrides this function and may create a
+ // device instance internally, or reject the configuration as invalid.
+ // @param service The dbus name where our configuration is
+ // @param config The common configuration properties which are shared
+ // by all devices.
+ // Also includes the object path to fetch other
+ // configuration properties.
+ // @returns true if the configuration was accepted
+ virtual sdbusplus::async::task<bool> initDevice(const std::string& service,
+ const std::string& path,
+ SoftwareConfig& config) = 0;
+
+ sdbusplus::async::context& ctx;
+
+ private:
+ // request the bus name on dbus after all configuration has been parsed
+ // and the devices have been initialized
+ // @returns the name on dbus
+ std::string setupBusName();
+
+ // this is appended to the common prefix to construct the dbus name
+ std::string serviceNameSuffix;
+
+ sdbusplus::server::manager_t manager;
+
+ friend Software;
+ friend Device;
+};
+
+}; // namespace phosphor::software::manager