xref: /openbmc/phosphor-bmc-code-mgmt/bmc/serialize.hpp (revision 7e446a407a579ec72f48009008ad2f83c01c2262)
1 #pragma once
2 
3 #include "config.h"
4 
5 #include "version.hpp"
6 
7 #include <string>
8 
9 namespace phosphor
10 {
11 namespace software
12 {
13 namespace updater
14 {
15 
16 using VersionPurpose =
17     sdbusplus::server::xyz::openbmc_project::software::Version::VersionPurpose;
18 
19 /** @brief Serialization function - stores priority information to file
20  *  @param[in] flashId - The flash id of the version for which to store
21  *                       information.
22  *  @param[in] priority - RedundancyPriority value for that version.
23  **/
24 void storePriority(const std::string& flashId, uint8_t priority);
25 
26 /** @brief Serialization function - stores purpose information to file
27  *  @param[in] flashId - The flash id of the version for which to store
28  *                       information.
29  *  @param[in] purpose - VersionPurpose value for that version.
30  **/
31 void storePurpose(const std::string& flashId, VersionPurpose purpose);
32 
33 /** @brief Serialization function - restores priority information from file
34  *  @param[in] flashId - The flash id of the version for which to retrieve
35  *                       information.
36  *  @param[in] priority - RedundancyPriority reference for that version.
37  *  @return true if restore was successful, false if not
38  **/
39 bool restorePriority(const std::string& flashId, uint8_t& priority);
40 
41 /** @brief Serialization function - restores purpose information from file
42  *  @param[in] flashId - The flash id of the version for which to retrieve
43  *                       information.
44  *  @param[in] purpose - VersionPurpose reference for that version.
45  *  @return true if restore was successful, false if not
46  **/
47 bool restorePurpose(const std::string& flashId, VersionPurpose& purpose);
48 
49 /** @brief Removes the serial directory for a given version.
50  *  @param[in] flash Id - The flash id of the version for which to remove a
51  *                        file, if it exists.
52  **/
53 void removePersistDataDirectory(const std::string& flashId);
54 
55 } // namespace updater
56 } // namespace software
57 } // namespace phosphor
58