blob: 3b2e8a0b0051f34c77a7ca6a77ae36a62c43622e [file] [log] [blame]
Jayanth Othayoth25e39c82021-07-12 01:00:17 -05001#include "extensions/phal/common_utils.hpp"
Jayanth Othayoth6552de02021-07-12 00:55:57 -05002#include "extensions/phal/phal_error.hpp"
Chirag Sharmaa2576932020-12-05 23:17:41 -06003#include "registration.hpp"
4
5#include <libekb.H>
6
7#include <phosphor-logging/log.hpp>
8
9namespace openpower
10{
11namespace phal
12{
13
14using namespace phosphor::logging;
15
16void prePoweroff(void)
17{
18 try
19 {
20 phal_init();
21 }
22 catch (const std::exception& ex)
23 {
24 log<level::ERR>("Exception raised during init PHAL",
25 entry("EXCEPTION=%s", ex.what()));
Jayanth Othayoth2b211702021-09-06 05:14:23 -050026 openpower::pel::detail::processBootError(false);
Chirag Sharmaa2576932020-12-05 23:17:41 -060027 // Dont throw exception on failure because, we need to proceed
28 // further eventhough there is failure for proc-pre-poweroff
29 return;
30 }
31
32 // To clear trace if success
Jayanth Othayoth2b211702021-09-06 05:14:23 -050033 openpower::pel::detail::processBootError(true);
Chirag Sharmaa2576932020-12-05 23:17:41 -060034
35 // callback method will be called upon failure which will create the PEL
36 int rc = ipl_pre_poweroff();
37 if (rc)
38 {
39 log<level::ERR>("pre_poweroff failed");
40 // Dont throw exception on failure because, we need to proceed
41 // further eventhough there is failure for proc-pre-poweroff
42 return;
43 }
44}
45
46REGISTER_PROCEDURE("prePoweroff", prePoweroff)
47
48} // namespace phal
49} // namespace openpower