blob: ef74b2e3c6e95323f77ca750f6f0e50dd93bc257 [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001
Ben Tyner552992a2021-04-15 10:57:17 -05002#include <buildinfo.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 Shelleyd5073512021-01-14 12:51:18 -06008#include <util/hei_includes.hpp>
Zane Shelley75e68e92019-10-18 16:16:23 -05009
Zane Shelley5a266612019-08-15 16:23:53 -050010namespace libhei
11{
12
Zane Shelley3a02e242020-05-08 16:25:36 -050013//------------------------------------------------------------------------------
14
15// Definitions for the interfaces defined in hei_main.hpp.
16
17void initialize(void* i_buffer, size_t i_bufferSize)
18{
19 Isolator::getSingleton().initialize(i_buffer, i_bufferSize);
20}
21
22void uninitialize()
23{
24 Isolator::getSingleton().uninitialize();
25}
26
27void isolate(const std::vector<Chip>& i_chipList, IsolationData& o_isoData)
28{
29 Isolator::getSingleton().isolate(i_chipList, o_isoData);
30}
31
32//------------------------------------------------------------------------------
33
Zane Shelley5a266612019-08-15 16:23:53 -050034void Isolator::uninitialize()
35{
Zane Shelleyd39aa572020-05-14 10:35:57 -050036 // Clear all of the isolation objects.
Zane Shelleydd69c962020-05-05 22:19:11 -050037 iv_isoChips.clear();
38
Zane Shelleyd0af3582019-09-19 10:48:59 -050039 // Must flush the hardware register cache before deleting any
40 // HardwareRegister objects.
41 HardwareRegister::flushAll();
42
Zane Shelleyf8c92f92020-05-16 10:17:16 -050043 // Clear the operator register flyweights.
44 Flyweight<const ConstantRegister>::getSingleton().clear();
45 Flyweight<const AndRegister>::getSingleton().clear();
46 Flyweight<const OrRegister>::getSingleton().clear();
47 Flyweight<const NotRegister>::getSingleton().clear();
48 Flyweight<const LeftShiftRegister>::getSingleton().clear();
49 Flyweight<const RightShiftRegister>::getSingleton().clear();
50
Zane Shelley7bf1f6d2019-10-18 16:03:51 -050051 // Remove all of the HardwareRegister objects stored in the flyweights.
Zane Shelley981e56a2020-05-11 21:24:20 -050052 Flyweight<const ScomRegister>::getSingleton().clear();
53 Flyweight<const IdScomRegister>::getSingleton().clear();
Zane Shelley5a266612019-08-15 16:23:53 -050054}
55
Zane Shelley229c1552020-05-04 22:44:15 -050056void Isolator::isolate(const std::vector<Chip>& i_chipList,
57 IsolationData& o_isoData) const
Zane Shelley5a266612019-08-15 16:23:53 -050058{
Zane Shelley5a266612019-08-15 16:23:53 -050059 // Flush the isolation data to ensure a clean slate.
Zane Shelley93b61ad2019-10-16 20:41:03 -050060 o_isoData.flush();
Zane Shelley5a266612019-08-15 16:23:53 -050061
Zane Shelleyd0af3582019-09-19 10:48:59 -050062 // Flush the hardware register cache to avoid using stale data.
63 HardwareRegister::flushAll();
64
Zane Shelley61565dc2019-09-18 21:57:10 -050065 // Analyze active error on each chip.
Zane Shelleyfe27b652019-10-28 11:33:07 -050066 for (const auto& chip : i_chipList)
Zane Shelleyb406de42019-09-09 16:10:38 -050067 {
Zane Shelleydd69c962020-05-05 22:19:11 -050068 // Isolation objects for this chip's type must exist.
69 const auto& itr = iv_isoChips.find(chip.getType());
70 HEI_ASSERT(iv_isoChips.end() != itr);
71
72 // Analyze this chip.
73 itr->second->analyze(chip, o_isoData);
Zane Shelleyb406de42019-09-09 16:10:38 -050074 }
Zane Shelley5a266612019-08-15 16:23:53 -050075}
76
Ben Tyner552992a2021-04-15 10:57:17 -050077const char* getBuildInfo()
78{
79 return BUILDINFO;
80}
81
Zane Shelley5a266612019-08-15 16:23:53 -050082} // end namespace libhei