blob: fc717cac9a88e22c1656d99aa88b64ad77ddc923 [file] [log] [blame]
Zane Shelley0b8368c2021-03-18 17:33:41 -05001#pragma once
2
3#include <analyzer/service_data.hpp>
4
5namespace analyzer
6{
7
8/** @brief An abstract class for service event resolutions. */
9class 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.
25inline Resolution::~Resolution() {}
26
27/** @brief Resolves a hardware callout service event. */
28class HardwareCalloutResolution : public Resolution
29{
30 public:
31 /**
32 * @brief Constructor from components.
Zane Shelley96d54862021-09-17 11:16:12 -050033 * @param i_unitPath The devtree path of a guardable unit relative to a
Zane Shelley0b8368c2021-03-18 17:33:41 -050034 * chip. An empty string refers to the chip itself.
35 * @param i_priority The callout priority.
Zane Shelley2f921302021-08-09 13:23:25 -050036 * @param i_guard True, if guard is required. False, otherwise.
Zane Shelley0b8368c2021-03-18 17:33:41 -050037 */
Zane Shelley96d54862021-09-17 11:16:12 -050038 HardwareCalloutResolution(const std::string& i_unitPath,
Zane Shelley9980d482022-01-28 15:21:47 -060039 callout::Priority i_priority, bool i_guard) :
Zane Shelley96d54862021-09-17 11:16:12 -050040 iv_unitPath(i_unitPath),
Zane Shelley0b8368c2021-03-18 17:33:41 -050041 iv_priority(i_priority), iv_guard(i_guard)
42 {}
43
44 private:
45 /** The devtree path of a guardable unit relative to a chip. An empty string
46 * refers to the chip itself. */
Zane Shelley96d54862021-09-17 11:16:12 -050047 const std::string iv_unitPath;
Zane Shelley0b8368c2021-03-18 17:33:41 -050048
49 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050050 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -050051
Zane Shelley2f921302021-08-09 13:23:25 -050052 /** True, if guard is required. False, otherwise. */
53 const bool iv_guard;
Zane Shelley0b8368c2021-03-18 17:33:41 -050054
55 public:
56 void resolve(ServiceData& io_sd) const override;
57};
58
Zane Shelley5d63cef2021-09-17 18:10:17 -050059/** @brief Resolution to callout a connected chip/target. */
60class ConnectedCalloutResolution : public Resolution
61{
62 public:
63 /**
64 * @brief Constructor from components.
65 * @param i_busType The bus type.
66 * @param i_unitPath The path of the chip unit that is connected to the
67 * other chip. An empty string refers to the chip itself,
68 * which generally means this chip is a child of another.
69 * @param i_priority The callout priority.
70 * @param i_guard The guard type for this callout.
71 */
72 ConnectedCalloutResolution(const callout::BusType& i_busType,
73 const std::string& i_unitPath,
Zane Shelley9980d482022-01-28 15:21:47 -060074 callout::Priority i_priority, bool i_guard) :
Zane Shelley5d63cef2021-09-17 18:10:17 -050075 iv_busType(i_busType),
76 iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard)
77 {}
78
79 private:
80 /** The bus type. */
81 const callout::BusType iv_busType;
82
83 /** The devtree path the chip unit that is connected to the other chip. An
84 * empty string refers to the chip itself, which generally means this chip
85 * is a child of the other chip. */
86 const std::string iv_unitPath;
87
88 /** The callout priority. */
89 const callout::Priority iv_priority;
90
91 /** True, if guard is required. False, otherwise. */
92 const bool iv_guard;
93
94 public:
95 void resolve(ServiceData& io_sd) const override;
96};
97
Zane Shelley4757a7b2021-09-20 22:23:38 -050098/**
99 * @brief Resolution to callout all parts on a bus (RX/TX endpoints and
100 * everything else in between).
101 */
102class BusCalloutResolution : public Resolution
103{
104 public:
105 /**
106 * @brief Constructor from components.
107 * @param i_busType The bus type.
108 * @param i_unitPath The path of the chip unit that is connected to the
109 * other chip. An empty string refers to the chip itself,
110 * which generally means this chip is a child of another.
111 * @param i_priority The callout priority.
112 * @param i_guard The guard type for this callout.
113 */
114 BusCalloutResolution(const callout::BusType& i_busType,
115 const std::string& i_unitPath,
Zane Shelley9980d482022-01-28 15:21:47 -0600116 callout::Priority i_priority, bool i_guard) :
Zane Shelley4757a7b2021-09-20 22:23:38 -0500117 iv_busType(i_busType),
118 iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard)
119 {}
120
121 private:
122 /** The bus type. */
123 const callout::BusType iv_busType;
124
125 /** The devtree path the chip unit that is connected to the other chip. An
126 * empty string refers to the chip itself, which generally means this chip
127 * is a child of the other chip. */
128 const std::string iv_unitPath;
129
130 /** The callout priority. */
131 const callout::Priority iv_priority;
132
133 /** True, if guard is required. False, otherwise. */
134 const bool iv_guard;
135
136 public:
137 void resolve(ServiceData& io_sd) const override;
138};
139
Zane Shelley84721d92021-09-08 13:30:27 -0500140/** @brief Resolves a clock callout service event. */
141class ClockCalloutResolution : public Resolution
142{
143 public:
144 /**
145 * @brief Constructor from components.
146 * @param i_clockType The clock type.
147 * @param i_priority The callout priority.
148 * @param i_guard The guard type for this callout.
149 */
150 ClockCalloutResolution(const callout::ClockType& i_clockType,
Zane Shelley9980d482022-01-28 15:21:47 -0600151 callout::Priority i_priority, bool i_guard) :
Zane Shelley84721d92021-09-08 13:30:27 -0500152 iv_clockType(i_clockType),
153 iv_priority(i_priority), iv_guard(i_guard)
154 {}
155
156 private:
157 /** The clock type. */
158 const callout::ClockType iv_clockType;
159
160 /** The callout priority. */
161 const callout::Priority iv_priority;
162
163 /** True, if guard is required. False, otherwise. */
164 const bool iv_guard;
165
166 public:
167 void resolve(ServiceData& io_sd) const override;
168};
169
Zane Shelley0b8368c2021-03-18 17:33:41 -0500170/** @brief Resolves a procedure callout service event. */
171class ProcedureCalloutResolution : public Resolution
172{
173 public:
174 /**
175 * @brief Constructor from components.
176 * @param i_procedure The procedure callout type.
177 * @param i_priority The callout priority.
178 */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500179 ProcedureCalloutResolution(const callout::Procedure& i_procedure,
Zane Shelley9980d482022-01-28 15:21:47 -0600180 callout::Priority i_priority) :
Zane Shelley0b8368c2021-03-18 17:33:41 -0500181 iv_procedure(i_procedure),
182 iv_priority(i_priority)
183 {}
184
185 private:
186 /** The procedure callout type. */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500187 const callout::Procedure iv_procedure;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500188
189 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500190 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500191
192 public:
Zane Shelleyc85716c2021-08-17 10:54:06 -0500193 void resolve(ServiceData& io_sd) const override;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500194};
195
Zane Shelleya4134772022-01-10 17:22:44 -0600196/** @brief Resolves a part callout service event. */
197class PartCalloutResolution : public Resolution
198{
199 public:
200 /**
201 * @brief Constructor from components.
202 * @param i_part The part callout type.
203 * @param i_priority The callout priority.
204 */
205 PartCalloutResolution(const callout::PartType& i_part,
Zane Shelley9980d482022-01-28 15:21:47 -0600206 callout::Priority i_priority) :
Zane Shelleya4134772022-01-10 17:22:44 -0600207 iv_part(i_part),
208 iv_priority(i_priority)
209 {}
210
211 private:
212 /** The part callout type. */
213 const callout::PartType iv_part;
214
215 /** The callout priority. */
216 const callout::Priority iv_priority;
217
218 public:
219 void resolve(ServiceData& io_sd) const override;
220};
221
Zane Shelley0b8368c2021-03-18 17:33:41 -0500222/**
Zane Shelleye13a9f92021-12-16 21:19:11 -0600223 * @brief Some service actions cannot be contained within the RAS data files.
224 * This resolution class allows a predefined plugin function to be
225 * called to do additional service action work.
226 */
227class PluginResolution : public Resolution
228{
229 public:
230 /**
231 * @brief Constructor from components.
232 * @param i_name The name of the plugin.
233 * @param i_instance A plugin could be defined for multiple chip
234 * units/registers.
235 */
236 PluginResolution(const std::string& i_name, unsigned int i_instance) :
237 iv_name(i_name), iv_instance(i_instance)
238 {}
239
240 private:
241 /** The name of the plugin. */
242 const std::string iv_name;
243
244 /** Some plugins will define the same action for multiple instances of a
245 * register (i.e. for each core on a processor). */
246 const unsigned int iv_instance;
247
248 public:
249 void resolve(ServiceData& io_sd) const override;
250};
251
252/**
Zane Shelley723fa232021-08-09 12:02:06 -0500253 * @brief Contains a list of resolutions. This resolutions will be resolved the
254 * list in the order in which they were inputted into the constructor.
Zane Shelley0b8368c2021-03-18 17:33:41 -0500255 */
Zane Shelley723fa232021-08-09 12:02:06 -0500256class ResolutionList : public Resolution
Zane Shelley0b8368c2021-03-18 17:33:41 -0500257{
258 public:
Zane Shelley723fa232021-08-09 12:02:06 -0500259 /** @brief Default constructor. */
260 ResolutionList() = default;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500261
262 private:
Zane Shelley723fa232021-08-09 12:02:06 -0500263 /** The resolution list. */
264 std::vector<std::shared_ptr<Resolution>> iv_list;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500265
266 public:
Zane Shelley723fa232021-08-09 12:02:06 -0500267 /**
268 * @brief Adds a new resolution to the end of the list.
269 * @param i_resolution The new resolution
270 */
271 void push(const std::shared_ptr<Resolution>& i_resolution)
272 {
273 iv_list.push_back(i_resolution);
274 }
275
276 // Overloaded from parent.
Zane Shelley0b8368c2021-03-18 17:33:41 -0500277 void resolve(ServiceData& io_sd) const override
278 {
Zane Shelley723fa232021-08-09 12:02:06 -0500279 for (const auto& e : iv_list)
280 {
281 e->resolve(io_sd);
282 }
Zane Shelley0b8368c2021-03-18 17:33:41 -0500283 }
284};
285
286} // namespace analyzer