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 | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 60 | /** @brief Resolves a clock callout service event. */ |
| 61 | class ClockCalloutResolution : public Resolution |
| 62 | { |
| 63 | public: |
| 64 | /** |
| 65 | * @brief Constructor from components. |
| 66 | * @param i_clockType The clock type. |
| 67 | * @param i_priority The callout priority. |
| 68 | * @param i_guard The guard type for this callout. |
| 69 | */ |
| 70 | ClockCalloutResolution(const callout::ClockType& i_clockType, |
| 71 | const callout::Priority& i_priority, bool i_guard) : |
| 72 | iv_clockType(i_clockType), |
| 73 | iv_priority(i_priority), iv_guard(i_guard) |
| 74 | {} |
| 75 | |
| 76 | private: |
| 77 | /** The clock type. */ |
| 78 | const callout::ClockType iv_clockType; |
| 79 | |
| 80 | /** The callout priority. */ |
| 81 | const callout::Priority iv_priority; |
| 82 | |
| 83 | /** True, if guard is required. False, otherwise. */ |
| 84 | const bool iv_guard; |
| 85 | |
| 86 | public: |
| 87 | void resolve(ServiceData& io_sd) const override; |
| 88 | }; |
| 89 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 90 | /** @brief Resolves a procedure callout service event. */ |
| 91 | class ProcedureCalloutResolution : public Resolution |
| 92 | { |
| 93 | public: |
| 94 | /** |
| 95 | * @brief Constructor from components. |
| 96 | * @param i_procedure The procedure callout type. |
| 97 | * @param i_priority The callout priority. |
| 98 | */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 99 | ProcedureCalloutResolution(const callout::Procedure& i_procedure, |
| 100 | const callout::Priority& i_priority) : |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 101 | iv_procedure(i_procedure), |
| 102 | iv_priority(i_priority) |
| 103 | {} |
| 104 | |
| 105 | private: |
| 106 | /** The procedure callout type. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 107 | const callout::Procedure iv_procedure; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 108 | |
| 109 | /** The callout priority. */ |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 110 | const callout::Priority iv_priority; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 111 | |
| 112 | public: |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 113 | void resolve(ServiceData& io_sd) const override; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | /** |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 117 | * @brief Contains a list of resolutions. This resolutions will be resolved the |
| 118 | * list in the order in which they were inputted into the constructor. |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 119 | */ |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 120 | class ResolutionList : public Resolution |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 121 | { |
| 122 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 123 | /** @brief Default constructor. */ |
| 124 | ResolutionList() = default; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 125 | |
| 126 | private: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 127 | /** The resolution list. */ |
| 128 | std::vector<std::shared_ptr<Resolution>> iv_list; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 129 | |
| 130 | public: |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 131 | /** |
| 132 | * @brief Adds a new resolution to the end of the list. |
| 133 | * @param i_resolution The new resolution |
| 134 | */ |
| 135 | void push(const std::shared_ptr<Resolution>& i_resolution) |
| 136 | { |
| 137 | iv_list.push_back(i_resolution); |
| 138 | } |
| 139 | |
| 140 | // Overloaded from parent. |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 141 | void resolve(ServiceData& io_sd) const override |
| 142 | { |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 143 | for (const auto& e : iv_list) |
| 144 | { |
| 145 | e->resolve(io_sd); |
| 146 | } |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 147 | } |
| 148 | }; |
| 149 | |
| 150 | } // namespace analyzer |