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. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 19 | /** |
| 20 | * @brief Constructor from components. |
| 21 | * @param i_chipType Type of chip associated with this register. |
| 22 | * @param i_id Unique ID for this register. |
| 23 | * @param i_instance Instance of this register |
| 24 | * @param i_accessLevel Hardware access level for this register. |
| 25 | * @param i_address A 4-byte address for this SCOM register. |
| 26 | */ |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 27 | ScomRegister(ChipType_t i_chipType, RegisterId_t i_id, |
| 28 | RegisterInstance_t i_instance, |
| 29 | RegisterAccessLevel_t i_accessLevel, uint32_t i_address) : |
| 30 | HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel), |
| 31 | iv_address(i_address) |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 32 | {} |
| 33 | |
| 34 | /** @brief Destructor. */ |
| 35 | ~ScomRegister() = default; |
| 36 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 37 | private: |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 38 | // This is needed to allow the flyweights to use the copy constructor, but |
| 39 | // not allow it to be used in general. |
| 40 | friend class Flyweight<ScomRegister>; |
| 41 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 42 | /** |
| 43 | * @brief Copy constructor. |
| 44 | * |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 45 | * Needed by Flyweight class, but should not be allowed in general. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 46 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 47 | ScomRegister(const ScomRegister&) = default; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * @brief Explicitly disables assignment operator. |
| 51 | * |
| 52 | * This is redundant since the compilier will implicitly delete this because |
| 53 | * of the constant instance variables, but helps communicate it is not |
| 54 | * allowed. |
| 55 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 56 | ScomRegister& operator=(const ScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 57 | |
| 58 | public: // Accessor functions |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 59 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 60 | RegisterType_t getRegisterType() const |
| 61 | { |
| 62 | return REG_TYPE_SCOM; |
| 63 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 64 | |
| 65 | /** Function overloaded from parent HardwareRegister class. */ |
| 66 | RegisterAddress_t getAddress() const |
| 67 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 68 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 72 | size_t getSize() const |
| 73 | { |
| 74 | return 8; |
| 75 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 76 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 77 | private: // Instance variables |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 78 | /** This register's address. */ |
| 79 | const uint32_t iv_address; |
| 80 | |
| 81 | }; // end class ScomRegister |
| 82 | |
| 83 | /** |
| 84 | * @brief A Power Systems Indirect SCOM register. |
| 85 | * |
| 86 | * Address width: 8 bytes |
| 87 | * Register width: 2* bytes (see note below) |
| 88 | * Bit order: Ascending (0-63 left to right) |
| 89 | * |
| 90 | * IMPORTANT NOTE: |
| 91 | * Technically, only two bytes of data are actually used. However, the bit |
| 92 | * definition of these registers put the two bytes at the end of the returned |
| 93 | * value (bit 48-63). Therefore, this class will be made to look like the |
| 94 | * width is 8 bytes in order to make the bit indexing work in the returned |
| 95 | * BitString. |
| 96 | */ |
| 97 | class IdScomRegister : public HardwareRegister |
| 98 | { |
| 99 | public: // Constructor, destructors, assignment, etc. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 100 | /** |
| 101 | * @brief Constructor from components. |
| 102 | * @param i_chipType Type of chip associated with this register. |
| 103 | * @param i_id Unique ID for this register. |
| 104 | * @param i_instance Instance of this register |
| 105 | * @param i_accessLevel Hardware access level for this register. |
| 106 | * @param i_address An 8-byte address for this Indirect SCOM register. |
| 107 | */ |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 108 | IdScomRegister(ChipType_t i_chipType, RegisterId_t i_id, |
| 109 | RegisterInstance_t i_instance, |
| 110 | RegisterAccessLevel_t i_accessLevel, uint64_t i_address) : |
| 111 | HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel), |
| 112 | iv_address(i_address) |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 113 | {} |
| 114 | |
| 115 | /** @brief Destructor. */ |
| 116 | ~IdScomRegister() = default; |
| 117 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 118 | private: |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 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 Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 123 | /** |
| 124 | * @brief Copy constructor. |
| 125 | * |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 126 | * Needed by Flyweight class, but should not be allowed in general. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 127 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 128 | IdScomRegister(const IdScomRegister&) = default; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 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 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 137 | IdScomRegister& operator=(const IdScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 138 | |
| 139 | public: // Accessor functions |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 140 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 141 | RegisterType_t getRegisterType() const |
| 142 | { |
| 143 | return REG_TYPE_ID_SCOM; |
| 144 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 145 | |
| 146 | /** Function overloaded from parent HardwareRegister class. */ |
| 147 | RegisterAddress_t getAddress() const |
| 148 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 149 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 153 | size_t getSize() const |
| 154 | { |
| 155 | return 8; // See note in class documentation. |
| 156 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 157 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 158 | private: // Instance variables |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 159 | /** This register's address. */ |
| 160 | const uint64_t iv_address; |
| 161 | |
| 162 | }; // end class IdScomRegister |
| 163 | |
| 164 | } // end namespace libhei |