PHAL: Helper function to set PDBG_DTB
Helper function to set PDBG_DTB environment variable for the
CEC device tree path.
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I79c3ba1f1ef1c1e9bb7ab80ed16477098e489ca8
diff --git a/extensions/phal/common_utils.cpp b/extensions/phal/common_utils.cpp
index e168aed..d9749db 100644
--- a/extensions/phal/common_utils.cpp
+++ b/extensions/phal/common_utils.cpp
@@ -29,16 +29,7 @@
openpower::pel::addBootErrorCallbacks();
// PDBG_DTB environment variable set to CEC device tree path
- static constexpr auto PDBG_DTB_PATH =
- "/var/lib/phosphor-software-manager/pnor/rw/DEVTREE";
-
- if (setenv("PDBG_DTB", PDBG_DTB_PATH, 1))
- {
- log<level::ERR>(
- fmt::format("Failed to set PDBG_DTB: ({})", strerror(errno))
- .c_str());
- throw std::runtime_error("Failed to set PDBG_DTB");
- }
+ setDevtreeEnv();
if (!pdbg_targets_init(NULL))
{
@@ -187,5 +178,20 @@
return 0;
}
+void setDevtreeEnv()
+{
+ // PDBG_DTB environment variable set to CEC device tree path
+ static constexpr auto PDBG_DTB_PATH =
+ "/var/lib/phosphor-software-manager/pnor/rw/DEVTREE";
+
+ if (setenv("PDBG_DTB", PDBG_DTB_PATH, 1))
+ {
+ log<level::ERR>(
+ fmt::format("Failed to set PDBG_DTB: ({})", strerror(errno))
+ .c_str());
+ throw std::runtime_error("Failed to set PDBG_DTB");
+ }
+}
+
} // namespace phal
} // namespace openpower
diff --git a/extensions/phal/common_utils.hpp b/extensions/phal/common_utils.hpp
index 277272c..ffd5977 100644
--- a/extensions/phal/common_utils.hpp
+++ b/extensions/phal/common_utils.hpp
@@ -76,5 +76,12 @@
*/
uint32_t probeTarget(struct pdbg_target* procTarget);
+/**
+ * @brief Helper function to set PDBG_DTB
+ *
+ * PDBG_DTB environment variable set to CEC device tree path
+ */
+void setDevtreeEnv();
+
} // namespace phal
} // namespace openpower