blob: 69309550085a37ad3e404ba116b50a58c0ec8e7f [file] [log] [blame]
Zane Shelley508ce582020-05-05 13:47:19 -05001#pragma once
2
3#include <hei_isolation_data.hpp>
4#include <isolator/hei_isolation_node.hpp>
5
6namespace libhei
7{
8
9/**
10 * @brief This class contains all information required to isolate attentions on
11 * a specific chip type.
12 *
13 * The primary function of this class is analyze(), which will do a depth-first
14 * search of the hardware attention reporting tree structure (characterized by
15 * IsolationNode objects) to find all active attentions on a chip.
16 *
17 * The data for each chip type is built from information in the Chip Data Files.
18 *
19 * IMPORTANT:
20 * Most of the objects created and referenced by this class are stored in the
21 * flyweight factories, which are used as a space saving mechanism by
22 * preventing duplicate object creation. For example, a large set of the
23 * registers for a specific chip model will likely be common between each of
24 * chip level of that model. It is not necessary to create new objects for
25 * each level when the attributes are all the same. Because the flyweights are
26 * used, it is not possible to remove all of the data for a specific chip
27 * model/level be deleting an IsolationChip object. Instead, you must call the
28 * main uninitialize() function and clear all data for all objects.
29 */
30class IsolationChip
31{
32 public: // Constructors, destructor, assignment
33 /** @brief Default constructor. */
34 IsolationChip(ChipType_t i_chipType, const RootNodeMap& i_rootNodes) :
35 iv_chipType(i_chipType), iv_rootNodes(i_rootNodes)
36 {}
37
38 /** @brief Destructor. */
39 ~IsolationChip() = default;
40
41 /** @brief Copy constructor. */
42 IsolationChip(const IsolationChip&) = delete;
43
44 /** @brief Assignment operator. */
45 IsolationChip& operator=(const IsolationChip&) = delete;
46
47 private: // Instance variables
48 /** This chip's type. */
49 const ChipType_t iv_chipType;
50
51 /** Root nodes for this chip type. */
52 const RootNodeMap iv_rootNodes;
53
54 public: // Member functions
55 /**
56 * @brief Finds all active attentions on this chip.
57 * @param i_chip The target chip for isolation. Will assert the given
58 * chip type matches iv_chipType.
59 * @param io_isoData The isolation data returned back to the user
60 * application.
61 * @return True, if any active attentions found on this chip.
62 * False, otherwise.
63 */
64 bool analyze(const Chip& i_chip, IsolationData& io_isoData) const;
65
66 /** @brief Chip type accessor. */
67 ChipType_t getChipType() const
68 {
69 return iv_chipType;
70 }
71};
72
73} // end namespace libhei