blob: edd5f30e753a6d88a0c5888060513c7945699e6e [file] [log] [blame]
Anupama B R08fa59e2025-03-06 22:55:11 -06001#pragma once
2
Rekha Aparnaffdff312025-03-25 01:10:56 -05003#include "constants.hpp"
4#include "event_logger.hpp"
5
Anupama B R08fa59e2025-03-06 22:55:11 -06006#include <string>
7
8namespace vpd
9{
10/**
11 * @brief class to implement single fab feature.
12 *
13 * The class hosts functionalities required to support single FAB feature.
14 *
15 */
16class SingleFab
17{
Rekha Aparnaffdff312025-03-25 01:10:56 -050018 public:
19 /**
20 * @brief API to support single FAB feature.
21 *
22 * This API updates the IM value to the P11 series or creates PEL in invalid
23 * case based on the IM value read from the cache and planar, considering
24 * the system mode and image.
25 *
26 * System mode can be of field mode or lab mode and system image can be
27 * special or normal image.
28 *
29 * @return 0 on success, -1 in case of failure.
30 */
31 int singleFabImOverride() const noexcept;
Anupama B R08fa59e2025-03-06 22:55:11 -060032
33 private:
34 /**
35 * @brief API to get IM value from persisted location.
36 *
37 * @return IM value on success, empty string otherwise.
38 */
39 std::string getImFromPersistedLocation() const noexcept;
Anupama B Rb5bfcbc2025-03-03 03:00:04 -060040
41 /**
42 * @brief API to get IM value from system planar EEPROM path.
43 *
44 * @return IM value on success, empty string otherwise.
45 */
46 std::string getImFromPlanar() const noexcept;
RekhaAparna01d3e693e2025-03-04 05:08:30 -060047
48 /**
49 * @brief API to update IM value on system planar EEPROM path.
50 *
51 * @param[in] i_imValue - IM value to be updated.
52 *
53 * @return true if value updated successfully, otherwise false.
54 */
55 bool setImOnPlanar(const std::string& i_imValue) const noexcept;
RekhaAparna01f05f3542025-03-02 22:25:23 -060056
57 /**
Souvik Roycd828d42025-03-24 02:29:45 -050058 * @brief API to update IM value on system planar EEPROM path to P11 series.
59 *
60 * @param[in] i_currentImValuePlanar - current IM value in planar EEPROM.
Souvik Roycd828d42025-03-24 02:29:45 -050061 */
Rekha Aparnaffdff312025-03-25 01:10:56 -050062 void updateSystemImValueInVpdToP11Series(
Souvik Roycd828d42025-03-24 02:29:45 -050063 std::string i_currentImValuePlanar) const noexcept;
Rekha Aparnaffdff312025-03-25 01:10:56 -050064
65 /**
66 * @brief API to check if it is a P10 system.
67 *
68 * @param[in] i_imValue - IM value of the system.
69 *
70 * @return true, if P10 system. Otherwise false.
71 */
72 inline bool isP10System(const std::string& i_imValue) const noexcept
73 {
74 try
75 {
76 return !(i_imValue.compare(constants::VALUE_0, constants::VALUE_4,
77 POWER10_IM_SERIES));
78 }
79 catch (const std::exception& l_ex)
80 {
81 EventLogger::createSyncPel(
82 types::ErrorType::InternalFailure,
83 types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
84 std::string(
85 "Failed to check if system is of P10 series. Error : ") +
86 l_ex.what(),
87 std::nullopt, std::nullopt, std::nullopt, std::nullopt);
88 return false;
89 }
90 }
91
92 /**
93 * @brief API to check if it is a P11 system.
94 *
95 * @param[in] i_imValue - IM value of the system.
96 *
97 * @return true, if P11 system. Otherwise false.
98 */
99 inline bool isP11System(const std::string& i_imValue) const noexcept
100 {
101 try
102 {
103 return !(i_imValue.compare(constants::VALUE_0, constants::VALUE_4,
104 POWER11_IM_SERIES));
105 }
106 catch (const std::exception& l_ex)
107 {
108 EventLogger::createSyncPel(
109 types::ErrorType::InternalFailure,
110 types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
111 std::string(
112 "Failed to check if system is of P11 series. Error : ") +
113 l_ex.what(),
114 std::nullopt, std::nullopt, std::nullopt, std::nullopt);
115 return false;
116 }
117 }
118
119 /**
120 * @brief API to check if it is a valid IM series.
121 *
122 * This API checks if the provided IM value is of either P10 or P11 series.
123 *
124 * @param[in] i_imValue - IM value of the system.
125 *
126 * @return true, if valid IM series. Otherwise false.
127 */
128 inline bool isValidImSeries(const std::string& l_imValue) const noexcept
129 {
130 return (isP10System(l_imValue) || isP11System(l_imValue));
131 }
132
133 // valid IM series.
134 static constexpr auto POWER10_IM_SERIES = "5000";
135 static constexpr auto POWER11_IM_SERIES = "6000";
Anupama B R08fa59e2025-03-06 22:55:11 -0600136};
137} // namespace vpd