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. 33 * @param i_unitPath The devtree path of a guardable unit relative to a 34 * chip. An empty string refers to the chip itself. 35 * @param i_priority The callout priority. 36 * @param i_guard True, if guard is required. False, otherwise. 37 */ 38 HardwareCalloutResolution(const std::string& i_unitPath, 39 callout::Priority i_priority, bool i_guard) : 40 iv_unitPath(i_unitPath), 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. */ 47 const std::string iv_unitPath; 48 49 /** The callout priority. */ 50 const callout::Priority iv_priority; 51 52 /** True, if guard is required. False, otherwise. */ 53 const bool iv_guard; 54 55 public: 56 void resolve(ServiceData& io_sd) const override; 57 }; 58 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, 74 callout::Priority i_priority, bool i_guard) : 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 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, 116 callout::Priority i_priority, bool i_guard) : 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 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, 151 callout::Priority i_priority, bool i_guard) : 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 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 */ 179 ProcedureCalloutResolution(const callout::Procedure& i_procedure, 180 callout::Priority i_priority) : 181 iv_procedure(i_procedure), 182 iv_priority(i_priority) 183 {} 184 185 private: 186 /** The procedure callout type. */ 187 const callout::Procedure iv_procedure; 188 189 /** The callout priority. */ 190 const callout::Priority iv_priority; 191 192 public: 193 void resolve(ServiceData& io_sd) const override; 194 }; 195 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, 206 callout::Priority i_priority) : 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 222 /** 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 /** 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. 255 */ 256 class ResolutionList : public Resolution 257 { 258 public: 259 /** @brief Default constructor. */ 260 ResolutionList() = default; 261 262 private: 263 /** The resolution list. */ 264 std::vector<std::shared_ptr<Resolution>> iv_list; 265 266 public: 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. 277 void resolve(ServiceData& io_sd) const override 278 { 279 for (const auto& e : iv_list) 280 { 281 e->resolve(io_sd); 282 } 283 } 284 }; 285 286 } // namespace analyzer 287