blob: 7e395898e7ba40ad4a0631cb501560c813e1faa6 [file] [log] [blame]
Zane Shelleyf685afd2021-02-15 15:39:44 -06001#pragma once
2
Zane Shelley82be3ab2021-12-07 10:36:08 -06003#include <analyzer/analyzer_main.hpp>
Zane Shelleyc85716c2021-08-17 10:54:06 -05004#include <analyzer/callout.hpp>
Zane Shelley8af9e462021-03-11 10:44:28 -06005#include <hei_main.hpp>
Zane Shelleyf685afd2021-02-15 15:39:44 -06006#include <nlohmann/json.hpp>
Zane Shelley37acb282022-01-10 16:05:22 -06007#include <util/pdbg.hpp>
Zane Shelleyf685afd2021-02-15 15:39:44 -06008
9namespace analyzer
10{
11
Zane Shelley64791cf2021-02-15 17:02:37 -060012/**
13 * @brief Data regarding required service actions based on the hardware error
14 * analysis.
15 */
16class ServiceData
17{
18 public:
Zane Shelley8af9e462021-03-11 10:44:28 -060019 /**
20 * @brief Constructor from components.
21 * @param The signature of the root cause attention.
Zane Shelley82be3ab2021-12-07 10:36:08 -060022 * @param The type of analysis to perform.
Zane Shelley8af9e462021-03-11 10:44:28 -060023 */
Zane Shelley82be3ab2021-12-07 10:36:08 -060024 ServiceData(const libhei::Signature& i_rootCause,
25 AnalysisType i_analysisType) :
26 iv_rootCause(i_rootCause),
27 iv_analysisType(i_analysisType)
Zane Shelley8af9e462021-03-11 10:44:28 -060028 {}
Zane Shelley64791cf2021-02-15 17:02:37 -060029
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:
Zane Shelley8af9e462021-03-11 10:44:28 -060040 /** The signature of the root cause attention. */
41 const libhei::Signature iv_rootCause;
42
Zane Shelley82be3ab2021-12-07 10:36:08 -060043 /** The type of analysis to perform. */
44 const AnalysisType iv_analysisType;
Zane Shelleyca496192021-08-09 12:05:52 -050045
Zane Shelley64791cf2021-02-15 17:02:37 -060046 /** The list of callouts that will be added to a PEL. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050047 nlohmann::json iv_calloutList = nlohmann::json::array();
Zane Shelley64791cf2021-02-15 17:02:37 -060048
Zane Shelley2d114322021-08-25 17:06:12 -050049 /** 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
Zane Shelley64791cf2021-02-15 17:02:37 -060053 public:
Zane Shelley8af9e462021-03-11 10:44:28 -060054 /** @return The signature of the root cause attention. */
55 const libhei::Signature& getRootCause() const
56 {
57 return iv_rootCause;
58 }
59
Zane Shelley82be3ab2021-12-07 10:36:08 -060060 /** @return The type of analysis to perform. */
61 AnalysisType getAnalysisType() const
Zane Shelleyca496192021-08-09 12:05:52 -050062 {
Zane Shelley82be3ab2021-12-07 10:36:08 -060063 return iv_analysisType;
Zane Shelleyca496192021-08-09 12:05:52 -050064 }
65
Zane Shelleybf3326f2021-11-12 13:41:39 -060066 /** @return Returns the guard type based on current analysis policies. */
67 callout::GuardType queryGuardPolicy() const
68 {
Zane Shelley82be3ab2021-12-07 10:36:08 -060069 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 }
Zane Shelleybf3326f2021-11-12 13:41:39 -060077
Zane Shelley82be3ab2021-12-07 10:36:08 -060078 return callout::GuardType::NONE;
Zane Shelleybf3326f2021-11-12 13:41:39 -060079 }
80
Zane Shelleyc85716c2021-08-17 10:54:06 -050081 /**
Zane Shelley37acb282022-01-10 16:05:22 -060082 * @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 /** @brief Accessor to iv_calloutList. */
129 const nlohmann::json& getCalloutList() const
130 {
131 return iv_calloutList;
132 }
133
134 /** @brief Accessor to iv_calloutFFDC. */
135 const nlohmann::json& getCalloutFFDC() const
136 {
137 return iv_calloutFFDC;
138 }
139
140 private:
141 /**
Zane Shelleyc85716c2021-08-17 10:54:06 -0500142 * @brief Add callout information to the callout list.
143 * @param The JSON object for this callout.
144 */
Zane Shelley979e2872021-09-20 22:46:06 -0500145 void addCallout(const nlohmann::json& i_callout);
Zane Shelley64791cf2021-02-15 17:02:37 -0600146
Zane Shelley95135822021-08-23 09:00:05 -0500147 /**
Zane Shelley2d114322021-08-25 17:06:12 -0500148 * @brief Add FFDC for a callout that would otherwise not be available in
149 * the callout list (unit paths, bus types, etc.).
150 * @param The JSON object for this callout.
151 */
152 void addCalloutFFDC(const nlohmann::json& i_ffdc)
153 {
154 iv_calloutFFDC.push_back(i_ffdc);
155 }
156
Zane Shelley37acb282022-01-10 16:05:22 -0600157 /**
158 * @brief A simple helper function for all the callout functions that need
159 * to callout a target (callout only, no FFDC).
160 * @param i_target The chip or unit target to add to the callout list.
161 * @param i_priority The callout priority.
162 * @param i_guard True if guard is required. False, otherwise.
163 */
164 void addTargetCallout(pdbg_target* i_target,
165 const callout::Priority& i_priority, bool i_guard);
Zane Shelley5f6e3de2021-02-23 13:57:37 -0600166
Zane Shelley37acb282022-01-10 16:05:22 -0600167 /**
168 * @brief A simple helper function for all the callout functions that need
169 * to callout a the backplane (callout only, no FFDC).
170 * @param i_priority The callout priority.
171 */
172 void addBackplaneCallout(const callout::Priority& i_priority);
Zane Shelley64791cf2021-02-15 17:02:37 -0600173};
174
Zane Shelleyf685afd2021-02-15 15:39:44 -0600175} // namespace analyzer