blob: 81d66d950815081be17d672d0320eb7eacf7d3a0 [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;
21 Helper& operator=(Helper&&) = default;
22
23 /** @brief Constructor
24 *
25 * @param[in] bus - sdbusplus D-Bus bus connection
26 */
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050027 explicit Helper(sdbusplus::bus_t& bus) : bus(bus)
Lei YU56aaf452018-06-21 16:09:44 +080028 {
29 // Empty
30 }
31
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -050032 /** @brief Set an environment variable to the specified value
33 *
34 * @param[in] entryId - The variable name
35 * @param[in] value - The variable value
36 */
37 void setEntry(const std::string& entryId, uint8_t value);
38
Lei YU56aaf452018-06-21 16:09:44 +080039 /** @brief Clear an image with the entry id
40 *
41 * @param[in] entryId - The image entry id
42 */
43 void clearEntry(const std::string& entryId);
44
45 /** @brief Clean up all the unused images */
46 void cleanup();
47
48 /** @brief Do factory reset */
49 void factoryReset();
50
Adriana Kobylak25773a72022-01-21 15:24:48 +000051 /** @brief Remove the image with the flash id
Lei YU56aaf452018-06-21 16:09:44 +080052 *
Adriana Kobylak25773a72022-01-21 15:24:48 +000053 * @param[in] flashId - The flash id of the image
Lei YU56aaf452018-06-21 16:09:44 +080054 */
Adriana Kobylak25773a72022-01-21 15:24:48 +000055 void removeVersion(const std::string& flashId);
Lei YU56aaf452018-06-21 16:09:44 +080056
Adriana Kobylak25773a72022-01-21 15:24:48 +000057 /** @brief Update flash id in uboot env
Lei YU56aaf452018-06-21 16:09:44 +080058 *
Adriana Kobylak25773a72022-01-21 15:24:48 +000059 * @param[in] flashId - The flash id of the image
Lei YU56aaf452018-06-21 16:09:44 +080060 */
Adriana Kobylak25773a72022-01-21 15:24:48 +000061 void updateUbootVersionId(const std::string& flashId);
Lei YU56aaf452018-06-21 16:09:44 +080062
Lei YU56aaf452018-06-21 16:09:44 +080063 /** @brief Mirror Uboot to the alt uboot partition */
64 void mirrorAlt();
65
66 private:
67 /** @brief Persistent sdbusplus D-Bus bus connection. */
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050068 sdbusplus::bus_t& bus;
Lei YU56aaf452018-06-21 16:09:44 +080069};
70
71} // namespace updater
72} // namespace software
73} // namespace phosphor