blob: 36c8f6433474835476b963013b5f0d4a478ba704 [file] [log] [blame]
Zane Shelleyf685afd2021-02-15 15:39:44 -06001#pragma once
2
Zane Shelley55e7fec2022-01-28 15:29:44 -06003#include <fmt/format.h>
4
Zane Shelley82be3ab2021-12-07 10:36:08 -06005#include <analyzer/analyzer_main.hpp>
Zane Shelleyc85716c2021-08-17 10:54:06 -05006#include <analyzer/callout.hpp>
Zane Shelley8af9e462021-03-11 10:44:28 -06007#include <hei_main.hpp>
Zane Shelleyf685afd2021-02-15 15:39:44 -06008#include <nlohmann/json.hpp>
Zane Shelley37acb282022-01-10 16:05:22 -06009#include <util/pdbg.hpp>
Zane Shelleyf685afd2021-02-15 15:39:44 -060010
11namespace analyzer
12{
13
Zane Shelley64791cf2021-02-15 17:02:37 -060014/**
15 * @brief Data regarding required service actions based on the hardware error
16 * analysis.
17 */
18class ServiceData
19{
20 public:
Zane Shelley8af9e462021-03-11 10:44:28 -060021 /**
22 * @brief Constructor from components.
Zane Shelley62adf5c2022-01-18 21:06:50 -060023 * @param i_rootCause The signature of the root cause attention.
24 * @param i_analysisType The type of analysis to perform.
25 * @param i_isoData The data found during isolation.
Zane Shelley8af9e462021-03-11 10:44:28 -060026 */
Zane Shelley82be3ab2021-12-07 10:36:08 -060027 ServiceData(const libhei::Signature& i_rootCause,
Zane Shelley62adf5c2022-01-18 21:06:50 -060028 AnalysisType i_analysisType,
29 const libhei::IsolationData& i_isoData) :
Zane Shelley82be3ab2021-12-07 10:36:08 -060030 iv_rootCause(i_rootCause),
Zane Shelley62adf5c2022-01-18 21:06:50 -060031 iv_analysisType(i_analysisType), iv_isoData(i_isoData)
Zane Shelley8af9e462021-03-11 10:44:28 -060032 {}
Zane Shelley64791cf2021-02-15 17:02:37 -060033
34 /** @brief Destructor. */
35 ~ServiceData() = default;
36
37 /** @brief Copy constructor. */
38 ServiceData(const ServiceData&) = default;
39
40 /** @brief Assignment operator. */
41 ServiceData& operator=(const ServiceData&) = default;
42
43 private:
Zane Shelley8af9e462021-03-11 10:44:28 -060044 /** The signature of the root cause attention. */
45 const libhei::Signature iv_rootCause;
46
Zane Shelley82be3ab2021-12-07 10:36:08 -060047 /** The type of analysis to perform. */
48 const AnalysisType iv_analysisType;
Zane Shelleyca496192021-08-09 12:05:52 -050049
Zane Shelley62adf5c2022-01-18 21:06:50 -060050 /** The data found during isolation. */
51 const libhei::IsolationData iv_isoData;
52
Zane Shelley64791cf2021-02-15 17:02:37 -060053 /** The list of callouts that will be added to a PEL. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050054 nlohmann::json iv_calloutList = nlohmann::json::array();
Zane Shelley64791cf2021-02-15 17:02:37 -060055
Zane Shelley2d114322021-08-25 17:06:12 -050056 /** FFDC for callouts that would otherwise not be available in the
57 * callout list (unit paths, bus types, etc.). */
58 nlohmann::json iv_calloutFFDC = nlohmann::json::array();
59
Zane Shelley64791cf2021-02-15 17:02:37 -060060 public:
Zane Shelley8af9e462021-03-11 10:44:28 -060061 /** @return The signature of the root cause attention. */
62 const libhei::Signature& getRootCause() const
63 {
64 return iv_rootCause;
65 }
66
Zane Shelley82be3ab2021-12-07 10:36:08 -060067 /** @return The type of analysis to perform. */
68 AnalysisType getAnalysisType() const
Zane Shelleyca496192021-08-09 12:05:52 -050069 {
Zane Shelley82be3ab2021-12-07 10:36:08 -060070 return iv_analysisType;
Zane Shelleyca496192021-08-09 12:05:52 -050071 }
72
Zane Shelley62adf5c2022-01-18 21:06:50 -060073 /** @return The data found during isolation. */
74 const libhei::IsolationData& getIsolationData() const
75 {
76 return iv_isoData;
77 }
78
Zane Shelleybf3326f2021-11-12 13:41:39 -060079 /** @return Returns the guard type based on current analysis policies. */
80 callout::GuardType queryGuardPolicy() const
81 {
Zane Shelley82be3ab2021-12-07 10:36:08 -060082 if (AnalysisType::SYSTEM_CHECKSTOP == iv_analysisType)
83 {
84 return callout::GuardType::UNRECOVERABLE;
85 }
86 else if (AnalysisType::TERMINATE_IMMEDIATE == iv_analysisType)
87 {
88 return callout::GuardType::PREDICTIVE;
89 }
Zane Shelleybf3326f2021-11-12 13:41:39 -060090
Zane Shelley82be3ab2021-12-07 10:36:08 -060091 return callout::GuardType::NONE;
Zane Shelleybf3326f2021-11-12 13:41:39 -060092 }
93
Zane Shelleyc85716c2021-08-17 10:54:06 -050094 /**
Zane Shelley37acb282022-01-10 16:05:22 -060095 * @brief Add callout for a pdbg_target.
96 * @param i_target The chip or unit target to add to the callout list.
97 * @param i_priority The callout priority.
98 * @param i_guard True if guard is required. False, otherwise.
99 */
Zane Shelley9980d482022-01-28 15:21:47 -0600100 void calloutTarget(pdbg_target* i_target, callout::Priority i_priority,
101 bool i_guard);
Zane Shelley37acb282022-01-10 16:05:22 -0600102
103 /**
104 * @brief Add callout for a connected target on the other side of a bus.
105 * @param i_rxTarget The target on the receiving side (RX) of the bus.
106 * @param i_busType The bus type.
107 * @param i_priority The callout priority.
108 * @param i_guard True if guard is required. False, otherwise.
109 */
110 void calloutConnected(pdbg_target* i_rxTarget,
111 const callout::BusType& i_busType,
Zane Shelley9980d482022-01-28 15:21:47 -0600112 callout::Priority i_priority, bool i_guard);
Zane Shelley37acb282022-01-10 16:05:22 -0600113
114 /**
115 * @brief Add callout for an entire bus.
116 * @param i_rxTarget The target on the receiving side (RX) of the bus.
117 * @param i_busType The bus type.
118 * @param i_priority The callout priority.
119 * @param i_guard True if guard is required. False, otherwise.
120 */
121 void calloutBus(pdbg_target* i_rxTarget, const callout::BusType& i_busType,
Zane Shelley9980d482022-01-28 15:21:47 -0600122 callout::Priority i_priority, bool i_guard);
Zane Shelley37acb282022-01-10 16:05:22 -0600123
124 /**
125 * @brief Add callout for a clock.
126 * @param i_clockType The clock type.
127 * @param i_priority The callout priority.
128 * @param i_guard True if guard is required. False, otherwise.
129 */
130 void calloutClock(const callout::ClockType& i_clockType,
Zane Shelley9980d482022-01-28 15:21:47 -0600131 callout::Priority i_priority, bool i_guard);
Zane Shelley37acb282022-01-10 16:05:22 -0600132
133 /**
134 * @brief Add callout for a service procedure.
135 * @param i_procedure The procedure type.
136 * @param i_priority The callout priority.
137 */
138 void calloutProcedure(const callout::Procedure& i_procedure,
Zane Shelley9980d482022-01-28 15:21:47 -0600139 callout::Priority i_priority);
Zane Shelley37acb282022-01-10 16:05:22 -0600140
Zane Shelleya4134772022-01-10 17:22:44 -0600141 /**
142 * @brief Add callout for part type.
143 * @param i_part The part type.
144 * @param i_priority The callout priority.
145 */
146 void calloutPart(const callout::PartType& i_part,
Zane Shelley9980d482022-01-28 15:21:47 -0600147 callout::Priority i_priority);
Zane Shelleya4134772022-01-10 17:22:44 -0600148
Zane Shelley37acb282022-01-10 16:05:22 -0600149 /** @brief Accessor to iv_calloutList. */
150 const nlohmann::json& getCalloutList() const
151 {
152 return iv_calloutList;
153 }
154
155 /** @brief Accessor to iv_calloutFFDC. */
156 const nlohmann::json& getCalloutFFDC() const
157 {
158 return iv_calloutFFDC;
159 }
160
Zane Shelley55e7fec2022-01-28 15:29:44 -0600161 /**
162 * @brief Adds the SRC subsystem to the given additional PEL data.
163 * @param io_additionalData The additional PEL data.
164 */
165 void addSrcSubsystem(
166 std::map<std::string, std::string>& io_additionalData) const
167 {
Caleb Palmerc3fb2062022-02-04 15:10:59 -0600168 io_additionalData["PEL_SUBSYSTEM"] = fmt::format(
169 "0x{:02x}", static_cast<uint8_t>(iv_srcSubsystem.first));
Zane Shelley55e7fec2022-01-28 15:29:44 -0600170 }
171
172 /** @brief Accessor to iv_srcSubsystem. */
173 const std::pair<callout::SrcSubsystem, callout::Priority> getSubsys() const
174 {
175 return iv_srcSubsystem;
176 }
177
Zane Shelley37acb282022-01-10 16:05:22 -0600178 private:
179 /**
Zane Shelleyc85716c2021-08-17 10:54:06 -0500180 * @brief Add callout information to the callout list.
181 * @param The JSON object for this callout.
182 */
Zane Shelley979e2872021-09-20 22:46:06 -0500183 void addCallout(const nlohmann::json& i_callout);
Zane Shelley64791cf2021-02-15 17:02:37 -0600184
Zane Shelley95135822021-08-23 09:00:05 -0500185 /**
Zane Shelley2d114322021-08-25 17:06:12 -0500186 * @brief Add FFDC for a callout that would otherwise not be available in
187 * the callout list (unit paths, bus types, etc.).
188 * @param The JSON object for this callout.
189 */
190 void addCalloutFFDC(const nlohmann::json& i_ffdc)
191 {
192 iv_calloutFFDC.push_back(i_ffdc);
193 }
194
Zane Shelley37acb282022-01-10 16:05:22 -0600195 /**
196 * @brief A simple helper function for all the callout functions that need
197 * to callout a target (callout only, no FFDC).
198 * @param i_target The chip or unit target to add to the callout list.
199 * @param i_priority The callout priority.
200 * @param i_guard True if guard is required. False, otherwise.
201 */
Zane Shelley9980d482022-01-28 15:21:47 -0600202 void addTargetCallout(pdbg_target* i_target, callout::Priority i_priority,
203 bool i_guard);
Zane Shelley5f6e3de2021-02-23 13:57:37 -0600204
Zane Shelley37acb282022-01-10 16:05:22 -0600205 /**
206 * @brief A simple helper function for all the callout functions that need
207 * to callout a the backplane (callout only, no FFDC).
208 * @param i_priority The callout priority.
209 */
Zane Shelley9980d482022-01-28 15:21:47 -0600210 void addBackplaneCallout(callout::Priority i_priority);
Zane Shelley55e7fec2022-01-28 15:29:44 -0600211
212 private:
213 /**
214 * @brief Compares the current SRC subsystem type with the given SRC
215 * subsystem type and stores the highest priority callout subsystem.
216 * If the two subsystems are of equal priority. The stored subsystem
217 * is used.
218 * @param i_subsystem The given subsystem type.
219 * @param i_priority The callout priority associated with the given
220 * subsystem.
221 */
222 void setSrcSubsystem(callout::SrcSubsystem i_subsystem,
223 callout::Priority i_priority);
224
225 /**
226 * @brief Returns the appropriate SRC subsystem based on the input target.
227 * @param i_trgt The given pdbg target.
228 */
229 callout::SrcSubsystem getTargetSubsystem(pdbg_target* i_target);
230
231 /** The SRC subsystem field (2nd byte of the primary SRC) is based on the
232 * callouts the PEL. As callouts are to the service data, we'll need to
233 * keep track of the highest priority callout subsystem. */
234 std::pair<callout::SrcSubsystem, callout::Priority> iv_srcSubsystem = {
235 callout::SrcSubsystem::CEC_HARDWARE, callout::Priority::LOW};
Zane Shelley64791cf2021-02-15 17:02:37 -0600236};
237
Zane Shelleyf685afd2021-02-15 15:39:44 -0600238} // namespace analyzer