blob: 3488ab94606480e2967e8d14fd6ab41d223504ff [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 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 Shelley7bf1f6d2019-10-18 16:03:51 -050042 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley981e56a2020-05-11 21:24:20 -050043 Flyweight<const ScomRegister>::getSingleton().clear();
44 Flyweight<const IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050045}
46
Zane Shelley229c1552020-05-04 22:44:15 -050047void Isolator::isolate(const std::vector<Chip>& i_chipList,
48 IsolationData& o_isoData) const
Zane Shelley5a266612019-08-15 16:23:53 -050049{
Zane Shelley5a266612019-08-15 16:23:53 -050050 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050051 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050052
Zane Shelleyd0af3582019-09-19 10:48:59 -050053 // Flush the hardware register cache to avoid using stale data.
54 HardwareRegister::flushAll();
55
Zane Shelley61565dc2019-09-18 21:57:10 -050056 // Analyze active error on each chip.
Zane Shelleyfe27b652019-10-28 11:33:07 -050057 for (const auto& chip : i_chipList)
Zane Shelleyb406de42019-09-09 16:10:38 -050058 {
Zane Shelleydd69c962020-05-05 22:19:11 -050059 // Isolation objects for this chip's type must exist.
60 const auto& itr = iv_isoChips.find(chip.getType());
61 HEI_ASSERT(iv_isoChips.end() != itr);
62
63 // Analyze this chip.
64 itr->second->analyze(chip, o_isoData);
Zane Shelleyb406de42019-09-09 16:10:38 -050065 }
Zane Shelley5a266612019-08-15 16:23:53 -050066}
67
68} // end namespace libhei