blob: db80dbfacd1eb3ad941efc192352f99691af61b6 [file] [log] [blame]
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -05001#pragma once
2
3#include "item_updater.hpp"
4
5namespace openpower
6{
7namespace software
8{
9namespace updater
10{
11
12class GardResetMMC : public GardReset
13{
14 public:
15 using GardReset::GardReset;
16 virtual ~GardResetMMC() = default;
17
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050018 /**
Manojkiran Eda96442c82024-06-17 10:24:05 +053019 * @brief GUARD factory reset - clears the PNOR GUARD partition.
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050020 */
21 void reset() override;
Marri Devender Rao2b314972022-07-01 05:37:30 -050022
23 private:
24 /**
25 * @brief During host factory reset, host clears the guard records in the
26 * guard partition. BMC is not notified about host factory reset so
27 * it continues to disable the guarded items. Now modified to enable
28 * back CpuCore and DIMM items during factory reset.
29 */
30 void enableInventoryItems();
31
32 /**
33 * @brief Helper function to set enable flag for all the subtree objects
34 * implementing the specified interface.
35 *
36 * @param[in] - service D-Bus service name
37 * @param[in] - intf find objects that implement this interface
38 * @param[in] - objPath find subtree objects from this object path
39 * @return none
40 */
41 void enableInventoryItemsHelper(const std::string& service,
42 const std::string& intf,
43 const std::string& objPath);
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050044};
45
46/** @class ItemUpdaterMMC
47 * @brief Manages the activation of the host version items for static layout
48 */
49class ItemUpdaterMMC : public ItemUpdater
50{
51 public:
Patrick Williams0dea1992022-07-22 19:26:52 -050052 ItemUpdaterMMC(sdbusplus::bus_t& bus, const std::string& path) :
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050053 ItemUpdater(bus, path)
54 {
55 processPNORImage();
56 gardReset = std::make_unique<GardResetMMC>(bus, GARD_PATH);
57 volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
58
59 // Emit deferred signal.
60 emit_object_added();
61 }
62 virtual ~ItemUpdaterMMC() = default;
63
64 void freePriority(uint8_t value, const std::string& versionId) override;
65
66 void processPNORImage() override;
67
68 void deleteAll() override;
69
70 bool freeSpace() override;
71
72 void updateFunctionalAssociation(const std::string& versionId) override;
73
74 bool isVersionFunctional(const std::string& versionId) override;
75
76 private:
77 /** @brief Create Activation object */
78 std::unique_ptr<Activation> createActivationObject(
79 const std::string& path, const std::string& versionId,
80 const std::string& extVersion,
81 sdbusplus::xyz::openbmc_project::Software::server::Activation::
82 Activations activationStatus,
83 AssociationList& assocs) override;
84
85 /** @brief Create Version object */
Patrick Williamsf8e02422024-08-16 15:19:59 -040086 std::unique_ptr<Version> createVersionObject(
87 const std::string& objPath, const std::string& versionId,
88 const std::string& versionString,
89 sdbusplus::xyz::openbmc_project::Software::server::Version::
90 VersionPurpose versionPurpose,
91 const std::string& filePath) override;
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050092
93 /** @brief Validate if image is valid or not */
Adriana Kobylak01f71422025-02-07 09:58:50 -060094 bool validateImage(const std::string& path) override;
Adriana Kobylak8bc2ab42020-07-15 09:16:27 -050095
96 /** @brief Host factory reset - clears PNOR partitions for each
97 * Activation D-Bus object */
98 void reset() override;
99
100 /** @brief The functional version ID */
101 std::string functionalVersionId;
102};
103
104} // namespace updater
105} // namespace software
106} // namespace openpower