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/pldm/pldm_package_util.hpp b/common/pldm/pldm_package_util.hpp
index e510be1..4b544c2 100644
--- a/common/pldm/pldm_package_util.hpp
+++ b/common/pldm/pldm_package_util.hpp
@@ -4,6 +4,7 @@
 #include "sdbusplus/message/native_types.hpp"
 
 #include <cstdint>
+#include <functional>
 #include <memory>
 
 using namespace pldm::fw_update;
@@ -19,24 +20,27 @@
 
 // reads into a buffer, from file
 // @param file            the file to read from
-// @param package_data    the pre-allocated buffer for the package data
-// @param package_size    how many bytes to read from the file
-int readImagePackage(FILE* file, uint8_t* package_data, size_t package_size);
+// @param packageData     the pre-allocated buffer for the package data
+// @param packageSize     how many bytes to read from the file
+int readImagePackage(FILE* file, uint8_t* packageData, size_t packageSize);
 
 // @param image        file descriptor to the package
-// @param size_out     function will write the size of the package here
-// @returns            a pointer to the mmapped pldm package
-void* mmapImagePackage(sdbusplus::message::unix_fd image, size_t* size_out);
+// @param sizeOut      function will write the size of the package here
+// @returns            a unique pointer to the mmapped pldm package
+std::unique_ptr<void, std::function<void(void*)>> mmapImagePackage(
+    sdbusplus::message::unix_fd image, size_t* sizeOut);
 
 // @param packageParser          PackageParser instance
 // @param compatible             'compatible' string of device
 // @param vendorIANA             vendor iana of device
-// @param component_offset_out   function returns offset of component image
-// @param component_size_out     function returns size of component image
+// @param componentOffsetOut     function returns offset of component image
+// @param componentSizeOut       function returns size of component image
+// @param componentVersionOut    function returns version of component image
 // @returns                      0 on success
 int extractMatchingComponentImage(
     const std::shared_ptr<PackageParser>& packageParser,
     const std::string& compatible, uint32_t vendorIANA,
-    uint32_t* component_offset_out, size_t* size_out);
+    uint32_t* componentOffsetOut, size_t* componentSizeOut,
+    std::string& componentVersionOut);
 
 } // namespace pldm_package_util