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. |
Zane Shelley | 7667b71 | 2020-05-11 20:45:40 -0500 | [diff] [blame] | 21 | * @param i_id Unique ID for this register. |
| 22 | * @param i_instance Instance of this register |
| 23 | * @param i_flags Attribute flags for this register. |
| 24 | * @param i_address A 4-byte address for this SCOM register. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 25 | */ |
Zane Shelley | 5ec8810 | 2020-05-11 21:08:25 -0500 | [diff] [blame^] | 26 | ScomRegister(RegisterId_t i_id, Instance_t i_instance, |
| 27 | RegisterAttributeFlags_t i_flags, uint32_t i_address) : |
| 28 | HardwareRegister(i_id, i_instance, i_flags), |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 29 | iv_address(i_address) |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 30 | {} |
| 31 | |
| 32 | /** @brief Destructor. */ |
| 33 | ~ScomRegister() = default; |
| 34 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 35 | private: |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 36 | // This is needed to allow the flyweights to use the copy constructor, but |
| 37 | // not allow it to be used in general. |
| 38 | friend class Flyweight<ScomRegister>; |
| 39 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 40 | /** |
| 41 | * @brief Copy constructor. |
| 42 | * |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 43 | * Needed by Flyweight class, but should not be allowed in general. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 44 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 45 | ScomRegister(const ScomRegister&) = default; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 46 | |
| 47 | /** |
| 48 | * @brief Explicitly disables assignment operator. |
| 49 | * |
| 50 | * This is redundant since the compilier will implicitly delete this because |
| 51 | * of the constant instance variables, but helps communicate it is not |
| 52 | * allowed. |
| 53 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 54 | ScomRegister& operator=(const ScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 55 | |
| 56 | public: // Accessor functions |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 57 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 5ec8810 | 2020-05-11 21:08:25 -0500 | [diff] [blame^] | 58 | RegisterType_t getType() const |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 59 | { |
| 60 | return REG_TYPE_SCOM; |
| 61 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 62 | |
| 63 | /** Function overloaded from parent HardwareRegister class. */ |
| 64 | RegisterAddress_t getAddress() const |
| 65 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 66 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 70 | size_t getSize() const |
| 71 | { |
| 72 | return 8; |
| 73 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 74 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 75 | private: // Instance variables |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 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. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 98 | /** |
| 99 | * @brief Constructor from components. |
Zane Shelley | 7667b71 | 2020-05-11 20:45:40 -0500 | [diff] [blame] | 100 | * @param i_id Unique ID for this register. |
| 101 | * @param i_instance Instance of this register |
| 102 | * @param i_flags Attribute flags for this register. |
| 103 | * @param i_address An 8-byte address for this Indirect SCOM register. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 104 | */ |
Zane Shelley | 5ec8810 | 2020-05-11 21:08:25 -0500 | [diff] [blame^] | 105 | IdScomRegister(RegisterId_t i_id, Instance_t i_instance, |
| 106 | RegisterAttributeFlags_t i_flags, uint64_t i_address) : |
| 107 | HardwareRegister(i_id, i_instance, i_flags), |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 108 | iv_address(i_address) |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 109 | {} |
| 110 | |
| 111 | /** @brief Destructor. */ |
| 112 | ~IdScomRegister() = default; |
| 113 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 114 | private: |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 115 | // This is needed to allow the flyweights to use the copy constructor, but |
| 116 | // not allow it to be used in general. |
| 117 | friend class Flyweight<IdScomRegister>; |
| 118 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 119 | /** |
| 120 | * @brief Copy constructor. |
| 121 | * |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 122 | * Needed by Flyweight class, but should not be allowed in general. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 123 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 124 | IdScomRegister(const IdScomRegister&) = default; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * @brief Explicitly disables assignment operator. |
| 128 | * |
| 129 | * This is redundant since the compilier will implicitly delete this because |
| 130 | * of the constant instance variables, but helps communicate it is not |
| 131 | * allowed. |
| 132 | */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 133 | IdScomRegister& operator=(const IdScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 134 | |
| 135 | public: // Accessor functions |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 136 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 5ec8810 | 2020-05-11 21:08:25 -0500 | [diff] [blame^] | 137 | RegisterType_t getType() const |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 138 | { |
| 139 | return REG_TYPE_ID_SCOM; |
| 140 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 141 | |
| 142 | /** Function overloaded from parent HardwareRegister class. */ |
| 143 | RegisterAddress_t getAddress() const |
| 144 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 145 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 149 | size_t getSize() const |
| 150 | { |
| 151 | return 8; // See note in class documentation. |
| 152 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 153 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 154 | private: // Instance variables |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 155 | /** This register's address. */ |
| 156 | const uint64_t iv_address; |
| 157 | |
| 158 | }; // end class IdScomRegister |
| 159 | |
| 160 | } // end namespace libhei |