blob: 9e04b0abbff22e70beccb17041a252456d2a2c1c [file] [log] [blame]
Zane Shelley8deb0902019-10-14 15:52:27 -05001#pragma once
2
3#include <register/hei_hardware_register.hpp>
Zane Shelley2f341bf2019-10-16 11:19:36 -05004#include <util/hei_flyweight.hpp>
Zane Shelley8deb0902019-10-14 15:52:27 -05005
6namespace libhei
7{
8
9/**
10 * @brief A Power Systems SCOM register.
11 *
12 * Address width: 4 bytes
13 * Register width: 8 bytes
14 * Bit order: Ascending (0-63 left to right)
15 */
16class ScomRegister : public HardwareRegister
17{
18 public: // Constructor, destructors, assignment, etc.
19
20 /**
21 * @brief Constructor from components.
22 * @param i_chipType Type of chip associated with this register.
23 * @param i_id Unique ID for this register.
24 * @param i_instance Instance of this register
25 * @param i_accessLevel Hardware access level for this register.
26 * @param i_address A 4-byte address for this SCOM register.
27 */
Zane Shelley83da2452019-10-25 15:45:34 -050028 ScomRegister(ChipType_t i_chipType, RegisterId_t i_id,
29 RegisterInstance_t i_instance,
30 RegisterAccessLevel_t i_accessLevel, uint32_t i_address) :
31 HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel),
32 iv_address(i_address)
Zane Shelley8deb0902019-10-14 15:52:27 -050033 {}
34
35 /** @brief Destructor. */
36 ~ScomRegister() = default;
37
Zane Shelley2f341bf2019-10-16 11:19:36 -050038 private:
39
40 // This is needed to allow the flyweights to use the copy constructor, but
41 // not allow it to be used in general.
42 friend class Flyweight<ScomRegister>;
43
Zane Shelley8deb0902019-10-14 15:52:27 -050044 /**
45 * @brief Copy constructor.
46 *
Zane Shelley2f341bf2019-10-16 11:19:36 -050047 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -050048 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050049 ScomRegister(const ScomRegister&) = default;
Zane Shelley8deb0902019-10-14 15:52:27 -050050
51 /**
52 * @brief Explicitly disables assignment operator.
53 *
54 * This is redundant since the compilier will implicitly delete this because
55 * of the constant instance variables, but helps communicate it is not
56 * allowed.
57 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050058 ScomRegister& operator=(const ScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -050059
60 public: // Accessor functions
61
62 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050063 RegisterType_t getRegisterType() const
64 {
65 return REG_TYPE_SCOM;
66 }
Zane Shelley8deb0902019-10-14 15:52:27 -050067
68 /** Function overloaded from parent HardwareRegister class. */
69 RegisterAddress_t getAddress() const
70 {
Zane Shelley83da2452019-10-25 15:45:34 -050071 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -050072 }
73
74 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -050075 size_t getSize() const
76 {
77 return 8;
78 }
Zane Shelley8deb0902019-10-14 15:52:27 -050079
Zane Shelley8deb0902019-10-14 15:52:27 -050080 private: // Instance variables
81
82 /** This register's address. */
83 const uint32_t iv_address;
84
85}; // end class ScomRegister
86
87/**
88 * @brief A Power Systems Indirect SCOM register.
89 *
90 * Address width: 8 bytes
91 * Register width: 2* bytes (see note below)
92 * Bit order: Ascending (0-63 left to right)
93 *
94 * IMPORTANT NOTE:
95 * Technically, only two bytes of data are actually used. However, the bit
96 * definition of these registers put the two bytes at the end of the returned
97 * value (bit 48-63). Therefore, this class will be made to look like the
98 * width is 8 bytes in order to make the bit indexing work in the returned
99 * BitString.
100 */
101class IdScomRegister : public HardwareRegister
102{
103 public: // Constructor, destructors, assignment, etc.
104
105 /**
106 * @brief Constructor from components.
107 * @param i_chipType Type of chip associated with this register.
108 * @param i_id Unique ID for this register.
109 * @param i_instance Instance of this register
110 * @param i_accessLevel Hardware access level for this register.
111 * @param i_address An 8-byte address for this Indirect SCOM register.
112 */
Zane Shelley83da2452019-10-25 15:45:34 -0500113 IdScomRegister(ChipType_t i_chipType, RegisterId_t i_id,
114 RegisterInstance_t i_instance,
115 RegisterAccessLevel_t i_accessLevel, uint64_t i_address) :
116 HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel),
117 iv_address(i_address)
Zane Shelley8deb0902019-10-14 15:52:27 -0500118 {}
119
120 /** @brief Destructor. */
121 ~IdScomRegister() = default;
122
Zane Shelley2f341bf2019-10-16 11:19:36 -0500123 private:
124
125 // This is needed to allow the flyweights to use the copy constructor, but
126 // not allow it to be used in general.
127 friend class Flyweight<IdScomRegister>;
128
Zane Shelley8deb0902019-10-14 15:52:27 -0500129 /**
130 * @brief Copy constructor.
131 *
Zane Shelley2f341bf2019-10-16 11:19:36 -0500132 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -0500133 */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500134 IdScomRegister(const IdScomRegister&) = default;
Zane Shelley8deb0902019-10-14 15:52:27 -0500135
136 /**
137 * @brief Explicitly disables assignment operator.
138 *
139 * This is redundant since the compilier will implicitly delete this because
140 * of the constant instance variables, but helps communicate it is not
141 * allowed.
142 */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500143 IdScomRegister& operator=(const IdScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -0500144
145 public: // Accessor functions
146
147 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500148 RegisterType_t getRegisterType() const
149 {
150 return REG_TYPE_ID_SCOM;
151 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500152
153 /** Function overloaded from parent HardwareRegister class. */
154 RegisterAddress_t getAddress() const
155 {
Zane Shelley83da2452019-10-25 15:45:34 -0500156 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -0500157 }
158
159 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500160 size_t getSize() const
161 {
162 return 8; // See note in class documentation.
163 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500164
Zane Shelley8deb0902019-10-14 15:52:27 -0500165 private: // Instance variables
166
167 /** This register's address. */
168 const uint64_t iv_address;
169
170}; // end class IdScomRegister
171
172} // end namespace libhei