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, |
| 39 | const callout::Priority& i_priority, |
| 40 | bool i_guard) : |
| 41 | iv_unitPath(i_unitPath), |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 42 | 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 Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 48 | const std::string iv_unitPath; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 49 | |
| 50 | /** The callout priority. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 51 | const callout::Priority iv_priority; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 52 | |
Zane Shelley | 2f92130 | 2021-08-09 13:23:25 -0500 | [diff] [blame] | 53 | /** True, if guard is required. False, otherwise. */ |
| 54 | const bool iv_guard; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 55 | |
| 56 | public: |
| 57 | void resolve(ServiceData& io_sd) const override; |
| 58 | }; |
| 59 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 60 | /** @brief Resolution to callout a connected chip/target. */ |
| 61 | class 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 Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 100 | /** |
| 101 | * @brief Resolution to callout all parts on a bus (RX/TX endpoints and |
| 102 | * everything else in between). |
| 103 | */ |
| 104 | class BusCalloutResolution : public Resolution |
| 105 | { |
| 106 | public: |
| 107 | /** |
| 108 | * @brief Constructor from components. |
| 109 | * @param i_busType The bus type. |
| 110 | * @param i_unitPath The path of the chip unit that is connected to the |
| 111 | * other chip. An empty string refers to the chip itself, |
| 112 | * which generally means this chip is a child of another. |
| 113 | * @param i_priority The callout priority. |
| 114 | * @param i_guard The guard type for this callout. |
| 115 | */ |
| 116 | BusCalloutResolution(const callout::BusType& i_busType, |
| 117 | const std::string& i_unitPath, |
| 118 | const callout::Priority& i_priority, bool i_guard) : |
| 119 | iv_busType(i_busType), |
| 120 | iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard) |
| 121 | {} |
| 122 | |
| 123 | private: |
| 124 | /** The bus type. */ |
| 125 | const callout::BusType iv_busType; |
| 126 | |
| 127 | /** The devtree path the chip unit that is connected to the other chip. An |
| 128 | * empty string refers to the chip itself, which generally means this chip |
| 129 | * is a child of the other chip. */ |
| 130 | const std::string iv_unitPath; |
| 131 | |
| 132 | /** The callout priority. */ |
| 133 | const callout::Priority iv_priority; |
| 134 | |
| 135 | /** True, if guard is required. False, otherwise. */ |
| 136 | const bool iv_guard; |
| 137 | |
| 138 | public: |
| 139 | void resolve(ServiceData& io_sd) const override; |
| 140 | }; |
| 141 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 142 | /** @brief Resolves a clock callout service event. */ |
| 143 | class ClockCalloutResolution : public Resolution |
| 144 | { |
| 145 | public: |
| 146 | /** |
| 147 | * @brief Constructor from components. |
| 148 | * @param i_clockType The clock type. |
| 149 | * @param i_priority The callout priority. |
| 150 | * @param i_guard The guard type for this callout. |
| 151 | */ |
| 152 | ClockCalloutResolution(const callout::ClockType& i_clockType, |
| 153 | const callout::Priority& i_priority, bool i_guard) : |
| 154 | iv_clockType(i_clockType), |
| 155 | iv_priority(i_priority), iv_guard(i_guard) |
| 156 | {} |
| 157 | |
| 158 | private: |
| 159 | /** The clock type. */ |
| 160 | const callout::ClockType iv_clockType; |
| 161 | |
| 162 | /** The callout priority. */ |
| 163 | const callout::Priority iv_priority; |
| 164 | |
| 165 | /** True, if guard is required. False, otherwise. */ |
| 166 | const bool iv_guard; |
| 167 | |
| 168 | public: |
| 169 | void resolve(ServiceData& io_sd) const override; |
| 170 | }; |
| 171 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 172 | /** @brief Resolves a procedure callout service event. */ |
| 173 | class ProcedureCalloutResolution : public Resolution |
| 174 | { |
| 175 | public: |
| 176 | /** |
| 177 | * @brief Constructor from components. |
| 178 | * @param i_procedure The procedure callout type. |
| 179 | * @param i_priority The callout priority. |
| 180 | */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 181 | ProcedureCalloutResolution(const callout::Procedure& i_procedure, |
| 182 | const callout::Priority& i_priority) : |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 183 | iv_procedure(i_procedure), |
| 184 | iv_priority(i_priority) |
| 185 | {} |
| 186 | |
| 187 | private: |
| 188 | /** The procedure callout type. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 189 | const callout::Procedure iv_procedure; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 190 | |
| 191 | /** The callout priority. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 192 | const callout::Priority iv_priority; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 193 | |
| 194 | public: |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 195 | void resolve(ServiceData& io_sd) const override; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 196 | }; |
| 197 | |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 198 | /** @brief Resolves a part callout service event. */ |
| 199 | class PartCalloutResolution : public Resolution |
| 200 | { |
| 201 | public: |
| 202 | /** |
| 203 | * @brief Constructor from components. |
| 204 | * @param i_part The part callout type. |
| 205 | * @param i_priority The callout priority. |
| 206 | */ |
| 207 | PartCalloutResolution(const callout::PartType& i_part, |
| 208 | const callout::Priority& i_priority) : |
| 209 | iv_part(i_part), |
| 210 | iv_priority(i_priority) |
| 211 | {} |
| 212 | |
| 213 | private: |
| 214 | /** The part callout type. */ |
| 215 | const callout::PartType iv_part; |
| 216 | |
| 217 | /** The callout priority. */ |
| 218 | const callout::Priority iv_priority; |
| 219 | |
| 220 | public: |
| 221 | void resolve(ServiceData& io_sd) const override; |
| 222 | }; |
| 223 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 224 | /** |
Zane Shelley | e13a9f9 | 2021-12-16 21:19:11 -0600 | [diff] [blame] | 225 | * @brief Some service actions cannot be contained within the RAS data files. |
| 226 | * This resolution class allows a predefined plugin function to be |
| 227 | * called to do additional service action work. |
| 228 | */ |
| 229 | class PluginResolution : public Resolution |
| 230 | { |
| 231 | public: |
| 232 | /** |
| 233 | * @brief Constructor from components. |
| 234 | * @param i_name The name of the plugin. |
| 235 | * @param i_instance A plugin could be defined for multiple chip |
| 236 | * units/registers. |
| 237 | */ |
| 238 | PluginResolution(const std::string& i_name, unsigned int i_instance) : |
| 239 | iv_name(i_name), iv_instance(i_instance) |
| 240 | {} |
| 241 | |
| 242 | private: |
| 243 | /** The name of the plugin. */ |
| 244 | const std::string iv_name; |
| 245 | |
| 246 | /** Some plugins will define the same action for multiple instances of a |
| 247 | * register (i.e. for each core on a processor). */ |
| 248 | const unsigned int iv_instance; |
| 249 | |
| 250 | public: |
| 251 | void resolve(ServiceData& io_sd) const override; |
| 252 | }; |
| 253 | |
| 254 | /** |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 255 | * @brief Contains a list of resolutions. This resolutions will be resolved the |
| 256 | * list in the order in which they were inputted into the constructor. |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 257 | */ |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 258 | class ResolutionList : public Resolution |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 259 | { |
| 260 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 261 | /** @brief Default constructor. */ |
| 262 | ResolutionList() = default; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 263 | |
| 264 | private: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 265 | /** The resolution list. */ |
| 266 | std::vector<std::shared_ptr<Resolution>> iv_list; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 267 | |
| 268 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 269 | /** |
| 270 | * @brief Adds a new resolution to the end of the list. |
| 271 | * @param i_resolution The new resolution |
| 272 | */ |
| 273 | void push(const std::shared_ptr<Resolution>& i_resolution) |
| 274 | { |
| 275 | iv_list.push_back(i_resolution); |
| 276 | } |
| 277 | |
| 278 | // Overloaded from parent. |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 279 | void resolve(ServiceData& io_sd) const override |
| 280 | { |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 281 | for (const auto& e : iv_list) |
| 282 | { |
| 283 | e->resolve(io_sd); |
| 284 | } |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 285 | } |
| 286 | }; |
| 287 | |
| 288 | } // namespace analyzer |