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 | 83da245 | 2019-10-25 15:45:34 -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 | 83da245 | 2019-10-25 15:45:34 -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. */ |
| 63 | RegisterType_t getRegisterType() const { return REG_TYPE_SCOM; } |
| 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. */ |
| 72 | size_t getSize() const { return 8; } |
| 73 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 74 | 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 | */ |
| 95 | class 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 | */ |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 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) |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 112 | {} |
| 113 | |
| 114 | /** @brief Destructor. */ |
| 115 | ~IdScomRegister() = default; |
| 116 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 117 | 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 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 | 83da245 | 2019-10-25 15:45:34 -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 | 83da245 | 2019-10-25 15:45:34 -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 |
| 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 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 147 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | /** Function overloaded from parent HardwareRegister class. */ |
| 151 | size_t getSize() const { return 8; } // See note in class documentation. |
| 152 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 153 | 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 |