blob: a5e7beaed42ec4f9ca17d009972abe79258cafec [file] [log] [blame]
Marri Devender Rao78479602020-01-06 03:45:11 -06001#include "phalerror/phal_error.hpp"
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -05002
Marri Devender Rao78479602020-01-06 03:45:11 -06003#include <libipl.H>
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -05004
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -05005#include <phosphor-logging/log.hpp>
6#include <registration.hpp>
7namespace openpower
8{
9namespace phal
10{
11
12using namespace phosphor::logging;
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -050013
14/**
15 * @brief Starts the self boot engine on POWER processor position 0
16 * to kick off a boot.
17 * @return void
18 */
19void startHost()
20{
Marri Devender Rao78479602020-01-06 03:45:11 -060021 // add callback methods for debug traces and for boot failures
22 openpower::pel::addBootErrorCallbacks();
23
24 // callback method will be called upon failure which will create the PEL
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -050025 if (ipl_init() != 0)
26 {
27 log<level::ERR>("ipl_init failed");
Marri Devender Rao78479602020-01-06 03:45:11 -060028 throw std::runtime_error("Boot initialization failed");
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -050029 }
30
Marri Devender Rao78479602020-01-06 03:45:11 -060031 // callback method will be called upon failure which will create the PEL
32 int rc = ipl_run_major(0);
33 if (rc > 0)
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -050034 {
35 log<level::ERR>("step 0 failed to start the host");
Marri Devender Rao78479602020-01-06 03:45:11 -060036 throw std::runtime_error("Failed to execute host start boot step");
Ramesh Iyyarb181d3b2019-10-17 13:39:10 -050037 }
38}
39
40REGISTER_PROCEDURE("startHost", startHost);
41
42} // namespace phal
43} // namespace openpower