Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <register/hei_hardware_register.hpp> |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 4 | #include <util/hei_flyweight.hpp> |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 5 | |
| 6 | namespace 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 | */ |
| 16 | class 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 Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 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) |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 33 | {} |
| 34 | |
| 35 | /** @brief Destructor. */ |
| 36 | ~ScomRegister() = default; |
| 37 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 38 | 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 Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 44 | /** |
| 45 | * @brief Copy constructor. |
| 46 | * |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 47 | * Needed by Flyweight class, but should not be allowed in general. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 48 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 49 | ScomRegister(const ScomRegister&) = default; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 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 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 58 | ScomRegister& operator=(const ScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 59 | |
| 60 | public: // Accessor functions |
| 61 | |
| 62 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame^] | 63 | RegisterType_t getRegisterType() const |
| 64 | { |
| 65 | return REG_TYPE_SCOM; |
| 66 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 67 | |
| 68 | /** Function overloaded from parent HardwareRegister class. */ |
| 69 | RegisterAddress_t getAddress() const |
| 70 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 71 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame^] | 75 | size_t getSize() const |
| 76 | { |
| 77 | return 8; |
| 78 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 79 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 80 | 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 | */ |
| 101 | class 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 Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 113 | 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 Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 118 | {} |
| 119 | |
| 120 | /** @brief Destructor. */ |
| 121 | ~IdScomRegister() = default; |
| 122 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 123 | 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 Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 129 | /** |
| 130 | * @brief Copy constructor. |
| 131 | * |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 132 | * Needed by Flyweight class, but should not be allowed in general. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 133 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 134 | IdScomRegister(const IdScomRegister&) = default; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 135 | |
| 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 Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 143 | IdScomRegister& operator=(const IdScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 144 | |
| 145 | public: // Accessor functions |
| 146 | |
| 147 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame^] | 148 | RegisterType_t getRegisterType() const |
| 149 | { |
| 150 | return REG_TYPE_ID_SCOM; |
| 151 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 152 | |
| 153 | /** Function overloaded from parent HardwareRegister class. */ |
| 154 | RegisterAddress_t getAddress() const |
| 155 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 156 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame^] | 160 | size_t getSize() const |
| 161 | { |
| 162 | return 8; // See note in class documentation. |
| 163 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 164 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 165 | 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 |