blob: f9929944096ab8a451db5860c1347c7bdc1b2007 [file] [log] [blame]
Lei YU322f3f42019-02-21 16:10:41 +08001#pragma once
2
3#include "item_updater.hpp"
4
Andrew Geisslerab139ce2020-05-16 13:22:09 -05005#include <string>
6
Lei YU322f3f42019-02-21 16:10:41 +08007namespace openpower
8{
9namespace software
10{
11namespace updater
12{
13
Lei YU716de5b2019-03-01 16:03:53 +080014class GardResetStatic : public GardReset
15{
16 public:
17 using GardReset::GardReset;
18 virtual ~GardResetStatic() = default;
19
20 protected:
21 /**
Manojkiran Eda96442c82024-06-17 10:24:05 +053022 * @brief GUARD factory reset - clears the PNOR GUARD partition.
Lei YU716de5b2019-03-01 16:03:53 +080023 */
24 void reset() override;
25};
26
Lei YU322f3f42019-02-21 16:10:41 +080027/** @class ItemUpdaterStatic
28 * @brief Manages the activation of the host version items for static layout
29 */
30class ItemUpdaterStatic : public ItemUpdater
31{
32 public:
Patrick Williams0dea1992022-07-22 19:26:52 -050033 ItemUpdaterStatic(sdbusplus::bus_t& bus, const std::string& path) :
Lei YU322f3f42019-02-21 16:10:41 +080034 ItemUpdater(bus, path)
35 {
36 processPNORImage();
Lei YU716de5b2019-03-01 16:03:53 +080037 gardReset = std::make_unique<GardResetStatic>(bus, GARD_PATH);
Lei YU322f3f42019-02-21 16:10:41 +080038 volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
39
40 // Emit deferred signal.
41 emit_object_added();
42 }
43 virtual ~ItemUpdaterStatic() = default;
44
45 void freePriority(uint8_t value, const std::string& versionId) override;
46
47 void processPNORImage() override;
48
49 void deleteAll() override;
50
Lei YU6da3dae2019-02-28 14:26:37 +080051 bool freeSpace() override;
Lei YU322f3f42019-02-21 16:10:41 +080052
Lei YUa2e67162019-02-22 17:35:24 +080053 void updateFunctionalAssociation(const std::string& versionId) override;
54
Lei YU322f3f42019-02-21 16:10:41 +080055 bool isVersionFunctional(const std::string& versionId) override;
56
57 private:
58 /** @brief Create Activation object */
59 std::unique_ptr<Activation> createActivationObject(
60 const std::string& path, const std::string& versionId,
61 const std::string& extVersion,
62 sdbusplus::xyz::openbmc_project::Software::server::Activation::
63 Activations activationStatus,
64 AssociationList& assocs) override;
65
66 /** @brief Create Version object */
67 std::unique_ptr<Version>
68 createVersionObject(const std::string& objPath,
69 const std::string& versionId,
70 const std::string& versionString,
71 sdbusplus::xyz::openbmc_project::Software::server::
72 Version::VersionPurpose versionPurpose,
73 const std::string& filePath) override;
74
75 /** @brief Validate if image is valid or not */
76 bool validateImage(const std::string& path);
77
78 /** @brief Host factory reset - clears PNOR partitions for each
79 * Activation D-Bus object */
80 void reset() override;
Lei YUa2e67162019-02-22 17:35:24 +080081
82 /** @brief The functional version ID */
83 std::string functionalVersionId;
Lei YU322f3f42019-02-21 16:10:41 +080084};
85
86} // namespace updater
87} // namespace software
88} // namespace openpower