Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | |
| 2 | #include <isolator/hei_isolator.hpp> |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 3 | #include <isolator/hei_isolation_node.hpp> |
Zane Shelley | 75e68e9 | 2019-10-18 16:16:23 -0500 | [diff] [blame] | 4 | #include <register/hei_hardware_register.hpp> |
Zane Shelley | fc7ab19 | 2019-09-27 15:45:16 -0500 | [diff] [blame] | 5 | #include <util/hei_flyweight.hpp> |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 6 | |
Zane Shelley | 75e68e9 | 2019-10-18 16:16:23 -0500 | [diff] [blame] | 7 | // BEGIN temporary code |
| 8 | #include <register/hei_scom_register.hpp> |
| 9 | // END temporary code |
| 10 | |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 11 | namespace libhei |
| 12 | { |
| 13 | |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame^] | 14 | ReturnCode Isolator::initialize(void * i_buffer, size_t i_bufferSize, |
| 15 | bool i_forceInit) |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 16 | { |
| 17 | ReturnCode rc; |
| 18 | |
| 19 | // BEGIN temporary code |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame^] | 20 | HEI_INF("Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize, |
| 21 | i_forceInit); |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 22 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 23 | Flyweight<ScomRegister> & sfw = Flyweight<ScomRegister>::getSingleton(); |
| 24 | Flyweight<IdScomRegister> & ifw = Flyweight<IdScomRegister>::getSingleton(); |
| 25 | |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame^] | 26 | sfw.get(ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 27 | REG_INST_DEFAULT, REG_ACCESS_RW, 0x01234567 }); |
| 28 | sfw.get(ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 29 | REG_INST_DEFAULT, REG_ACCESS_RW, 0x00112233 }); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 30 | |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame^] | 31 | ifw.get(IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 32 | REG_INST_DEFAULT, REG_ACCESS_RW, |
| 33 | 0x0123456789abcdef }); |
| 34 | ifw.get(IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 35 | REG_INST_DEFAULT, REG_ACCESS_RW, |
| 36 | 0x0011223344556677 }); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 37 | // END temporary code |
| 38 | |
| 39 | return rc; |
| 40 | } |
| 41 | |
| 42 | void Isolator::uninitialize() |
| 43 | { |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 44 | // Remove all of the IsolationNode objects stored in the flyweights. This |
| 45 | // must be done before removing the HardwareRegister objects |
| 46 | Flyweight<IsolationNode>::getSingleton().clear(); |
| 47 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 48 | // Must flush the hardware register cache before deleting any |
| 49 | // HardwareRegister objects. |
| 50 | HardwareRegister::flushAll(); |
| 51 | |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 52 | // Remove all of the HardwareRegister objects stored in the flyweights. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 53 | Flyweight<ScomRegister>::getSingleton().clear(); |
| 54 | Flyweight<IdScomRegister>::getSingleton().clear(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 55 | } |
| 56 | |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame^] | 57 | ReturnCode Isolator::isolate(const std::vector<Chip> & i_chipList, |
| 58 | IsolationData & o_isoData) const |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 59 | { |
| 60 | ReturnCode rc; |
| 61 | |
| 62 | // Flush the isolation data to ensure a clean slate. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 63 | o_isoData.flush(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 64 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 65 | // Flush the hardware register cache to avoid using stale data. |
| 66 | HardwareRegister::flushAll(); |
| 67 | |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 68 | // Analyze active error on each chip. |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame^] | 69 | for (auto const & chip : i_chipList) |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 70 | { |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 71 | // BEGIN temporary code |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame^] | 72 | HEI_INF("Isolator::isolate(%p,%u)", chip.getChip(), chip.getType()); |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 73 | // END temporary code |
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 | return rc; |
| 77 | } |
| 78 | |
| 79 | } // end namespace libhei |