summaryrefslogtreecommitdiffstats
path: root/src/import/hwpf
diff options
context:
space:
mode:
authorAndre Marin <aamarin@us.ibm.com>2017-04-04 12:48:15 -0500
committerSachin Gupta <sgupta2m@in.ibm.com>2017-04-11 05:30:12 -0400
commit061be34b12456d1b1e46f5a65fe9c74b80b59738 (patch)
tree76643efd4c18db77c9f85de38cd7a8dcff23cb38 /src/import/hwpf
parent8dda0b4d0afedc71cf34c54183f58aba71720ad1 (diff)
downloadtalos-sbe-061be34b12456d1b1e46f5a65fe9c74b80b59738.tar.gz
talos-sbe-061be34b12456d1b1e46f5a65fe9c74b80b59738.zip
Add another writeBit API, modify getBit. Add unit tests.
Change-Id: I9bd9efdc4b2c8a2eac26b7b1f1e1ef183d81f9b6 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38817 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com> Reviewed-by: JACOB L. HARVEY <jlharvey@us.ibm.com> Reviewed-by: Matt K. Light <mklight@us.ibm.com> Reviewed-by: Thi N. Tran <thi@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38823 Reviewed-by: Hostboot Team <hostboot@us.ibm.com> Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'src/import/hwpf')
-rw-r--r--src/import/hwpf/fapi2/include/buffer.H34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/import/hwpf/fapi2/include/buffer.H b/src/import/hwpf/fapi2/include/buffer.H
index 8ee35cbd..eee15f3b 100644
--- a/src/import/hwpf/fapi2/include/buffer.H
+++ b/src/import/hwpf/fapi2/include/buffer.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER sbe Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -263,6 +263,7 @@ class buffer
/// @brief Write a bit in buffer to a given value
/// @tparam B Bit in buffer to write
/// @tparam C the count of bits to write, defaults to 1
+ /// @param[in] i_value the value to write
/// @return buffer& Useful for method chaining
/// @note Asserting that all the parameters are known at
/// compile time so this can be templated only. If that is not
@@ -278,6 +279,24 @@ class buffer
return *this;
}
+ ///
+ /// @brief Write a bit in buffer to a given value
+ /// @param[in] i_value the value to write
+ /// @param[in] i_bit the bit number to set.
+ /// @param[in] i_count the count of bits to set, defaults to 1
+ /// @return FAPI2_RC_SUCCESS if OK
+ ///
+ inline fapi2::ReturnCodes writeBit(const bool i_value,
+ const bits_type& i_bit,
+ const bits_type& i_count = 1)
+ {
+ if(i_value == 0)
+ {
+ return clearBit(i_bit, i_count);
+ }
+
+ return setBit(i_bit, i_count);
+ }
///
/// @brief Invert bit
@@ -315,14 +334,21 @@ class buffer
/// @brief Get the value of a bit in the buffer
/// @param[in] i_bit the bit number to set.
/// @param[in] i_count the count of bits to set, defaults to 1
- /// @return true if *any* bit is on, false if *every* bit is off
+ /// @return true if *any* bit is on,
+ /// false if *every* bit is off or if invalid input received
/// @note 0 is left-most
///
inline bool getBit(const bits_type& i_bit,
- const bits_type& i_count = 1)
+ const bits_type& i_count = 1) const
{
buffer<T> l_temp;
- l_temp.setBit(i_bit, i_count);
+
+ if(l_temp.setBit(i_bit, i_count) != fapi2::FAPI2_RC_SUCCESS)
+ {
+ FAPI_ERR("input out-of-bounds! (bit + count - 1) > %d", TT::bits_per_unit());
+ return false;
+ }
+
return l_temp & iv_data;
}
OpenPOWER on IntegriCloud