blob: db5668e1224a91dc0076e35b359372f4c7147d3e [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001
Zane Shelley3a02e242020-05-08 16:25:36 -05002#include <hei_includes.hpp>
Zane Shelley7bf1f6d2019-10-18 16:03:51 -05003#include <isolator/hei_isolation_node.hpp>
Zane Shelleyca9f6252019-10-25 21:17:30 -05004#include <isolator/hei_isolator.hpp>
Zane Shelleyb0559b92019-12-05 22:18:20 -06005#include <register/hei_operator_register.hpp>
Zane Shelley75e68e92019-10-18 16:16:23 -05006#include <register/hei_scom_register.hpp>
Zane Shelleydd69c962020-05-05 22:19:11 -05007#include <util/hei_flyweight.hpp>
Zane Shelley75e68e92019-10-18 16:16:23 -05008
Zane Shelley5a266612019-08-15 16:23:53 -05009namespace libhei
10{
11
Zane Shelley3a02e242020-05-08 16:25:36 -050012//------------------------------------------------------------------------------
13
14// Definitions for the interfaces defined in hei_main.hpp.
15
16void initialize(void* i_buffer, size_t i_bufferSize)
17{
18 Isolator::getSingleton().initialize(i_buffer, i_bufferSize);
19}
20
21void uninitialize()
22{
23 Isolator::getSingleton().uninitialize();
24}
25
26void isolate(const std::vector<Chip>& i_chipList, IsolationData& o_isoData)
27{
28 Isolator::getSingleton().isolate(i_chipList, o_isoData);
29}
30
31//------------------------------------------------------------------------------
32
Zane Shelley5a266612019-08-15 16:23:53 -050033void Isolator::uninitialize()
34{
Zane Shelleydd69c962020-05-05 22:19:11 -050035 // Clear all of the IsolationChip objects.
36 iv_isoChips.clear();
37
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050038 // Remove all of the IsolationNode objects stored in the flyweights. This
39 // must be done before removing the HardwareRegister objects
40 Flyweight<IsolationNode>::getSingleton().clear();
41
Zane Shelleyd0af3582019-09-19 10:48:59 -050042 // Must flush the hardware register cache before deleting any
43 // HardwareRegister objects.
44 HardwareRegister::flushAll();
45
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050046 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley8deb0902019-10-14 15:52:27 -050047 Flyweight<ScomRegister>::getSingleton().clear();
48 Flyweight<IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050049}
50
Zane Shelley229c1552020-05-04 22:44:15 -050051void Isolator::isolate(const std::vector<Chip>& i_chipList,
52 IsolationData& o_isoData) const
Zane Shelley5a266612019-08-15 16:23:53 -050053{
Zane Shelley5a266612019-08-15 16:23:53 -050054 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050055 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050056
Zane Shelleyd0af3582019-09-19 10:48:59 -050057 // Flush the hardware register cache to avoid using stale data.
58 HardwareRegister::flushAll();
59
Zane Shelley61565dc2019-09-18 21:57:10 -050060 // Analyze active error on each chip.
Zane Shelleyfe27b652019-10-28 11:33:07 -050061 for (const auto& chip : i_chipList)
Zane Shelleyb406de42019-09-09 16:10:38 -050062 {
Zane Shelleydd69c962020-05-05 22:19:11 -050063 // Isolation objects for this chip's type must exist.
64 const auto& itr = iv_isoChips.find(chip.getType());
65 HEI_ASSERT(iv_isoChips.end() != itr);
66
67 // Analyze this chip.
68 itr->second->analyze(chip, o_isoData);
Zane Shelleyb406de42019-09-09 16:10:38 -050069 }
Zane Shelley5a266612019-08-15 16:23:53 -050070}
71
72} // end namespace libhei