blob: 68dda7db068f560f307af1c0118e7957b699554b [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
Zane Shelley11b89942019-11-07 11:07:28 -06008#include <isolator/hei_isolation_node.hpp>
Zane Shelley75e68e92019-10-18 16:16:23 -05009#include <register/hei_scom_register.hpp>
10// END temporary code
11
Zane Shelley5a266612019-08-15 16:23:53 -050012namespace libhei
13{
14
Zane Shelleyfe27b652019-10-28 11:33:07 -050015ReturnCode Isolator::initialize(void* i_buffer, size_t i_bufferSize,
Zane Shelley83da2452019-10-25 15:45:34 -050016 bool i_forceInit)
Zane Shelley5a266612019-08-15 16:23:53 -050017{
18 ReturnCode rc;
19
20 // BEGIN temporary code
Zane Shelley83da2452019-10-25 15:45:34 -050021 HEI_INF("Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize,
22 i_forceInit);
Zane Shelley65ed96a2019-10-14 13:06:11 -050023
Zane Shelley11b89942019-11-07 11:07:28 -060024 auto& scom_fw = Flyweight<ScomRegister>::getSingleton();
25 auto& idScom_fw = Flyweight<IdScomRegister>::getSingleton();
26 auto& isoNode_fw = Flyweight<IsolationNode>::getSingleton();
Zane Shelley8deb0902019-10-14 15:52:27 -050027
Zane Shelley11b89942019-11-07 11:07:28 -060028 auto& idScom0 = idScom_fw.get(IdScomRegister{
29 static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x1111),
30 REG_INST_DEFAULT, REG_ACCESS_RW, 0x80000000FF000000});
Zane Shelley8deb0902019-10-14 15:52:27 -050031
Zane Shelley11b89942019-11-07 11:07:28 -060032 auto& scom0 = scom_fw.get(ScomRegister{
33 static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x2222),
34 REG_INST_DEFAULT, REG_ACCESS_RW, 0x00FF0000});
35
36 auto& node0 = isoNode_fw.get(IsolationNode{idScom0});
37 auto& node1 = isoNode_fw.get(IsolationNode{scom0});
38
39 node0.addRule(ATTN_TYPE_CHECKSTOP, &idScom0);
40 node0.addChild(48, &node1);
41
42 node1.addRule(ATTN_TYPE_CHECKSTOP, &scom0);
43
44 iv_isoStart[static_cast<ChipType_t>(0xdeadbeef)].push_back(
45 {&node0, ATTN_TYPE_CHECKSTOP});
Zane Shelley5a266612019-08-15 16:23:53 -050046 // END temporary code
47
48 return rc;
49}
50
51void Isolator::uninitialize()
52{
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050053 // Remove all of the IsolationNode objects stored in the flyweights. This
54 // must be done before removing the HardwareRegister objects
55 Flyweight<IsolationNode>::getSingleton().clear();
56
Zane Shelleyd0af3582019-09-19 10:48:59 -050057 // Must flush the hardware register cache before deleting any
58 // HardwareRegister objects.
59 HardwareRegister::flushAll();
60
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050061 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley8deb0902019-10-14 15:52:27 -050062 Flyweight<ScomRegister>::getSingleton().clear();
63 Flyweight<IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050064}
65
Zane Shelleyfe27b652019-10-28 11:33:07 -050066ReturnCode Isolator::isolate(const std::vector<Chip>& i_chipList,
67 IsolationData& o_isoData) const
Zane Shelley5a266612019-08-15 16:23:53 -050068{
69 ReturnCode rc;
70
71 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050072 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050073
Zane Shelleyd0af3582019-09-19 10:48:59 -050074 // Flush the hardware register cache to avoid using stale data.
75 HardwareRegister::flushAll();
76
Zane Shelley61565dc2019-09-18 21:57:10 -050077 // Analyze active error on each chip.
Zane Shelleyfe27b652019-10-28 11:33:07 -050078 for (const auto& chip : i_chipList)
Zane Shelleyb406de42019-09-09 16:10:38 -050079 {
Zane Shelley61565dc2019-09-18 21:57:10 -050080 // BEGIN temporary code
Zane Shelley83da2452019-10-25 15:45:34 -050081 HEI_INF("Isolator::isolate(%p,%u)", chip.getChip(), chip.getType());
Zane Shelley11b89942019-11-07 11:07:28 -060082
83 // Isolation objects for this chip's type must exist.
84 const auto& chip_itr = iv_isoStart.find(chip.getType());
85 HEI_ASSERT(iv_isoStart.end() != chip_itr);
86
87 for (const auto& pair : chip_itr->second)
88 {
89 if (pair.first->analyze(chip, pair.second, o_isoData))
90 {
91 for (const auto& sig : o_isoData.getSignatureList())
92 {
93 HEI_INF("Signature(%p,0x%x,0x%x,0x%x,0x%x)",
94 sig.getChip().getChip(), sig.getId(),
95 sig.getInstance(), sig.getBit(), sig.getAttnType());
96 }
97 }
98 }
Zane Shelley61565dc2019-09-18 21:57:10 -050099 // END temporary code
Zane Shelleyb406de42019-09-09 16:10:38 -0500100 }
Zane Shelley5a266612019-08-15 16:23:53 -0500101
102 return rc;
103}
104
105} // end namespace libhei