blob: f431cb3a2930a56850698f175a1c6d0a67e44793 [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 Shelleyb0559b92019-12-05 22:18:20 -06004#include <register/hei_operator_register.hpp>
Zane Shelley75e68e92019-10-18 16:16:23 -05005#include <register/hei_scom_register.hpp>
Zane Shelleydd69c962020-05-05 22:19:11 -05006#include <util/hei_flyweight.hpp>
Zane Shelleyd5073512021-01-14 12:51:18 -06007#include <util/hei_includes.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 Shelleyd39aa572020-05-14 10:35:57 -050035 // Clear all of the isolation objects.
Zane Shelleydd69c962020-05-05 22:19:11 -050036 iv_isoChips.clear();
37
Zane Shelleyd0af3582019-09-19 10:48:59 -050038 // Must flush the hardware register cache before deleting any
39 // HardwareRegister objects.
40 HardwareRegister::flushAll();
41
Zane Shelleyf8c92f92020-05-16 10:17:16 -050042 // Clear the operator register flyweights.
43 Flyweight<const ConstantRegister>::getSingleton().clear();
44 Flyweight<const AndRegister>::getSingleton().clear();
45 Flyweight<const OrRegister>::getSingleton().clear();
46 Flyweight<const NotRegister>::getSingleton().clear();
47 Flyweight<const LeftShiftRegister>::getSingleton().clear();
48 Flyweight<const RightShiftRegister>::getSingleton().clear();
49
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050050 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley981e56a2020-05-11 21:24:20 -050051 Flyweight<const ScomRegister>::getSingleton().clear();
52 Flyweight<const IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050053}
54
Zane Shelley229c1552020-05-04 22:44:15 -050055void Isolator::isolate(const std::vector<Chip>& i_chipList,
56 IsolationData& o_isoData) const
Zane Shelley5a266612019-08-15 16:23:53 -050057{
Zane Shelley5a266612019-08-15 16:23:53 -050058 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050059 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050060
Zane Shelleyd0af3582019-09-19 10:48:59 -050061 // Flush the hardware register cache to avoid using stale data.
62 HardwareRegister::flushAll();
63
Zane Shelley61565dc2019-09-18 21:57:10 -050064 // Analyze active error on each chip.
Zane Shelleyfe27b652019-10-28 11:33:07 -050065 for (const auto& chip : i_chipList)
Zane Shelleyb406de42019-09-09 16:10:38 -050066 {
Zane Shelleydd69c962020-05-05 22:19:11 -050067 // Isolation objects for this chip's type must exist.
68 const auto& itr = iv_isoChips.find(chip.getType());
69 HEI_ASSERT(iv_isoChips.end() != itr);
70
71 // Analyze this chip.
72 itr->second->analyze(chip, o_isoData);
Zane Shelleyb406de42019-09-09 16:10:38 -050073 }
Zane Shelley5a266612019-08-15 16:23:53 -050074}
75
Zane Shelley5a266612019-08-15 16:23:53 -050076} // end namespace libhei