Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 2 | #include <hei_includes.hpp> |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 3 | #include <isolator/hei_isolation_node.hpp> |
Zane Shelley | ca9f625 | 2019-10-25 21:17:30 -0500 | [diff] [blame] | 4 | #include <isolator/hei_isolator.hpp> |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 5 | #include <register/hei_operator_register.hpp> |
Zane Shelley | 75e68e9 | 2019-10-18 16:16:23 -0500 | [diff] [blame] | 6 | #include <register/hei_scom_register.hpp> |
Zane Shelley | dd69c96 | 2020-05-05 22:19:11 -0500 | [diff] [blame] | 7 | #include <util/hei_flyweight.hpp> |
Zane Shelley | 75e68e9 | 2019-10-18 16:16:23 -0500 | [diff] [blame] | 8 | |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 9 | namespace libhei |
| 10 | { |
| 11 | |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 12 | //------------------------------------------------------------------------------ |
| 13 | |
| 14 | // Definitions for the interfaces defined in hei_main.hpp. |
| 15 | |
| 16 | void initialize(void* i_buffer, size_t i_bufferSize) |
| 17 | { |
| 18 | Isolator::getSingleton().initialize(i_buffer, i_bufferSize); |
| 19 | } |
| 20 | |
| 21 | void uninitialize() |
| 22 | { |
| 23 | Isolator::getSingleton().uninitialize(); |
| 24 | } |
| 25 | |
| 26 | void isolate(const std::vector<Chip>& i_chipList, IsolationData& o_isoData) |
| 27 | { |
| 28 | Isolator::getSingleton().isolate(i_chipList, o_isoData); |
| 29 | } |
| 30 | |
| 31 | //------------------------------------------------------------------------------ |
| 32 | |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 33 | void Isolator::uninitialize() |
| 34 | { |
Zane Shelley | d39aa57 | 2020-05-14 10:35:57 -0500 | [diff] [blame] | 35 | // Clear all of the isolation objects. |
Zane Shelley | dd69c96 | 2020-05-05 22:19:11 -0500 | [diff] [blame] | 36 | iv_isoChips.clear(); |
| 37 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 38 | // Must flush the hardware register cache before deleting any |
| 39 | // HardwareRegister objects. |
| 40 | HardwareRegister::flushAll(); |
| 41 | |
Zane Shelley | f8c92f9 | 2020-05-16 10:17:16 -0500 | [diff] [blame] | 42 | // Clear the operator register flyweights. |
| 43 | Flyweight<const ConstantRegister>::getSingleton().clear(); |
| 44 | Flyweight<const AndRegister>::getSingleton().clear(); |
| 45 | Flyweight<const OrRegister>::getSingleton().clear(); |
| 46 | Flyweight<const NotRegister>::getSingleton().clear(); |
| 47 | Flyweight<const LeftShiftRegister>::getSingleton().clear(); |
| 48 | Flyweight<const RightShiftRegister>::getSingleton().clear(); |
| 49 | |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 50 | // Remove all of the HardwareRegister objects stored in the flyweights. |
Zane Shelley | 981e56a | 2020-05-11 21:24:20 -0500 | [diff] [blame] | 51 | Flyweight<const ScomRegister>::getSingleton().clear(); |
| 52 | Flyweight<const IdScomRegister>::getSingleton().clear(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 53 | } |
| 54 | |
Zane Shelley | 229c155 | 2020-05-04 22:44:15 -0500 | [diff] [blame] | 55 | void Isolator::isolate(const std::vector<Chip>& i_chipList, |
| 56 | IsolationData& o_isoData) const |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 57 | { |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 58 | // Flush the isolation data to ensure a clean slate. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 59 | o_isoData.flush(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 60 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 61 | // Flush the hardware register cache to avoid using stale data. |
| 62 | HardwareRegister::flushAll(); |
| 63 | |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 64 | // Analyze active error on each chip. |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 65 | for (const auto& chip : i_chipList) |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 66 | { |
Zane Shelley | dd69c96 | 2020-05-05 22:19:11 -0500 | [diff] [blame] | 67 | // Isolation objects for this chip's type must exist. |
| 68 | const auto& itr = iv_isoChips.find(chip.getType()); |
| 69 | HEI_ASSERT(iv_isoChips.end() != itr); |
| 70 | |
| 71 | // Analyze this chip. |
| 72 | itr->second->analyze(chip, o_isoData); |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 73 | } |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | } // end namespace libhei |