PHAL: Helper function to set PDATA_INFODB

systemd runntime global cofiguration keeps a copy of all
the varibles in the application space. Since the PDATA_INFODB
config variable is consumed by limited applications, removed
systemd global settings related to PDATA_INFODB environment.
So application level environment setting required. Added this
helper function to set PDATA_INFODB environment variable for
the attributes tool.

Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I3e689c0c0d03ec11201e5ee50240409a53e42aad
diff --git a/extensions/phal/pdbg_utils.cpp b/extensions/phal/pdbg_utils.cpp
index 748b73c..8eadd3c 100644
--- a/extensions/phal/pdbg_utils.cpp
+++ b/extensions/phal/pdbg_utils.cpp
@@ -137,5 +137,20 @@
     }
 }
 
+void setPdataInfoDBEnv()
+{
+    // PDATA_INFODB environment variable set to attributes tool  infodb path
+    static constexpr auto PDATA_INFODB_PATH =
+        "/usr/share/pdata/attributes_info.db";
+
+    if (setenv("PDATA_INFODB", PDATA_INFODB_PATH, 1))
+    {
+        log<level::ERR>(
+            fmt::format("Failed to set PDATA_INFODB: ({})", strerror(errno))
+                .c_str());
+        throw std::runtime_error("Failed to set PDATA_INFODB");
+    }
+}
+
 } // namespace phal
 } // namespace openpower
diff --git a/extensions/phal/pdbg_utils.hpp b/extensions/phal/pdbg_utils.hpp
index 3c1ef32..926d956 100644
--- a/extensions/phal/pdbg_utils.hpp
+++ b/extensions/phal/pdbg_utils.hpp
@@ -64,5 +64,12 @@
  */
 void setDevtreeEnv();
 
+/**
+ * @brief Helper function to set PDATA_INFODB
+ *
+ * PDATA_INFODB environment variable set to pdata attributes infodb path
+ */
+void setPdataInfoDBEnv();
+
 } // namespace phal
 } // namespace openpower