Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 3 | #include "activation.hpp" |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 4 | #include "item_updater_helper.hpp" |
Adriana Kobylak | 30352a6 | 2024-04-09 09:25:36 -0500 | [diff] [blame] | 5 | #include "msl_verify.hpp" |
Jagpal Singh Gill | 6d131aa | 2024-04-07 23:56:48 -0700 | [diff] [blame] | 6 | #include "update_manager.hpp" |
Saqib Khan | 705f1bf | 2017-06-09 23:58:38 -0500 | [diff] [blame] | 7 | #include "version.hpp" |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 8 | #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp" |
| 9 | |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 10 | #include <sdbusplus/async.hpp> |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 11 | #include <sdbusplus/server.hpp> |
John Wang | 85c356f | 2019-09-11 16:20:13 +0800 | [diff] [blame] | 12 | #include <xyz/openbmc_project/Association/Definitions/server.hpp> |
Michael Tritz | 37a5904 | 2017-07-12 13:44:53 -0500 | [diff] [blame] | 13 | #include <xyz/openbmc_project/Common/FactoryReset/server.hpp> |
Michael Tritz | 0129d92 | 2017-08-10 19:33:46 -0500 | [diff] [blame] | 14 | #include <xyz/openbmc_project/Control/FieldMode/server.hpp> |
Adriana Kobylak | 30352a6 | 2024-04-09 09:25:36 -0500 | [diff] [blame] | 15 | #include <xyz/openbmc_project/Software/MinimumVersion/server.hpp> |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 16 | |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 17 | #include <string> |
Bright Cheng | 8e9ccfe | 2019-11-18 16:18:44 +0800 | [diff] [blame] | 18 | #include <vector> |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 19 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 20 | namespace phosphor |
| 21 | { |
| 22 | namespace software |
| 23 | { |
| 24 | namespace updater |
| 25 | { |
| 26 | |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 27 | using ActivationIntf = |
| 28 | sdbusplus::xyz::openbmc_project::Software::server::Activation; |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 29 | using ItemUpdaterInherit = sdbusplus::server::object_t< |
Patrick Williams | 1e9a5f1 | 2023-08-23 16:53:06 -0500 | [diff] [blame] | 30 | sdbusplus::server::xyz::openbmc_project::common::FactoryReset, |
| 31 | sdbusplus::server::xyz::openbmc_project::control::FieldMode, |
| 32 | sdbusplus::server::xyz::openbmc_project::association::Definitions, |
| 33 | sdbusplus::server::xyz::openbmc_project::collection::DeleteAll>; |
Adriana Kobylak | 30352a6 | 2024-04-09 09:25:36 -0500 | [diff] [blame] | 34 | using MinimumVersionInherit = sdbusplus::server::object_t< |
| 35 | sdbusplus::server::xyz::openbmc_project::software::MinimumVersion>; |
Michael Tritz | 37a5904 | 2017-07-12 13:44:53 -0500 | [diff] [blame] | 36 | |
Patrick Williams | e75d10f | 2017-05-30 16:56:32 -0500 | [diff] [blame] | 37 | namespace MatchRules = sdbusplus::bus::match::rules; |
Gunnar Mills | 4844291 | 2017-10-06 13:34:07 -0500 | [diff] [blame] | 38 | using VersionClass = phosphor::software::manager::Version; |
Gunnar Mills | ded875d | 2017-08-28 16:44:52 -0500 | [diff] [blame] | 39 | using AssociationList = |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 40 | std::vector<std::tuple<std::string, std::string, std::string>>; |
Jagpal Singh Gill | 6d131aa | 2024-04-07 23:56:48 -0700 | [diff] [blame] | 41 | using UpdateManager = phosphor::software::update::Manager; |
Gunnar Mills | ded875d | 2017-08-28 16:44:52 -0500 | [diff] [blame] | 42 | |
Adriana Kobylak | 30352a6 | 2024-04-09 09:25:36 -0500 | [diff] [blame] | 43 | /** @class MinimumVersion |
| 44 | * @brief OpenBMC MinimumVersion implementation. |
| 45 | * @details A concrete implementation for |
| 46 | * xyz.openbmc_project.Software.MinimumVersion DBus API. |
| 47 | */ |
| 48 | class MinimumVersion : public MinimumVersionInherit |
| 49 | { |
| 50 | public: |
| 51 | /** @brief Constructs MinimumVersion |
| 52 | * |
| 53 | * @param[in] bus - The D-Bus bus object |
| 54 | * @param[in] path - The D-bus object path |
| 55 | */ |
| 56 | MinimumVersion(sdbusplus::bus_t& bus, const std::string& path) : |
| 57 | MinimumVersionInherit(bus, path.c_str(), action::emit_interface_added) |
| 58 | {} |
| 59 | }; |
| 60 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 61 | /** @class ItemUpdater |
| 62 | * @brief Manages the activation of the BMC version items. |
| 63 | */ |
Michael Tritz | 37a5904 | 2017-07-12 13:44:53 -0500 | [diff] [blame] | 64 | class ItemUpdater : public ItemUpdaterInherit |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 65 | { |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 66 | public: |
| 67 | /* |
| 68 | * @brief Types of Activation status for image validation. |
| 69 | */ |
| 70 | enum class ActivationStatus |
| 71 | { |
| 72 | ready, |
| 73 | invalid, |
| 74 | active |
| 75 | }; |
Saqib Khan | 35e83f3 | 2017-05-22 11:37:32 -0500 | [diff] [blame] | 76 | |
Jagpal Singh Gill | dd003f5 | 2024-08-13 15:45:50 -0700 | [diff] [blame] | 77 | /** @brief Types of Updater. */ |
| 78 | enum class UpdaterType |
| 79 | { |
| 80 | BMC, |
| 81 | BIOS, |
| 82 | ALL |
| 83 | }; |
| 84 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 85 | /** @brief Constructs ItemUpdater |
| 86 | * |
| 87 | * @param[in] bus - The D-Bus bus object |
| 88 | */ |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 89 | ItemUpdater(sdbusplus::async::context& ctx, const std::string& path, |
Jagpal Singh Gill | dd003f5 | 2024-08-13 15:45:50 -0700 | [diff] [blame] | 90 | UpdaterType type = UpdaterType::ALL, |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 91 | bool useUpdateDBusInterface = true) : |
| 92 | ItemUpdaterInherit(ctx.get_bus(), path.c_str(), |
Patrick Williams | 35aa9a8 | 2022-04-05 15:55:30 -0500 | [diff] [blame] | 93 | ItemUpdaterInherit::action::defer_emit), |
Jagpal Singh Gill | 46f2a39 | 2024-11-04 18:02:28 -0800 | [diff] [blame] | 94 | type(type), useUpdateDBusInterface(useUpdateDBusInterface), ctx(ctx), |
Jagpal Singh Gill | 6d131aa | 2024-04-07 23:56:48 -0700 | [diff] [blame] | 95 | bus(ctx.get_bus()), helper(bus) |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 96 | { |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 97 | if (!useUpdateDBusInterface) |
| 98 | { |
| 99 | versionMatch = std::make_unique<sdbusplus::bus::match_t>( |
| 100 | bus, |
| 101 | MatchRules::interfacesAdded() + |
| 102 | MatchRules::path("/xyz/openbmc_project/software"), |
| 103 | std::bind(std::mem_fn(&ItemUpdater::createActivation), this, |
| 104 | std::placeholders::_1)); |
| 105 | } |
Lei YU | 531fbc2 | 2021-12-10 20:03:18 +0800 | [diff] [blame] | 106 | getRunningSlot(); |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 107 | setBMCInventoryPath(); |
Jagpal Singh Gill | dd003f5 | 2024-08-13 15:45:50 -0700 | [diff] [blame] | 108 | if (type == UpdaterType::BMC || type == UpdaterType::ALL) |
| 109 | { |
| 110 | processBMCImage(); |
| 111 | } |
| 112 | if (type == UpdaterType::BIOS || type == UpdaterType::ALL) |
| 113 | { |
Lei YU | 6e9fb1d | 2021-02-19 18:01:40 +0800 | [diff] [blame] | 114 | #ifdef HOST_BIOS_UPGRADE |
Jagpal Singh Gill | dd003f5 | 2024-08-13 15:45:50 -0700 | [diff] [blame] | 115 | createBIOSObject(); |
Lei YU | 6e9fb1d | 2021-02-19 18:01:40 +0800 | [diff] [blame] | 116 | #endif |
Jagpal Singh Gill | dd003f5 | 2024-08-13 15:45:50 -0700 | [diff] [blame] | 117 | } |
| 118 | restoreFieldModeStatus(); |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 119 | emit_object_added(); |
| 120 | }; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 121 | |
Adriana Kobylak | bbcb7be | 2018-07-17 15:47:34 -0500 | [diff] [blame] | 122 | /** @brief Save priority value to persistent storage (flash and optionally |
| 123 | * a U-Boot environment variable) |
| 124 | * |
| 125 | * @param[in] versionId - The Id of the version |
| 126 | * @param[in] value - The priority value |
| 127 | * @return None |
| 128 | */ |
| 129 | void savePriority(const std::string& versionId, uint8_t value); |
| 130 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 131 | /** @brief Sets the given priority free by incrementing |
| 132 | * any existing priority with the same value by 1 |
| 133 | * |
| 134 | * @param[in] value - The priority that needs to be set free. |
| 135 | * @param[in] versionId - The Id of the version for which we |
| 136 | * are trying to free up the priority. |
| 137 | * @return None |
| 138 | */ |
| 139 | void freePriority(uint8_t value, const std::string& versionId); |
Saqib Khan | 4c1aec0 | 2017-07-06 11:46:13 -0500 | [diff] [blame] | 140 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 141 | /** |
| 142 | * @brief Create and populate the active BMC Version. |
| 143 | */ |
| 144 | void processBMCImage(); |
Saqib Khan | ba23988 | 2017-05-26 08:41:54 -0500 | [diff] [blame] | 145 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 146 | /** |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 147 | * @brief Verifies the image at filepath and creates the version and |
| 148 | * activation object. In case activation object already exists for the |
| 149 | * specified id, update the activation status based on image verification. |
| 150 | * @param[in] id - The unique identifier for the update. |
| 151 | * @param[in] path - The object path for the relevant objects. |
| 152 | * @param[in] version - The version of the image. |
| 153 | * @param[in] purpose - The purpose of the image. |
| 154 | * @param[in] extendedVersion The extended version of the image. |
| 155 | * @param[in] filePath - The file path where the image is located. |
| 156 | * @param[in] compatibleNames - The compatible name for the image. |
| 157 | * @param[out] Activations - Whether the image is ready to activate or not. |
| 158 | */ |
| 159 | ActivationIntf::Activations verifyAndCreateObjects( |
| 160 | std::string& id, std::string& path, std::string& version, |
| 161 | VersionClass::VersionPurpose purpose, std::string& extendedVersion, |
| 162 | std ::string& filePath, std::vector<std::string>& compatibleNames); |
| 163 | |
| 164 | /** |
| 165 | * @brief Creates the activation object |
| 166 | * @param[in] id - The unique identifier for the update. |
| 167 | * @param[in] path - The object path for the activation object. |
| 168 | * @param[in] applyTime - The apply time for the image |
| 169 | */ |
| 170 | void createActivationWithApplyTime( |
| 171 | std::string& id, std::string& path, |
| 172 | ApplyTimeIntf::RequestedApplyTimes applyTime); |
| 173 | |
| 174 | /** |
| 175 | * @brief Request the activation for the specified update. |
| 176 | * @param[in] id - The unique identifier for the update. |
| 177 | * @param[out] bool - status for the action. |
| 178 | */ |
| 179 | bool requestActivation(std::string& id); |
| 180 | |
| 181 | /** |
| 182 | * @brief Change the activation status for the specified update. |
| 183 | * @param[in] id - The unique identifier for the update. |
| 184 | * @param[in] status - The activation status to set. |
| 185 | * @param[out] bool - status for the action. |
| 186 | */ |
| 187 | bool updateActivationStatus(std::string& id, |
| 188 | ActivationIntf::Activations status); |
| 189 | |
| 190 | /** |
Jagpal Singh Gill | 6d131aa | 2024-04-07 23:56:48 -0700 | [diff] [blame] | 191 | * @brief Create the Update object |
| 192 | * @param[in] id - The unique identifier for the update. |
| 193 | * @param[in] path - The object path for the update object. |
| 194 | */ |
| 195 | void createUpdateObject(const std::string& id, const std::string& path); |
| 196 | |
| 197 | /** |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 198 | * @brief Erase specified entry D-Bus object |
| 199 | * if Action property is not set to Active |
| 200 | * |
| 201 | * @param[in] entryId - unique identifier of the entry |
| 202 | */ |
| 203 | void erase(std::string entryId); |
Leonel Gonzalez | 3526ef7 | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 204 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 205 | /** |
| 206 | * @brief Deletes all versions except for the current one |
| 207 | */ |
Pavithra Barithaya | 36cc1c8 | 2024-06-22 00:41:28 -0500 | [diff] [blame] | 208 | void deleteAll() override; |
Gunnar Mills | ded875d | 2017-08-28 16:44:52 -0500 | [diff] [blame] | 209 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 210 | /** @brief Creates an active association to the |
| 211 | * newly active software image |
| 212 | * |
| 213 | * @param[in] path - The path to create the association to. |
| 214 | */ |
| 215 | void createActiveAssociation(const std::string& path); |
Gunnar Mills | ded875d | 2017-08-28 16:44:52 -0500 | [diff] [blame] | 216 | |
Adriana Kobylak | 991af7e | 2018-12-10 13:08:38 -0600 | [diff] [blame] | 217 | /** @brief Removes the associations from the provided software image path |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 218 | * |
Adriana Kobylak | 991af7e | 2018-12-10 13:08:38 -0600 | [diff] [blame] | 219 | * @param[in] path - The path to remove the associations from. |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 220 | */ |
Adriana Kobylak | 991af7e | 2018-12-10 13:08:38 -0600 | [diff] [blame] | 221 | void removeAssociations(const std::string& path); |
Gunnar Mills | ded875d | 2017-08-28 16:44:52 -0500 | [diff] [blame] | 222 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 223 | /** @brief Determine if the given priority is the lowest |
| 224 | * |
| 225 | * @param[in] value - The priority that needs to be checked. |
| 226 | * |
| 227 | * @return boolean corresponding to whether the given |
| 228 | * priority is lowest. |
| 229 | */ |
| 230 | bool isLowestPriority(uint8_t value); |
Saqib Khan | b9da663 | 2017-09-13 09:48:37 -0500 | [diff] [blame] | 231 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 232 | /** |
| 233 | * @brief Updates the U-Boot variables to point to the requested |
| 234 | * versionId, so that the systems boots from this version on |
| 235 | * the next reboot. |
| 236 | * |
| 237 | * @param[in] versionId - The version to point the system to boot from. |
| 238 | */ |
| 239 | void updateUbootEnvVars(const std::string& versionId); |
Adriana Kobylak | b77551c | 2017-10-27 12:46:23 -0500 | [diff] [blame] | 240 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 241 | /** |
| 242 | * @brief Updates the uboot variables to point to BMC version with lowest |
| 243 | * priority, so that the system boots from this version on the |
| 244 | * next boot. |
| 245 | */ |
| 246 | void resetUbootEnvVars(); |
Saqib Khan | 49446ae | 2017-10-02 10:54:20 -0500 | [diff] [blame] | 247 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 248 | /** @brief Brings the total number of active BMC versions to |
| 249 | * ACTIVE_BMC_MAX_ALLOWED -1. This function is intended to be |
| 250 | * run before activating a new BMC version. If this function |
| 251 | * needs to delete any BMC version(s) it will delete the |
| 252 | * version(s) with the highest priority, skipping the |
| 253 | * functional BMC version. |
Adriana Kobylak | a696359 | 2018-09-07 14:13:29 -0500 | [diff] [blame] | 254 | * |
| 255 | * @param[in] caller - The Activation object that called this function. |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 256 | */ |
Lei YU | 0cd6d84 | 2021-12-27 11:56:02 +0800 | [diff] [blame] | 257 | void freeSpace(const Activation& caller); |
Adriana Kobylak | 204e1e7 | 2018-01-24 16:00:05 -0600 | [diff] [blame] | 258 | |
AppaRao Puli | 1bb6dcb | 2020-03-27 20:51:57 +0530 | [diff] [blame] | 259 | /** @brief Creates a updateable association to the |
| 260 | * "running" BMC software image |
| 261 | * |
| 262 | * @param[in] path - The path to create the association. |
| 263 | */ |
| 264 | void createUpdateableAssociation(const std::string& path); |
| 265 | |
Adriana Kobylak | ec4eec3 | 2019-11-13 14:28:35 -0600 | [diff] [blame] | 266 | /** @brief Persistent map of Version D-Bus objects and their |
| 267 | * version id */ |
| 268 | std::map<std::string, std::unique_ptr<VersionClass>> versions; |
| 269 | |
Bright Cheng | 8e9ccfe | 2019-11-18 16:18:44 +0800 | [diff] [blame] | 270 | /** @brief Vector of needed BMC images in the tarball*/ |
| 271 | std::vector<std::string> imageUpdateList; |
| 272 | |
Manojkiran Eda | 19dd56b | 2024-06-17 14:29:52 +0530 | [diff] [blame] | 273 | /** @brief The slot of running BMC image */ |
Lei YU | 531fbc2 | 2021-12-10 20:03:18 +0800 | [diff] [blame] | 274 | uint32_t runningImageSlot = 0; |
| 275 | |
Jagpal Singh Gill | 46f2a39 | 2024-11-04 18:02:28 -0800 | [diff] [blame] | 276 | /** @brief The type of updater. */ |
| 277 | UpdaterType type; |
| 278 | |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 279 | /** @brief Flag to indicate if the update interface is used or not */ |
| 280 | bool useUpdateDBusInterface; |
| 281 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 282 | private: |
| 283 | /** @brief Callback function for Software.Version match. |
| 284 | * @details Creates an Activation D-Bus object. |
| 285 | * |
| 286 | * @param[in] msg - Data associated with subscribed signal |
| 287 | */ |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 288 | void createActivation(sdbusplus::message_t& msg); |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 289 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 290 | /** |
| 291 | * @brief Validates the presence of SquashFS image in the image dir. |
| 292 | * |
| 293 | * @param[in] filePath - The path to the image dir. |
| 294 | * @param[out] result - ActivationStatus Enum. |
| 295 | * ready if validation was successful. |
| 296 | * invalid if validation fail. |
| 297 | * active if image is the current version. |
| 298 | * |
| 299 | */ |
| 300 | ActivationStatus validateSquashFSImage(const std::string& filePath); |
Saqib Khan | 35e83f3 | 2017-05-22 11:37:32 -0500 | [diff] [blame] | 301 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 302 | /** @brief BMC factory reset - marks the read-write partition for |
| 303 | * recreation upon reboot. */ |
| 304 | void reset() override; |
Michael Tritz | 37a5904 | 2017-07-12 13:44:53 -0500 | [diff] [blame] | 305 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 306 | /** |
| 307 | * @brief Enables field mode, if value=true. |
| 308 | * |
| 309 | * @param[in] value - If true, enables field mode. |
| 310 | * @param[out] result - Returns the current state of field mode. |
| 311 | * |
| 312 | */ |
| 313 | bool fieldModeEnabled(bool value) override; |
Michael Tritz | 0129d92 | 2017-08-10 19:33:46 -0500 | [diff] [blame] | 314 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 315 | /** @brief Sets the BMC inventory item path under |
| 316 | * /xyz/openbmc_project/inventory/system/chassis/. */ |
| 317 | void setBMCInventoryPath(); |
Gunnar Mills | b60add1 | 2017-08-24 16:41:42 -0500 | [diff] [blame] | 318 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 319 | /** @brief The path to the BMC inventory item. */ |
| 320 | std::string bmcInventoryPath; |
Gunnar Mills | b60add1 | 2017-08-24 16:41:42 -0500 | [diff] [blame] | 321 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 322 | /** @brief Restores field mode status on reboot. */ |
| 323 | void restoreFieldModeStatus(); |
Michael Tritz | 0129d92 | 2017-08-10 19:33:46 -0500 | [diff] [blame] | 324 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 325 | /** @brief Creates a functional association to the |
| 326 | * "running" BMC software image |
| 327 | * |
| 328 | * @param[in] path - The path to create the association to. |
| 329 | */ |
| 330 | void createFunctionalAssociation(const std::string& path); |
Gunnar Mills | 88e8a32 | 2017-09-13 11:09:28 -0500 | [diff] [blame] | 331 | |
Jagpal Singh Gill | 6d131aa | 2024-04-07 23:56:48 -0700 | [diff] [blame] | 332 | /** @brief D-Bus context */ |
| 333 | sdbusplus::async::context& ctx; |
| 334 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 335 | /** @brief Persistent sdbusplus D-Bus bus connection. */ |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 336 | sdbusplus::bus_t& bus; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 337 | |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 338 | /** @brief The helper of image updater. */ |
| 339 | Helper helper; |
| 340 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 341 | /** @brief Persistent map of Activation D-Bus objects and their |
| 342 | * version id */ |
| 343 | std::map<std::string, std::unique_ptr<Activation>> activations; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 344 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 345 | /** @brief sdbusplus signal match for Software.Version */ |
Jagpal Singh Gill | bb024eb | 2024-04-07 23:34:00 -0700 | [diff] [blame] | 346 | std::unique_ptr<sdbusplus::bus::match_t> versionMatch; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 347 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 348 | /** @brief This entry's associations */ |
Patrick Williams | fc33ba8 | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 349 | AssociationList assocs; |
Gunnar Mills | ded875d | 2017-08-28 16:44:52 -0500 | [diff] [blame] | 350 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 351 | /** @brief Clears read only partition for |
| 352 | * given Activation D-Bus object. |
| 353 | * |
| 354 | * @param[in] versionId - The version id. |
| 355 | */ |
Pavithra Barithaya | 6d17852 | 2024-06-24 04:17:29 -0500 | [diff] [blame] | 356 | void removeReadOnlyPartition(const std::string& versionId); |
Eddie James | eaa1ee0 | 2018-03-01 10:09:10 -0600 | [diff] [blame] | 357 | |
| 358 | /** @brief Copies U-Boot from the currently booted BMC chip to the |
| 359 | * alternate chip. |
| 360 | */ |
| 361 | void mirrorUbootToAlt(); |
Bright Cheng | 8e9ccfe | 2019-11-18 16:18:44 +0800 | [diff] [blame] | 362 | |
| 363 | /** @brief Check the required image files |
| 364 | * |
| 365 | * @param[in] filePath - BMC tarball file path |
| 366 | * @param[in] imageList - Image filenames included in the BMC tarball |
| 367 | * @param[out] result - Boolean |
| 368 | * true if all image files are found in BMC tarball |
| 369 | * false if one of image files is missing |
| 370 | */ |
Pavithra Barithaya | c5f6e7e | 2024-06-24 09:50:21 -0500 | [diff] [blame] | 371 | static bool checkImage(const std::string& filePath, |
| 372 | const std::vector<std::string>& imageList); |
Lei YU | 6e9fb1d | 2021-02-19 18:01:40 +0800 | [diff] [blame] | 373 | |
Adriana Kobylak | 30352a6 | 2024-04-09 09:25:36 -0500 | [diff] [blame] | 374 | /** @brief Persistent MinimumVersion D-Bus object */ |
| 375 | std::unique_ptr<MinimumVersion> minimumVersionObject; |
| 376 | |
Jagpal Singh Gill | 6d131aa | 2024-04-07 23:56:48 -0700 | [diff] [blame] | 377 | /** @brief Persistent map of Update D-Bus objects and their SwIds */ |
| 378 | std::map<std::string, std::unique_ptr<UpdateManager>> updateManagers; |
| 379 | |
Lei YU | 6e9fb1d | 2021-02-19 18:01:40 +0800 | [diff] [blame] | 380 | #ifdef HOST_BIOS_UPGRADE |
| 381 | /** @brief Create the BIOS object without knowing the version. |
| 382 | * |
| 383 | * The object is created only to provide the DBus access so that an |
| 384 | * external service could set the correct BIOS version. |
| 385 | * On BIOS code update, the version is updated accordingly. |
| 386 | */ |
| 387 | void createBIOSObject(); |
| 388 | |
| 389 | /** @brief Persistent Activation D-Bus object for BIOS */ |
| 390 | std::unique_ptr<Activation> biosActivation; |
| 391 | |
Lei YU | 16aa28a | 2021-05-07 10:17:30 +0800 | [diff] [blame] | 392 | public: |
Lei YU | 6e9fb1d | 2021-02-19 18:01:40 +0800 | [diff] [blame] | 393 | /** @brief Persistent Version D-Bus object for BIOS */ |
| 394 | std::unique_ptr<VersionClass> biosVersion; |
| 395 | #endif |
Lei YU | 531fbc2 | 2021-12-10 20:03:18 +0800 | [diff] [blame] | 396 | |
| 397 | /** @brief Get the slot number of running image */ |
| 398 | void getRunningSlot(); |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 399 | }; |
| 400 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 401 | } // namespace updater |
| 402 | } // namespace software |
| 403 | } // namespace phosphor |