diff options
author | Lei YU <mine260309@gmail.com> | 2019-03-14 14:41:53 +0800 |
---|---|---|
committer | Lei YU <mine260309@gmail.com> | 2019-03-18 11:25:47 +0800 |
commit | e499446423d6ebe96f74e079de36a8929d47277b (patch) | |
tree | 228794ab38e5e46e06fee89ae462244779a84d10 /ubi/item_updater_ubi.cpp | |
parent | 7d832d7d30acfe942c7bb924ca14b9edaddca049 (diff) | |
download | openpower-pnor-code-mgmt-e499446423d6ebe96f74e079de36a8929d47277b.tar.gz openpower-pnor-code-mgmt-e499446423d6ebe96f74e079de36a8929d47277b.zip |
Refactor: Use hiomapd instead of mboxd
mbox service is renamed to hiomapd and provides "Suspend" and
"Resume" method calls, which is more appropriate for raw "cmd" calls.
Use the new methods to suspend and resume hiomapd.
Move "getService()" function into utils so it is shared by multiple
files.
Tested: Verify the reset works on Romulus
Change-Id: I8f89de134b13126697bfc69a21a3148a01c34cca
Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'ubi/item_updater_ubi.cpp')
-rw-r--r-- | ubi/item_updater_ubi.cpp | 64 |
1 files changed, 5 insertions, 59 deletions
diff --git a/ubi/item_updater_ubi.cpp b/ubi/item_updater_ubi.cpp index 83a514d7f..188b0bffd 100644 --- a/ubi/item_updater_ubi.cpp +++ b/ubi/item_updater_ubi.cpp @@ -4,6 +4,7 @@ #include "activation_ubi.hpp" #include "serialize.hpp" +#include "utils.hpp" #include "version.hpp" #include "xyz/openbmc_project/Common/error.hpp" @@ -31,10 +32,6 @@ using namespace phosphor::logging; constexpr auto squashFSImage = "pnor.xz.squashfs"; -// TODO: Change paths once openbmc/openbmc#1663 is completed. -constexpr auto MBOXD_INTERFACE = "org.openbmc.mboxd"; -constexpr auto MBOXD_PATH = "/org/openbmc/mboxd"; - std::unique_ptr<Activation> ItemUpdaterUbi::createActivationObject( const std::string& path, const std::string& versionId, const std::string& extVersion, @@ -213,20 +210,7 @@ void ItemUpdaterUbi::removeReadWritePartition(const std::string& versionId) void ItemUpdaterUbi::reset() { - std::vector<uint8_t> mboxdArgs; - - // Suspend mboxd - no args required. - auto dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH, - MBOXD_INTERFACE, "cmd"); - - dbusCall.append(static_cast<uint8_t>(3), mboxdArgs); - - auto responseMsg = bus.call(dbusCall); - if (responseMsg.is_method_error()) - { - log<level::ERR>("Error in mboxd suspend call"); - elog<InternalFailure>(); - } + utils::hiomapdSuspend(bus); constexpr static auto patchDir = "/usr/local/share/pnor"; if (fs::is_directory(patchDir)) @@ -259,21 +243,7 @@ void ItemUpdaterUbi::reset() } } - // Resume mboxd with arg 1, indicating that the flash was modified. - dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH, MBOXD_INTERFACE, - "cmd"); - - mboxdArgs.push_back(1); - dbusCall.append(static_cast<uint8_t>(4), mboxdArgs); - - responseMsg = bus.call(dbusCall); - if (responseMsg.is_method_error()) - { - log<level::ERR>("Error in mboxd resume call"); - elog<InternalFailure>(); - } - - return; + utils::hiomapdResume(bus); } bool ItemUpdaterUbi::isVersionFunctional(const std::string& versionId) @@ -425,39 +395,15 @@ void GardResetUbi::reset() // need to be updated in the future. auto path = fs::path(PNOR_PRSV_ACTIVE_PATH); path /= "GUARD"; - std::vector<uint8_t> mboxdArgs; - - auto dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH, - MBOXD_INTERFACE, "cmd"); - // Suspend mboxd - no args required. - dbusCall.append(static_cast<uint8_t>(3), mboxdArgs); - - auto responseMsg = bus.call(dbusCall); - if (responseMsg.is_method_error()) - { - log<level::ERR>("Error in mboxd suspend call"); - elog<InternalFailure>(); - } + utils::hiomapdSuspend(bus); if (fs::is_regular_file(path)) { fs::remove(path); } - dbusCall = bus.new_method_call(MBOXD_INTERFACE, MBOXD_PATH, MBOXD_INTERFACE, - "cmd"); - - // Resume mboxd with arg 1, indicating that the flash is modified. - mboxdArgs.push_back(1); - dbusCall.append(static_cast<uint8_t>(4), mboxdArgs); - - responseMsg = bus.call(dbusCall); - if (responseMsg.is_method_error()) - { - log<level::ERR>("Error in mboxd resume call"); - elog<InternalFailure>(); - } + utils::hiomapdResume(bus); } } // namespace updater |