Anupama B R | 08fa59e | 2025-03-06 22:55:11 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Rekha Aparna | ffdff31 | 2025-03-25 01:10:56 -0500 | [diff] [blame] | 3 | #include "constants.hpp" |
| 4 | #include "event_logger.hpp" |
| 5 | |
Anupama B R | 08fa59e | 2025-03-06 22:55:11 -0600 | [diff] [blame] | 6 | #include <string> |
| 7 | |
| 8 | namespace 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 | */ |
| 16 | class SingleFab |
| 17 | { |
Rekha Aparna | ffdff31 | 2025-03-25 01:10:56 -0500 | [diff] [blame] | 18 | 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 R | 08fa59e | 2025-03-06 22:55:11 -0600 | [diff] [blame] | 32 | |
| 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 R | b5bfcbc | 2025-03-03 03:00:04 -0600 | [diff] [blame] | 40 | |
| 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; |
RekhaAparna01 | d3e693e | 2025-03-04 05:08:30 -0600 | [diff] [blame] | 47 | |
| 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; |
RekhaAparna01 | f05f354 | 2025-03-02 22:25:23 -0600 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * @brief API to check is field mode enabled. |
| 59 | * |
| 60 | * @return true, if field mode is enabled. otherwise false. |
| 61 | */ |
| 62 | bool isFieldModeEnabled() const noexcept; |
Souvik Roy | cd828d4 | 2025-03-24 02:29:45 -0500 | [diff] [blame] | 63 | |
| 64 | /** |
| 65 | * @brief API to update IM value on system planar EEPROM path to P11 series. |
| 66 | * |
| 67 | * @param[in] i_currentImValuePlanar - current IM value in planar EEPROM. |
Souvik Roy | cd828d4 | 2025-03-24 02:29:45 -0500 | [diff] [blame] | 68 | */ |
Rekha Aparna | ffdff31 | 2025-03-25 01:10:56 -0500 | [diff] [blame] | 69 | void updateSystemImValueInVpdToP11Series( |
Souvik Roy | cd828d4 | 2025-03-24 02:29:45 -0500 | [diff] [blame] | 70 | std::string i_currentImValuePlanar) const noexcept; |
Rekha Aparna | ffdff31 | 2025-03-25 01:10:56 -0500 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * @brief API to check if it is a P10 system. |
| 74 | * |
| 75 | * @param[in] i_imValue - IM value of the system. |
| 76 | * |
| 77 | * @return true, if P10 system. Otherwise false. |
| 78 | */ |
| 79 | inline bool isP10System(const std::string& i_imValue) const noexcept |
| 80 | { |
| 81 | try |
| 82 | { |
| 83 | return !(i_imValue.compare(constants::VALUE_0, constants::VALUE_4, |
| 84 | POWER10_IM_SERIES)); |
| 85 | } |
| 86 | catch (const std::exception& l_ex) |
| 87 | { |
| 88 | EventLogger::createSyncPel( |
| 89 | types::ErrorType::InternalFailure, |
| 90 | types::SeverityType::Informational, __FILE__, __FUNCTION__, 0, |
| 91 | std::string( |
| 92 | "Failed to check if system is of P10 series. Error : ") + |
| 93 | l_ex.what(), |
| 94 | std::nullopt, std::nullopt, std::nullopt, std::nullopt); |
| 95 | return false; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @brief API to check if it is a P11 system. |
| 101 | * |
| 102 | * @param[in] i_imValue - IM value of the system. |
| 103 | * |
| 104 | * @return true, if P11 system. Otherwise false. |
| 105 | */ |
| 106 | inline bool isP11System(const std::string& i_imValue) const noexcept |
| 107 | { |
| 108 | try |
| 109 | { |
| 110 | return !(i_imValue.compare(constants::VALUE_0, constants::VALUE_4, |
| 111 | POWER11_IM_SERIES)); |
| 112 | } |
| 113 | catch (const std::exception& l_ex) |
| 114 | { |
| 115 | EventLogger::createSyncPel( |
| 116 | types::ErrorType::InternalFailure, |
| 117 | types::SeverityType::Informational, __FILE__, __FUNCTION__, 0, |
| 118 | std::string( |
| 119 | "Failed to check if system is of P11 series. Error : ") + |
| 120 | l_ex.what(), |
| 121 | std::nullopt, std::nullopt, std::nullopt, std::nullopt); |
| 122 | return false; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * @brief API to check if it is a valid IM series. |
| 128 | * |
| 129 | * This API checks if the provided IM value is of either P10 or P11 series. |
| 130 | * |
| 131 | * @param[in] i_imValue - IM value of the system. |
| 132 | * |
| 133 | * @return true, if valid IM series. Otherwise false. |
| 134 | */ |
| 135 | inline bool isValidImSeries(const std::string& l_imValue) const noexcept |
| 136 | { |
| 137 | return (isP10System(l_imValue) || isP11System(l_imValue)); |
| 138 | } |
| 139 | |
| 140 | // valid IM series. |
| 141 | static constexpr auto POWER10_IM_SERIES = "5000"; |
| 142 | static constexpr auto POWER11_IM_SERIES = "6000"; |
Anupama B R | 08fa59e | 2025-03-06 22:55:11 -0600 | [diff] [blame] | 143 | }; |
| 144 | } // namespace vpd |