Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 2 | #include <isolator/hei_isolation_node.hpp> |
Zane Shelley | ca9f625 | 2019-10-25 21:17:30 -0500 | [diff] [blame] | 3 | #include <isolator/hei_isolator.hpp> |
Zane Shelley | 75e68e9 | 2019-10-18 16:16:23 -0500 | [diff] [blame] | 4 | #include <register/hei_hardware_register.hpp> |
Zane Shelley | fc7ab19 | 2019-09-27 15:45:16 -0500 | [diff] [blame] | 5 | #include <util/hei_flyweight.hpp> |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 6 | |
Zane Shelley | 75e68e9 | 2019-10-18 16:16:23 -0500 | [diff] [blame] | 7 | // BEGIN temporary code |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 8 | #include <isolator/hei_isolation_node.hpp> |
Zane Shelley | b0559b9 | 2019-12-05 22:18:20 -0600 | [diff] [blame] | 9 | #include <register/hei_operator_register.hpp> |
Zane Shelley | 75e68e9 | 2019-10-18 16:16:23 -0500 | [diff] [blame] | 10 | #include <register/hei_scom_register.hpp> |
| 11 | // END temporary code |
| 12 | |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 13 | namespace libhei |
| 14 | { |
| 15 | |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 16 | ReturnCode Isolator::initialize(void* i_buffer, size_t i_bufferSize, |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 17 | bool i_forceInit) |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 18 | { |
| 19 | ReturnCode rc; |
| 20 | |
| 21 | // BEGIN temporary code |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 22 | HEI_INF("Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize, |
| 23 | i_forceInit); |
Zane Shelley | 65ed96a | 2019-10-14 13:06:11 -0500 | [diff] [blame] | 24 | |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 25 | auto& scom_fw = Flyweight<ScomRegister>::getSingleton(); |
| 26 | auto& idScom_fw = Flyweight<IdScomRegister>::getSingleton(); |
| 27 | auto& isoNode_fw = Flyweight<IsolationNode>::getSingleton(); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 28 | |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 29 | auto& idScom0 = idScom_fw.get(IdScomRegister{ |
| 30 | static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x1111), |
| 31 | REG_INST_DEFAULT, REG_ACCESS_RW, 0x80000000FF000000}); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 32 | |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 33 | auto& scom0 = scom_fw.get(ScomRegister{ |
| 34 | static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x2222), |
| 35 | REG_INST_DEFAULT, REG_ACCESS_RW, 0x00FF0000}); |
| 36 | |
| 37 | auto& node0 = isoNode_fw.get(IsolationNode{idScom0}); |
| 38 | auto& node1 = isoNode_fw.get(IsolationNode{scom0}); |
| 39 | |
| 40 | node0.addRule(ATTN_TYPE_CHECKSTOP, &idScom0); |
| 41 | node0.addChild(48, &node1); |
| 42 | |
| 43 | node1.addRule(ATTN_TYPE_CHECKSTOP, &scom0); |
| 44 | |
| 45 | iv_isoStart[static_cast<ChipType_t>(0xdeadbeef)].push_back( |
| 46 | {&node0, ATTN_TYPE_CHECKSTOP}); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 47 | // END temporary code |
| 48 | |
| 49 | return rc; |
| 50 | } |
| 51 | |
| 52 | void Isolator::uninitialize() |
| 53 | { |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 54 | // Remove all of the IsolationNode objects stored in the flyweights. This |
| 55 | // must be done before removing the HardwareRegister objects |
| 56 | Flyweight<IsolationNode>::getSingleton().clear(); |
| 57 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 58 | // Must flush the hardware register cache before deleting any |
| 59 | // HardwareRegister objects. |
| 60 | HardwareRegister::flushAll(); |
| 61 | |
Zane Shelley | 7bf1f6d | 2019-10-18 16:03:51 -0500 | [diff] [blame] | 62 | // Remove all of the HardwareRegister objects stored in the flyweights. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 63 | Flyweight<ScomRegister>::getSingleton().clear(); |
| 64 | Flyweight<IdScomRegister>::getSingleton().clear(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 65 | } |
| 66 | |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 67 | ReturnCode Isolator::isolate(const std::vector<Chip>& i_chipList, |
| 68 | IsolationData& o_isoData) const |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 69 | { |
| 70 | ReturnCode rc; |
| 71 | |
| 72 | // Flush the isolation data to ensure a clean slate. |
Zane Shelley | 93b61ad | 2019-10-16 20:41:03 -0500 | [diff] [blame] | 73 | o_isoData.flush(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 74 | |
Zane Shelley | d0af358 | 2019-09-19 10:48:59 -0500 | [diff] [blame] | 75 | // Flush the hardware register cache to avoid using stale data. |
| 76 | HardwareRegister::flushAll(); |
| 77 | |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 78 | // Analyze active error on each chip. |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 79 | for (const auto& chip : i_chipList) |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 80 | { |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 81 | // BEGIN temporary code |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 82 | HEI_INF("Isolator::isolate(%p,%u)", chip.getChip(), chip.getType()); |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 83 | |
| 84 | // Isolation objects for this chip's type must exist. |
| 85 | const auto& chip_itr = iv_isoStart.find(chip.getType()); |
| 86 | HEI_ASSERT(iv_isoStart.end() != chip_itr); |
| 87 | |
| 88 | for (const auto& pair : chip_itr->second) |
| 89 | { |
| 90 | if (pair.first->analyze(chip, pair.second, o_isoData)) |
| 91 | { |
| 92 | for (const auto& sig : o_isoData.getSignatureList()) |
| 93 | { |
| 94 | HEI_INF("Signature(%p,0x%x,0x%x,0x%x,0x%x)", |
| 95 | sig.getChip().getChip(), sig.getId(), |
| 96 | sig.getInstance(), sig.getBit(), sig.getAttnType()); |
| 97 | } |
| 98 | } |
| 99 | } |
Zane Shelley | 61565dc | 2019-09-18 21:57:10 -0500 | [diff] [blame] | 100 | // END temporary code |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 101 | } |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 102 | |
| 103 | return rc; |
| 104 | } |
| 105 | |
| 106 | } // end namespace libhei |