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) : |
Patrick Williams | a0c724d | 2024-08-16 15:21:54 -0400 | [diff] [blame] | 40 | iv_unitPath(i_unitPath), iv_priority(i_priority), iv_guard(i_guard) |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 41 | {} |
| 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 Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 46 | const std::string iv_unitPath; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 47 | |
| 48 | /** The callout priority. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 49 | const callout::Priority iv_priority; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 50 | |
Zane Shelley | 2f92130 | 2021-08-09 13:23:25 -0500 | [diff] [blame] | 51 | /** True, if guard is required. False, otherwise. */ |
| 52 | const bool iv_guard; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 53 | |
| 54 | public: |
| 55 | void resolve(ServiceData& io_sd) const override; |
| 56 | }; |
| 57 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 58 | /** @brief Resolution to callout a connected chip/target. */ |
| 59 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 73 | callout::Priority i_priority, bool i_guard) : |
Patrick Williams | a0c724d | 2024-08-16 15:21:54 -0400 | [diff] [blame] | 74 | iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority), |
| 75 | iv_guard(i_guard) |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 76 | {} |
| 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 Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 97 | /** |
| 98 | * @brief Resolution to callout all parts on a bus (RX/TX endpoints and |
| 99 | * everything else in between). |
| 100 | */ |
| 101 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 115 | callout::Priority i_priority, bool i_guard) : |
Patrick Williams | a0c724d | 2024-08-16 15:21:54 -0400 | [diff] [blame] | 116 | iv_busType(i_busType), iv_unitPath(i_unitPath), iv_priority(i_priority), |
| 117 | iv_guard(i_guard) |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 118 | {} |
| 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 Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 139 | /** @brief Resolves a clock callout service event. */ |
| 140 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 150 | callout::Priority i_priority, bool i_guard) : |
Patrick Williams | a0c724d | 2024-08-16 15:21:54 -0400 | [diff] [blame] | 151 | iv_clockType(i_clockType), iv_priority(i_priority), iv_guard(i_guard) |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 152 | {} |
| 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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 168 | /** @brief Resolves a procedure callout service event. */ |
| 169 | class 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 Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 177 | ProcedureCalloutResolution(const callout::Procedure& i_procedure, |
Zane Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 178 | callout::Priority i_priority) : |
Patrick Williams | a0c724d | 2024-08-16 15:21:54 -0400 | [diff] [blame] | 179 | iv_procedure(i_procedure), iv_priority(i_priority) |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 180 | {} |
| 181 | |
| 182 | private: |
| 183 | /** The procedure callout type. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 184 | const callout::Procedure iv_procedure; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 185 | |
| 186 | /** The callout priority. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 187 | const callout::Priority iv_priority; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 188 | |
| 189 | public: |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 190 | void resolve(ServiceData& io_sd) const override; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 191 | }; |
| 192 | |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 193 | /** @brief Resolves a part callout service event. */ |
| 194 | class 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 Shelley | 9980d48 | 2022-01-28 15:21:47 -0600 | [diff] [blame] | 203 | callout::Priority i_priority) : |
Patrick Williams | a0c724d | 2024-08-16 15:21:54 -0400 | [diff] [blame] | 204 | iv_part(i_part), iv_priority(i_priority) |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 205 | {} |
| 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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 218 | /** |
Zane Shelley | e13a9f9 | 2021-12-16 21:19:11 -0600 | [diff] [blame] | 219 | * @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 | */ |
| 223 | class 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 Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 249 | * @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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 251 | */ |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 252 | class ResolutionList : public Resolution |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 253 | { |
| 254 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 255 | /** @brief Default constructor. */ |
| 256 | ResolutionList() = default; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 257 | |
| 258 | private: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 259 | /** The resolution list. */ |
| 260 | std::vector<std::shared_ptr<Resolution>> iv_list; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 261 | |
| 262 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 263 | /** |
| 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 Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 273 | void resolve(ServiceData& io_sd) const override |
| 274 | { |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 275 | for (const auto& e : iv_list) |
| 276 | { |
| 277 | e->resolve(io_sd); |
| 278 | } |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 279 | } |
| 280 | }; |
| 281 | |
| 282 | } // namespace analyzer |