xref: /openbmc/phosphor-bmc-code-mgmt/item_updater.hpp (revision 46f2a39857a03b6960b3a82ae786d522d38290fd)
1ec1b41c4SGunnar Mills #pragma once
2ec1b41c4SGunnar Mills 
3ec1b41c4SGunnar Mills #include "activation.hpp"
456aaf454SLei YU #include "item_updater_helper.hpp"
530352a66SAdriana Kobylak #include "msl_verify.hpp"
66d131aa7SJagpal Singh Gill #include "update_manager.hpp"
7705f1bfcSSaqib Khan #include "version.hpp"
8b0ce996aSGunnar Mills #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
9b0ce996aSGunnar Mills 
10bb024ebaSJagpal Singh Gill #include <sdbusplus/async.hpp>
11b0ce996aSGunnar Mills #include <sdbusplus/server.hpp>
1285c356f7SJohn Wang #include <xyz/openbmc_project/Association/Definitions/server.hpp>
1337a59043SMichael Tritz #include <xyz/openbmc_project/Common/FactoryReset/server.hpp>
140129d926SMichael Tritz #include <xyz/openbmc_project/Control/FieldMode/server.hpp>
1530352a66SAdriana Kobylak #include <xyz/openbmc_project/Software/MinimumVersion/server.hpp>
16ec1b41c4SGunnar Mills 
1758aa7508SAdriana Kobylak #include <string>
188e9ccfe7SBright Cheng #include <vector>
1958aa7508SAdriana Kobylak 
20ec1b41c4SGunnar Mills namespace phosphor
21ec1b41c4SGunnar Mills {
22ec1b41c4SGunnar Mills namespace software
23ec1b41c4SGunnar Mills {
24ec1b41c4SGunnar Mills namespace updater
25ec1b41c4SGunnar Mills {
26ec1b41c4SGunnar Mills 
27bb024ebaSJagpal Singh Gill using ActivationIntf =
28bb024ebaSJagpal Singh Gill     sdbusplus::xyz::openbmc_project::Software::server::Activation;
29bf2bb2b1SPatrick Williams using ItemUpdaterInherit = sdbusplus::server::object_t<
301e9a5f1aSPatrick Williams     sdbusplus::server::xyz::openbmc_project::common::FactoryReset,
311e9a5f1aSPatrick Williams     sdbusplus::server::xyz::openbmc_project::control::FieldMode,
321e9a5f1aSPatrick Williams     sdbusplus::server::xyz::openbmc_project::association::Definitions,
331e9a5f1aSPatrick Williams     sdbusplus::server::xyz::openbmc_project::collection::DeleteAll>;
3430352a66SAdriana Kobylak using MinimumVersionInherit = sdbusplus::server::object_t<
3530352a66SAdriana Kobylak     sdbusplus::server::xyz::openbmc_project::software::MinimumVersion>;
3637a59043SMichael Tritz 
37e75d10f5SPatrick Williams namespace MatchRules = sdbusplus::bus::match::rules;
3848442917SGunnar Mills using VersionClass = phosphor::software::manager::Version;
39ded875dcSGunnar Mills using AssociationList =
40ded875dcSGunnar Mills     std::vector<std::tuple<std::string, std::string, std::string>>;
416d131aa7SJagpal Singh Gill using UpdateManager = phosphor::software::update::Manager;
42ded875dcSGunnar Mills 
4330352a66SAdriana Kobylak /** @class MinimumVersion
4430352a66SAdriana Kobylak  *  @brief OpenBMC MinimumVersion implementation.
4530352a66SAdriana Kobylak  *  @details A concrete implementation for
4630352a66SAdriana Kobylak  *  xyz.openbmc_project.Software.MinimumVersion DBus API.
4730352a66SAdriana Kobylak  */
4830352a66SAdriana Kobylak class MinimumVersion : public MinimumVersionInherit
4930352a66SAdriana Kobylak {
5030352a66SAdriana Kobylak   public:
5130352a66SAdriana Kobylak     /** @brief Constructs MinimumVersion
5230352a66SAdriana Kobylak      *
5330352a66SAdriana Kobylak      * @param[in] bus - The D-Bus bus object
5430352a66SAdriana Kobylak      * @param[in] path - The D-bus object path
5530352a66SAdriana Kobylak      */
MinimumVersion(sdbusplus::bus_t & bus,const std::string & path)5630352a66SAdriana Kobylak     MinimumVersion(sdbusplus::bus_t& bus, const std::string& path) :
5730352a66SAdriana Kobylak         MinimumVersionInherit(bus, path.c_str(), action::emit_interface_added)
5830352a66SAdriana Kobylak     {}
5930352a66SAdriana Kobylak };
6030352a66SAdriana Kobylak 
61ec1b41c4SGunnar Mills /** @class ItemUpdater
62ec1b41c4SGunnar Mills  *  @brief Manages the activation of the BMC version items.
63ec1b41c4SGunnar Mills  */
6437a59043SMichael Tritz class ItemUpdater : public ItemUpdaterInherit
65ec1b41c4SGunnar Mills {
66ec1b41c4SGunnar Mills   public:
6735e83f3eSSaqib Khan     /*
6835e83f3eSSaqib Khan      * @brief Types of Activation status for image validation.
6935e83f3eSSaqib Khan      */
7035e83f3eSSaqib Khan     enum class ActivationStatus
7135e83f3eSSaqib Khan     {
7235e83f3eSSaqib Khan         ready,
7335e83f3eSSaqib Khan         invalid,
7435e83f3eSSaqib Khan         active
7535e83f3eSSaqib Khan     };
7635e83f3eSSaqib Khan 
77dd003f54SJagpal Singh Gill     /** @brief Types of Updater. */
78dd003f54SJagpal Singh Gill     enum class UpdaterType
79dd003f54SJagpal Singh Gill     {
80dd003f54SJagpal Singh Gill         BMC,
81dd003f54SJagpal Singh Gill         BIOS,
82dd003f54SJagpal Singh Gill         ALL
83dd003f54SJagpal Singh Gill     };
84dd003f54SJagpal Singh Gill 
85ec1b41c4SGunnar Mills     /** @brief Constructs ItemUpdater
86ec1b41c4SGunnar Mills      *
8748442917SGunnar Mills      * @param[in] bus    - The D-Bus bus object
88ec1b41c4SGunnar Mills      */
ItemUpdater(sdbusplus::async::context & ctx,const std::string & path,UpdaterType type=UpdaterType::ALL,bool useUpdateDBusInterface=true)89bb024ebaSJagpal Singh Gill     ItemUpdater(sdbusplus::async::context& ctx, const std::string& path,
90dd003f54SJagpal Singh Gill                 UpdaterType type = UpdaterType::ALL,
91bb024ebaSJagpal Singh Gill                 bool useUpdateDBusInterface = true) :
92bb024ebaSJagpal Singh Gill         ItemUpdaterInherit(ctx.get_bus(), path.c_str(),
9335aa9a88SPatrick Williams                            ItemUpdaterInherit::action::defer_emit),
94*46f2a398SJagpal Singh Gill         type(type), useUpdateDBusInterface(useUpdateDBusInterface), ctx(ctx),
956d131aa7SJagpal Singh Gill         bus(ctx.get_bus()), helper(bus)
96bb024ebaSJagpal Singh Gill     {
97bb024ebaSJagpal Singh Gill         if (!useUpdateDBusInterface)
98bb024ebaSJagpal Singh Gill         {
99bb024ebaSJagpal Singh Gill             versionMatch = std::make_unique<sdbusplus::bus::match_t>(
100bb024ebaSJagpal Singh Gill                 bus,
101e75d10f5SPatrick Williams                 MatchRules::interfacesAdded() +
102e75d10f5SPatrick Williams                     MatchRules::path("/xyz/openbmc_project/software"),
103bb024ebaSJagpal Singh Gill                 std::bind(std::mem_fn(&ItemUpdater::createActivation), this,
104bb024ebaSJagpal Singh Gill                           std::placeholders::_1));
105bb024ebaSJagpal Singh Gill         }
106531fbc25SLei YU         getRunningSlot();
107b60add1eSGunnar Mills         setBMCInventoryPath();
108dd003f54SJagpal Singh Gill         if (type == UpdaterType::BMC || type == UpdaterType::ALL)
109dd003f54SJagpal Singh Gill         {
110ba239881SSaqib Khan             processBMCImage();
111dd003f54SJagpal Singh Gill         }
112dd003f54SJagpal Singh Gill         if (type == UpdaterType::BIOS || type == UpdaterType::ALL)
113dd003f54SJagpal Singh Gill         {
1146e9fb1d6SLei YU #ifdef HOST_BIOS_UPGRADE
1156e9fb1d6SLei YU             createBIOSObject();
1166e9fb1d6SLei YU #endif
117dd003f54SJagpal Singh Gill         }
118dd003f54SJagpal Singh Gill         restoreFieldModeStatus();
1190129d926SMichael Tritz         emit_object_added();
120e75d10f5SPatrick Williams     };
121ec1b41c4SGunnar Mills 
122bbcb7be1SAdriana Kobylak     /** @brief Save priority value to persistent storage (flash and optionally
123bbcb7be1SAdriana Kobylak      *  a U-Boot environment variable)
124bbcb7be1SAdriana Kobylak      *
125bbcb7be1SAdriana Kobylak      *  @param[in] versionId - The Id of the version
126bbcb7be1SAdriana Kobylak      *  @param[in] value - The priority value
127bbcb7be1SAdriana Kobylak      *  @return None
128bbcb7be1SAdriana Kobylak      */
129bbcb7be1SAdriana Kobylak     void savePriority(const std::string& versionId, uint8_t value);
130bbcb7be1SAdriana Kobylak 
1314c1aec09SSaqib Khan     /** @brief Sets the given priority free by incrementing
1324c1aec09SSaqib Khan      *  any existing priority with the same value by 1
1334c1aec09SSaqib Khan      *
1344c1aec09SSaqib Khan      *  @param[in] value - The priority that needs to be set free.
135b9da6634SSaqib Khan      *  @param[in] versionId - The Id of the version for which we
136b9da6634SSaqib Khan      *                         are trying to free up the priority.
1374c1aec09SSaqib Khan      *  @return None
1384c1aec09SSaqib Khan      */
139b9da6634SSaqib Khan     void freePriority(uint8_t value, const std::string& versionId);
1404c1aec09SSaqib Khan 
141ba239881SSaqib Khan     /**
142ba239881SSaqib Khan      * @brief Create and populate the active BMC Version.
143ba239881SSaqib Khan      */
144ba239881SSaqib Khan     void processBMCImage();
145ba239881SSaqib Khan 
1463526ef73SLeonel Gonzalez     /**
147bb024ebaSJagpal Singh Gill      * @brief Verifies the image at filepath and creates the version and
148bb024ebaSJagpal Singh Gill      * activation object. In case activation object already exists for the
149bb024ebaSJagpal Singh Gill      * specified id, update the activation status based on image verification.
150bb024ebaSJagpal Singh Gill      * @param[in] id - The unique identifier for the update.
151bb024ebaSJagpal Singh Gill      * @param[in] path - The object path for the relevant objects.
152bb024ebaSJagpal Singh Gill      * @param[in] version - The version of the image.
153bb024ebaSJagpal Singh Gill      * @param[in] purpose - The purpose of the image.
154bb024ebaSJagpal Singh Gill      * @param[in] extendedVersion The extended version of the image.
155bb024ebaSJagpal Singh Gill      * @param[in] filePath - The file path where the image is located.
156bb024ebaSJagpal Singh Gill      * @param[in] compatibleNames - The compatible name for the image.
157bb024ebaSJagpal Singh Gill      * @param[out] Activations - Whether the image is ready to activate or not.
158bb024ebaSJagpal Singh Gill      */
159bb024ebaSJagpal Singh Gill     ActivationIntf::Activations verifyAndCreateObjects(
160bb024ebaSJagpal Singh Gill         std::string& id, std::string& path, std::string& version,
161bb024ebaSJagpal Singh Gill         VersionClass::VersionPurpose purpose, std::string& extendedVersion,
162bb024ebaSJagpal Singh Gill         std ::string& filePath, std::vector<std::string>& compatibleNames);
163bb024ebaSJagpal Singh Gill 
164bb024ebaSJagpal Singh Gill     /**
165bb024ebaSJagpal Singh Gill      * @brief Creates the activation object
166bb024ebaSJagpal Singh Gill      * @param[in] id - The unique identifier for the update.
167bb024ebaSJagpal Singh Gill      * @param[in] path - The object path for the activation object.
168bb024ebaSJagpal Singh Gill      * @param[in] applyTime - The apply time for the image
169bb024ebaSJagpal Singh Gill      */
170bb024ebaSJagpal Singh Gill     void createActivationWithApplyTime(
171bb024ebaSJagpal Singh Gill         std::string& id, std::string& path,
172bb024ebaSJagpal Singh Gill         ApplyTimeIntf::RequestedApplyTimes applyTime);
173bb024ebaSJagpal Singh Gill 
174bb024ebaSJagpal Singh Gill     /**
175bb024ebaSJagpal Singh Gill      * @brief Request the activation for the specified update.
176bb024ebaSJagpal Singh Gill      * @param[in] id - The unique identifier for the update.
177bb024ebaSJagpal Singh Gill      * @param[out] bool - status for the action.
178bb024ebaSJagpal Singh Gill      */
179bb024ebaSJagpal Singh Gill     bool requestActivation(std::string& id);
180bb024ebaSJagpal Singh Gill 
181bb024ebaSJagpal Singh Gill     /**
182bb024ebaSJagpal Singh Gill      * @brief Change the activation status for the specified update.
183bb024ebaSJagpal Singh Gill      * @param[in] id - The unique identifier for the update.
184bb024ebaSJagpal Singh Gill      * @param[in] status - The activation status to set.
185bb024ebaSJagpal Singh Gill      * @param[out] bool - status for the action.
186bb024ebaSJagpal Singh Gill      */
187bb024ebaSJagpal Singh Gill     bool updateActivationStatus(std::string& id,
188bb024ebaSJagpal Singh Gill                                 ActivationIntf::Activations status);
189bb024ebaSJagpal Singh Gill 
190bb024ebaSJagpal Singh Gill     /**
1916d131aa7SJagpal Singh Gill      * @brief Create the Update object
1926d131aa7SJagpal Singh Gill      * @param[in] id - The unique identifier for the update.
1936d131aa7SJagpal Singh Gill      * @param[in] path - The object path for the update object.
1946d131aa7SJagpal Singh Gill      */
1956d131aa7SJagpal Singh Gill     void createUpdateObject(const std::string& id, const std::string& path);
1966d131aa7SJagpal Singh Gill 
1976d131aa7SJagpal Singh Gill     /**
19848442917SGunnar Mills      * @brief Erase specified entry D-Bus object
1993526ef73SLeonel Gonzalez      *        if Action property is not set to Active
2003526ef73SLeonel Gonzalez      *
2013526ef73SLeonel Gonzalez      * @param[in] entryId - unique identifier of the entry
2023526ef73SLeonel Gonzalez      */
2033526ef73SLeonel Gonzalez     void erase(std::string entryId);
2043526ef73SLeonel Gonzalez 
205bc1bf3afSMichael Tritz     /**
206bc1bf3afSMichael Tritz      * @brief Deletes all versions except for the current one
207bc1bf3afSMichael Tritz      */
20836cc1c84SPavithra Barithaya     void deleteAll() override;
209ded875dcSGunnar Mills 
210ded875dcSGunnar Mills     /** @brief Creates an active association to the
211ded875dcSGunnar Mills      *  newly active software image
212ded875dcSGunnar Mills      *
213ded875dcSGunnar Mills      * @param[in]  path - The path to create the association to.
214ded875dcSGunnar Mills      */
215f10b2326SGunnar Mills     void createActiveAssociation(const std::string& path);
216ded875dcSGunnar Mills 
217991af7ecSAdriana Kobylak     /** @brief Removes the associations from the provided software image path
218ded875dcSGunnar Mills      *
219991af7ecSAdriana Kobylak      * @param[in]  path - The path to remove the associations from.
220ded875dcSGunnar Mills      */
221991af7ecSAdriana Kobylak     void removeAssociations(const std::string& path);
222ded875dcSGunnar Mills 
223b9da6634SSaqib Khan     /** @brief Determine if the given priority is the lowest
224b9da6634SSaqib Khan      *
225b9da6634SSaqib Khan      *  @param[in] value - The priority that needs to be checked.
226b9da6634SSaqib Khan      *
227b9da6634SSaqib Khan      *  @return boolean corresponding to whether the given
228b9da6634SSaqib Khan      *      priority is lowest.
229b9da6634SSaqib Khan      */
230b9da6634SSaqib Khan     bool isLowestPriority(uint8_t value);
231b9da6634SSaqib Khan 
23249446ae9SSaqib Khan     /**
233b77551cdSAdriana Kobylak      * @brief Updates the U-Boot variables to point to the requested
234b77551cdSAdriana Kobylak      *        versionId, so that the systems boots from this version on
235b77551cdSAdriana Kobylak      *        the next reboot.
236b77551cdSAdriana Kobylak      *
237b77551cdSAdriana Kobylak      * @param[in] versionId - The version to point the system to boot from.
238b77551cdSAdriana Kobylak      */
239b77551cdSAdriana Kobylak     void updateUbootEnvVars(const std::string& versionId);
240b77551cdSAdriana Kobylak 
241b77551cdSAdriana Kobylak     /**
24249446ae9SSaqib Khan      * @brief Updates the uboot variables to point to BMC version with lowest
24349446ae9SSaqib Khan      *        priority, so that the system boots from this version on the
24449446ae9SSaqib Khan      *        next boot.
24549446ae9SSaqib Khan      */
24649446ae9SSaqib Khan     void resetUbootEnvVars();
24749446ae9SSaqib Khan 
248204e1e74SAdriana Kobylak     /** @brief Brings the total number of active BMC versions to
249204e1e74SAdriana Kobylak      *         ACTIVE_BMC_MAX_ALLOWED -1. This function is intended to be
250204e1e74SAdriana Kobylak      *         run before activating a new BMC version. If this function
251204e1e74SAdriana Kobylak      *         needs to delete any BMC version(s) it will delete the
252204e1e74SAdriana Kobylak      *         version(s) with the highest priority, skipping the
253204e1e74SAdriana Kobylak      *         functional BMC version.
254a6963590SAdriana Kobylak      *
255a6963590SAdriana Kobylak      * @param[in] caller - The Activation object that called this function.
256204e1e74SAdriana Kobylak      */
2570cd6d84bSLei YU     void freeSpace(const Activation& caller);
258204e1e74SAdriana Kobylak 
2591bb6dcb4SAppaRao Puli     /** @brief Creates a updateable association to the
2601bb6dcb4SAppaRao Puli      *  "running" BMC software image
2611bb6dcb4SAppaRao Puli      *
2621bb6dcb4SAppaRao Puli      * @param[in]  path - The path to create the association.
2631bb6dcb4SAppaRao Puli      */
2641bb6dcb4SAppaRao Puli     void createUpdateableAssociation(const std::string& path);
2651bb6dcb4SAppaRao Puli 
266ec4eec34SAdriana Kobylak     /** @brief Persistent map of Version D-Bus objects and their
267ec4eec34SAdriana Kobylak      * version id */
268ec4eec34SAdriana Kobylak     std::map<std::string, std::unique_ptr<VersionClass>> versions;
269ec4eec34SAdriana Kobylak 
2708e9ccfe7SBright Cheng     /** @brief Vector of needed BMC images in the tarball*/
2718e9ccfe7SBright Cheng     std::vector<std::string> imageUpdateList;
2728e9ccfe7SBright Cheng 
27319dd56beSManojkiran Eda     /** @brief The slot of running BMC image */
274531fbc25SLei YU     uint32_t runningImageSlot = 0;
275531fbc25SLei YU 
276*46f2a398SJagpal Singh Gill     /** @brief The type of updater. */
277*46f2a398SJagpal Singh Gill     UpdaterType type;
278*46f2a398SJagpal Singh Gill 
279bb024ebaSJagpal Singh Gill     /** @brief Flag to indicate if the update interface is used or not */
280bb024ebaSJagpal Singh Gill     bool useUpdateDBusInterface;
281bb024ebaSJagpal Singh Gill 
282ec1b41c4SGunnar Mills   private:
283ec1b41c4SGunnar Mills     /** @brief Callback function for Software.Version match.
28448442917SGunnar Mills      *  @details Creates an Activation D-Bus object.
285ec1b41c4SGunnar Mills      *
286ec1b41c4SGunnar Mills      * @param[in]  msg       - Data associated with subscribed signal
287ec1b41c4SGunnar Mills      */
288bf2bb2b1SPatrick Williams     void createActivation(sdbusplus::message_t& msg);
289ec1b41c4SGunnar Mills 
29035e83f3eSSaqib Khan     /**
29148442917SGunnar Mills      * @brief Validates the presence of SquashFS image in the image dir.
29235e83f3eSSaqib Khan      *
29319177d3eSSaqib Khan      * @param[in]  filePath  - The path to the image dir.
29435e83f3eSSaqib Khan      * @param[out] result    - ActivationStatus Enum.
29535e83f3eSSaqib Khan      *                         ready if validation was successful.
29635e83f3eSSaqib Khan      *                         invalid if validation fail.
29735e83f3eSSaqib Khan      *                         active if image is the current version.
29835e83f3eSSaqib Khan      *
29935e83f3eSSaqib Khan      */
30019177d3eSSaqib Khan     ActivationStatus validateSquashFSImage(const std::string& filePath);
30135e83f3eSSaqib Khan 
30237a59043SMichael Tritz     /** @brief BMC factory reset - marks the read-write partition for
30337a59043SMichael Tritz      * recreation upon reboot. */
30437a59043SMichael Tritz     void reset() override;
30537a59043SMichael Tritz 
3060129d926SMichael Tritz     /**
3070129d926SMichael Tritz      * @brief Enables field mode, if value=true.
3080129d926SMichael Tritz      *
3090129d926SMichael Tritz      * @param[in]  value  - If true, enables field mode.
3100129d926SMichael Tritz      * @param[out] result - Returns the current state of field mode.
3110129d926SMichael Tritz      *
3120129d926SMichael Tritz      */
3130129d926SMichael Tritz     bool fieldModeEnabled(bool value) override;
3140129d926SMichael Tritz 
315b60add1eSGunnar Mills     /** @brief Sets the BMC inventory item path under
316b60add1eSGunnar Mills      *  /xyz/openbmc_project/inventory/system/chassis/. */
317b60add1eSGunnar Mills     void setBMCInventoryPath();
318b60add1eSGunnar Mills 
319b60add1eSGunnar Mills     /** @brief The path to the BMC inventory item. */
320b60add1eSGunnar Mills     std::string bmcInventoryPath;
321b60add1eSGunnar Mills 
3220129d926SMichael Tritz     /** @brief Restores field mode status on reboot. */
3230129d926SMichael Tritz     void restoreFieldModeStatus();
3240129d926SMichael Tritz 
32588e8a325SGunnar Mills     /** @brief Creates a functional association to the
32688e8a325SGunnar Mills      *  "running" BMC software image
32788e8a325SGunnar Mills      *
32888e8a325SGunnar Mills      * @param[in]  path - The path to create the association to.
32988e8a325SGunnar Mills      */
33088e8a325SGunnar Mills     void createFunctionalAssociation(const std::string& path);
33188e8a325SGunnar Mills 
3326d131aa7SJagpal Singh Gill     /** @brief D-Bus context */
3336d131aa7SJagpal Singh Gill     sdbusplus::async::context& ctx;
3346d131aa7SJagpal Singh Gill 
33548442917SGunnar Mills     /** @brief Persistent sdbusplus D-Bus bus connection. */
336bf2bb2b1SPatrick Williams     sdbusplus::bus_t& bus;
337ec1b41c4SGunnar Mills 
33856aaf454SLei YU     /** @brief The helper of image updater. */
33956aaf454SLei YU     Helper helper;
34056aaf454SLei YU 
34148442917SGunnar Mills     /** @brief Persistent map of Activation D-Bus objects and their
342ec1b41c4SGunnar Mills      * version id */
343ec1b41c4SGunnar Mills     std::map<std::string, std::unique_ptr<Activation>> activations;
344ec1b41c4SGunnar Mills 
345ec1b41c4SGunnar Mills     /** @brief sdbusplus signal match for Software.Version */
346bb024ebaSJagpal Singh Gill     std::unique_ptr<sdbusplus::bus::match_t> versionMatch;
347ec1b41c4SGunnar Mills 
348ded875dcSGunnar Mills     /** @brief This entry's associations */
349fc33ba86SPatrick Williams     AssociationList assocs;
350ded875dcSGunnar Mills 
3513526ef73SLeonel Gonzalez     /** @brief Clears read only partition for
35248442917SGunnar Mills      * given Activation D-Bus object.
3533526ef73SLeonel Gonzalez      *
3543526ef73SLeonel Gonzalez      * @param[in]  versionId - The version id.
3553526ef73SLeonel Gonzalez      */
3566d17852dSPavithra Barithaya     void removeReadOnlyPartition(const std::string& versionId);
357eaa1ee05SEddie James 
358eaa1ee05SEddie James     /** @brief Copies U-Boot from the currently booted BMC chip to the
359eaa1ee05SEddie James      *  alternate chip.
360eaa1ee05SEddie James      */
361eaa1ee05SEddie James     void mirrorUbootToAlt();
3628e9ccfe7SBright Cheng 
3638e9ccfe7SBright Cheng     /** @brief Check the required image files
3648e9ccfe7SBright Cheng      *
3658e9ccfe7SBright Cheng      * @param[in] filePath - BMC tarball file path
3668e9ccfe7SBright Cheng      * @param[in] imageList - Image filenames included in the BMC tarball
3678e9ccfe7SBright Cheng      * @param[out] result - Boolean
3688e9ccfe7SBright Cheng      *                      true if all image files are found in BMC tarball
3698e9ccfe7SBright Cheng      *                      false if one of image files is missing
3708e9ccfe7SBright Cheng      */
371c5f6e7e1SPavithra Barithaya     static bool checkImage(const std::string& filePath,
3728e9ccfe7SBright Cheng                            const std::vector<std::string>& imageList);
3736e9fb1d6SLei YU 
37430352a66SAdriana Kobylak     /** @brief Persistent MinimumVersion D-Bus object */
37530352a66SAdriana Kobylak     std::unique_ptr<MinimumVersion> minimumVersionObject;
37630352a66SAdriana Kobylak 
3776d131aa7SJagpal Singh Gill     /** @brief Persistent map of Update D-Bus objects and their SwIds */
3786d131aa7SJagpal Singh Gill     std::map<std::string, std::unique_ptr<UpdateManager>> updateManagers;
3796d131aa7SJagpal Singh Gill 
3806e9fb1d6SLei YU #ifdef HOST_BIOS_UPGRADE
3816e9fb1d6SLei YU     /** @brief Create the BIOS object without knowing the version.
3826e9fb1d6SLei YU      *
3836e9fb1d6SLei YU      *  The object is created only to provide the DBus access so that an
3846e9fb1d6SLei YU      *  external service could set the correct BIOS version.
3856e9fb1d6SLei YU      *  On BIOS code update, the version is updated accordingly.
3866e9fb1d6SLei YU      */
3876e9fb1d6SLei YU     void createBIOSObject();
3886e9fb1d6SLei YU 
3896e9fb1d6SLei YU     /** @brief Persistent Activation D-Bus object for BIOS */
3906e9fb1d6SLei YU     std::unique_ptr<Activation> biosActivation;
3916e9fb1d6SLei YU 
39216aa28a0SLei YU   public:
3936e9fb1d6SLei YU     /** @brief Persistent Version D-Bus object for BIOS */
3946e9fb1d6SLei YU     std::unique_ptr<VersionClass> biosVersion;
3956e9fb1d6SLei YU #endif
396531fbc25SLei YU 
397531fbc25SLei YU     /** @brief Get the slot number of running image */
398531fbc25SLei YU     void getRunningSlot();
399ec1b41c4SGunnar Mills };
400ec1b41c4SGunnar Mills 
401ec1b41c4SGunnar Mills } // namespace updater
402ec1b41c4SGunnar Mills } // namespace software
403ec1b41c4SGunnar Mills } // namespace phosphor
404