Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 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. |
| 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. |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 33 | * @param i_unitPath The devtree path of a guardable unit relative to a |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 34 | * chip. An empty string refers to the chip itself. |
| 35 | * @param i_priority The callout priority. |
Zane Shelley | 2f92130 | 2021-08-09 13:23:25 -0500 | [diff] [blame] | 36 | * @param i_guard True, if guard is required. False, otherwise. |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 37 | */ |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 38 | HardwareCalloutResolution(const std::string& i_unitPath, |
Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 39 | callout::Priority i_priority, bool i_guard) : |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 40 | iv_unitPath(i_unitPath), |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 41 | 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 Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 47 | const std::string iv_unitPath; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 48 | |
| 49 | /** The callout priority. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 50 | const callout::Priority iv_priority; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 51 | |
Zane Shelley | 2f92130 | 2021-08-09 13:23:25 -0500 | [diff] [blame] | 52 | /** True, if guard is required. False, otherwise. */ |
| 53 | const bool iv_guard; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 54 | |
| 55 | public: |
| 56 | void resolve(ServiceData& io_sd) const override; |
| 57 | }; |
| 58 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 59 | /** @brief Resolution to callout a connected chip/target. */ |
| 60 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 74 | callout::Priority i_priority, bool i_guard) : |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 75 | 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 Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 98 | /** |
| 99 | * @brief Resolution to callout all parts on a bus (RX/TX endpoints and |
| 100 | * everything else in between). |
| 101 | */ |
| 102 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 116 | callout::Priority i_priority, bool i_guard) : |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 117 | 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 Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 140 | /** @brief Resolves a clock callout service event. */ |
| 141 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 151 | callout::Priority i_priority, bool i_guard) : |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 152 | 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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 170 | /** @brief Resolves a procedure callout service event. */ |
| 171 | class 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 Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 179 | ProcedureCalloutResolution(const callout::Procedure& i_procedure, |
Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 180 | callout::Priority i_priority) : |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 181 | iv_procedure(i_procedure), |
| 182 | iv_priority(i_priority) |
| 183 | {} |
| 184 | |
| 185 | private: |
| 186 | /** The procedure callout type. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 187 | const callout::Procedure iv_procedure; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 188 | |
| 189 | /** The callout priority. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 190 | const callout::Priority iv_priority; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 191 | |
| 192 | public: |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 193 | void resolve(ServiceData& io_sd) const override; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 194 | }; |
| 195 | |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 196 | /** @brief Resolves a part callout service event. */ |
| 197 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 206 | callout::Priority i_priority) : |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 207 | 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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 222 | /** |
Zane Shelley | e13a9f9 | 2021-12-16 21:19:11 -0600 | [diff] [blame] | 223 | * @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 | */ |
| 227 | class 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 Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 253 | * @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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 255 | */ |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 256 | class ResolutionList : public Resolution |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 257 | { |
| 258 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 259 | /** @brief Default constructor. */ |
| 260 | ResolutionList() = default; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 261 | |
| 262 | private: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 263 | /** The resolution list. */ |
| 264 | std::vector<std::shared_ptr<Resolution>> iv_list; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 265 | |
| 266 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 267 | /** |
| 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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 277 | void resolve(ServiceData& io_sd) const override |
| 278 | { |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 279 | for (const auto& e : iv_list) |
| 280 | { |
| 281 | e->resolve(io_sd); |
| 282 | } |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 283 | } |
| 284 | }; |
| 285 | |
| 286 | } // namespace analyzer |