blob: 99daa7b9fc278b80570529822755176a9d945320 [file] [log] [blame]
Chirag Sharmaa2576932020-12-05 23:17:41 -06001extern "C"
2{
3#include <libpdbg.h>
4}
5
6#include "phalerror/phal_error.hpp"
7#include "procedures/phal/common_utils.hpp"
8
9#include <libekb.H>
10
11#include <phosphor-logging/log.hpp>
12
13namespace openpower
14{
15namespace phal
16{
17
18using namespace phosphor::logging;
19
20void phal_init(enum ipl_mode mode)
21{
22 // TODO: Setting boot error callback should not be in common code
23 // because, we wont get proper reason in PEL for failure.
24 // So, need to make code like caller of this function pass error
25 // handling callback.
26 // add callback methods for debug traces and for boot failures
27 openpower::pel::addBootErrorCallbacks();
28
29 if (!pdbg_targets_init(NULL))
30 {
31 log<level::ERR>("pdbg_targets_init failed");
32 throw std::runtime_error("pdbg target initialization failed");
33 }
34
35 if (libekb_init())
36 {
37 log<level::ERR>("libekb_init failed");
38 throw std::runtime_error("libekb initialization failed");
39 }
40
41 if (ipl_init(mode) != 0)
42 {
43 log<level::ERR>("ipl_init failed");
44 throw std::runtime_error("libipl initialization failed");
45 }
46}
47
48} // namespace phal
49} // namespace openpower