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 | 981e56a | 2020-05-11 21:24:20 -0500 | [diff] [blame] | 36 | /** @brief Copy constructor. */ |
| 37 | ScomRegister(const ScomRegister&) = delete; |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 38 | |
Zane Shelley | 981e56a | 2020-05-11 21:24:20 -0500 | [diff] [blame] | 39 | /** @brief Assignment operator. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 40 | ScomRegister& operator=(const ScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 41 | |
| 42 | public: // Accessor functions |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 43 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 5ec8810 | 2020-05-11 21:08:25 -0500 | [diff] [blame] | 44 | RegisterType_t getType() const |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 45 | { |
| 46 | return REG_TYPE_SCOM; |
| 47 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 48 | |
| 49 | /** Function overloaded from parent HardwareRegister class. */ |
| 50 | RegisterAddress_t getAddress() const |
| 51 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 52 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 56 | size_t getSize() const |
| 57 | { |
| 58 | return 8; |
| 59 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 60 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 61 | private: // Instance variables |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 62 | /** This register's address. */ |
| 63 | const uint32_t iv_address; |
| 64 | |
| 65 | }; // end class ScomRegister |
| 66 | |
| 67 | /** |
| 68 | * @brief A Power Systems Indirect SCOM register. |
| 69 | * |
| 70 | * Address width: 8 bytes |
| 71 | * Register width: 2* bytes (see note below) |
| 72 | * Bit order: Ascending (0-63 left to right) |
| 73 | * |
| 74 | * IMPORTANT NOTE: |
| 75 | * Technically, only two bytes of data are actually used. However, the bit |
| 76 | * definition of these registers put the two bytes at the end of the returned |
| 77 | * value (bit 48-63). Therefore, this class will be made to look like the |
| 78 | * width is 8 bytes in order to make the bit indexing work in the returned |
| 79 | * BitString. |
| 80 | */ |
| 81 | class IdScomRegister : public HardwareRegister |
| 82 | { |
| 83 | public: // Constructor, destructors, assignment, etc. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 84 | /** |
| 85 | * @brief Constructor from components. |
Zane Shelley | 7667b71 | 2020-05-11 20:45:40 -0500 | [diff] [blame] | 86 | * @param i_id Unique ID for this register. |
| 87 | * @param i_instance Instance of this register |
| 88 | * @param i_flags Attribute flags for this register. |
| 89 | * @param i_address An 8-byte address for this Indirect SCOM register. |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 90 | */ |
Zane Shelley | 5ec8810 | 2020-05-11 21:08:25 -0500 | [diff] [blame] | 91 | IdScomRegister(RegisterId_t i_id, Instance_t i_instance, |
| 92 | RegisterAttributeFlags_t i_flags, uint64_t i_address) : |
| 93 | HardwareRegister(i_id, i_instance, i_flags), |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 94 | iv_address(i_address) |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 95 | {} |
| 96 | |
| 97 | /** @brief Destructor. */ |
| 98 | ~IdScomRegister() = default; |
| 99 | |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 100 | private: |
Zane Shelley | 981e56a | 2020-05-11 21:24:20 -0500 | [diff] [blame] | 101 | /** @brief Copy constructor. */ |
| 102 | IdScomRegister(const IdScomRegister&) = delete; |
Zane Shelley | 2f341bf | 2019-10-16 11:19:36 -0500 | [diff] [blame] | 103 | |
Zane Shelley | 981e56a | 2020-05-11 21:24:20 -0500 | [diff] [blame] | 104 | /** @brief Assignment operator. */ |
Zane Shelley | fe27b65 | 2019-10-28 11:33:07 -0500 | [diff] [blame] | 105 | IdScomRegister& operator=(const IdScomRegister&) = delete; |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 106 | |
| 107 | public: // Accessor functions |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 108 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 5ec8810 | 2020-05-11 21:08:25 -0500 | [diff] [blame] | 109 | RegisterType_t getType() const |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 110 | { |
| 111 | return REG_TYPE_ID_SCOM; |
| 112 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 113 | |
| 114 | /** Function overloaded from parent HardwareRegister class. */ |
| 115 | RegisterAddress_t getAddress() const |
| 116 | { |
Zane Shelley | 83da245 | 2019-10-25 15:45:34 -0500 | [diff] [blame] | 117 | return static_cast<RegisterAddress_t>(iv_address); |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /** Function overloaded from parent HardwareRegister class. */ |
Zane Shelley | 7f7a42d | 2019-10-28 13:28:31 -0500 | [diff] [blame] | 121 | size_t getSize() const |
| 122 | { |
| 123 | return 8; // See note in class documentation. |
| 124 | } |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 125 | |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 126 | private: // Instance variables |
Zane Shelley | 8deb090 | 2019-10-14 15:52:27 -0500 | [diff] [blame] | 127 | /** This register's address. */ |
| 128 | const uint64_t iv_address; |
| 129 | |
| 130 | }; // end class IdScomRegister |
| 131 | |
| 132 | } // end namespace libhei |