Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <analyzer/resolution.hpp> |
| 4 | #include <hei_main.hpp> |
| 5 | #include <nlohmann/json.hpp> |
| 6 | |
| 7 | #include <map> |
| 8 | |
| 9 | namespace analyzer |
| 10 | { |
Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 11 | /** |
| 12 | * @brief Manages the RAS data files and resolves service actions required for |
| 13 | * error signatures. |
| 14 | */ |
| 15 | class RasDataParser |
| 16 | { |
| 17 | public: |
| 18 | /** @brief Default constructor. */ |
| 19 | RasDataParser() |
| 20 | { |
| 21 | initDataFiles(); |
| 22 | } |
| 23 | |
Caleb Palmer | f118439 | 2022-10-07 15:17:22 -0500 | [diff] [blame] | 24 | /** Define all RAS data flags that may be associated with a signature */ |
| 25 | enum RasDataFlags |
| 26 | { |
| 27 | SUE_SOURCE, |
| 28 | SUE_SEEN, |
| 29 | CS_POSSIBLE, |
| 30 | RECOVERED_ERROR, |
| 31 | INFORMATIONAL_ONLY, |
| 32 | MNFG_INFORMATIONAL_ONLY, |
| 33 | MASK_BUT_DONT_CLEAR, |
| 34 | CRC_RELATED_ERR, |
| 35 | CRC_ROOT_CAUSE, |
| 36 | ODP_DATA_CORRUPT_SIDE_EFFECT, |
| 37 | ODP_DATA_CORRUPT_ROOT_CAUSE, |
| 38 | }; |
| 39 | |
Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 40 | private: |
| 41 | /** @brief The RAS data files. */ |
| 42 | std::map<libhei::ChipType_t, nlohmann::json> iv_dataFiles; |
| 43 | |
| 44 | public: |
| 45 | /** |
| 46 | * @brief Returns a resolution for all the RAS actions needed for the given |
| 47 | * signature. |
| 48 | * @param i_signature The target error signature. |
| 49 | */ |
| 50 | std::shared_ptr<Resolution> |
| 51 | getResolution(const libhei::Signature& i_signature); |
| 52 | |
Caleb Palmer | f118439 | 2022-10-07 15:17:22 -0500 | [diff] [blame] | 53 | /** |
| 54 | * @brief Initializes the signature list within the input isolation data |
| 55 | * with their appropriate flags based on the RAS data files. |
| 56 | * @param i_signature The target error signature. |
| 57 | * @param i_flag The flag to check for |
| 58 | * @return True if the flag is set for the given signature, else false. |
| 59 | */ |
| 60 | bool isFlagSet(const libhei::Signature& i_signature, |
| 61 | const RasDataFlags i_flag); |
| 62 | |
Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 63 | private: |
| 64 | /** |
| 65 | * @brief Parses all of the RAS data JSON files and validates them against |
| 66 | * the associated schema. |
| 67 | */ |
| 68 | void initDataFiles(); |
Zane Shelley | 7698b30 | 2021-08-09 16:00:03 -0500 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * @brief Parses a signature in the given data file and returns a string |
| 72 | * representing the target action for the signature. |
| 73 | * @param i_data The parsed RAS data file associated with the |
| 74 | * signature's chip type. |
| 75 | * @param i_signature The target signature. |
| 76 | * @return A string representing the target action for the signature. |
| 77 | */ |
| 78 | std::string parseSignature(const nlohmann::json& i_data, |
| 79 | const libhei::Signature& i_signature); |
| 80 | |
| 81 | /** |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 82 | * @brief Parses a bus object in the given data file and returns the bus |
| 83 | * type and unit path. |
| 84 | * @param i_data The parsed RAS data file associated with the signature's |
| 85 | * chip type. |
| 86 | * @param i_name The name of the target bus. |
| 87 | * @return A tuple containing the bus type and unit path. |
| 88 | */ |
| 89 | std::tuple<callout::BusType, std::string> |
| 90 | parseBus(const nlohmann::json& i_data, const std::string& i_name); |
| 91 | |
| 92 | /** |
Zane Shelley | 7698b30 | 2021-08-09 16:00:03 -0500 | [diff] [blame] | 93 | * @brief Parses an action in the given data file and returns the |
| 94 | * corresponding resolution. |
| 95 | * @param i_data The parsed RAS data file associated with the signature's |
| 96 | * chip type. |
| 97 | * @param i_action The target action to parse from the given RAS data. |
| 98 | * @return A resolution (or nested resolutions) representing the given |
| 99 | * action. |
| 100 | * @note This function is called recursively because an action could |
| 101 | * reference another action. This function will maintain a stack of |
| 102 | * parsed actions and will assert that the same action cannot be |
| 103 | * parsed more than once in the recursion stack. |
| 104 | */ |
| 105 | std::shared_ptr<Resolution> parseAction(const nlohmann::json& i_data, |
| 106 | const std::string& i_action); |
| 107 | |
| 108 | /** |
| 109 | * @brief Returns a callout priority enum value for the given string. |
| 110 | * @param i_priority The priority string. |
| 111 | * @return A callout priority enum value. |
| 112 | */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 113 | callout::Priority getPriority(const std::string& i_priority); |
Zane Shelley | a9b4434 | 2021-08-08 17:15:52 -0500 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | } // namespace analyzer |