Jayanth Othayoth | 13c57ad | 2021-07-16 06:02:21 -0500 | [diff] [blame^] | 1 | #include "fw_update_watch.hpp" |
| 2 | |
| 3 | #include <fmt/format.h> |
| 4 | |
| 5 | #include <phosphor-logging/elog.hpp> |
| 6 | #include <sdbusplus/exception.hpp> |
| 7 | |
| 8 | namespace openpower |
| 9 | { |
| 10 | namespace phal |
| 11 | { |
| 12 | namespace fwupdate |
| 13 | { |
| 14 | using namespace phosphor::logging; |
| 15 | using Message = std::string; |
| 16 | using Attributes = std::variant<Message>; |
| 17 | using PropertyName = std::string; |
| 18 | using PropertyMap = std::map<PropertyName, Attributes>; |
| 19 | using InterfaceName = std::string; |
| 20 | using InterfaceMap = std::map<InterfaceName, PropertyMap>; |
| 21 | |
| 22 | void Watch::fwIntfAddedCallback(sdbusplus::message::message& msg) |
| 23 | { |
| 24 | // DBusInterfaceAdded interfaces; |
| 25 | sdbusplus::message::object_path objectPath; |
| 26 | InterfaceMap interfaceMap; |
| 27 | |
| 28 | try |
| 29 | { |
| 30 | msg.read(objectPath, interfaceMap); |
| 31 | } |
| 32 | catch (const sdbusplus::exception::SdBusError& e) |
| 33 | { |
| 34 | log<level::ERR>(fmt::format("Failed to parse software add signal" |
| 35 | "Exception [{}] REPLY_SIG [{}]", |
| 36 | e.what(), msg.get_signature()) |
| 37 | .c_str()); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | auto iter = interfaceMap.find("xyz.openbmc_project.Software.Activation"); |
| 42 | if (iter == interfaceMap.end()) |
| 43 | { |
| 44 | // Skip not related Software Activation |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | auto attr = iter->second.find("Activation"); |
| 49 | if (attr == iter->second.end()) |
| 50 | { |
| 51 | // Skip not related to Activation property. |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | auto& imageProperty = std::get<InterfaceName>(attr->second); |
| 56 | if (imageProperty.empty()) |
| 57 | { |
| 58 | // Skip, no image property |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | if (imageProperty == |
| 63 | "xyz.openbmc_project.Software.Activation.Activations.Ready" && |
| 64 | !isSoftwareUpdateInProgress()) |
| 65 | { |
| 66 | log<level::INFO>("Software path interface add signal received"); |
| 67 | |
| 68 | // Set status to code update in progress. |
| 69 | // Interface added signal triggered multiple times in code update path, |
| 70 | // it's due to additional interfaces added by the software manager app |
| 71 | // after the version interface is created. |
| 72 | // Device tree data collection is required only for the first trigger |
| 73 | setSoftwareUpdateProgress(true); |
| 74 | |
| 75 | // Colect device tree data |
| 76 | openpower::phal::fwupdate::exportDevtree(); |
| 77 | } |
| 78 | |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | void exportDevtree() |
| 83 | {} |
| 84 | |
| 85 | } // namespace fwupdate |
| 86 | } // namespace phal |
| 87 | } // namespace openpower |