Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 4 | |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 5 | #include <string> |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace software |
| 10 | { |
| 11 | namespace updater |
| 12 | { |
| 13 | |
| 14 | class Helper |
| 15 | { |
| 16 | public: |
| 17 | Helper() = delete; |
| 18 | Helper(const Helper&) = delete; |
| 19 | Helper& operator=(const Helper&) = delete; |
| 20 | Helper(Helper&&) = default; |
Pavithra Barithaya | 4fd0d0f | 2024-06-22 00:37:22 -0500 | [diff] [blame] | 21 | Helper& operator=(Helper&&) = delete; |
Pavithra Barithaya | 48de55f | 2024-06-22 05:30:44 -0500 | [diff] [blame] | 22 | ~Helper() = default; |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 23 | |
| 24 | /** @brief Constructor |
| 25 | * |
| 26 | * @param[in] bus - sdbusplus D-Bus bus connection |
| 27 | */ |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 28 | explicit Helper(sdbusplus::bus_t& bus) : bus(bus) |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 29 | { |
| 30 | // Empty |
| 31 | } |
| 32 | |
Adriana Kobylak | bbcb7be | 2018-07-17 15:47:34 -0500 | [diff] [blame] | 33 | /** @brief Set an environment variable to the specified value |
| 34 | * |
| 35 | * @param[in] entryId - The variable name |
| 36 | * @param[in] value - The variable value |
| 37 | */ |
| 38 | void setEntry(const std::string& entryId, uint8_t value); |
| 39 | |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 40 | /** @brief Clear an image with the entry id |
| 41 | * |
| 42 | * @param[in] entryId - The image entry id |
| 43 | */ |
| 44 | void clearEntry(const std::string& entryId); |
| 45 | |
| 46 | /** @brief Clean up all the unused images */ |
| 47 | void cleanup(); |
| 48 | |
| 49 | /** @brief Do factory reset */ |
Pavithra Barithaya | c5f6e7e | 2024-06-24 09:50:21 -0500 | [diff] [blame] | 50 | static void factoryReset(); |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 51 | |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 52 | /** @brief Remove the image with the flash id |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 53 | * |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 54 | * @param[in] flashId - The flash id of the image |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 55 | */ |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 56 | void removeVersion(const std::string& flashId); |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 57 | |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 58 | /** @brief Update flash id in uboot env |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 59 | * |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 60 | * @param[in] flashId - The flash id of the image |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 61 | */ |
Adriana Kobylak | 25773a7 | 2022-01-21 15:24:48 +0000 | [diff] [blame] | 62 | void updateUbootVersionId(const std::string& flashId); |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 63 | |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 64 | /** @brief Mirror Uboot to the alt uboot partition */ |
| 65 | void mirrorAlt(); |
| 66 | |
| 67 | private: |
| 68 | /** @brief Persistent sdbusplus D-Bus bus connection. */ |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 69 | sdbusplus::bus_t& bus; |
Lei YU | 56aaf45 | 2018-06-21 16:09:44 +0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // namespace updater |
| 73 | } // namespace software |
| 74 | } // namespace phosphor |