summaryrefslogtreecommitdiffstats
path: root/src/import/generic/memory/lib/utils
diff options
context:
space:
mode:
authorMark Pizzutillo <Mark.Pizzutillo@ibm.com>2019-08-26 18:02:37 -0400
committerChristian R Geddes <crgeddes@us.ibm.com>2019-09-27 13:49:09 -0500
commit48abe5e8afb54e389f45233e66e100a501d038e8 (patch)
tree2a930b0edc5367239fc100baf5df1b45185cf8eb /src/import/generic/memory/lib/utils
parent04d5973bec03c271184ff87f1e0dbb3aa57857d4 (diff)
downloadblackbird-hostboot-48abe5e8afb54e389f45233e66e100a501d038e8.tar.gz
blackbird-hostboot-48abe5e8afb54e389f45233e66e100a501d038e8.zip
Add support for new pmic sequencing SPD fields
Change-Id: I8847090585161375fbb2c0ef853cffed80a67cc3 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/82961 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Louis Stermole <stermole@us.ibm.com> Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com> Reviewed-by: Jennifer A Stofer <stofer@us.ibm.com> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/83375 Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Christian R Geddes <crgeddes@us.ibm.com>
Diffstat (limited to 'src/import/generic/memory/lib/utils')
-rw-r--r--src/import/generic/memory/lib/utils/find.H20
-rw-r--r--src/import/generic/memory/lib/utils/index.H17
2 files changed, 37 insertions, 0 deletions
diff --git a/src/import/generic/memory/lib/utils/find.H b/src/import/generic/memory/lib/utils/find.H
index f96252913..dd5a6dbfd 100644
--- a/src/import/generic/memory/lib/utils/find.H
+++ b/src/import/generic/memory/lib/utils/find.H
@@ -39,10 +39,12 @@
#include <fapi2.H>
#include <vector>
#include <generic/memory/lib/utils/c_str.H>
+#include <generic/memory/lib/utils/index.H>
#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
namespace mss
{
+
///
/// @brief Helper to find a set of elements based on a fapi2 target
/// @tparam M the target type to be returned
@@ -258,6 +260,24 @@ find_targets( const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
}
///
+/// @brief Helper to find a set of elements based on a fapi2 target, then sort them
+/// @tparam M the target type to be returned
+/// @tparam T the fapi2 target type of the argument
+/// @param[in] i_target the fapi2 target T
+/// @param[in] i_state [optional] fapi2 target state (defaults to TARGET_STATE_FUNCTIONAL)
+/// @return a vector of M targets sorted by mss::index.
+/// @note this uses mss::index so the targets will be sorted via ATTR_REL_POS of their immediate parent
+///
+template< fapi2::TargetType M, fapi2::TargetType T >
+static inline std::vector< fapi2::Target<M> > find_targets_sorted_by_index( const fapi2::Target<T>& i_target,
+ fapi2::TargetState i_state = fapi2::TARGET_STATE_FUNCTIONAL )
+{
+ std::vector<fapi2::Target<M>> l_targets = find_targets<M, T>(i_target, i_state);
+ sort_targets_by_index(l_targets);
+ return l_targets;
+}
+
+///
/// @brief find a key value from a vector of STL pairs
/// @tparam T input type
/// @tparam OT the output type to be returned
diff --git a/src/import/generic/memory/lib/utils/index.H b/src/import/generic/memory/lib/utils/index.H
index fde43f711..1657a9e18 100644
--- a/src/import/generic/memory/lib/utils/index.H
+++ b/src/import/generic/memory/lib/utils/index.H
@@ -74,6 +74,23 @@ fapi_try_exit:
}
///
+/// @brief Sort the provided target vector in order of index (low to high)
+///
+/// @tparam T TargetType
+/// @param[in,out] io_targets vector of targets to sort
+///
+template <fapi2::TargetType T>
+inline void sort_targets_by_index(std::vector<fapi2::Target<T>>& io_targets)
+{
+ std::sort(io_targets.begin(), io_targets.end(), [] (
+ const fapi2::Target<T>& l_first_target,
+ const fapi2::Target<T>& l_second_target) -> bool
+ {
+ return mss::index(l_first_target) < mss::index(l_first_target);
+ });
+}
+
+///
/// @brief Return an attribute array index from a rank number
/// @param[in] i_rank uint64_t a rank number DIMM0 {0, 1, 2, 3} DIMM1 {0, 1, 2, 3}
/// @return size_t the attribute array index.
OpenPOWER on IntegriCloud