summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Glancy <sglancy@us.ibm.com>2018-08-30 15:54:28 -0500
committerChristian R. Geddes <crgeddes@us.ibm.com>2018-09-18 10:13:11 -0500
commit4f35730b3dbecc04c63c2cd6a269eba2bc19fe33 (patch)
treeaf45380588227c499da6ae62d056915b95b2730f /src
parent263f34b1674278904e02ec68d12176ce94638b39 (diff)
downloadtalos-hostboot-4f35730b3dbecc04c63c2cd6a269eba2bc19fe33.tar.gz
talos-hostboot-4f35730b3dbecc04c63c2cd6a269eba2bc19fe33.zip
Adds endian_swap to fapi2
Change-Id: Ie076098cd05ea0ae768d8da142df1b933ab7eb07 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/65525 Dev-Ready: STEPHEN GLANCY <sglancy@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: HWSV CI <hwsv-ci+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: Louis Stermole <stermole@us.ibm.com> Reviewed-by: ANDRE A. MARIN <aamarin@us.ibm.com> Reviewed-by: Matt K. Light <mklight@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/65529 Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/import/chips/p9/procedures/hwp/memory/lib/dimm/eff_dimm.C3
-rw-r--r--src/import/chips/p9/procedures/hwp/memory/lib/utils/swizzle.H21
-rw-r--r--src/import/hwpf/fapi2/include/utils.H27
3 files changed, 28 insertions, 23 deletions
diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/dimm/eff_dimm.C b/src/import/chips/p9/procedures/hwp/memory/lib/dimm/eff_dimm.C
index 9b3243609..8446c6838 100644
--- a/src/import/chips/p9/procedures/hwp/memory/lib/dimm/eff_dimm.C
+++ b/src/import/chips/p9/procedures/hwp/memory/lib/dimm/eff_dimm.C
@@ -48,7 +48,6 @@
#include <lib/shared/mss_kind.H>
#include <lib/phy/dp16.H>
#include <lib/mss_attribute_accessors_manual.H>
-#include <endian.h>
namespace mss
{
@@ -826,7 +825,7 @@ fapi2::ReturnCode eff_dimm::dram_mfg_id()
FAPI_TRY( iv_spd_decoder.dram_manufacturer_id_code(l_decoder_val), "Failed getting dram id code from SPD %s",
mss::c_str(iv_dimm) );
- endian_swap(l_decoder_val);
+ fapi2::endian_swap(l_decoder_val);
switch (l_decoder_val)
{
diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/utils/swizzle.H b/src/import/chips/p9/procedures/hwp/memory/lib/utils/swizzle.H
index 57523f5bd..74449540b 100644
--- a/src/import/chips/p9/procedures/hwp/memory/lib/utils/swizzle.H
+++ b/src/import/chips/p9/procedures/hwp/memory/lib/utils/swizzle.H
@@ -42,27 +42,6 @@ namespace mss
{
///
-/// @brief Endian swapping
-/// @tparam T input type
-/// @param[in,out] io_input integral input
-/// @note https://stackoverflow.com/questions/105252/how-do-i-convert-between-big-endian-and-little-endian-values-in-c
-///
-template < typename T >
-void endian_swap(T& io_input)
-{
- constexpr size_t MIN_BYTES = 2;
- static_assert(sizeof(T) >= MIN_BYTES, "Byte swapping requires at least 2 bytes of data");
-
- uint8_t* l_varArray = reinterpret_cast<uint8_t*>(&io_input);
-
- for(size_t i = 0; i < sizeof(io_input) / 2; i++)
- {
- const size_t BYTE_SWAP_INDEX = sizeof(io_input) - 1 - i;
- std::swap(l_varArray[BYTE_SWAP_INDEX], l_varArray[i]);
- }
-}
-
-///
/// @brief Swap two bits in a buffer
/// @tparam TB the bit in the buffer to move to SB
/// @tparam SB the bit in the buffer to move to TB
diff --git a/src/import/hwpf/fapi2/include/utils.H b/src/import/hwpf/fapi2/include/utils.H
index 8534d3bdb..174d9e2dd 100644
--- a/src/import/hwpf/fapi2/include/utils.H
+++ b/src/import/hwpf/fapi2/include/utils.H
@@ -38,6 +38,33 @@
namespace fapi2
{
+
+///
+/// @brief Endian swapping
+/// @tparam T input type
+/// @param[in,out] io_input integral input
+/// @note https://stackoverflow.com/questions/105252/how-do-i-convert-between-big-endian-and-little-endian-values-in-c
+/// This function does not take into account the system's endianness, but just does the endian swap
+///
+template < typename T >
+void endian_swap(T& io_input)
+{
+ constexpr size_t MIN_BYTES = 2;
+ static_assert(sizeof(T) >= MIN_BYTES, "Byte swapping requires at least 2 bytes of data");
+
+ uint8_t* l_varArray = reinterpret_cast<uint8_t*>(&io_input);
+
+ for(size_t i = 0; i < sizeof(io_input) / 2; i++)
+ {
+ const size_t BYTE_SWAP_INDEX = sizeof(io_input) - 1 - i;
+
+ // Rolling our own swap as certain downstream libraries do not have std::swap enabled
+ const auto l_temp = l_varArray[BYTE_SWAP_INDEX];
+ l_varArray[BYTE_SWAP_INDEX] = l_varArray[i];
+ l_varArray[i] = l_temp;
+ }
+}
+
#ifndef __PPE__
///
/// @brief Enable/Disable special wakeup on processor chip core(s)
OpenPOWER on IntegriCloud