blob: 0b3f88fac4f27e535601f93ceeea3f7ee708e72b [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001
2#include <isolator/hei_isolator.hpp>
Zane Shelley61565dc2019-09-18 21:57:10 -05003#include <register/hei_hardware_register.hpp>
Zane Shelleyfc7ab192019-09-27 15:45:16 -05004#include <util/hei_flyweight.hpp>
Zane Shelley5a266612019-08-15 16:23:53 -05005
6namespace libhei
7{
8
9ReturnCode 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 Shelley65ed96a2019-10-14 13:06:11 -050017
18 Flyweight<HardwareRegister>::getSingleton().get( HardwareRegister {} );
Zane Shelley5a266612019-08-15 16:23:53 -050019 // END temporary code
20
21 return rc;
22}
23
24void Isolator::uninitialize()
25{
Zane Shelleyd0af3582019-09-19 10:48:59 -050026 // Must flush the hardware register cache before deleting any
27 // HardwareRegister objects.
28 HardwareRegister::flushAll();
29
Zane Shelley5a266612019-08-15 16:23:53 -050030 // BEGIN temporary code
31 HEI_INF( "Isolator::uninitialize()" );
32 // END temporary code
Zane Shelleyfc7ab192019-09-27 15:45:16 -050033
34 // Remove all of the isolation objects stored in the flyweights.
35 Flyweight<HardwareRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050036}
37
Zane Shelleyb406de42019-09-09 16:10:38 -050038ReturnCode Isolator::isolate( const std::vector<Chip> & i_chipList,
39 IsolationData & o_isoData ) const
Zane Shelley5a266612019-08-15 16:23:53 -050040{
41 ReturnCode rc;
42
43 // Flush the isolation data to ensure a clean slate.
44 o_isoData.clear();
45
Zane Shelleyd0af3582019-09-19 10:48:59 -050046 // Flush the hardware register cache to avoid using stale data.
47 HardwareRegister::flushAll();
48
Zane Shelley61565dc2019-09-18 21:57:10 -050049 // Analyze active error on each chip.
Zane Shelleyb406de42019-09-09 16:10:38 -050050 for ( auto const & chip : i_chipList )
51 {
Zane Shelley61565dc2019-09-18 21:57:10 -050052 // 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 Shelleyb406de42019-09-09 16:10:38 -050057 HEI_INF( "Isolator::isolate(%p,%u)", chip.getChip(),
58 chip.getType() );
Zane Shelley61565dc2019-09-18 21:57:10 -050059 // END temporary code
60
61 // Clean up the hardware accessor chip to prevent accidental hardware
62 // access.
63 HardwareRegister::clearAccessor();
Zane Shelleyb406de42019-09-09 16:10:38 -050064 }
Zane Shelley5a266612019-08-15 16:23:53 -050065
66 return rc;
67}
68
69} // end namespace libhei