blob: c0584a2f7801caeff4e1a3e2c66356e7a697e8c3 [file] [log] [blame]
Lei YU56aaf452018-06-21 16:09:44 +08001#pragma once
2
Lei YU56aaf452018-06-21 16:09:44 +08003#include <sdbusplus/bus.hpp>
Adriana Kobylak58aa7502020-06-08 11:12:11 -05004
Gunnar Millsb0ce9962018-09-07 13:39:10 -05005#include <string>
Lei YU56aaf452018-06-21 16:09:44 +08006
7namespace phosphor
8{
9namespace software
10{
11namespace updater
12{
13
14class Helper
15{
16 public:
17 Helper() = delete;
18 Helper(const Helper&) = delete;
19 Helper& operator=(const Helper&) = delete;
20 Helper(Helper&&) = default;
Pavithra Barithaya4fd0d0f2024-06-22 00:37:22 -050021 Helper& operator=(Helper&&) = delete;
Pavithra Barithaya48de55f2024-06-22 05:30:44 -050022 ~Helper() = default;
Lei YU56aaf452018-06-21 16:09:44 +080023
24 /** @brief Constructor
25 *
26 * @param[in] bus - sdbusplus D-Bus bus connection
27 */
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050028 explicit Helper(sdbusplus::bus_t& bus) : bus(bus)
Lei YU56aaf452018-06-21 16:09:44 +080029 {
30 // Empty
31 }
32
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -050033 /** @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 YU56aaf452018-06-21 16:09:44 +080040 /** @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 */
50 void factoryReset();
51
Adriana Kobylak25773a72022-01-21 15:24:48 +000052 /** @brief Remove the image with the flash id
Lei YU56aaf452018-06-21 16:09:44 +080053 *
Adriana Kobylak25773a72022-01-21 15:24:48 +000054 * @param[in] flashId - The flash id of the image
Lei YU56aaf452018-06-21 16:09:44 +080055 */
Adriana Kobylak25773a72022-01-21 15:24:48 +000056 void removeVersion(const std::string& flashId);
Lei YU56aaf452018-06-21 16:09:44 +080057
Adriana Kobylak25773a72022-01-21 15:24:48 +000058 /** @brief Update flash id in uboot env
Lei YU56aaf452018-06-21 16:09:44 +080059 *
Adriana Kobylak25773a72022-01-21 15:24:48 +000060 * @param[in] flashId - The flash id of the image
Lei YU56aaf452018-06-21 16:09:44 +080061 */
Adriana Kobylak25773a72022-01-21 15:24:48 +000062 void updateUbootVersionId(const std::string& flashId);
Lei YU56aaf452018-06-21 16:09:44 +080063
Lei YU56aaf452018-06-21 16:09:44 +080064 /** @brief Mirror Uboot to the alt uboot partition */
65 void mirrorAlt();
66
67 private:
68 /** @brief Persistent sdbusplus D-Bus bus connection. */
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050069 sdbusplus::bus_t& bus;
Lei YU56aaf452018-06-21 16:09:44 +080070};
71
72} // namespace updater
73} // namespace software
74} // namespace phosphor