blob: 9b72b95ee2f09515d28b2a3615e870e2e32a2044 [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) :
Patrick Williamsa0c724d2024-08-16 15:21:54 -040040 iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard)
Zane Shelley0b8368c2021-03-18 17:33:41 -050041 {}
42
43 private:
44 /** The devtree path of a guardable unit relative to a chip. An empty string
45 * refers to the chip itself. */
Zane Shelley96d54862021-09-17 11:16:12 -050046 const std::string iv_unitPath;
Zane Shelley0b8368c2021-03-18 17:33:41 -050047
48 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050049 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -050050
Zane Shelley2f921302021-08-09 13:23:25 -050051 /** True, if guard is required. False, otherwise. */
52 const bool iv_guard;
Zane Shelley0b8368c2021-03-18 17:33:41 -050053
54 public:
55 void resolve(ServiceData& io_sd) const override;
56};
57
Zane Shelley5d63cef2021-09-17 18:10:17 -050058/** @brief Resolution to callout a connected chip/target. */
59class 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 */
71 ConnectedCalloutResolution(const callout::BusType& i_busType,
72 const std::string& i_unitPath,
Zane Shelley9980d482022-01-28 15:21:47 -060073 callout::Priority i_priority, bool i_guard) :
Patrick Williamsa0c724d2024-08-16 15:21:54 -040074 iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority),
75 iv_guard(i_guard)
Zane Shelley5d63cef2021-09-17 18:10:17 -050076 {}
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
Zane Shelley4757a7b2021-09-20 22:23:38 -050097/**
98 * @brief Resolution to callout all parts on a bus (RX/TX endpoints and
99 * everything else in between).
100 */
101class 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 */
113 BusCalloutResolution(const callout::BusType& i_busType,
114 const std::string& i_unitPath,
Zane Shelley9980d482022-01-28 15:21:47 -0600115 callout::Priority i_priority, bool i_guard) :
Patrick Williamsa0c724d2024-08-16 15:21:54 -0400116 iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority),
117 iv_guard(i_guard)
Zane Shelley4757a7b2021-09-20 22:23:38 -0500118 {}
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
Zane Shelley84721d92021-09-08 13:30:27 -0500139/** @brief Resolves a clock callout service event. */
140class 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 */
149 ClockCalloutResolution(const callout::ClockType& i_clockType,
Zane Shelley9980d482022-01-28 15:21:47 -0600150 callout::Priority i_priority, bool i_guard) :
Patrick Williamsa0c724d2024-08-16 15:21:54 -0400151 iv_clockType(i_clockType), iv_priority(i_priority), iv_guard(i_guard)
Zane Shelley84721d92021-09-08 13:30:27 -0500152 {}
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
Zane Shelley0b8368c2021-03-18 17:33:41 -0500168/** @brief Resolves a procedure callout service event. */
169class 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 */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500177 ProcedureCalloutResolution(const callout::Procedure& i_procedure,
Zane Shelley9980d482022-01-28 15:21:47 -0600178 callout::Priority i_priority) :
Patrick Williamsa0c724d2024-08-16 15:21:54 -0400179 iv_procedure(i_procedure), iv_priority(i_priority)
Zane Shelley0b8368c2021-03-18 17:33:41 -0500180 {}
181
182 private:
183 /** The procedure callout type. */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500184 const callout::Procedure iv_procedure;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500185
186 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500187 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500188
189 public:
Zane Shelleyc85716c2021-08-17 10:54:06 -0500190 void resolve(ServiceData& io_sd) const override;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500191};
192
Zane Shelleya4134772022-01-10 17:22:44 -0600193/** @brief Resolves a part callout service event. */
194class 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 */
202 PartCalloutResolution(const callout::PartType& i_part,
Zane Shelley9980d482022-01-28 15:21:47 -0600203 callout::Priority i_priority) :
Patrick Williamsa0c724d2024-08-16 15:21:54 -0400204 iv_part(i_part), iv_priority(i_priority)
Zane Shelleya4134772022-01-10 17:22:44 -0600205 {}
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
Zane Shelley0b8368c2021-03-18 17:33:41 -0500218/**
Zane Shelleye13a9f92021-12-16 21:19:11 -0600219 * @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 */
223class 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 */
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/**
Zane Shelley723fa232021-08-09 12:02:06 -0500249 * @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.
Zane Shelley0b8368c2021-03-18 17:33:41 -0500251 */
Zane Shelley723fa232021-08-09 12:02:06 -0500252class ResolutionList : public Resolution
Zane Shelley0b8368c2021-03-18 17:33:41 -0500253{
254 public:
Zane Shelley723fa232021-08-09 12:02:06 -0500255 /** @brief Default constructor. */
256 ResolutionList() = default;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500257
258 private:
Zane Shelley723fa232021-08-09 12:02:06 -0500259 /** The resolution list. */
260 std::vector<std::shared_ptr<Resolution>> iv_list;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500261
262 public:
Zane Shelley723fa232021-08-09 12:02:06 -0500263 /**
264 * @brief Adds a new resolution to the end of the list.
265 * @param i_resolution The new resolution
266 */
267 void push(const std::shared_ptr<Resolution>& i_resolution)
268 {
269 iv_list.push_back(i_resolution);
270 }
271
272 // Overloaded from parent.
Zane Shelley0b8368c2021-03-18 17:33:41 -0500273 void resolve(ServiceData& io_sd) const override
274 {
Zane Shelley723fa232021-08-09 12:02:06 -0500275 for (const auto& e : iv_list)
276 {
277 e->resolve(io_sd);
278 }
Zane Shelley0b8368c2021-03-18 17:33:41 -0500279 }
280};
281
282} // namespace analyzer