blob: 04fd124ef36a424692887fd7ad668a9e25bc7e5b [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 */
28 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 )
33 {}
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 */
49 ScomRegister( const ScomRegister & ) = default;
50
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 */
58 ScomRegister & operator=( const ScomRegister & ) = delete;
59
60 public: // Accessor functions
61
62 /** Function overloaded from parent HardwareRegister class. */
63 RegisterType_t getRegisterType() const { return REG_TYPE_SCOM; }
64
65 /** Function overloaded from parent HardwareRegister class. */
66 RegisterAddress_t getAddress() const
67 {
68 return static_cast<RegisterAddress_t>( iv_address );
69 }
70
71 /** Function overloaded from parent HardwareRegister class. */
72 size_t getSize() const { return 8; }
73
Zane Shelley8deb0902019-10-14 15:52:27 -050074 private: // Instance variables
75
76 /** This register's address. */
77 const uint32_t iv_address;
78
79}; // end class ScomRegister
80
81/**
82 * @brief A Power Systems Indirect SCOM register.
83 *
84 * Address width: 8 bytes
85 * Register width: 2* bytes (see note below)
86 * Bit order: Ascending (0-63 left to right)
87 *
88 * IMPORTANT NOTE:
89 * Technically, only two bytes of data are actually used. However, the bit
90 * definition of these registers put the two bytes at the end of the returned
91 * value (bit 48-63). Therefore, this class will be made to look like the
92 * width is 8 bytes in order to make the bit indexing work in the returned
93 * BitString.
94 */
95class IdScomRegister : public HardwareRegister
96{
97 public: // Constructor, destructors, assignment, etc.
98
99 /**
100 * @brief Constructor from components.
101 * @param i_chipType Type of chip associated with this register.
102 * @param i_id Unique ID for this register.
103 * @param i_instance Instance of this register
104 * @param i_accessLevel Hardware access level for this register.
105 * @param i_address An 8-byte address for this Indirect SCOM register.
106 */
107 IdScomRegister( ChipType_t i_chipType, RegisterId_t i_id,
108 RegisterInstance_t i_instance,
109 RegisterAccessLevel_t i_accessLevel, uint64_t i_address ) :
110 HardwareRegister( i_chipType, i_id, i_instance, i_accessLevel ),
111 iv_address( i_address )
112 {}
113
114 /** @brief Destructor. */
115 ~IdScomRegister() = default;
116
Zane Shelley2f341bf2019-10-16 11:19:36 -0500117 private:
118
119 // This is needed to allow the flyweights to use the copy constructor, but
120 // not allow it to be used in general.
121 friend class Flyweight<IdScomRegister>;
122
Zane Shelley8deb0902019-10-14 15:52:27 -0500123 /**
124 * @brief Copy constructor.
125 *
Zane Shelley2f341bf2019-10-16 11:19:36 -0500126 * Needed by Flyweight class, but should not be allowed in general.
Zane Shelley8deb0902019-10-14 15:52:27 -0500127 */
128 IdScomRegister( const IdScomRegister & ) = default;
129
130 /**
131 * @brief Explicitly disables assignment operator.
132 *
133 * This is redundant since the compilier will implicitly delete this because
134 * of the constant instance variables, but helps communicate it is not
135 * allowed.
136 */
137 IdScomRegister & operator=( const IdScomRegister & ) = delete;
138
139 public: // Accessor functions
140
141 /** Function overloaded from parent HardwareRegister class. */
142 RegisterType_t getRegisterType() const { return REG_TYPE_ID_SCOM; }
143
144 /** Function overloaded from parent HardwareRegister class. */
145 RegisterAddress_t getAddress() const
146 {
147 return static_cast<RegisterAddress_t>( iv_address );
148 }
149
150 /** Function overloaded from parent HardwareRegister class. */
151 size_t getSize() const { return 8; } // See note in class documentation.
152
Zane Shelley8deb0902019-10-14 15:52:27 -0500153 private: // Instance variables
154
155 /** This register's address. */
156 const uint64_t iv_address;
157
158}; // end class IdScomRegister
159
160} // end namespace libhei
161