Replace RegisterAccessLevel_t with RegisterAttributeFlags_t
The Chip Data File format allows for an 8-bit attribute flag field, two
of which determine the register access level. Using a query function to
get the access level information from the attribute field instead of
having separate member variables per flag.
Change-Id: Ica4e408910e23ab8419964c35830ced5aa435d97
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/src/register/hei_hardware_register.cpp b/src/register/hei_hardware_register.cpp
index 0f994c0..bf9a55a 100644
--- a/src/register/hei_hardware_register.cpp
+++ b/src/register/hei_hardware_register.cpp
@@ -23,8 +23,7 @@
// will be created in the cache, if it does not exist, when the cache is
// accessed below.
- auto al = getAccessLevel();
- if ((REG_ACCESS_NONE != al) && (REG_ACCESS_WO != al))
+ if (queryAttrFlag(REG_ATTR_ACCESS_READ))
{
read(i_chip);
}
@@ -45,8 +44,7 @@
// will be created in the cache, if it does not exist, when the cache is
// accessed below.
- auto al = getAccessLevel();
- if ((REG_ACCESS_NONE != al) && (REG_ACCESS_WO != al))
+ if (queryAttrFlag(REG_ATTR_ACCESS_READ))
{
read(i_chip);
}
@@ -68,8 +66,7 @@
if (i_force || !queryCache(i_chip))
{
// This register must be readable.
- auto al = getAccessLevel();
- HEI_ASSERT((REG_ACCESS_NONE != al) && (REG_ACCESS_WO != al));
+ HEI_ASSERT(queryAttrFlag(REG_ATTR_ACCESS_READ));
// Get the buffer from the register cache.
BitString& bs = accessCache(i_chip);
@@ -109,8 +106,7 @@
verifyAccessorChip(i_chip);
// This register must be writable.
- auto al = getAccessLevel();
- HEI_ASSERT((REG_ACCESS_NONE != al) && (REG_ACCESS_RO != al));
+ HEI_ASSERT(queryAttrFlag(REG_ATTR_ACCESS_WRITE));
// An entry for this register must exist in the cache.
HEI_ASSERT(queryCache(i_chip));
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index 81fb79b..fe71c75 100644
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -43,17 +43,16 @@
protected:
/**
* @brief Constructor from components.
- * @param i_chipType Type of chip associated with this register.
- * @param i_id Unique ID for this register.
- * @param i_instance Instance of this register
- * @param i_accessLevel Hardware access level for this register.
+ * @param i_chipType Type of chip associated with this register.
+ * @param i_id Unique ID for this register.
+ * @param i_instance Instance of this register
+ * @param i_flags Attribute flags for this register.
*/
HardwareRegister(ChipType_t i_chipType, RegisterId_t i_id,
- Instance_t i_instance,
- RegisterAccessLevel_t i_accessLevel) :
+ Instance_t i_instance, RegisterAttributeFlags_t i_flags) :
Register(),
iv_chipType(i_chipType), iv_id(i_id), iv_instance(i_instance),
- iv_accessLevel(i_accessLevel)
+ iv_flags(i_flags)
{}
private: // Instance variables
@@ -70,7 +69,7 @@
/** The hardware access level of this register (read/write, read-only,
* write-only, etc.). */
- const RegisterAccessLevel_t iv_accessLevel;
+ const RegisterAttributeFlags_t iv_flags;
public: // Accessor functions
/** @return The type of chip associated with this register. */
@@ -91,10 +90,10 @@
return iv_instance;
}
- /** @return The hardware access level of this register. */
- RegisterAccessLevel_t getAccessLevel() const
+ /** @return True if given flag is enabled, false if disabled. */
+ bool queryAttrFlag(RegisterAttributeFlags_t i_flag) const
{
- return iv_accessLevel;
+ return (0 != (iv_flags & i_flag));
}
// NOTE: The following are determined by child classes.
diff --git a/src/register/hei_scom_register.hpp b/src/register/hei_scom_register.hpp
index b93674a..d5921fd 100644
--- a/src/register/hei_scom_register.hpp
+++ b/src/register/hei_scom_register.hpp
@@ -18,16 +18,16 @@
public: // Constructor, destructors, assignment, etc.
/**
* @brief Constructor from components.
- * @param i_chipType Type of chip associated with this register.
- * @param i_id Unique ID for this register.
- * @param i_instance Instance of this register
- * @param i_accessLevel Hardware access level for this register.
- * @param i_address A 4-byte address for this SCOM register.
+ * @param i_chipType Type of chip associated with this register.
+ * @param i_id Unique ID for this register.
+ * @param i_instance Instance of this register
+ * @param i_flags Attribute flags for this register.
+ * @param i_address A 4-byte address for this SCOM register.
*/
ScomRegister(ChipType_t i_chipType, RegisterId_t i_id,
- Instance_t i_instance, RegisterAccessLevel_t i_accessLevel,
+ Instance_t i_instance, RegisterAttributeFlags_t i_flags,
uint32_t i_address) :
- HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel),
+ HardwareRegister(i_chipType, i_id, i_instance, i_flags),
iv_address(i_address)
{}
@@ -99,16 +99,16 @@
public: // Constructor, destructors, assignment, etc.
/**
* @brief Constructor from components.
- * @param i_chipType Type of chip associated with this register.
- * @param i_id Unique ID for this register.
- * @param i_instance Instance of this register
- * @param i_accessLevel Hardware access level for this register.
- * @param i_address An 8-byte address for this Indirect SCOM register.
+ * @param i_chipType Type of chip associated with this register.
+ * @param i_id Unique ID for this register.
+ * @param i_instance Instance of this register
+ * @param i_flags Attribute flags for this register.
+ * @param i_address An 8-byte address for this Indirect SCOM register.
*/
IdScomRegister(ChipType_t i_chipType, RegisterId_t i_id,
- Instance_t i_instance, RegisterAccessLevel_t i_accessLevel,
+ Instance_t i_instance, RegisterAttributeFlags_t i_flags,
uint64_t i_address) :
- HardwareRegister(i_chipType, i_id, i_instance, i_accessLevel),
+ HardwareRegister(i_chipType, i_id, i_instance, i_flags),
iv_address(i_address)
{}