1 #include "extensions/phal/common_utils.hpp" 2 3 #include "attributes_info.H" 4 5 #include "extensions/phal/pdbg_utils.hpp" 6 #include "extensions/phal/phal_error.hpp" 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 28 // PDBG_DTB environment variable set to CEC device tree path 29 setDevtreeEnv(); 30 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 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 73 } // namespace phal 74 } // namespace openpower 75