blob: 759eb1332c786b579d5f685159af4936794f0258 [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001
Zane Shelley7bf1f6d2019-10-18 16:03:51 -05002#include <isolator/hei_isolation_node.hpp>
Zane Shelleyca9f6252019-10-25 21:17:30 -05003#include <isolator/hei_isolator.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
Zane Shelleyfe27b652019-10-28 11:33:07 -050014ReturnCode Isolator::initialize(void* i_buffer, size_t i_bufferSize,
Zane Shelley83da2452019-10-25 15:45:34 -050015 bool i_forceInit)
Zane Shelley5a266612019-08-15 16:23:53 -050016{
17 ReturnCode rc;
18
19 // BEGIN temporary code
Zane Shelley83da2452019-10-25 15:45:34 -050020 HEI_INF("Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize,
21 i_forceInit);
Zane Shelley65ed96a2019-10-14 13:06:11 -050022
Zane Shelley7c8faa12019-10-28 22:26:28 -050023 Flyweight<ScomRegister>& sfw = Flyweight<ScomRegister>::getSingleton();
Zane Shelleyfe27b652019-10-28 11:33:07 -050024 Flyweight<IdScomRegister>& ifw = Flyweight<IdScomRegister>::getSingleton();
Zane Shelley8deb0902019-10-14 15:52:27 -050025
Zane Shelleyc4771992019-10-28 22:01:49 -050026 sfw.get(ScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
27 REG_ACCESS_RW, 0x01234567});
28 sfw.get(ScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
29 REG_ACCESS_RW, 0x00112233});
Zane Shelley8deb0902019-10-14 15:52:27 -050030
Zane Shelleyc4771992019-10-28 22:01:49 -050031 ifw.get(IdScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
32 REG_ACCESS_RW, 0x0123456789abcdef});
33 ifw.get(IdScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
34 REG_ACCESS_RW, 0x0011223344556677});
Zane Shelley5a266612019-08-15 16:23:53 -050035 // END temporary code
36
37 return rc;
38}
39
40void Isolator::uninitialize()
41{
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050042 // Remove all of the IsolationNode objects stored in the flyweights. This
43 // must be done before removing the HardwareRegister objects
44 Flyweight<IsolationNode>::getSingleton().clear();
45
Zane Shelleyd0af3582019-09-19 10:48:59 -050046 // Must flush the hardware register cache before deleting any
47 // HardwareRegister objects.
48 HardwareRegister::flushAll();
49
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050050 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley8deb0902019-10-14 15:52:27 -050051 Flyweight<ScomRegister>::getSingleton().clear();
52 Flyweight<IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050053}
54
Zane Shelleyfe27b652019-10-28 11:33:07 -050055ReturnCode Isolator::isolate(const std::vector<Chip>& i_chipList,
56 IsolationData& o_isoData) const
Zane Shelley5a266612019-08-15 16:23:53 -050057{
58 ReturnCode rc;
59
60 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050061 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050062
Zane Shelleyd0af3582019-09-19 10:48:59 -050063 // Flush the hardware register cache to avoid using stale data.
64 HardwareRegister::flushAll();
65
Zane Shelley61565dc2019-09-18 21:57:10 -050066 // Analyze active error on each chip.
Zane Shelleyfe27b652019-10-28 11:33:07 -050067 for (const auto& chip : i_chipList)
Zane Shelleyb406de42019-09-09 16:10:38 -050068 {
Zane Shelley61565dc2019-09-18 21:57:10 -050069 // BEGIN temporary code
Zane Shelley83da2452019-10-25 15:45:34 -050070 HEI_INF("Isolator::isolate(%p,%u)", chip.getChip(), chip.getType());
Zane Shelley61565dc2019-09-18 21:57:10 -050071 // END temporary code
Zane Shelleyb406de42019-09-09 16:10:38 -050072 }
Zane Shelley5a266612019-08-15 16:23:53 -050073
74 return rc;
75}
76
77} // end namespace libhei