1 #pragma once
2 
3 #include "item_updater.hpp"
4 
5 #include <string>
6 
7 namespace openpower
8 {
9 namespace software
10 {
11 namespace updater
12 {
13 
14 class GardResetStatic : public GardReset
15 {
16   public:
17     using GardReset::GardReset;
18     virtual ~GardResetStatic() = default;
19 
20   protected:
21     /**
22      * @brief GUARD factory reset - clears the PNOR GUARD partition.
23      */
24     void reset() override;
25 };
26 
27 /** @class ItemUpdaterStatic
28  *  @brief Manages the activation of the host version items for static layout
29  */
30 class ItemUpdaterStatic : public ItemUpdater
31 {
32   public:
ItemUpdaterStatic(sdbusplus::bus_t & bus,const std::string & path)33     ItemUpdaterStatic(sdbusplus::bus_t& bus, const std::string& path) :
34         ItemUpdater(bus, path)
35     {
36         processPNORImage();
37         gardReset = std::make_unique<GardResetStatic>(bus, GARD_PATH);
38         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 
51     bool freeSpace() override;
52 
53     void updateFunctionalAssociation(const std::string& versionId) override;
54 
55     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;
81 
82     /** @brief The functional version ID */
83     std::string functionalVersionId;
84 };
85 
86 } // namespace updater
87 } // namespace software
88 } // namespace openpower
89