primary-proc: move function to common utils
This is a useful function which can be utilized in upcoming work so move
to the common utilities
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I87873b4dbedbeef0a18474eba39798fde298ea36
diff --git a/procedures/phal/common_utils.cpp b/procedures/phal/common_utils.cpp
index 4ead474..ca37ace 100644
--- a/procedures/phal/common_utils.cpp
+++ b/procedures/phal/common_utils.cpp
@@ -2,6 +2,7 @@
{
#include <libpdbg.h>
}
+#include "attributes_info.H"
#include "phalerror/phal_error.hpp"
#include "procedures/phal/common_utils.hpp"
@@ -58,5 +59,33 @@
}
}
+/**
+ * @brief Check if primary processor or not
+ *
+ * @return True/False
+ */
+bool isPrimaryProc(struct pdbg_target* procTarget)
+{
+ ATTR_PROC_MASTER_TYPE_Type type;
+
+ // Get processor type (Primary or Secondary)
+ if (DT_GET_PROP(ATTR_PROC_MASTER_TYPE, procTarget, type))
+ {
+ log<level::ERR>("Attribute [ATTR_PROC_MASTER_TYPE] get failed");
+ throw std::runtime_error(
+ "Attribute [ATTR_PROC_MASTER_TYPE] get failed");
+ }
+
+ /* Attribute value 0 corresponds to primary processor */
+ if (type == ENUM_ATTR_PROC_MASTER_TYPE_ACTING_MASTER)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
} // namespace phal
} // namespace openpower