phal: ipl_error_callback_func prototype related changes
libipl ipl_error_callback_func prototype changed to support additional
error handling support. This commits includes the changes related to
this function prototype function.
Also made changes in internal error handling to make direct
call to processBootError instead of callback function.
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: I76aa1c4d41e4b2685b3c6534afe35988f35bc103
diff --git a/extensions/phal/phal_error.cpp b/extensions/phal/phal_error.cpp
index 9f08f5b..8d0d65e 100644
--- a/extensions/phal/phal_error.cpp
+++ b/extensions/phal/phal_error.cpp
@@ -9,7 +9,6 @@
#include <attributes_info.H>
#include <fmt/format.h>
#include <libekb.H>
-#include <libipl.H>
#include <nlohmann/json.hpp>
#include <phosphor-logging/elog.hpp>
@@ -257,9 +256,26 @@
return it->second;
}
-void processBootErrorCallback(bool status)
+void processIplErrorCallback(const ipl_error_info& errInfo)
{
- log<level::INFO>("processBootCallback ", entry("STATUS=%d", status));
+ log<level::INFO>(
+ fmt::format("processIplErrorCallback: Error type(%x) \n", errInfo.type)
+ .c_str());
+
+ if (errInfo.type == IPL_NO_ERR)
+ {
+ // reset trace log and exit
+ reset();
+ return;
+ }
+ // TODO: Keeping the existing behaviour now
+ // Handle errors based on special reason codes once support is available
+ processBootError(false);
+}
+
+void processBootError(bool status)
+{
+ log<level::INFO>("processBootError ", entry("STATUS=%d", status));
try
{
// return If no failure during hwp execution
@@ -520,7 +536,7 @@
ipl_set_logfunc(detail::processLogTraceCallback, NULL);
// add callback for ipl failures
- ipl_set_error_callback_func(detail::processBootErrorCallback);
+ ipl_set_error_callback_func(detail::processIplErrorCallback);
}
} // namespace pel
diff --git a/extensions/phal/phal_error.hpp b/extensions/phal/phal_error.hpp
index b132b8f..746b733 100644
--- a/extensions/phal/phal_error.hpp
+++ b/extensions/phal/phal_error.hpp
@@ -1,6 +1,9 @@
#pragma once
+#include <libipl.H>
+
#include <cstdarg>
+
namespace openpower
{
namespace pel
@@ -23,6 +26,16 @@
void processLogTraceCallback(void* private_data, const char* fmt, va_list ap);
/**
+ * @brief Process ipl failure/success status
+ *
+ * If status is success log traces are cleared else used in the
+ * creation of failure
+ *
+ * @param[in] errInfo - Error info structure
+ */
+void processIplErrorCallback(const ipl_error_info& errInfo);
+
+/**
* @brief Process boot failure/success status
*
* If status is success log traces are cleared else used in the
@@ -30,12 +43,13 @@
*
* @param[in] status - Boot execution status
*/
-void processBootErrorCallback(bool status);
+void processBootError(bool status);
/**
* @brief Reset trace log list
*/
void reset();
+
} // namespace detail
/**
diff --git a/procedures/phal/proc_pre_poweroff.cpp b/procedures/phal/proc_pre_poweroff.cpp
index 1293080..3b2e8a0 100644
--- a/procedures/phal/proc_pre_poweroff.cpp
+++ b/procedures/phal/proc_pre_poweroff.cpp
@@ -23,14 +23,14 @@
{
log<level::ERR>("Exception raised during init PHAL",
entry("EXCEPTION=%s", ex.what()));
- openpower::pel::detail::processBootErrorCallback(false);
+ openpower::pel::detail::processBootError(false);
// Dont throw exception on failure because, we need to proceed
// further eventhough there is failure for proc-pre-poweroff
return;
}
// To clear trace if success
- openpower::pel::detail::processBootErrorCallback(true);
+ openpower::pel::detail::processBootError(true);
// callback method will be called upon failure which will create the PEL
int rc = ipl_pre_poweroff();
diff --git a/procedures/phal/start_host.cpp b/procedures/phal/start_host.cpp
index 9b853d7..12eddc3 100644
--- a/procedures/phal/start_host.cpp
+++ b/procedures/phal/start_host.cpp
@@ -183,12 +183,12 @@
{
log<level::ERR>("Exception raised during init PHAL",
entry("EXCEPTION=%s", ex.what()));
- openpower::pel::detail::processBootErrorCallback(false);
+ openpower::pel::detail::processBootError(false);
throw std::runtime_error("PHAL initialization failed");
}
// To clear trace if success
- openpower::pel::detail::processBootErrorCallback(true);
+ openpower::pel::detail::processBootError(true);
setClkNETerminationSite();
@@ -223,12 +223,12 @@
selectBootSeeprom();
// To clear trace as it is success
- openpower::pel::detail::processBootErrorCallback(true);
+ openpower::pel::detail::processBootError(true);
}
catch (const std::exception& ex)
{
// create PEL in failure
- openpower::pel::detail::processBootErrorCallback(false);
+ openpower::pel::detail::processBootError(false);
log<level::ERR>("SEEPROM selection failed", entry("ERR=%s", ex.what()));
throw ex;
}