Config option to enable PHAL APIs

There are a couple required PHAL APIs that are not available upstream.
It is uncertain if these APIs will ever be available upstream.
Fortunately, the APIs are only needed to provide information that is
displayed in a PEL. So there is a less accuate alternative when the APIs
are not available.

Change-Id: I1a4a1838520c18053ab31f561d05875d4a94c20e
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/util/pdbg.cpp b/util/pdbg.cpp
index 605df77..03c8037 100644
--- a/util/pdbg.cpp
+++ b/util/pdbg.cpp
@@ -4,6 +4,10 @@
 #include <util/pdbg.hpp>
 #include <util/trace.hpp>
 
+#ifdef CONFIG_PHAL_API
+#include <attribute_info.H>
+#endif
+
 namespace util
 {
 
@@ -226,6 +230,64 @@
 
 //------------------------------------------------------------------------------
 
+std::string getLocationCode(pdbg_target* trgt)
+{
+    if (nullptr == trgt)
+    {
+        // Either the path is wrong or the attribute doesn't exist.
+        return std::string{};
+    }
+
+#ifdef CONFIG_PHAL_API
+
+    ATTR_LOCATION_CODE_Type val;
+    if (DT_GET_PROP(ATTR_LOCATION_CODE, trgt, val))
+    {
+        // Get the immediate parent in the devtree path and try again.
+        return getLocationCode(pdbg_target_parent(nullptr, trgt));
+    }
+
+    // Attribute found.
+    return std::string{val};
+
+#else
+
+    return std::string{getPath(trgt)};
+
+#endif
+}
+
+//------------------------------------------------------------------------------
+
+std::string getPhysDevPath(pdbg_target* trgt)
+{
+    if (nullptr == trgt)
+    {
+        // Either the path is wrong or the attribute doesn't exist.
+        return std::string{};
+    }
+
+#ifdef CONFIG_PHAL_API
+
+    ATTR_PHYS_DEV_PATH_Type val;
+    if (DT_GET_PROP(ATTR_PHYS_DEV_PATH, trgt, val))
+    {
+        // Get the immediate parent in the devtree path and try again.
+        return getPhysDevPath(pdbg_target_parent(nullptr, trgt));
+    }
+
+    // Attribute found.
+    return std::string{val};
+
+#else
+
+    return std::string{getPath(trgt)};
+
+#endif
+}
+
+//------------------------------------------------------------------------------
+
 } // namespace pdbg
 
 } // namespace util