diff options
author | Andre Marin <aamarin@us.ibm.com> | 2017-04-04 12:48:15 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2017-04-11 10:22:16 -0400 |
commit | 97d6fee68a3980cbedb37d7daf30cdb338efabda (patch) | |
tree | 02bb4976160e197b0978a57934c509da9db2b9c0 /src/import/hwpf/fapi2 | |
parent | dbfa69fb24cc90c9fa074b73e88c0971eae24e3a (diff) | |
download | talos-hostboot-97d6fee68a3980cbedb37d7daf30cdb338efabda.tar.gz talos-hostboot-97d6fee68a3980cbedb37d7daf30cdb338efabda.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/38824
Reviewed-by: Hostboot Team <hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/import/hwpf/fapi2')
-rw-r--r-- | src/import/hwpf/fapi2/include/buffer.H | 34 |
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 777924190..08ce5ebeb 100644 --- a/src/import/hwpf/fapi2/include/buffer.H +++ b/src/import/hwpf/fapi2/include/buffer.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot 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; } |