Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | |
| 2 | #include <isolator/hei_isolator.hpp> |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -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 | |
| 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 | |
| 18 | Flyweight<HardwareRegister>::getSingleton().get( HardwareRegister {} ); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 19 | // END temporary code |
| 20 | |
| 21 | return rc; |
| 22 | } |
| 23 | |
| 24 | void Isolator::uninitialize() |
| 25 | { |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 26 | // Must flush the hardware register cache before deleting any |
| 27 | // HardwareRegister objects. |
| 28 | HardwareRegister::flushAll(); |
| 29 | |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 30 | // BEGIN temporary code |
| 31 | HEI_INF( "Isolator::uninitialize()" ); |
| 32 | // END temporary code |
Zane Shelley | fc7ab19 | 2019-09-27 15:45:16 -0500 | [diff] [blame] | 33 | |
| 34 | // Remove all of the isolation objects stored in the flyweights. |
| 35 | Flyweight<HardwareRegister>::getSingleton().clear(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 36 | } |
| 37 | |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 38 | ReturnCode Isolator::isolate( const std::vector<Chip> & i_chipList, |
| 39 | IsolationData & o_isoData ) const |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 40 | { |
| 41 | ReturnCode rc; |
| 42 | |
| 43 | // Flush the isolation data to ensure a clean slate. |
| 44 | o_isoData.clear(); |
| 45 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 46 | // Flush the hardware register cache to avoid using stale data. |
| 47 | HardwareRegister::flushAll(); |
| 48 | |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 49 | // Analyze active error on each chip. |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 50 | for ( auto const & chip : i_chipList ) |
| 51 | { |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 52 | // In order to access hardware, we must tell the HardwareRegisters which |
| 53 | // chip to access. |
| 54 | HardwareRegister::setAccessor( chip ); |
| 55 | |
| 56 | // BEGIN temporary code |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 57 | HEI_INF( "Isolator::isolate(%p,%u)", chip.getChip(), |
| 58 | chip.getType() ); |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 59 | // END temporary code |
| 60 | |
| 61 | // Clean up the hardware accessor chip to prevent accidental hardware |
| 62 | // access. |
| 63 | HardwareRegister::clearAccessor(); |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 64 | } |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 65 | |
| 66 | return rc; |
| 67 | } |
| 68 | |
| 69 | } // end namespace libhei |