blob: e9770548ccd1c1c22c850c94cfc45b83962daac3 [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001
2#include <isolator/hei_isolator.hpp>
Zane Shelley7bf1f6d2019-10-18 16:03:51 -05003#include <isolator/hei_isolation_node.hpp>
Zane Shelley75e68e92019-10-18 16:16:23 -05004#include <register/hei_hardware_register.hpp>
Zane Shelleyfc7ab192019-09-27 15:45:16 -05005#include <util/hei_flyweight.hpp>
Zane Shelley5a266612019-08-15 16:23:53 -05006
Zane Shelley75e68e92019-10-18 16:16:23 -05007// BEGIN temporary code
8#include <register/hei_scom_register.hpp>
9// END temporary code
10
Zane Shelley5a266612019-08-15 16:23:53 -050011namespace libhei
12{
13
14ReturnCode Isolator::initialize( void * i_buffer, size_t i_bufferSize,
15 bool i_forceInit )
16{
17 ReturnCode rc;
18
19 // BEGIN temporary code
20 HEI_INF( "Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize,
21 i_forceInit );
Zane Shelley65ed96a2019-10-14 13:06:11 -050022
Zane Shelley8deb0902019-10-14 15:52:27 -050023 Flyweight<ScomRegister> & sfw = Flyweight<ScomRegister>::getSingleton();
24 Flyweight<IdScomRegister> & ifw = Flyweight<IdScomRegister>::getSingleton();
25
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 } );
30
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 Shelley5a266612019-08-15 16:23:53 -050037 // END temporary code
38
39 return rc;
40}
41
42void Isolator::uninitialize()
43{
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050044 // 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 Shelleyd0af3582019-09-19 10:48:59 -050048 // Must flush the hardware register cache before deleting any
49 // HardwareRegister objects.
50 HardwareRegister::flushAll();
51
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050052 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley8deb0902019-10-14 15:52:27 -050053 Flyweight<ScomRegister>::getSingleton().clear();
54 Flyweight<IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050055}
56
Zane Shelleyb406de42019-09-09 16:10:38 -050057ReturnCode Isolator::isolate( const std::vector<Chip> & i_chipList,
58 IsolationData & o_isoData ) const
Zane Shelley5a266612019-08-15 16:23:53 -050059{
60 ReturnCode rc;
61
62 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050063 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050064
Zane Shelleyd0af3582019-09-19 10:48:59 -050065 // Flush the hardware register cache to avoid using stale data.
66 HardwareRegister::flushAll();
67
Zane Shelley61565dc2019-09-18 21:57:10 -050068 // Analyze active error on each chip.
Zane Shelleyb406de42019-09-09 16:10:38 -050069 for ( auto const & chip : i_chipList )
70 {
Zane Shelley61565dc2019-09-18 21:57:10 -050071 // BEGIN temporary code
Zane Shelleyb406de42019-09-09 16:10:38 -050072 HEI_INF( "Isolator::isolate(%p,%u)", chip.getChip(),
73 chip.getType() );
Zane Shelley61565dc2019-09-18 21:57:10 -050074 // END temporary code
Zane Shelleyb406de42019-09-09 16:10:38 -050075 }
Zane Shelley5a266612019-08-15 16:23:53 -050076
77 return rc;
78}
79
80} // end namespace libhei