blob: 7e3a0327b4c1a0939f978f33519dee9f17065cda [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 Shelleyb0559b92019-12-05 22:18:20 -06009#include <register/hei_operator_register.hpp>
Zane Shelley75e68e92019-10-18 16:16:23 -050010#include <register/hei_scom_register.hpp>
11// END temporary code
12
Zane Shelley5a266612019-08-15 16:23:53 -050013namespace libhei
14{
15
Zane Shelleydd109cc2020-04-30 21:41:41 -050016void Isolator::initialize(void* i_buffer, size_t i_bufferSize)
Zane Shelley5a266612019-08-15 16:23:53 -050017{
Zane Shelley5a266612019-08-15 16:23:53 -050018 // BEGIN temporary code
Zane Shelleydd109cc2020-04-30 21:41:41 -050019 HEI_INF("Isolator::initialize(%p,%" PRIu64 ")", i_buffer,
20 (uint64_t)i_bufferSize);
Zane Shelley65ed96a2019-10-14 13:06:11 -050021
Zane Shelley11b89942019-11-07 11:07:28 -060022 auto& scom_fw = Flyweight<ScomRegister>::getSingleton();
23 auto& idScom_fw = Flyweight<IdScomRegister>::getSingleton();
24 auto& isoNode_fw = Flyweight<IsolationNode>::getSingleton();
Zane Shelley8deb0902019-10-14 15:52:27 -050025
Zane Shelley11b89942019-11-07 11:07:28 -060026 auto& idScom0 = idScom_fw.get(IdScomRegister{
27 static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x1111),
28 REG_INST_DEFAULT, REG_ACCESS_RW, 0x80000000FF000000});
Zane Shelley8deb0902019-10-14 15:52:27 -050029
Zane Shelley11b89942019-11-07 11:07:28 -060030 auto& scom0 = scom_fw.get(ScomRegister{
31 static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x2222),
32 REG_INST_DEFAULT, REG_ACCESS_RW, 0x00FF0000});
33
34 auto& node0 = isoNode_fw.get(IsolationNode{idScom0});
35 auto& node1 = isoNode_fw.get(IsolationNode{scom0});
36
37 node0.addRule(ATTN_TYPE_CHECKSTOP, &idScom0);
38 node0.addChild(48, &node1);
39
40 node1.addRule(ATTN_TYPE_CHECKSTOP, &scom0);
41
42 iv_isoStart[static_cast<ChipType_t>(0xdeadbeef)].push_back(
43 {&node0, ATTN_TYPE_CHECKSTOP});
Zane Shelley5a266612019-08-15 16:23:53 -050044 // END temporary code
Zane Shelley5a266612019-08-15 16:23:53 -050045}
46
47void Isolator::uninitialize()
48{
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050049 // Remove all of the IsolationNode objects stored in the flyweights. This
50 // must be done before removing the HardwareRegister objects
51 Flyweight<IsolationNode>::getSingleton().clear();
52
Zane Shelleyd0af3582019-09-19 10:48:59 -050053 // Must flush the hardware register cache before deleting any
54 // HardwareRegister objects.
55 HardwareRegister::flushAll();
56
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050057 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley8deb0902019-10-14 15:52:27 -050058 Flyweight<ScomRegister>::getSingleton().clear();
59 Flyweight<IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050060}
61
Zane Shelley229c1552020-05-04 22:44:15 -050062void Isolator::isolate(const std::vector<Chip>& i_chipList,
63 IsolationData& o_isoData) const
Zane Shelley5a266612019-08-15 16:23:53 -050064{
Zane Shelley5a266612019-08-15 16:23:53 -050065 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050066 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050067
Zane Shelleyd0af3582019-09-19 10:48:59 -050068 // Flush the hardware register cache to avoid using stale data.
69 HardwareRegister::flushAll();
70
Zane Shelley61565dc2019-09-18 21:57:10 -050071 // Analyze active error on each chip.
Zane Shelleyfe27b652019-10-28 11:33:07 -050072 for (const auto& chip : i_chipList)
Zane Shelleyb406de42019-09-09 16:10:38 -050073 {
Zane Shelley61565dc2019-09-18 21:57:10 -050074 // BEGIN temporary code
Zane Shelley83da2452019-10-25 15:45:34 -050075 HEI_INF("Isolator::isolate(%p,%u)", chip.getChip(), chip.getType());
Zane Shelley11b89942019-11-07 11:07:28 -060076
77 // Isolation objects for this chip's type must exist.
78 const auto& chip_itr = iv_isoStart.find(chip.getType());
79 HEI_ASSERT(iv_isoStart.end() != chip_itr);
80
81 for (const auto& pair : chip_itr->second)
82 {
83 if (pair.first->analyze(chip, pair.second, o_isoData))
84 {
85 for (const auto& sig : o_isoData.getSignatureList())
86 {
87 HEI_INF("Signature(%p,0x%x,0x%x,0x%x,0x%x)",
88 sig.getChip().getChip(), sig.getId(),
89 sig.getInstance(), sig.getBit(), sig.getAttnType());
90 }
91 }
92 }
Zane Shelley61565dc2019-09-18 21:57:10 -050093 // END temporary code
Zane Shelleyb406de42019-09-09 16:10:38 -050094 }
Zane Shelley5a266612019-08-15 16:23:53 -050095}
96
97} // end namespace libhei