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