Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | |
| 2 | #include <isolator/hei_isolator.hpp> |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame^] | 3 | #include <register/hei_scom_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 | |
| 6 | namespace libhei |
| 7 | { |
| 8 | |
| 9 | ReturnCode Isolator::initialize( void * i_buffer, size_t i_bufferSize, |
| 10 | bool i_forceInit ) |
| 11 | { |
| 12 | ReturnCode rc; |
| 13 | |
| 14 | // BEGIN temporary code |
| 15 | HEI_INF( "Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize, |
| 16 | i_forceInit ); |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 17 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame^] | 18 | Flyweight<ScomRegister> & sfw = Flyweight<ScomRegister>::getSingleton(); |
| 19 | Flyweight<IdScomRegister> & ifw = Flyweight<IdScomRegister>::getSingleton(); |
| 20 | |
| 21 | sfw.get( ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 22 | REG_INST_DEFAULT, REG_ACCESS_RW, 0x01234567 } ); |
| 23 | sfw.get( ScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 24 | REG_INST_DEFAULT, REG_ACCESS_RW, 0x00112233 } ); |
| 25 | |
| 26 | ifw.get( IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 27 | REG_INST_DEFAULT, REG_ACCESS_RW, |
| 28 | 0x0123456789abcdef } ); |
| 29 | ifw.get( IdScomRegister { CHIP_TYPE_INVALID, REG_ID_INVALID, |
| 30 | REG_INST_DEFAULT, REG_ACCESS_RW, |
| 31 | 0x0011223344556677 } ); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 32 | // END temporary code |
| 33 | |
| 34 | return rc; |
| 35 | } |
| 36 | |
| 37 | void Isolator::uninitialize() |
| 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 | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 43 | // BEGIN temporary code |
| 44 | HEI_INF( "Isolator::uninitialize()" ); |
| 45 | // END temporary code |
Zane Shelley | fc7ab19 | 2019-09-27 15:45:16 -0500 | [diff] [blame] | 46 | |
| 47 | // Remove all of the isolation objects stored in the flyweights. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame^] | 48 | Flyweight<ScomRegister>::getSingleton().clear(); |
| 49 | Flyweight<IdScomRegister>::getSingleton().clear(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 50 | } |
| 51 | |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 52 | ReturnCode Isolator::isolate( const std::vector<Chip> & i_chipList, |
| 53 | IsolationData & o_isoData ) const |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 54 | { |
| 55 | ReturnCode rc; |
| 56 | |
| 57 | // Flush the isolation data to ensure a clean slate. |
| 58 | o_isoData.clear(); |
| 59 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 60 | // Flush the hardware register cache to avoid using stale data. |
| 61 | HardwareRegister::flushAll(); |
| 62 | |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 63 | // Analyze active error on each chip. |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 64 | for ( auto const & chip : i_chipList ) |
| 65 | { |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 66 | // In order to access hardware, we must tell the HardwareRegisters which |
| 67 | // chip to access. |
| 68 | HardwareRegister::setAccessor( chip ); |
| 69 | |
| 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 |
| 74 | |
| 75 | // Clean up the hardware accessor chip to prevent accidental hardware |
| 76 | // access. |
| 77 | HardwareRegister::clearAccessor(); |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 78 | } |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 79 | |
| 80 | return rc; |
| 81 | } |
| 82 | |
| 83 | } // end namespace libhei |