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