blob: 784273079d08fec79373b2d58e066acbdfe19cee [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001#pragma once
2
Zane Shelleydd69c962020-05-05 22:19:11 -05003#include <chip_data/hei_chip_data.hpp>
Zane Shelley5a266612019-08-15 16:23:53 -05004#include <hei_isolation_data.hpp>
Zane Shelley11b89942019-11-07 11:07:28 -06005#include <isolator/hei_isolation_node.hpp>
Zane Shelley5a266612019-08-15 16:23:53 -05006
7namespace libhei
8{
9
10/**
11 * @brief This class is a complement to the main APIs. Its purpose is to store
12 * and maintain all of the objects necessary for isolation.
13 *
14 * The intended flow is to:
15 * - Create a singleton instance of an Isolator object via getSingleton().
16 * - Use initialize() to input each necessary Chip Data File provided by the
17 * user application.
Zane Shelleyb406de42019-09-09 16:10:38 -050018 * - Call isolate() to find all active errors being reported by the given list
19 * of chips.
Zane Shelley5a266612019-08-15 16:23:53 -050020 * - Once isolation is no longer needed, use uninitialize() to free up
21 * internal resources.
22 *
23 * The purpose of the singleton instance is to avoid initializing the object
24 * each time isolation is required. The data provided by the Chip Data Files is
25 * static. So reinitializing would be a waste of time, unless for some reason
26 * the Chip Data Files themselves are updated, which would require
27 * reinitialization anyway. Of course, leaving the object in memory chews up
28 * resources. So, some users may need to weigh performance vs. memory usage.
29 */
30class Isolator
31{
32 private: // This class cannot be instantiated. Use getSingleton() instead.
Zane Shelley5a266612019-08-15 16:23:53 -050033 /** @brief Default constructor. */
34 Isolator() = default;
35
36 /** @brief Destructor. */
37 ~Isolator()
38 {
39 // Clear out all of the internal isolation objects.
40 uninitialize();
41 }
42
43 /** @brief Copy constructor. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050044 Isolator(const Isolator&) = delete;
Zane Shelley5a266612019-08-15 16:23:53 -050045
46 /** @brief Assignment operator. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050047 Isolator& operator=(const Isolator&) = delete;
Zane Shelley5a266612019-08-15 16:23:53 -050048
Zane Shelleydd69c962020-05-05 22:19:11 -050049 private:
50 /** Keeps track of all chip types that have been initialized. */
Zane Shelley4de8ff82020-05-14 15:39:01 -050051 IsolationChip::Map iv_isoChips;
Zane Shelleydd69c962020-05-05 22:19:11 -050052
Zane Shelley5a266612019-08-15 16:23:53 -050053 public:
Zane Shelley5a266612019-08-15 16:23:53 -050054 /** @brief Provides access to a singleton instance of this object. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050055 static Isolator& getSingleton()
Zane Shelley5a266612019-08-15 16:23:53 -050056 {
57 static Isolator theIsolator;
58 return theIsolator;
59 }
60
Caleb Palmer18980282025-05-16 10:48:25 -050061 /**
62 * @brief Provides access to an isolation chip within this object.
63 * @param i_chipType The chip type of the isolation chip to access.
64 * @return ConstPtr to the isolation chip object.
65 */
66 IsolationChip::ConstPtr getIsoChip(ChipType_t i_chipType) const
67 {
68 auto itr = iv_isoChips.find(i_chipType);
69 HEI_ASSERT(iv_isoChips.end() != itr); // The IsolationChip should exist.
70
71 return itr->second;
72 }
73
Zane Shelley5a266612019-08-15 16:23:53 -050074 /** @brief See API wrapper description in hei_main.hpp. */
Zane Shelleydd69c962020-05-05 22:19:11 -050075 void initialize(void* i_buffer, size_t i_bufferSize)
76 {
77 parseChipDataFile(i_buffer, i_bufferSize, iv_isoChips);
78 }
Zane Shelley5a266612019-08-15 16:23:53 -050079
80 /**
81 * @brief See API wrapper description in hei_main.hpp.
82 *
83 * This function is called in the destructor. Therefore, it should never
84 * throw an exception.
85 */
86 void uninitialize();
87
88 /** @brief See API wrapper description in hei_main.hpp. */
Zane Shelley229c1552020-05-04 22:44:15 -050089 void isolate(const std::vector<Chip>& i_chipList,
90 IsolationData& o_isoData) const;
Zane Shelley11b89942019-11-07 11:07:28 -060091
Caleb Palmere4ad4e32024-08-07 09:48:14 -050092#ifdef __HEI_ENABLE_HW_WRITE
93 /**
94 * @brief Performs the given write operation on the input signature. The
95 * node and bit in the input signature will determine which register
96 * and bit are to be written by the operation.
97 * @param i_op The given write operation rule. See the OpRuleName_t enum
98 * for supported values.
99 * @param i_sig The signature to determine what's to be written.
100 * @return True if write operation failed, false if successful.
101 */
102 bool performWriteOp(OpRuleName_t i_op, Signature i_sig);
103#endif
104
Zane Shelley5a266612019-08-15 16:23:53 -0500105}; // end class Isolator
106
107} // end namespace libhei