Jayanth Othayoth | c3d6b87 | 2021-07-28 05:07:25 -0500 | [diff] [blame] | 1 | #include "extensions/phal/common_utils.hpp" |
| 2 | |
Andrew Geissler | 5c3f925 | 2021-06-10 10:53:05 -0500 | [diff] [blame] | 3 | #include "attributes_info.H" |
Chirag Sharma | a257693 | 2020-12-05 23:17:41 -0600 | [diff] [blame] | 4 | |
Jayanth Othayoth | c3d6b87 | 2021-07-28 05:07:25 -0500 | [diff] [blame] | 5 | #include "extensions/phal/pdbg_utils.hpp" |
Jayanth Othayoth | 6552de0 | 2021-07-12 00:55:57 -0500 | [diff] [blame] | 6 | #include "extensions/phal/phal_error.hpp" |
Chirag Sharma | a257693 | 2020-12-05 23:17:41 -0600 | [diff] [blame] | 7 | |
| 8 | #include <libekb.H> |
| 9 | |
| 10 | #include <phosphor-logging/log.hpp> |
| 11 | |
| 12 | namespace openpower |
| 13 | { |
| 14 | namespace phal |
| 15 | { |
| 16 | |
| 17 | using namespace phosphor::logging; |
| 18 | |
| 19 | void phal_init(enum ipl_mode mode) |
| 20 | { |
| 21 | // TODO: Setting boot error callback should not be in common code |
| 22 | // because, we wont get proper reason in PEL for failure. |
| 23 | // So, need to make code like caller of this function pass error |
| 24 | // handling callback. |
| 25 | // add callback methods for debug traces and for boot failures |
| 26 | openpower::pel::addBootErrorCallbacks(); |
| 27 | |
Jayanth Othayoth | 583a9ed | 2021-06-29 05:42:45 -0500 | [diff] [blame] | 28 | // PDBG_DTB environment variable set to CEC device tree path |
Jayanth Othayoth | 2de8c8d | 2021-07-16 06:40:33 -0500 | [diff] [blame] | 29 | setDevtreeEnv(); |
Jayanth Othayoth | 583a9ed | 2021-06-29 05:42:45 -0500 | [diff] [blame] | 30 | |
Chirag Sharma | a257693 | 2020-12-05 23:17:41 -0600 | [diff] [blame] | 31 | if (!pdbg_targets_init(NULL)) |
| 32 | { |
| 33 | log<level::ERR>("pdbg_targets_init failed"); |
| 34 | throw std::runtime_error("pdbg target initialization failed"); |
| 35 | } |
| 36 | |
| 37 | if (libekb_init()) |
| 38 | { |
| 39 | log<level::ERR>("libekb_init failed"); |
| 40 | throw std::runtime_error("libekb initialization failed"); |
| 41 | } |
| 42 | |
| 43 | if (ipl_init(mode) != 0) |
| 44 | { |
| 45 | log<level::ERR>("ipl_init failed"); |
| 46 | throw std::runtime_error("libipl initialization failed"); |
| 47 | } |
| 48 | } |
| 49 | |
Andrew Geissler | 5c3f925 | 2021-06-10 10:53:05 -0500 | [diff] [blame] | 50 | bool isPrimaryProc(struct pdbg_target* procTarget) |
| 51 | { |
| 52 | ATTR_PROC_MASTER_TYPE_Type type; |
| 53 | |
| 54 | // Get processor type (Primary or Secondary) |
| 55 | if (DT_GET_PROP(ATTR_PROC_MASTER_TYPE, procTarget, type)) |
| 56 | { |
| 57 | log<level::ERR>("Attribute [ATTR_PROC_MASTER_TYPE] get failed"); |
| 58 | throw std::runtime_error( |
| 59 | "Attribute [ATTR_PROC_MASTER_TYPE] get failed"); |
| 60 | } |
| 61 | |
| 62 | /* Attribute value 0 corresponds to primary processor */ |
| 63 | if (type == ENUM_ATTR_PROC_MASTER_TYPE_ACTING_MASTER) |
| 64 | { |
| 65 | return true; |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | return false; |
| 70 | } |
| 71 | } |
| 72 | |
Chirag Sharma | a257693 | 2020-12-05 23:17:41 -0600 | [diff] [blame] | 73 | } // namespace phal |
| 74 | } // namespace openpower |