PEL: Add location code information support for sub FRUs

only for FRU(Field Replaceable Units) devices. Existing SBE
error handling code doesn't provide Location code information
to PEL back-end code, and which creates errors in PEL
processing for sub FRU callouts from PHAL requested error PEL.

This commits helps to fix the this problem by using libphal
based api to get location code instead of direct devtree
attribute read. Libphal api uses algorithm to get Location code
for sub FRUs by getting information from the parent FRU.

Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I7203c8a3175e17e8126448c4d6605b75c07d591d
diff --git a/extensions/openpower-pels/fapi_data_process.cpp b/extensions/openpower-pels/fapi_data_process.cpp
index 3550e1f..e74e2c0 100644
--- a/extensions/openpower-pels/fapi_data_process.cpp
+++ b/extensions/openpower-pels/fapi_data_process.cpp
@@ -6,6 +6,8 @@
 
 #include <attributes_info.H>
 #include <fmt/format.h>
+#include <libphal.H>
+#include <phal_exception.H>
 
 #include <algorithm>
 #include <cstdlib>
@@ -25,6 +27,7 @@
 {
 
 using namespace phosphor::logging;
+using namespace openpower::phal::exception;
 
 /**
  * Used to pass buffer to pdbg callback api to get required target
@@ -70,6 +73,8 @@
 int pdbgCallbackToGetTgtReqAttrsVal(struct pdbg_target* target,
                                     void* appPrivData)
 {
+    using namespace openpower::phal::pdbg;
+
     TargetInfo* targetInfo = static_cast<TargetInfo*>(appPrivData);
 
     ATTR_PHYS_BIN_PATH_Type physBinPath;
@@ -100,10 +105,18 @@
         return continueTgtTraversal;
     }
 
-    if (DT_GET_PROP(ATTR_LOCATION_CODE, target, targetInfo->locationCode))
+    try
     {
-        log<level::ERR>("Could not read LOCATION_CODE attribute");
-        return requireAttrNotFound;
+        // Get location code information
+        openpower::phal::pdbg::getLocationCode(target,
+                                               targetInfo->locationCode);
+    }
+    catch (const std::exception& e)
+    {
+        // log message and continue with default data
+        log<level::ERR>(fmt::format("getLocationCode({}): Exception({})",
+                                    pdbg_target_path(target), e.what())
+                            .c_str());
     }
 
     if (DT_GET_PROP(ATTR_PHYS_DEV_PATH, target, targetInfo->physDevPath))