Ramesh Iyyar | c98bab5 | 2020-04-16 04:04:29 -0500 | [diff] [blame^] | 1 | extern "C" { |
| 2 | #include <libpdbg.h> |
| 3 | } |
| 4 | |
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 5 | #include "phalerror/phal_error.hpp" |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 6 | |
Ramesh Iyyar | c98bab5 | 2020-04-16 04:04:29 -0500 | [diff] [blame^] | 7 | #include <libekb.H> |
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 8 | #include <libipl.H> |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 9 | |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 10 | #include <phosphor-logging/log.hpp> |
| 11 | #include <registration.hpp> |
| 12 | namespace openpower |
| 13 | { |
| 14 | namespace phal |
| 15 | { |
| 16 | |
| 17 | using namespace phosphor::logging; |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * @brief Starts the self boot engine on POWER processor position 0 |
| 21 | * to kick off a boot. |
| 22 | * @return void |
| 23 | */ |
| 24 | void startHost() |
| 25 | { |
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 26 | // add callback methods for debug traces and for boot failures |
| 27 | openpower::pel::addBootErrorCallbacks(); |
| 28 | |
Ramesh Iyyar | c98bab5 | 2020-04-16 04:04:29 -0500 | [diff] [blame^] | 29 | if (!pdbg_targets_init(NULL)) |
| 30 | { |
| 31 | log<level::ERR>("pdbg_targets_init failed"); |
| 32 | openpower::pel::detail::processBootErrorCallback(false); |
| 33 | throw std::runtime_error("pdbg target initialization failed"); |
| 34 | } |
| 35 | // To clear trace if success |
| 36 | openpower::pel::detail::processBootErrorCallback(true); |
| 37 | |
| 38 | if (libekb_init()) |
| 39 | { |
| 40 | log<level::ERR>("libekb_init failed"); |
| 41 | openpower::pel::detail::processBootErrorCallback(false); |
| 42 | throw std::runtime_error("libekb initialization failed"); |
| 43 | } |
| 44 | // To clear trace if success |
| 45 | openpower::pel::detail::processBootErrorCallback(true); |
| 46 | |
| 47 | if (ipl_init(IPL_AUTOBOOT) != 0) |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 48 | { |
| 49 | log<level::ERR>("ipl_init failed"); |
Ramesh Iyyar | c98bab5 | 2020-04-16 04:04:29 -0500 | [diff] [blame^] | 50 | openpower::pel::detail::processBootErrorCallback(false); |
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 51 | throw std::runtime_error("Boot initialization failed"); |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 52 | } |
Ramesh Iyyar | c98bab5 | 2020-04-16 04:04:29 -0500 | [diff] [blame^] | 53 | // To clear trace if success |
| 54 | openpower::pel::detail::processBootErrorCallback(true); |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 55 | |
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 56 | // callback method will be called upon failure which will create the PEL |
| 57 | int rc = ipl_run_major(0); |
| 58 | if (rc > 0) |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 59 | { |
| 60 | log<level::ERR>("step 0 failed to start the host"); |
Marri Devender Rao | 7847960 | 2020-01-06 03:45:11 -0600 | [diff] [blame] | 61 | throw std::runtime_error("Failed to execute host start boot step"); |
Ramesh Iyyar | b181d3b | 2019-10-17 13:39:10 -0500 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | |
| 65 | REGISTER_PROCEDURE("startHost", startHost); |
| 66 | |
| 67 | } // namespace phal |
| 68 | } // namespace openpower |