Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Zane Shelley | dd69c96 | 2020-05-05 22:19:11 -0500 | [diff] [blame] | 3 | #include <chip_data/hei_chip_data.hpp> |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 4 | #include <hei_isolation_data.hpp> |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 5 | #include <isolator/hei_isolation_node.hpp> |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 6 | |
| 7 | namespace libhei |
| 8 | { |
| 9 | |
| 10 | /** |
| 11 | * @brief This class is a complement to the main APIs. Its purpose is to store |
| 12 | * and maintain all of the objects necessary for isolation. |
| 13 | * |
| 14 | * The intended flow is to: |
| 15 | * - Create a singleton instance of an Isolator object via getSingleton(). |
| 16 | * - Use initialize() to input each necessary Chip Data File provided by the |
| 17 | * user application. |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 18 | * - Call isolate() to find all active errors being reported by the given list |
| 19 | * of chips. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 20 | * - Once isolation is no longer needed, use uninitialize() to free up |
| 21 | * internal resources. |
| 22 | * |
| 23 | * The purpose of the singleton instance is to avoid initializing the object |
| 24 | * each time isolation is required. The data provided by the Chip Data Files is |
| 25 | * static. So reinitializing would be a waste of time, unless for some reason |
| 26 | * the Chip Data Files themselves are updated, which would require |
| 27 | * reinitialization anyway. Of course, leaving the object in memory chews up |
| 28 | * resources. So, some users may need to weigh performance vs. memory usage. |
| 29 | */ |
| 30 | class Isolator |
| 31 | { |
| 32 | private: // This class cannot be instantiated. Use getSingleton() instead. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 33 | /** @brief Default constructor. */ |
| 34 | Isolator() = default; |
| 35 | |
| 36 | /** @brief Destructor. */ |
| 37 | ~Isolator() |
| 38 | { |
| 39 | // Clear out all of the internal isolation objects. |
| 40 | uninitialize(); |
| 41 | } |
| 42 | |
| 43 | /** @brief Copy constructor. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 44 | Isolator(const Isolator&) = delete; |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 45 | |
| 46 | /** @brief Assignment operator. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 47 | Isolator& operator=(const Isolator&) = delete; |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 48 | |
Zane Shelley | dd69c96 | 2020-05-05 22:19:11 -0500 | [diff] [blame] | 49 | private: |
| 50 | /** Keeps track of all chip types that have been initialized. */ |
Zane Shelley | 4de8ff8 | 2020-05-14 15:39:01 -0500 | [diff] [blame] | 51 | IsolationChip::Map iv_isoChips; |
Zane Shelley | dd69c96 | 2020-05-05 22:19:11 -0500 | [diff] [blame] | 52 | |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 53 | public: |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 54 | /** @brief Provides access to a singleton instance of this object. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 55 | static Isolator& getSingleton() |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 56 | { |
| 57 | static Isolator theIsolator; |
| 58 | return theIsolator; |
| 59 | } |
| 60 | |
| 61 | /** @brief See API wrapper description in hei_main.hpp. */ |
Zane Shelley | dd69c96 | 2020-05-05 22:19:11 -0500 | [diff] [blame] | 62 | void initialize(void* i_buffer, size_t i_bufferSize) |
| 63 | { |
| 64 | parseChipDataFile(i_buffer, i_bufferSize, iv_isoChips); |
| 65 | } |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * @brief See API wrapper description in hei_main.hpp. |
| 69 | * |
| 70 | * This function is called in the destructor. Therefore, it should never |
| 71 | * throw an exception. |
| 72 | */ |
| 73 | void uninitialize(); |
| 74 | |
| 75 | /** @brief See API wrapper description in hei_main.hpp. */ |
Zane Shelley | 229c155 | 2020-05-04 22:44:15 -0500 | [diff] [blame] | 76 | void isolate(const std::vector<Chip>& i_chipList, |
| 77 | IsolationData& o_isoData) const; |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 78 | |
Caleb Palmer | e4ad4e3 | 2024-08-07 09:48:14 -0500 | [diff] [blame^] | 79 | #ifdef __HEI_ENABLE_HW_WRITE |
| 80 | /** |
| 81 | * @brief Performs the given write operation on the input signature. The |
| 82 | * node and bit in the input signature will determine which register |
| 83 | * and bit are to be written by the operation. |
| 84 | * @param i_op The given write operation rule. See the OpRuleName_t enum |
| 85 | * for supported values. |
| 86 | * @param i_sig The signature to determine what's to be written. |
| 87 | * @return True if write operation failed, false if successful. |
| 88 | */ |
| 89 | bool performWriteOp(OpRuleName_t i_op, Signature i_sig); |
| 90 | #endif |
| 91 | |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 92 | }; // end class Isolator |
| 93 | |
| 94 | } // end namespace libhei |