1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 
5 #include <string>
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;
21     Helper& operator=(Helper&&) = delete;
22     ~Helper() = default;
23 
24     /** @brief Constructor
25      *
26      *  @param[in] bus - sdbusplus D-Bus bus connection
27      */
Helper(sdbusplus::bus_t & bus)28     explicit Helper(sdbusplus::bus_t& bus) : bus(bus)
29     {
30         // Empty
31     }
32 
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 
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 */
50     static void factoryReset();
51 
52     /** @brief Remove the image with the flash id
53      *
54      * @param[in] flashId - The flash id of the image
55      */
56     void removeVersion(const std::string& flashId);
57 
58     /** @brief Update flash id in uboot env
59      *
60      * @param[in] flashId - The flash id of the image
61      */
62     void updateUbootVersionId(const std::string& flashId);
63 
64     /** @brief Mirror Uboot to the alt uboot partition */
65     void mirrorAlt();
66 
67   private:
68     /** @brief Persistent sdbusplus D-Bus bus connection. */
69     sdbusplus::bus_t& bus;
70 };
71 
72 } // namespace updater
73 } // namespace software
74 } // namespace phosphor
75