1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 #include <sdbusplus/server.hpp> 5 6 namespace openpower 7 { 8 namespace phal 9 { 10 namespace fwupdate 11 { 12 13 static constexpr auto OBJ_SOFTWARE = "/xyz/openbmc_project/software"; 14 15 /** @class Watch 16 * @brief Adds d-bus signal based watch for software path interface add. 17 * @details This implements methods for watching for software path 18 * interface add signal and call appropriate function to initiate phal 19 * devtree attribute data collection and save to preserve partition. 20 * Rules: 21 * - Watch for interfaces added for the software path 22 * - If interface added is “Activation” 23 * - if Activation property value is “Ready” 24 * - Then software update is going to start 25 * - Collect phal devtree required attribute list and save to 26 * pre-defined location 27 * 28 */ 29 class Watch 30 { 31 public: 32 Watch() = delete; 33 ~Watch() = default; 34 Watch(const Watch&) = delete; 35 Watch& operator=(const Watch&) = delete; 36 Watch(Watch&&) = default; 37 Watch& operator=(Watch&&) = default; 38 39 /** @brief constructs watch for interface add signals. 40 * @param[in] bus - The Dbus bus object 41 */ 42 Watch(sdbusplus::bus_t & bus)43 Watch(sdbusplus::bus_t& bus) : 44 addMatch(bus, 45 sdbusplus::bus::match::rules::interfacesAdded() + 46 sdbusplus::bus::match::rules::path(OBJ_SOFTWARE), 47 std::bind(std::mem_fn(&Watch::fwIntfAddedCallback), this, 48 std::placeholders::_1)) 49 {} 50 51 private: 52 /** @brief Method to check whether software update is in progress 53 * @return - bool 54 */ isSoftwareUpdateInProgress() const55 bool isSoftwareUpdateInProgress() const 56 { 57 return softwareUpdateInProgress; 58 } 59 60 /** @brief Method to indicate whether software update is in progress 61 * 62 * @param[in] progress 63 * 64 */ setSoftwareUpdateProgress(bool progress)65 void setSoftwareUpdateProgress(bool progress) 66 { 67 softwareUpdateInProgress = progress; 68 } 69 70 /** @brief Callback function for software path add signal. 71 * @details Function provide required data related to new 72 * software path interface added to see software update progress. 73 * 74 * @param[in] msg - Data associated with subscribed signal 75 */ 76 void fwIntfAddedCallback(sdbusplus::message_t& msg); 77 78 /** @brief sdbusplus signal match for software path add */ 79 sdbusplus::bus::match_t addMatch; 80 81 /** @brief indicates whether software update is going on */ 82 bool softwareUpdateInProgress = false; 83 }; 84 85 /** @brief function to export phal devtree data file based 86 * on the filter file, 87 */ 88 void exportDevtree(); 89 90 } // namespace fwupdate 91 } // namespace phal 92 } // namespace openpower 93