1 #pragma once 2 3 #include <analyzer/analyzer_main.hpp> 4 #include <analyzer/callout.hpp> 5 #include <hei_main.hpp> 6 #include <nlohmann/json.hpp> 7 #include <util/pdbg.hpp> 8 9 namespace analyzer 10 { 11 12 /** 13 * @brief Data regarding required service actions based on the hardware error 14 * analysis. 15 */ 16 class ServiceData 17 { 18 public: 19 /** 20 * @brief Constructor from components. 21 * @param The signature of the root cause attention. 22 * @param The type of analysis to perform. 23 */ 24 ServiceData(const libhei::Signature& i_rootCause, 25 AnalysisType i_analysisType) : 26 iv_rootCause(i_rootCause), 27 iv_analysisType(i_analysisType) 28 {} 29 30 /** @brief Destructor. */ 31 ~ServiceData() = default; 32 33 /** @brief Copy constructor. */ 34 ServiceData(const ServiceData&) = default; 35 36 /** @brief Assignment operator. */ 37 ServiceData& operator=(const ServiceData&) = default; 38 39 private: 40 /** The signature of the root cause attention. */ 41 const libhei::Signature iv_rootCause; 42 43 /** The type of analysis to perform. */ 44 const AnalysisType iv_analysisType; 45 46 /** The list of callouts that will be added to a PEL. */ 47 nlohmann::json iv_calloutList = nlohmann::json::array(); 48 49 /** FFDC for callouts that would otherwise not be available in the 50 * callout list (unit paths, bus types, etc.). */ 51 nlohmann::json iv_calloutFFDC = nlohmann::json::array(); 52 53 public: 54 /** @return The signature of the root cause attention. */ 55 const libhei::Signature& getRootCause() const 56 { 57 return iv_rootCause; 58 } 59 60 /** @return The type of analysis to perform. */ 61 AnalysisType getAnalysisType() const 62 { 63 return iv_analysisType; 64 } 65 66 /** @return Returns the guard type based on current analysis policies. */ 67 callout::GuardType queryGuardPolicy() const 68 { 69 if (AnalysisType::SYSTEM_CHECKSTOP == iv_analysisType) 70 { 71 return callout::GuardType::UNRECOVERABLE; 72 } 73 else if (AnalysisType::TERMINATE_IMMEDIATE == iv_analysisType) 74 { 75 return callout::GuardType::PREDICTIVE; 76 } 77 78 return callout::GuardType::NONE; 79 } 80 81 /** 82 * @brief Add callout for a pdbg_target. 83 * @param i_target The chip or unit target to add to the callout list. 84 * @param i_priority The callout priority. 85 * @param i_guard True if guard is required. False, otherwise. 86 */ 87 void calloutTarget(pdbg_target* i_target, 88 const callout::Priority& i_priority, bool i_guard); 89 90 /** 91 * @brief Add callout for a connected target on the other side of a bus. 92 * @param i_rxTarget The target on the receiving side (RX) of the bus. 93 * @param i_busType The bus type. 94 * @param i_priority The callout priority. 95 * @param i_guard True if guard is required. False, otherwise. 96 */ 97 void calloutConnected(pdbg_target* i_rxTarget, 98 const callout::BusType& i_busType, 99 const callout::Priority& i_priority, bool i_guard); 100 101 /** 102 * @brief Add callout for an entire bus. 103 * @param i_rxTarget The target on the receiving side (RX) of the bus. 104 * @param i_busType The bus type. 105 * @param i_priority The callout priority. 106 * @param i_guard True if guard is required. False, otherwise. 107 */ 108 void calloutBus(pdbg_target* i_rxTarget, const callout::BusType& i_busType, 109 const callout::Priority& i_priority, bool i_guard); 110 111 /** 112 * @brief Add callout for a clock. 113 * @param i_clockType The clock type. 114 * @param i_priority The callout priority. 115 * @param i_guard True if guard is required. False, otherwise. 116 */ 117 void calloutClock(const callout::ClockType& i_clockType, 118 const callout::Priority& i_priority, bool i_guard); 119 120 /** 121 * @brief Add callout for a service procedure. 122 * @param i_procedure The procedure type. 123 * @param i_priority The callout priority. 124 */ 125 void calloutProcedure(const callout::Procedure& i_procedure, 126 const callout::Priority& i_priority); 127 128 /** 129 * @brief Add callout for part type. 130 * @param i_part The part type. 131 * @param i_priority The callout priority. 132 */ 133 void calloutPart(const callout::PartType& i_part, 134 const callout::Priority& i_priority); 135 136 /** @brief Accessor to iv_calloutList. */ 137 const nlohmann::json& getCalloutList() const 138 { 139 return iv_calloutList; 140 } 141 142 /** @brief Accessor to iv_calloutFFDC. */ 143 const nlohmann::json& getCalloutFFDC() const 144 { 145 return iv_calloutFFDC; 146 } 147 148 private: 149 /** 150 * @brief Add callout information to the callout list. 151 * @param The JSON object for this callout. 152 */ 153 void addCallout(const nlohmann::json& i_callout); 154 155 /** 156 * @brief Add FFDC for a callout that would otherwise not be available in 157 * the callout list (unit paths, bus types, etc.). 158 * @param The JSON object for this callout. 159 */ 160 void addCalloutFFDC(const nlohmann::json& i_ffdc) 161 { 162 iv_calloutFFDC.push_back(i_ffdc); 163 } 164 165 /** 166 * @brief A simple helper function for all the callout functions that need 167 * to callout a target (callout only, no FFDC). 168 * @param i_target The chip or unit target to add to the callout list. 169 * @param i_priority The callout priority. 170 * @param i_guard True if guard is required. False, otherwise. 171 */ 172 void addTargetCallout(pdbg_target* i_target, 173 const callout::Priority& i_priority, bool i_guard); 174 175 /** 176 * @brief A simple helper function for all the callout functions that need 177 * to callout a the backplane (callout only, no FFDC). 178 * @param i_priority The callout priority. 179 */ 180 void addBackplaneCallout(const callout::Priority& i_priority); 181 }; 182 183 } // namespace analyzer 184