procedures/phal/start_host: Initialized libpdbg, libekb and libipl
Currently ipl_init is initializing libpdbg and libekb but
as per recent design changes, phal expecting all phal library
initialization should just happen in application rather than
doing via ipl_init. so, same support added in this patch.
ipl_init expecting boot mode explicitly from application so,
setting IPL_AUTOBOOT (continuous ipling) to boot the system.
Signed-off-by: Ramesh Iyyar <rameshi1@in.ibm.com>
Change-Id: I38026082cfa2fb21e042b50ddb7c627956a317be
diff --git a/phalerror/phal_error.cpp b/phalerror/phal_error.cpp
index 45aa3de..cecd399 100644
--- a/phalerror/phal_error.cpp
+++ b/phalerror/phal_error.cpp
@@ -1,6 +1,9 @@
-#include "phal_error.hpp"
+extern "C" {
+#include <libpdbg.h>
+}
#include "create_pel.hpp"
+#include "phal_error.hpp"
#include <libekb.H>
#include <libipl.H>
@@ -84,14 +87,23 @@
traceLog.clear();
counter = 0;
}
+
+void pDBGLogTraceCallbackHelper(int log_level, const char* fmt, va_list ap)
+{
+ processLogTraceCallback(NULL, fmt, ap);
+}
} // namespace detail
void addBootErrorCallbacks()
{
// set log level to info
+ pdbg_set_loglevel(PDBG_INFO);
+ libekb_set_loglevel(LIBEKB_LOG_INF);
ipl_set_loglevel(IPL_INFO);
// add callback for debug traces
+ pdbg_set_logfunc(detail::pDBGLogTraceCallbackHelper);
+ libekb_set_logfunc(detail::processLogTraceCallback, NULL);
ipl_set_logfunc(detail::processLogTraceCallback, NULL);
// add callback for ipl failures
diff --git a/procedures/phal/start_host.cpp b/procedures/phal/start_host.cpp
index a5e7bea..3899924 100644
--- a/procedures/phal/start_host.cpp
+++ b/procedures/phal/start_host.cpp
@@ -1,5 +1,10 @@
+extern "C" {
+#include <libpdbg.h>
+}
+
#include "phalerror/phal_error.hpp"
+#include <libekb.H>
#include <libipl.H>
#include <phosphor-logging/log.hpp>
@@ -21,12 +26,32 @@
// add callback methods for debug traces and for boot failures
openpower::pel::addBootErrorCallbacks();
- // callback method will be called upon failure which will create the PEL
- if (ipl_init() != 0)
+ if (!pdbg_targets_init(NULL))
+ {
+ log<level::ERR>("pdbg_targets_init failed");
+ openpower::pel::detail::processBootErrorCallback(false);
+ throw std::runtime_error("pdbg target initialization failed");
+ }
+ // To clear trace if success
+ openpower::pel::detail::processBootErrorCallback(true);
+
+ if (libekb_init())
+ {
+ log<level::ERR>("libekb_init failed");
+ openpower::pel::detail::processBootErrorCallback(false);
+ throw std::runtime_error("libekb initialization failed");
+ }
+ // To clear trace if success
+ openpower::pel::detail::processBootErrorCallback(true);
+
+ if (ipl_init(IPL_AUTOBOOT) != 0)
{
log<level::ERR>("ipl_init failed");
+ openpower::pel::detail::processBootErrorCallback(false);
throw std::runtime_error("Boot initialization failed");
}
+ // To clear trace if success
+ openpower::pel::detail::processBootErrorCallback(true);
// callback method will be called upon failure which will create the PEL
int rc = ipl_run_major(0);