Remove the ReturnCode class
It was over-engineered and no longer needed.
Change-Id: Iac337f8c8bf1e1a376a1fbc44fc053ec02c76542
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/src/hei_includes.hpp b/src/hei_includes.hpp
index bf771e5..ac56493 100644
--- a/src/hei_includes.hpp
+++ b/src/hei_includes.hpp
@@ -26,5 +26,4 @@
// Internal includes
#include <hei_chip.hpp>
-#include <hei_return_code.hpp>
#include <hei_types.hpp>
diff --git a/src/hei_return_code.hpp b/src/hei_return_code.hpp
deleted file mode 100644
index 4090bf3..0000000
--- a/src/hei_return_code.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-
-namespace libhei
-{
-
-class ReturnCode
-{
- public:
- /**
- * @brief Constructor.
- * @param i_rc The error code value.
- */
- explicit constexpr ReturnCode(uint32_t i_rc = 0) : iv_rc(i_rc) {}
-
- /** @brief Default copy constructor. */
- ReturnCode(const ReturnCode&) = default;
-
- /** @brief Default assignment operator. */
- ReturnCode& operator=(const ReturnCode&) = default;
-
- /** @brief Default destructor. */
- ~ReturnCode() = default;
-
- /** @brief Integral type conversion function. */
- operator uint32_t() const
- {
- return iv_rc;
- }
-
- /** @brief Integral type conversion function. */
- operator uint64_t() const
- {
- return iv_rc;
- }
-
- /** @brief Equals operator. */
- bool operator==(const ReturnCode& rhs) const
- {
- return rhs.iv_rc == iv_rc;
- }
-
- /** @brief Not equals operator. */
- bool operator!=(const ReturnCode& rhs) const
- {
- return rhs.iv_rc != iv_rc;
- }
-
- /**
- * @brief Returns the error code value.
- *
- * We'd prefer to use the integral type conversion functions above, but
- * some compilers will throw warnings when passing this object into
- * functions with variadic arguments, like printf().
- */
- uint32_t get() const
- {
- return iv_rc;
- }
-
- private:
- uint32_t iv_rc; ///< return code value
-};
-
-// clang-format off
-
-/** Function returned successfully. */
-static constexpr ReturnCode RC_SUCCESS = ReturnCode();
-
-/** Generic return code indicating something along the hardware register access
- * path failed and the returned data is undefined and should not be used. */
-static constexpr ReturnCode RC_REG_ACCESS_FAILURE = ReturnCode(0x00000004);
-
-// clang-format on
-
-} // end namespace libhei
diff --git a/src/hei_user_interface.hpp b/src/hei_user_interface.hpp
index 9fa908d..e8740f3 100644
--- a/src/hei_user_interface.hpp
+++ b/src/hei_user_interface.hpp
@@ -72,12 +72,13 @@
* address (right justified), which is provided to the
* isolator by the user application via the Chip Data Files.
*
- * @return RC_SUCCESS or RC_REG_ACCESS_FAILURE. Note that in the case of a
- * failure the user application is responsible for reporting why the
- * register access failed.
+ * @return false => register access was successful
+ * true => hardware access failure
+ * Note that in the case of a failure, the user application is
+ * responsible for reporting why the register access failed.
*/
-ReturnCode registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
- uint64_t i_regType, uint64_t i_address);
+bool registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
+ uint64_t i_regType, uint64_t i_address);
#ifndef __HEI_READ_ONLY
@@ -105,12 +106,13 @@
* address (right justified), which is provided to the
* isolator by the user application via the Chip Data Files.
*
- * @return RC_SUCCESS or RC_REG_ACCESS_FAILURE. Note that in the case of a
- * failure the user application is responsible for reporting why the
- * register access failed.
+ * @return false => register access was successful
+ * true => hardware access failure
+ * Note that in the case of a failure, the user application is
+ * responsible for reporting why the register access failed.
*/
-ReturnCode registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
- uint64_t i_regType, uint64_t i_address);
+bool registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
+ uint64_t i_regType, uint64_t i_address);
// used by HEI_INF macro in this library
void hei_inf(char* format, ...); // implemented in user application
diff --git a/src/register/hei_hardware_register.cpp b/src/register/hei_hardware_register.cpp
index 74df35f..213991d 100644
--- a/src/register/hei_hardware_register.cpp
+++ b/src/register/hei_hardware_register.cpp
@@ -56,9 +56,9 @@
//------------------------------------------------------------------------------
-ReturnCode HardwareRegister::read(const Chip& i_chip, bool i_force) const
+bool HardwareRegister::read(const Chip& i_chip, bool i_force) const
{
- ReturnCode rc;
+ bool accessFailure = false;
// Verify this register belongs on i_chip.
verifyAccessorChip(i_chip);
@@ -78,9 +78,9 @@
size_t sz_buffer = BitString::getMinBytes(bs.getBitLen());
// Read this register from hardware.
- rc = registerRead(i_chip, bs.getBufAddr(), sz_buffer, getRegisterType(),
- getAddress());
- if (RC_SUCCESS != rc)
+ accessFailure = registerRead(i_chip, bs.getBufAddr(), sz_buffer,
+ getRegisterType(), getAddress());
+ if (accessFailure)
{
// The read failed and we can't trust what was put in the register
// cache. So remove this instance's entry from the cache.
@@ -94,16 +94,16 @@
}
}
- return rc;
+ return accessFailure;
}
//------------------------------------------------------------------------------
#ifndef __HEI_READ_ONLY
-ReturnCode HardwareRegister::write(const Chip& i_chip) const
+bool HardwareRegister::write(const Chip& i_chip) const
{
- ReturnCode rc;
+ bool accessFailure = false;
// Verify this register belongs on i_chip.
verifyAccessorChip(i_chip);
@@ -122,17 +122,17 @@
size_t sz_buffer = BitString::getMinBytes(bs.getBitLen());
// Write to this register to hardware.
- rc = registerWrite(i_chip, bs.getBufAddr(), sz_buffer, getRegisterType(),
- getAddress());
+ accessFailure = registerWrite(i_chip, bs.getBufAddr(), sz_buffer,
+ getRegisterType(), getAddress());
- if (RC_SUCCESS == rc)
+ if (accessFailure)
{
// Sanity check. The returned size of the data written to the buffer
// should match the register size.
HEI_ASSERT(getSize() == sz_buffer);
}
- return rc;
+ return accessFailure;
}
#endif // __HEI_READ_ONLY
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index d8edfd8..cc3cf76 100644
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -156,7 +156,7 @@
* read from hardware and update the cache.
* @return See the return code from the registerRead() user interface API.
*/
- ReturnCode read(const Chip& i_chip, bool i_force = false) const;
+ bool read(const Chip& i_chip, bool i_force = false) const;
#ifndef __HEI_READ_ONLY
@@ -166,7 +166,7 @@
* @param i_chip The target chip in which this register belongs.
* @return See the return code from the registerWrite() user interface API.
*/
- ReturnCode write(const Chip& i_chip) const;
+ bool write(const Chip& i_chip) const;
#endif // __HEI_READ_ONLY