blob: aee38514122764110c73225500b2001900bb3aca [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,
39 const callout::Priority& i_priority,
40 bool i_guard) :
41 iv_unitPath(i_unitPath),
Zane Shelley0b8368c2021-03-18 17:33:41 -050042 iv_priority(i_priority), iv_guard(i_guard)
43 {}
44
45 private:
46 /** The devtree path of a guardable unit relative to a chip. An empty string
47 * refers to the chip itself. */
Zane Shelley96d54862021-09-17 11:16:12 -050048 const std::string iv_unitPath;
Zane Shelley0b8368c2021-03-18 17:33:41 -050049
50 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050051 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -050052
Zane Shelley2f921302021-08-09 13:23:25 -050053 /** True, if guard is required. False, otherwise. */
54 const bool iv_guard;
Zane Shelley0b8368c2021-03-18 17:33:41 -050055
56 public:
57 void resolve(ServiceData& io_sd) const override;
58};
59
Zane Shelley5d63cef2021-09-17 18:10:17 -050060/** @brief Resolution to callout a connected chip/target. */
61class ConnectedCalloutResolution : public Resolution
62{
63 public:
64 /**
65 * @brief Constructor from components.
66 * @param i_busType The bus type.
67 * @param i_unitPath The path of the chip unit that is connected to the
68 * other chip. An empty string refers to the chip itself,
69 * which generally means this chip is a child of another.
70 * @param i_priority The callout priority.
71 * @param i_guard The guard type for this callout.
72 */
73 ConnectedCalloutResolution(const callout::BusType& i_busType,
74 const std::string& i_unitPath,
75 const callout::Priority& i_priority,
76 bool i_guard) :
77 iv_busType(i_busType),
78 iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard)
79 {}
80
81 private:
82 /** The bus type. */
83 const callout::BusType iv_busType;
84
85 /** The devtree path the chip unit that is connected to the other chip. An
86 * empty string refers to the chip itself, which generally means this chip
87 * is a child of the other chip. */
88 const std::string iv_unitPath;
89
90 /** The callout priority. */
91 const callout::Priority iv_priority;
92
93 /** True, if guard is required. False, otherwise. */
94 const bool iv_guard;
95
96 public:
97 void resolve(ServiceData& io_sd) const override;
98};
99
Zane Shelley84721d92021-09-08 13:30:27 -0500100/** @brief Resolves a clock callout service event. */
101class ClockCalloutResolution : public Resolution
102{
103 public:
104 /**
105 * @brief Constructor from components.
106 * @param i_clockType The clock type.
107 * @param i_priority The callout priority.
108 * @param i_guard The guard type for this callout.
109 */
110 ClockCalloutResolution(const callout::ClockType& i_clockType,
111 const callout::Priority& i_priority, bool i_guard) :
112 iv_clockType(i_clockType),
113 iv_priority(i_priority), iv_guard(i_guard)
114 {}
115
116 private:
117 /** The clock type. */
118 const callout::ClockType iv_clockType;
119
120 /** The callout priority. */
121 const callout::Priority iv_priority;
122
123 /** True, if guard is required. False, otherwise. */
124 const bool iv_guard;
125
126 public:
127 void resolve(ServiceData& io_sd) const override;
128};
129
Zane Shelley0b8368c2021-03-18 17:33:41 -0500130/** @brief Resolves a procedure callout service event. */
131class ProcedureCalloutResolution : public Resolution
132{
133 public:
134 /**
135 * @brief Constructor from components.
136 * @param i_procedure The procedure callout type.
137 * @param i_priority The callout priority.
138 */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500139 ProcedureCalloutResolution(const callout::Procedure& i_procedure,
140 const callout::Priority& i_priority) :
Zane Shelley0b8368c2021-03-18 17:33:41 -0500141 iv_procedure(i_procedure),
142 iv_priority(i_priority)
143 {}
144
145 private:
146 /** The procedure callout type. */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500147 const callout::Procedure iv_procedure;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500148
149 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -0500150 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500151
152 public:
Zane Shelleyc85716c2021-08-17 10:54:06 -0500153 void resolve(ServiceData& io_sd) const override;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500154};
155
156/**
Zane Shelley723fa232021-08-09 12:02:06 -0500157 * @brief Contains a list of resolutions. This resolutions will be resolved the
158 * list in the order in which they were inputted into the constructor.
Zane Shelley0b8368c2021-03-18 17:33:41 -0500159 */
Zane Shelley723fa232021-08-09 12:02:06 -0500160class ResolutionList : public Resolution
Zane Shelley0b8368c2021-03-18 17:33:41 -0500161{
162 public:
Zane Shelley723fa232021-08-09 12:02:06 -0500163 /** @brief Default constructor. */
164 ResolutionList() = default;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500165
166 private:
Zane Shelley723fa232021-08-09 12:02:06 -0500167 /** The resolution list. */
168 std::vector<std::shared_ptr<Resolution>> iv_list;
Zane Shelley0b8368c2021-03-18 17:33:41 -0500169
170 public:
Zane Shelley723fa232021-08-09 12:02:06 -0500171 /**
172 * @brief Adds a new resolution to the end of the list.
173 * @param i_resolution The new resolution
174 */
175 void push(const std::shared_ptr<Resolution>& i_resolution)
176 {
177 iv_list.push_back(i_resolution);
178 }
179
180 // Overloaded from parent.
Zane Shelley0b8368c2021-03-18 17:33:41 -0500181 void resolve(ServiceData& io_sd) const override
182 {
Zane Shelley723fa232021-08-09 12:02:06 -0500183 for (const auto& e : iv_list)
184 {
185 e->resolve(io_sd);
186 }
Zane Shelley0b8368c2021-03-18 17:33:41 -0500187 }
188};
189
190} // namespace analyzer