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