blob: da0eee9c4f4de157880ac22aff3f019031c48cff [file] [log] [blame]
Zane Shelley8deb0902019-10-14 15:52:27 -05001#pragma once
2
3#include <register/hei_hardware_register.hpp>
Zane Shelley2f341bf2019-10-16 11:19:36 -05004#include <util/hei_flyweight.hpp>
Zane Shelley8deb0902019-10-14 15:52:27 -05005
6namespace 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 */
16class ScomRegister : public HardwareRegister
17{
18 public: // Constructor, destructors, assignment, etc.
Zane Shelley8deb0902019-10-14 15:52:27 -050019 /**
20 * @brief Constructor from components.
Zane Shelley7667b712020-05-11 20:45:40 -050021 * @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 Shelley8deb0902019-10-14 15:52:27 -050025 */
Zane Shelley5ec88102020-05-11 21:08:25 -050026 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 Shelley83da2452019-10-25 15:45:34 -050029 iv_address(i_address)
Zane Shelley8deb0902019-10-14 15:52:27 -050030 {}
31
32 /** @brief Destructor. */
33 ~ScomRegister() = default;
34
Zane Shelley2f341bf2019-10-16 11:19:36 -050035 private:
Zane Shelley981e56a2020-05-11 21:24:20 -050036 /** @brief Copy constructor. */
37 ScomRegister(const ScomRegister&) = delete;
Zane Shelley2f341bf2019-10-16 11:19:36 -050038
Zane Shelley981e56a2020-05-11 21:24:20 -050039 /** @brief Assignment operator. */
Zane Shelleyfe27b652019-10-28 11:33:07 -050040 ScomRegister& operator=(const ScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -050041
42 public: // Accessor functions
Zane Shelley8deb0902019-10-14 15:52:27 -050043 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5a78fa82022-09-16 16:49:58 -050044 RegisterType_t getType() const override
Zane Shelley7f7a42d2019-10-28 13:28:31 -050045 {
46 return REG_TYPE_SCOM;
47 }
Zane Shelley8deb0902019-10-14 15:52:27 -050048
49 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5a78fa82022-09-16 16:49:58 -050050 RegisterAddress_t getAddress() const override
Zane Shelley8deb0902019-10-14 15:52:27 -050051 {
Zane Shelley83da2452019-10-25 15:45:34 -050052 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -050053 }
54
55 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5a78fa82022-09-16 16:49:58 -050056 size_t getSize() const override
Zane Shelley7f7a42d2019-10-28 13:28:31 -050057 {
58 return 8;
59 }
Zane Shelley8deb0902019-10-14 15:52:27 -050060
Zane Shelley8deb0902019-10-14 15:52:27 -050061 private: // Instance variables
Zane Shelley8deb0902019-10-14 15:52:27 -050062 /** 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 */
81class IdScomRegister : public HardwareRegister
82{
83 public: // Constructor, destructors, assignment, etc.
Zane Shelley8deb0902019-10-14 15:52:27 -050084 /**
85 * @brief Constructor from components.
Zane Shelley7667b712020-05-11 20:45:40 -050086 * @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 Shelley8deb0902019-10-14 15:52:27 -050090 */
Zane Shelley5ec88102020-05-11 21:08:25 -050091 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 Shelley83da2452019-10-25 15:45:34 -050094 iv_address(i_address)
Zane Shelley8deb0902019-10-14 15:52:27 -050095 {}
96
97 /** @brief Destructor. */
98 ~IdScomRegister() = default;
99
Zane Shelley2f341bf2019-10-16 11:19:36 -0500100 private:
Zane Shelley981e56a2020-05-11 21:24:20 -0500101 /** @brief Copy constructor. */
102 IdScomRegister(const IdScomRegister&) = delete;
Zane Shelley2f341bf2019-10-16 11:19:36 -0500103
Zane Shelley981e56a2020-05-11 21:24:20 -0500104 /** @brief Assignment operator. */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500105 IdScomRegister& operator=(const IdScomRegister&) = delete;
Zane Shelley8deb0902019-10-14 15:52:27 -0500106
107 public: // Accessor functions
Zane Shelley8deb0902019-10-14 15:52:27 -0500108 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5a78fa82022-09-16 16:49:58 -0500109 RegisterType_t getType() const override
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500110 {
111 return REG_TYPE_ID_SCOM;
112 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500113
114 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5a78fa82022-09-16 16:49:58 -0500115 RegisterAddress_t getAddress() const override
Zane Shelley8deb0902019-10-14 15:52:27 -0500116 {
Zane Shelley83da2452019-10-25 15:45:34 -0500117 return static_cast<RegisterAddress_t>(iv_address);
Zane Shelley8deb0902019-10-14 15:52:27 -0500118 }
119
120 /** Function overloaded from parent HardwareRegister class. */
Zane Shelley5a78fa82022-09-16 16:49:58 -0500121 size_t getSize() const override
Zane Shelley7f7a42d2019-10-28 13:28:31 -0500122 {
123 return 8; // See note in class documentation.
124 }
Zane Shelley8deb0902019-10-14 15:52:27 -0500125
Zane Shelley8deb0902019-10-14 15:52:27 -0500126 private: // Instance variables
Zane Shelley8deb0902019-10-14 15:52:27 -0500127 /** This register's address. */
128 const uint64_t iv_address;
129
130}; // end class IdScomRegister
131
132} // end namespace libhei