1 #pragma once
2
3 #include <analyzer/service_data.hpp>
4
5 namespace analyzer
6 {
7
8 /** @brief An abstract class for service event resolutions. */
9 class Resolution
10 {
11 public:
12 /** @brief Pure virtual destructor. */
13 virtual ~Resolution() = 0;
14
15 public:
16 /**
17 * @brief Resolves the service actions required by this resolution.
18 * @param io_sd An object containing the service data collected during
19 * hardware error analysis.
20 */
21 virtual void resolve(ServiceData& io_sd) const = 0;
22 };
23
24 // Pure virtual destructor must be defined.
~Resolution()25 inline Resolution::~Resolution() {}
26
27 /** @brief Resolves a hardware callout service event. */
28 class HardwareCalloutResolution : public Resolution
29 {
30 public:
31 /**
32 * @brief Constructor from components.
33 * @param i_unitPath The devtree path of a guardable unit relative to a
34 * chip. An empty string refers to the chip itself.
35 * @param i_priority The callout priority.
36 * @param i_guard True, if guard is required. False, otherwise.
37 */
HardwareCalloutResolution(const std::string & i_unitPath,callout::Priority i_priority,bool i_guard)38 HardwareCalloutResolution(const std::string& i_unitPath,
39 callout::Priority i_priority, bool i_guard) :
40 iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard)
41 {}
42
43 private:
44 /** The devtree path of a guardable unit relative to a chip. An empty string
45 * refers to the chip itself. */
46 const std::string iv_unitPath;
47
48 /** The callout priority. */
49 const callout::Priority iv_priority;
50
51 /** True, if guard is required. False, otherwise. */
52 const bool iv_guard;
53
54 public:
55 void resolve(ServiceData& io_sd) const override;
56 };
57
58 /** @brief Resolution to callout a connected chip/target. */
59 class ConnectedCalloutResolution : public Resolution
60 {
61 public:
62 /**
63 * @brief Constructor from components.
64 * @param i_busType The bus type.
65 * @param i_unitPath The path of the chip unit that is connected to the
66 * other chip. An empty string refers to the chip itself,
67 * which generally means this chip is a child of another.
68 * @param i_priority The callout priority.
69 * @param i_guard The guard type for this callout.
70 */
ConnectedCalloutResolution(const callout::BusType & i_busType,const std::string & i_unitPath,callout::Priority i_priority,bool i_guard)71 ConnectedCalloutResolution(const callout::BusType& i_busType,
72 const std::string& i_unitPath,
73 callout::Priority i_priority, bool i_guard) :
74 iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority),
75 iv_guard(i_guard)
76 {}
77
78 private:
79 /** The bus type. */
80 const callout::BusType iv_busType;
81
82 /** The devtree path the chip unit that is connected to the other chip. An
83 * empty string refers to the chip itself, which generally means this chip
84 * is a child of the other chip. */
85 const std::string iv_unitPath;
86
87 /** The callout priority. */
88 const callout::Priority iv_priority;
89
90 /** True, if guard is required. False, otherwise. */
91 const bool iv_guard;
92
93 public:
94 void resolve(ServiceData& io_sd) const override;
95 };
96
97 /**
98 * @brief Resolution to callout all parts on a bus (RX/TX endpoints and
99 * everything else in between).
100 */
101 class BusCalloutResolution : public Resolution
102 {
103 public:
104 /**
105 * @brief Constructor from components.
106 * @param i_busType The bus type.
107 * @param i_unitPath The path of the chip unit that is connected to the
108 * other chip. An empty string refers to the chip itself,
109 * which generally means this chip is a child of another.
110 * @param i_priority The callout priority.
111 * @param i_guard The guard type for this callout.
112 */
BusCalloutResolution(const callout::BusType & i_busType,const std::string & i_unitPath,callout::Priority i_priority,bool i_guard)113 BusCalloutResolution(const callout::BusType& i_busType,
114 const std::string& i_unitPath,
115 callout::Priority i_priority, bool i_guard) :
116 iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority),
117 iv_guard(i_guard)
118 {}
119
120 private:
121 /** The bus type. */
122 const callout::BusType iv_busType;
123
124 /** The devtree path the chip unit that is connected to the other chip. An
125 * empty string refers to the chip itself, which generally means this chip
126 * is a child of the other chip. */
127 const std::string iv_unitPath;
128
129 /** The callout priority. */
130 const callout::Priority iv_priority;
131
132 /** True, if guard is required. False, otherwise. */
133 const bool iv_guard;
134
135 public:
136 void resolve(ServiceData& io_sd) const override;
137 };
138
139 /** @brief Resolves a clock callout service event. */
140 class ClockCalloutResolution : public Resolution
141 {
142 public:
143 /**
144 * @brief Constructor from components.
145 * @param i_clockType The clock type.
146 * @param i_priority The callout priority.
147 * @param i_guard The guard type for this callout.
148 */
ClockCalloutResolution(const callout::ClockType & i_clockType,callout::Priority i_priority,bool i_guard)149 ClockCalloutResolution(const callout::ClockType& i_clockType,
150 callout::Priority i_priority, bool i_guard) :
151 iv_clockType(i_clockType), iv_priority(i_priority), iv_guard(i_guard)
152 {}
153
154 private:
155 /** The clock type. */
156 const callout::ClockType iv_clockType;
157
158 /** The callout priority. */
159 const callout::Priority iv_priority;
160
161 /** True, if guard is required. False, otherwise. */
162 const bool iv_guard;
163
164 public:
165 void resolve(ServiceData& io_sd) const override;
166 };
167
168 /** @brief Resolves a procedure callout service event. */
169 class ProcedureCalloutResolution : public Resolution
170 {
171 public:
172 /**
173 * @brief Constructor from components.
174 * @param i_procedure The procedure callout type.
175 * @param i_priority The callout priority.
176 */
ProcedureCalloutResolution(const callout::Procedure & i_procedure,callout::Priority i_priority)177 ProcedureCalloutResolution(const callout::Procedure& i_procedure,
178 callout::Priority i_priority) :
179 iv_procedure(i_procedure), iv_priority(i_priority)
180 {}
181
182 private:
183 /** The procedure callout type. */
184 const callout::Procedure iv_procedure;
185
186 /** The callout priority. */
187 const callout::Priority iv_priority;
188
189 public:
190 void resolve(ServiceData& io_sd) const override;
191 };
192
193 /** @brief Resolves a part callout service event. */
194 class PartCalloutResolution : public Resolution
195 {
196 public:
197 /**
198 * @brief Constructor from components.
199 * @param i_part The part callout type.
200 * @param i_priority The callout priority.
201 */
PartCalloutResolution(const callout::PartType & i_part,callout::Priority i_priority)202 PartCalloutResolution(const callout::PartType& i_part,
203 callout::Priority i_priority) :
204 iv_part(i_part), iv_priority(i_priority)
205 {}
206
207 private:
208 /** The part callout type. */
209 const callout::PartType iv_part;
210
211 /** The callout priority. */
212 const callout::Priority iv_priority;
213
214 public:
215 void resolve(ServiceData& io_sd) const override;
216 };
217
218 /**
219 * @brief Some service actions cannot be contained within the RAS data files.
220 * This resolution class allows a predefined plugin function to be
221 * called to do additional service action work.
222 */
223 class PluginResolution : public Resolution
224 {
225 public:
226 /**
227 * @brief Constructor from components.
228 * @param i_name The name of the plugin.
229 * @param i_instance A plugin could be defined for multiple chip
230 * units/registers.
231 */
PluginResolution(const std::string & i_name,unsigned int i_instance)232 PluginResolution(const std::string& i_name, unsigned int i_instance) :
233 iv_name(i_name), iv_instance(i_instance)
234 {}
235
236 private:
237 /** The name of the plugin. */
238 const std::string iv_name;
239
240 /** Some plugins will define the same action for multiple instances of a
241 * register (i.e. for each core on a processor). */
242 const unsigned int iv_instance;
243
244 public:
245 void resolve(ServiceData& io_sd) const override;
246 };
247
248 /**
249 * @brief Contains a list of resolutions. This resolutions will be resolved the
250 * list in the order in which they were inputted into the constructor.
251 */
252 class ResolutionList : public Resolution
253 {
254 public:
255 /** @brief Default constructor. */
256 ResolutionList() = default;
257
258 private:
259 /** The resolution list. */
260 std::vector<std::shared_ptr<Resolution>> iv_list;
261
262 public:
263 /**
264 * @brief Adds a new resolution to the end of the list.
265 * @param i_resolution The new resolution
266 */
push(const std::shared_ptr<Resolution> & i_resolution)267 void push(const std::shared_ptr<Resolution>& i_resolution)
268 {
269 iv_list.push_back(i_resolution);
270 }
271
272 // Overloaded from parent.
resolve(ServiceData & io_sd) const273 void resolve(ServiceData& io_sd) const override
274 {
275 for (const auto& e : iv_list)
276 {
277 e->resolve(io_sd);
278 }
279 }
280 };
281
282 } // namespace analyzer
283