From 9f89e2e1cf7e739dcd3cb975815ed37750c81c26 Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Wed, 30 May 2018 13:16:20 -0500 Subject: activation: Create ubi write function Move the code that creates the ubi volumes into a separate write flash function to make it easier to implement different flash write functions for other flash layouts. To implement a different write flash function: 1. Modify the Makefile.am file to include the desired code location. Ex: if UBI include ubi/Makefile.am.include else include /Makefile.am.include 2. Implement the Activation::flashWrite in /flash.cpp Tested: Verified code update still worked. Change-Id: Ide4d135695dad27e0dc1b5a776a276dfb2ca9aa6 Signed-off-by: Adriana Kobylak --- Makefile.am | 2 ++ activation.cpp | 12 +----------- activation.hpp | 6 +++++- flash.hpp | 29 +++++++++++++++++++++++++++++ ubi/Makefile.am.include | 2 ++ ubi/flash.cpp | 29 +++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 flash.hpp create mode 100644 ubi/Makefile.am.include create mode 100644 ubi/flash.cpp diff --git a/Makefile.am b/Makefile.am index 9b6b508..adba0e4 100755 --- a/Makefile.am +++ b/Makefile.am @@ -39,6 +39,8 @@ phosphor_image_updater_SOURCES = \ item_updater.cpp \ item_updater_main.cpp +include ubi/Makefile.am.include + if WANT_SIGNATURE_VERIFY_BUILD noinst_HEADERS += image_verify.hpp phosphor_image_updater_SOURCES += image_verify.cpp diff --git a/activation.cpp b/activation.cpp index ee0bcf8..b81a7e2 100644 --- a/activation.cpp +++ b/activation.cpp @@ -99,17 +99,7 @@ auto Activation::activation(Activations value) -> Activations } #endif - auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, - SYSTEMD_INTERFACE, "StartUnit"); - method.append("obmc-flash-bmc-ubirw.service", "replace"); - bus.call_noreply(method); - - auto roServiceFile = - "obmc-flash-bmc-ubiro@" + versionId + ".service"; - method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, - SYSTEMD_INTERFACE, "StartUnit"); - method.append(roServiceFile, "replace"); - bus.call_noreply(method); + flashWrite(); activationProgress->progress(10); } diff --git a/activation.hpp b/activation.hpp index 51756f2..55377b1 100644 --- a/activation.hpp +++ b/activation.hpp @@ -3,6 +3,7 @@ #include #include #include +#include "flash.hpp" #include "xyz/openbmc_project/Software/RedundancyPriority/server.hpp" #include "xyz/openbmc_project/Software/ActivationProgress/server.hpp" #include "org/openbmc/Associations/server.hpp" @@ -188,7 +189,7 @@ class ActivationProgress : public ActivationProgressInherit * @details A concrete implementation for * xyz.openbmc_project.Software.Activation DBus API. */ -class Activation : public ActivationInherit +class Activation : public ActivationInherit, Flash { public: /** @brief Constructs Activation Software Manager @@ -245,6 +246,9 @@ class Activation : public ActivationInherit RequestedActivations requestedActivation(RequestedActivations value) override; + /** @brief Overloaded write flash function */ + void flashWrite() override; + /** @brief Check if systemd state change is relevant to this object * * Instance specific interface to handle the detected systemd state diff --git a/flash.hpp b/flash.hpp new file mode 100644 index 0000000..470d99c --- /dev/null +++ b/flash.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include + +namespace phosphor +{ +namespace software +{ +namespace updater +{ + +/** + * @class Flash + * @brief Contains flash management functions. + * @details The software class that contains functions to interact + * with the flash. + */ +class Flash +{ + public: + /** + * @brief Writes the image file(s) to flash + */ + virtual void flashWrite() = 0; +}; + +} // namespace updater +} // namespace software +} // namespace phosphor diff --git a/ubi/Makefile.am.include b/ubi/Makefile.am.include new file mode 100644 index 0000000..7bcfcb2 --- /dev/null +++ b/ubi/Makefile.am.include @@ -0,0 +1,2 @@ +phosphor_image_updater_SOURCES += \ + %reldir%/flash.cpp diff --git a/ubi/flash.cpp b/ubi/flash.cpp new file mode 100644 index 0000000..39015bd --- /dev/null +++ b/ubi/flash.cpp @@ -0,0 +1,29 @@ +#include "activation.hpp" +#include "config.h" + +namespace phosphor +{ +namespace software +{ +namespace updater +{ + +void Activation::flashWrite() +{ + auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, + SYSTEMD_INTERFACE, "StartUnit"); + method.append("obmc-flash-bmc-ubirw.service", "replace"); + bus.call_noreply(method); + + auto roServiceFile = "obmc-flash-bmc-ubiro@" + versionId + ".service"; + method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH, + SYSTEMD_INTERFACE, "StartUnit"); + method.append(roServiceFile, "replace"); + bus.call_noreply(method); + + return; +} + +} // namespace updater +} // namespace software +} // namepsace phosphor -- cgit v1.2.3