Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "item_updater.hpp" |
| 4 | |
| 5 | namespace openpower |
| 6 | { |
| 7 | namespace software |
| 8 | { |
| 9 | namespace updater |
| 10 | { |
| 11 | |
Lei YU | 716de5b | 2019-03-01 16:03:53 +0800 | [diff] [blame] | 12 | class GardResetUbi : public GardReset |
| 13 | { |
| 14 | public: |
| 15 | using GardReset::GardReset; |
| 16 | virtual ~GardResetUbi() = default; |
| 17 | |
| 18 | protected: |
| 19 | /** |
| 20 | * @brief GARD factory reset - clears the PNOR GARD partition. |
| 21 | */ |
| 22 | void reset() override; |
| 23 | }; |
| 24 | |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 25 | /** @class ItemUpdaterUbi |
| 26 | * @brief Manages the activation of the host version items for ubi layout |
| 27 | */ |
| 28 | class ItemUpdaterUbi : public ItemUpdater |
| 29 | { |
| 30 | public: |
| 31 | ItemUpdaterUbi(sdbusplus::bus::bus& bus, const std::string& path) : |
| 32 | ItemUpdater(bus, path) |
| 33 | { |
| 34 | processPNORImage(); |
Lei YU | 716de5b | 2019-03-01 16:03:53 +0800 | [diff] [blame] | 35 | gardReset = std::make_unique<GardResetUbi>(bus, GARD_PATH); |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 36 | volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath); |
| 37 | |
| 38 | // Emit deferred signal. |
| 39 | emit_object_added(); |
| 40 | } |
| 41 | virtual ~ItemUpdaterUbi() = default; |
| 42 | |
| 43 | void freePriority(uint8_t value, const std::string& versionId) override; |
| 44 | |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 45 | void processPNORImage() override; |
| 46 | |
| 47 | bool erase(std::string entryId) override; |
| 48 | |
| 49 | void deleteAll() override; |
| 50 | |
Lei YU | 6da3dae | 2019-02-28 14:26:37 +0800 | [diff] [blame] | 51 | bool freeSpace() override; |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 52 | |
| 53 | bool isVersionFunctional(const std::string& versionId) override; |
| 54 | |
Lei YU | bee5140 | 2019-02-26 11:36:34 +0800 | [diff] [blame] | 55 | /** @brief Determine the software version id |
| 56 | * from the symlink target (e.g. /media/ro-2a1022fe). |
| 57 | * |
| 58 | * @param[in] symlinkPath - The path of the symlink. |
| 59 | * @param[out] id - The version id as a string. |
| 60 | */ |
| 61 | static std::string determineId(const std::string& symlinkPath); |
| 62 | |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 63 | private: |
Lei YU | a9ac927 | 2019-02-22 16:38:35 +0800 | [diff] [blame] | 64 | std::unique_ptr<Activation> createActivationObject( |
| 65 | const std::string& path, const std::string& versionId, |
| 66 | const std::string& extVersion, |
| 67 | sdbusplus::xyz::openbmc_project::Software::server::Activation:: |
| 68 | Activations activationStatus, |
| 69 | AssociationList& assocs) override; |
| 70 | |
| 71 | std::unique_ptr<Version> |
| 72 | createVersionObject(const std::string& objPath, |
| 73 | const std::string& versionId, |
| 74 | const std::string& versionString, |
| 75 | sdbusplus::xyz::openbmc_project::Software::server:: |
| 76 | Version::VersionPurpose versionPurpose, |
| 77 | const std::string& filePath) override; |
| 78 | |
| 79 | bool validateImage(const std::string& path) override; |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 80 | |
| 81 | /** @brief Host factory reset - clears PNOR partitions for each |
| 82 | * Activation D-Bus object */ |
| 83 | void reset() override; |
| 84 | |
| 85 | /** |
| 86 | * @brief Validates the presence of SquashFS image in the image dir. |
| 87 | * |
| 88 | * @param[in] filePath - The path to the SquashFS image. |
| 89 | * @param[out] result - 0 --> if validation was successful |
| 90 | * - -1--> Otherwise |
| 91 | */ |
| 92 | static int validateSquashFSImage(const std::string& filePath); |
| 93 | |
| 94 | /** @brief Clears read only PNOR partition for |
| 95 | * given Activation D-Bus object |
| 96 | * |
| 97 | * @param[in] versionId - The id of the ro partition to remove. |
| 98 | */ |
Lei YU | 1db9adf | 2019-03-05 16:02:31 +0800 | [diff] [blame^] | 99 | void removeReadOnlyPartition(const std::string& versionId); |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 100 | |
| 101 | /** @brief Clears read write PNOR partition for |
| 102 | * given Activation D-Bus object |
| 103 | * |
| 104 | * @param[in] versionId - The id of the rw partition to remove. |
| 105 | */ |
Lei YU | 1db9adf | 2019-03-05 16:02:31 +0800 | [diff] [blame^] | 106 | void removeReadWritePartition(const std::string& versionId); |
Lei YU | f3ce433 | 2019-02-21 14:09:49 +0800 | [diff] [blame] | 107 | |
| 108 | /** @brief Clears preserved PNOR partition */ |
| 109 | void removePreservedPartition(); |
| 110 | }; |
| 111 | |
| 112 | } // namespace updater |
| 113 | } // namespace software |
| 114 | } // namespace openpower |