Removed ChipType_t dependency in HardwareRegister
This dependency defeated the purpose of the flyweights because a
register that does not differ between chip model/EC would end up having
an instance for each model/EC. The explodes the memory used for these
objects.
This does expose a problem where someone may try to access a register
that does not exist for a specific chip type. However, they should be
getting the register objects from the IsolationChip class for the
specific chip type anyway. Therefore, the exposure is minimal compared
to the memory savings.
Change-Id: I926a71ea180fca7e39572ffe17d9f64e35395e53
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 bf9a55a..2d2167e 100644
--- a/src/register/hei_hardware_register.cpp
+++ b/src/register/hei_hardware_register.cpp
@@ -14,9 +14,6 @@
const BitString* HardwareRegister::getBitString(const Chip& i_chip) const
{
- // Verify this register belongs on i_chip.
- verifyAccessorChip(i_chip);
-
// Calling read() will ensure that an entry exists in the cache and the
// entry has at been synched with hardware at least once. Note that we
// cannot read hardware for write-only registers. In this case, an entry
@@ -35,9 +32,6 @@
BitString& HardwareRegister::accessBitString(const Chip& i_chip)
{
- // Verify this register belongs on i_chip.
- verifyAccessorChip(i_chip);
-
// Calling read() will ensure that an entry exists in the cache and the
// entry has at been synched with hardware at least once. Note that we
// cannot read hardware for write-only registers. In this case, an entry
@@ -58,9 +52,6 @@
{
bool accessFailure = false;
- // Verify this register belongs on i_chip.
- verifyAccessorChip(i_chip);
-
// Read from hardware only if the read is forced or the entry for this
// instance does not exist in the cache.
if (i_force || !queryCache(i_chip))
@@ -76,7 +67,7 @@
// Read this register from hardware.
accessFailure = registerRead(i_chip, bs.getBufAddr(), sz_buffer,
- getRegisterType(), getAddress());
+ getType(), getAddress());
if (accessFailure)
{
// The read failed and we can't trust what was put in the register
@@ -102,9 +93,6 @@
{
bool accessFailure = false;
- // Verify this register belongs on i_chip.
- verifyAccessorChip(i_chip);
-
// This register must be writable.
HEI_ASSERT(queryAttrFlag(REG_ATTR_ACCESS_WRITE));
@@ -118,8 +106,8 @@
size_t sz_buffer = BitString::getMinBytes(bs.getBitLen());
// Write to this register to hardware.
- accessFailure = registerWrite(i_chip, bs.getBufAddr(), sz_buffer,
- getRegisterType(), getAddress());
+ accessFailure = registerWrite(i_chip, bs.getBufAddr(), sz_buffer, getType(),
+ getAddress());
if (accessFailure)
{
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index fe71c75..ae7480e 100644
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -43,22 +43,17 @@
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_flags Attribute flags for this register.
*/
- HardwareRegister(ChipType_t i_chipType, RegisterId_t i_id,
- Instance_t i_instance, RegisterAttributeFlags_t i_flags) :
+ HardwareRegister(RegisterId_t i_id, Instance_t i_instance,
+ RegisterAttributeFlags_t i_flags) :
Register(),
- iv_chipType(i_chipType), iv_id(i_id), iv_instance(i_instance),
- iv_flags(i_flags)
+ iv_id(i_id), iv_instance(i_instance), iv_flags(i_flags)
{}
private: // Instance variables
- /** The type of chip associated with register. */
- const ChipType_t iv_chipType;
-
/** The unique ID for this register. */
const RegisterId_t iv_id;
@@ -72,12 +67,6 @@
const RegisterAttributeFlags_t iv_flags;
public: // Accessor functions
- /** @return The type of chip associated with this register. */
- ChipType_t getChipType() const
- {
- return iv_chipType;
- }
-
/* @return The unique ID for this register. */
RegisterId_t getId() const
{
@@ -99,7 +88,7 @@
// NOTE: The following are determined by child classes.
/** @return This register's type. */
- virtual RegisterType_t getRegisterType() const = 0;
+ virtual RegisterType_t getType() const = 0;
/** @return The address of this register. */
virtual RegisterAddress_t getAddress() const = 0;
@@ -111,30 +100,22 @@
/** @brief Equals operator. */
bool operator==(const HardwareRegister& i_r) const
{
- // Comparing register type, chip type, and address should be sufficient.
- return (getRegisterType() == i_r.getRegisterType()) &&
- (getChipType() == i_r.getChipType()) &&
- (getAddress() == i_r.getAddress());
+ // Comparing register type and address should be sufficient.
+ return (getAddress() == i_r.getAddress()) &&
+ (getType() == i_r.getType());
}
/** @brief Less than operator. */
bool operator<(const HardwareRegister& i_r) const
{
- // Comparing register type, chip type, and address should be sufficient.
- if (getRegisterType() < i_r.getRegisterType())
+ // Comparing register type and address should be sufficient.
+ if (getAddress() < i_r.getAddress())
{
return true;
}
- else if (getRegisterType() == i_r.getRegisterType())
+ else if (getAddress() == i_r.getAddress())
{
- if (getChipType() < i_r.getChipType())
- {
- return true;
- }
- else if (getChipType() == i_r.getChipType())
- {
- return (getAddress() < i_r.getAddress());
- }
+ return (getType() < i_r.getType());
}
return false;
@@ -180,13 +161,6 @@
*/
BitString& accessBitString(const Chip& i_chip);
- private: // Hardware accessor management functions.
- /** @brief Asserts this register belongs on the target accessor chip. */
- void verifyAccessorChip(const Chip& i_chip) const
- {
- HEI_ASSERT(getChipType() == i_chip.getType());
- }
-
private: // Register cache class variable
/**
* @brief Caches the contents of registers read from hardware.
diff --git a/src/register/hei_scom_register.hpp b/src/register/hei_scom_register.hpp
index d5921fd..47a6852 100644
--- a/src/register/hei_scom_register.hpp
+++ b/src/register/hei_scom_register.hpp
@@ -18,16 +18,14 @@
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_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, RegisterAttributeFlags_t i_flags,
- uint32_t i_address) :
- HardwareRegister(i_chipType, i_id, i_instance, i_flags),
+ ScomRegister(RegisterId_t i_id, Instance_t i_instance,
+ RegisterAttributeFlags_t i_flags, uint32_t i_address) :
+ HardwareRegister(i_id, i_instance, i_flags),
iv_address(i_address)
{}
@@ -57,7 +55,7 @@
public: // Accessor functions
/** Function overloaded from parent HardwareRegister class. */
- RegisterType_t getRegisterType() const
+ RegisterType_t getType() const
{
return REG_TYPE_SCOM;
}
@@ -99,16 +97,14 @@
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_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, RegisterAttributeFlags_t i_flags,
- uint64_t i_address) :
- HardwareRegister(i_chipType, i_id, i_instance, i_flags),
+ IdScomRegister(RegisterId_t i_id, Instance_t i_instance,
+ RegisterAttributeFlags_t i_flags, uint64_t i_address) :
+ HardwareRegister(i_id, i_instance, i_flags),
iv_address(i_address)
{}
@@ -138,7 +134,7 @@
public: // Accessor functions
/** Function overloaded from parent HardwareRegister class. */
- RegisterType_t getRegisterType() const
+ RegisterType_t getType() const
{
return REG_TYPE_ID_SCOM;
}