From 1e3a888edab060be5b016aff86a5d547b5be6643 Mon Sep 17 00:00:00 2001 From: Mark Wenning Date: Mon, 7 Nov 2011 11:53:10 -0600 Subject: RTC4319: Shutdown if IStep fails - add macro to report error to testHWP.C - new TASKARGS macros (prepare for join change) - istep dispatcher, extinitsvc and initsvc now call shutdown() - pass error codes to parent task - fix errorlog tags, see RTC3840 - added ErrlUserDetails module, mostly for debug - review fixes Change-Id: Ib5009f1bf0f7657d4da5bd6d1ecf64e6113b3383 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/486 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES Reviewed-by: A. Patrick Williams III --- src/include/sys/misc.h | 16 ++ src/include/usr/initservice/initsvcreasoncodes.H | 94 ++++----- src/include/usr/initservice/initsvcstructs.H | 8 + src/include/usr/initservice/taskargs.H | 36 ++-- src/usr/cxxtest/cxxtestexec.C | 8 +- src/usr/hwas/hwas.C | 166 ++++++++------- src/usr/hwas/testHWP.C | 8 +- src/usr/hwpf/hwp/fapiHwpExecInitFile.C | 4 +- src/usr/initservice/baseinitsvc/initservice.C | 56 +++--- src/usr/initservice/extinitsvc/extinitsvc.C | 223 +++++++++++---------- src/usr/initservice/extinitsvc/extinitsvc.H | 11 - .../initservice/istepdispatcher/istepdispatcher.C | 146 +++++++++----- src/usr/initservice/taskargs/taskargs.C | 10 +- 13 files changed, 439 insertions(+), 347 deletions(-) diff --git a/src/include/sys/misc.h b/src/include/sys/misc.h index bb9d177ad..8c90b2363 100644 --- a/src/include/sys/misc.h +++ b/src/include/sys/misc.h @@ -25,6 +25,22 @@ #include +/** + * @enum ShutdownStatus + * + * Shutdown values for shutdown command. + */ + +enum ShutdownStatus +{ + SHUTDOWN_STATUS_GOOD = 0x01230000, + SHUTDOWN_STATUS_UT_FAILED = 0x01230001, + SHUTDOWN_STATUS_ISTEP_FAILED = 0x01230002, + SHUTDOWN_STATUS_EXTINITSVC_FAILED = 0x01230003, + SHUTDOWN_STATUS_INITSVC_FAILED = 0x01230004, +}; + + #ifdef __cplusplus extern "C" { diff --git a/src/include/usr/initservice/initsvcreasoncodes.H b/src/include/usr/initservice/initsvcreasoncodes.H index 1f13850ea..d3ccc37fb 100644 --- a/src/include/usr/initservice/initsvcreasoncodes.H +++ b/src/include/usr/initservice/initsvcreasoncodes.H @@ -42,66 +42,58 @@ namespace INITSERVICE */ enum InitServiceModuleID { - UNDEFINED_MODULE_ERRL_ID = 0x00, - BASE_INITSVC_ERRL_ID, - START_TRACE_ERRL_ID, - START_ERRL_ERRL_ID, - START_XSCOMDD_ERRL_ID, - START_PNORDD_ERRL_ID, - START_EXTINITSVC_ERRL_ID, - START_TARGETING_ERRL_ID, - GET_MASTER_CHIP_TARGET_ERRL_ID, - START_MAILBOXDD_ERRL_ID, - START_SP_COMM_ERRL_ID, - ENABLE_STREAMING_TRACE_ERRL_ID, - START_PROGRESS_CODES_ERRL_ID, - START_FSIDD_ERRL_ID, - SETUP_SLAVE_LINKS_ERRL_ID, - START_FSISCOM_ERRL_ID, - START_FSI_II2C_ERRL_ID, - START_HWP_ERRL_ID, - READ_MAX_CONFIG_FROM_PNOR_ERRL_ID, - APPLY_PRESENCE_DETECT_ERRL_ID, - APPLY_PARTIAL_BAD_ERRL_ID, - APPLY_GARD_ERRL_ID, - COLLECT_HW_ERRL_IDEC_ERRL_ID, - VERIFY_ERRL_IDEC_ERRL_ID, - DISABLE_WATCHDOG_ERRL_ID, - EXECUTE_ISTEPS_ERRL_ID, - START_VFS_ERRL_ID, - START_ECMDDATABUFFER_ERRL_ID, - START_HWPF_ERRL_ID, - START_FAPI_ERRL_ID, - START_PLAT_ERRL_ID, - - ISTEP_1_ERRL_ID, - ISTEP_2_ERRL_ID, - ISTEP_3_ERRL_ID, - ISTEP_4_ERRL_ID, - ISTEP_5_ERRL_ID, + UNDEFINED_MODULE_ERRL_ID = 0x00, + + // base image modules + BASE_INITSVC_ERRL_ID = 0x01, + START_TRACE_ERRL_ID = 0x02, + START_ERRL_ERRL_ID = 0x03, + START_PNORDD_ERRL_ID = 0x04, + START_VFS_ERRL_ID = 0x05, + START_EXTINITSVC_ERRL_ID = 0x06, + + // extended image modules + START_ECMDDATABUFFER_ERRL_ID = 0x10, + START_HWPF_ERRL_ID = 0x11, + START_FAPI_ERRL_ID = 0x12, + START_HWP_ERRL_ID = 0x13, + START_PLAT_ERRL_ID = 0x14, + EXECUTE_ISTEPS_ERRL_ID = 0x15, + START_FSIDD_ERRL_ID = 0x16, + START_FSISCOM_ERRL_ID = 0x17, + START_TARGETING_ERRL_ID = 0x18, + + + // Internal InitService codes + INITSVC_START_TASK_MOD_ID = 0x20, + INITSVC_START_FN_MOD_ID = 0x21, + INITSVC_TASK_RETURNED_ERROR_ID = 0x22, + EXTINITSVC_TASK_RETURNED_ERROR_ID = 0x23, + CXXTEST_TASK_RETURNED_ERROR_ID = 0x24, + ISTEP_RETURNED_ERROR_ID = 0x25, // // HWAS: ISTEP 4 // HWAS named isteps (substeps) // @todo sync these names up with Dean's document later // - HWAS_1_ERRL_ID, - HWAS_2_ERRL_ID, - HWAS_3_ERRL_ID, - HWAS_4_ERRL_ID, - HWAS_5_ERRL_ID, - HWAS_6_ERRL_ID, - HWAS_7_ERRL_ID, - HWAS_8_ERRL_ID, - HWAS_9_ERRL_ID, + HWAS_1_ERRL_ID = 0x30, + HWAS_2_ERRL_ID = 0x31, + HWAS_3_ERRL_ID = 0x32, + HWAS_4_ERRL_ID = 0x33, + HWAS_5_ERRL_ID = 0x34, + HWAS_6_ERRL_ID = 0x35, + HWAS_7_ERRL_ID = 0x36, + HWAS_8_ERRL_ID = 0x37, + HWAS_9_ERRL_ID = 0x38, // reserve some tasks for my unit tests... START_CXXTEST_ERRL_ID = 0xf0, - INIT_SVC_TEST1_ERRL_ID, - INIT_SVC_TEST2_ERRL_ID, - INIT_SVC_TEST3_ERRL_ID, - INIT_SVC_TEST4_ERRL_ID, - INIT_SVC_TEST5_ERRL_ID, + INIT_SVC_TEST1_ERRL_ID = 0xf1, + INIT_SVC_TEST2_ERRL_ID = 0xf2, + INIT_SVC_TEST3_ERRL_ID = 0xf3, + INIT_SVC_TEST4_ERRL_ID = 0xf4, + INIT_SVC_TEST5_ERRL_ID = 0xf5, }; diff --git a/src/include/usr/initservice/initsvcstructs.H b/src/include/usr/initservice/initsvcstructs.H index 5ad0ddad7..92913eb9b 100644 --- a/src/include/usr/initservice/initsvcstructs.H +++ b/src/include/usr/initservice/initsvcstructs.H @@ -94,6 +94,10 @@ enum ModuleType * - module_id for errorlog if task fails * */ +/** + * @todo module_id is fairly useless, we should use the taskname string + * to id the module. Schedule for termination.... + */ struct TaskFlags { TaskType task_type; // task execution flags @@ -110,6 +114,10 @@ struct TaskFlags * - execution flags, see TaskFlags above * */ +/** + * @todo store a pointer to the taskname string here instead of allocating + * 64 bytes for each entry? + */ struct TaskInfo { const char taskname[VFS_MODULE_NAME_MAX]; diff --git a/src/include/usr/initservice/taskargs.H b/src/include/usr/initservice/taskargs.H index 7f32b05c0..bf83e3ece 100644 --- a/src/include/usr/initservice/taskargs.H +++ b/src/include/usr/initservice/taskargs.H @@ -36,11 +36,25 @@ #include #include #include -#include //needed to make macro work +#include // needed to make macro work #include #include +/** + * @enum + * + * Return codes that are passed from ISTEP dispatcher to extinitsvc to initsvc + * thru TASKARGS + * + * - TASKARGS_SHUTDOWN_RC - task or istep has returned an error, + * initsvc has initiated a shutdown + */ +enum +{ + TASKARGS_SHUTDOWN_RC = 0xf0000001, +}; + /** * @note macro to setup the input void * pArgs pointer. @@ -50,6 +64,7 @@ INITSERVICE::TaskArgs *pTaskArgs = \ static_cast(P_ARGS) + /** * @note macro to wait on the TaskArgs barrier and end the task */ @@ -58,13 +73,7 @@ { \ pTaskArgs->waitChildSync(); \ } \ - task_end() \ - -/** - * @note macro to post an error log to IStepDispatcher - */ -#define POST_ERROR_LOG( MyErrl ) \ - pTaskArgs->postErrorLog( MyErrl ) + task_end() /** @@ -76,7 +85,7 @@ { \ TASKARGS_INIT_TASKARGS(io_pArgs); \ \ - MyInitFn( pTaskArgs ); \ + MyInitFn( io_pArgs ); \ \ TASKARGS_WAIT_AND_ENDTASK(); \ } @@ -85,15 +94,6 @@ namespace INITSERVICE { -/** - * @def TASKARGS_UNDEFINED64 - * iv_taskreturncode and iv_taskcommand are initialized to this value - - * if parent or child change them, it can be easily recognized - * - * - */ -const uint64_t TASKARGS_UNDEFINED64 = 0xbadc0ffee0ddf00d; - /** * @class TaskArgs * diff --git a/src/usr/cxxtest/cxxtestexec.C b/src/usr/cxxtest/cxxtestexec.C index 0c5a633e5..82e387152 100644 --- a/src/usr/cxxtest/cxxtestexec.C +++ b/src/usr/cxxtest/cxxtestexec.C @@ -67,7 +67,8 @@ void _start(void *io_pArgs) errlHndl_t l_errl = NULL; std::vector module_list; tid_t tidrc = 0; - TASKARGS_INIT_TASKARGS( io_pArgs ); + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); // output a blank line so that it's easier to find the beginning of @@ -142,6 +143,7 @@ void _start(void *io_pArgs) // dump out an informational errorlog assert(l_errl == NULL); - - TASKARGS_WAIT_AND_ENDTASK(); + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); } diff --git a/src/usr/hwas/hwas.C b/src/usr/hwas/hwas.C index f5948e859..0d0883ed7 100644 --- a/src/usr/hwas/hwas.C +++ b/src/usr/hwas/hwas.C @@ -46,111 +46,127 @@ namespace HWAS { - trace_desc_t *g_trac_hwas = NULL; - TRAC_INIT(&g_trac_hwas, "HWAS", 1024 ); // yah. +trace_desc_t *g_trac_hwas = NULL; +TRAC_INIT(&g_trac_hwas, "HWAS", 1024 ); - using namespace TARGETING; // +using namespace TARGETING; - void init_target_states( void *io_pArgs ) - { - TASKARGS_INIT_TASKARGS( io_pArgs ); +void init_target_states( void *io_pArgs ) +{ + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); - TRACDCOMP( g_trac_hwas, "init_target_states entry" ); - // printkd("init_target_states\n"); + TRACDCOMP( g_trac_hwas, "init_target_states entry" ); - TASKARGS_WAIT_AND_ENDTASK(); - } + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); +} - void init_fsi( void *io_pArgs ) - { - errlHndl_t l_errl = NULL; - TASKARGS_INIT_TASKARGS( io_pArgs ); - - TRACDCOMP( g_trac_hwas, "init_fsi entry" ); - // printkd("init_fsi\n"); - - //@todo - //@VBU workaround - Disable init_fsi - //Temporarily disable the FSI initialization in VBU because of - //an MFSI/CFSI XSCOM hardware bug. - TARGETING::EntityPath syspath(TARGETING::EntityPath::PATH_PHYSICAL); - syspath.addLast(TARGETING::TYPE_SYS,0); - TARGETING::Target* sys = TARGETING::targetService().toTarget(syspath); - uint8_t vpo_mode = 0; - if( sys +void init_fsi( void *io_pArgs ) +{ + errlHndl_t l_errl = NULL; + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); + + TRACDCOMP( g_trac_hwas, "init_fsi entry" ); + + //@todo + //@VBU workaround - Disable init_fsi + //Temporarily disable the FSI initialization in VBU because of + //an MFSI/CFSI XSCOM hardware bug. + TARGETING::EntityPath syspath(TARGETING::EntityPath::PATH_PHYSICAL); + syspath.addLast(TARGETING::TYPE_SYS,0); + TARGETING::Target* sys = TARGETING::targetService().toTarget(syspath); + uint8_t vpo_mode = 0; + if( sys && sys->tryGetAttr(vpo_mode) && (vpo_mode == 1) ) - { - TASKARGS_WAIT_AND_ENDTASK(); - TRACFCOMP( g_trac_hwas, "HWBUG Workaround - No FSI initialization"); - return; - } - - l_errl = FSI::initializeHardware( ); - if ( l_errl ) - { - TRACFCOMP( g_trac_hwas, "ERROR: failed to init FSI hardware" ); - POST_ERROR_LOG( l_errl ); - } - - TASKARGS_WAIT_AND_ENDTASK(); + { + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); + TRACFCOMP( g_trac_hwas, "HWBUG Workaround - No FSI initialization"); + return; } - void apply_fsi_info( void *io_pArgs ) + l_errl = FSI::initializeHardware( ); + if ( l_errl ) { - TASKARGS_INIT_TASKARGS( io_pArgs ); + TRACFCOMP( g_trac_hwas, "ERROR: failed to init FSI hardware" ); + pTaskArgs->postErrorLog( l_errl ); + } - TRACDCOMP( g_trac_hwas, "apply_fsi_info entry" ); - //printkd("apply_fsi_info\n"); + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); +} +void apply_fsi_info( void *io_pArgs ) +{ + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); - TASKARGS_WAIT_AND_ENDTASK(); - } + TRACDCOMP( g_trac_hwas, "apply_fsi_info entry" ); - void apply_dd_presence( void *io_pArgs ) - { - TASKARGS_INIT_TASKARGS( io_pArgs ); - TRACDCOMP( g_trac_hwas, "apply_dd_presence entry" ); - //printkd("apply_dd_presence\n"); + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); +} +void apply_dd_presence( void *io_pArgs ) +{ + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); - TASKARGS_WAIT_AND_ENDTASK(); - } + TRACDCOMP( g_trac_hwas, "apply_dd_presence entry" ); - void apply_pr_keyword_data( void *io_pArgs ) - { - TASKARGS_INIT_TASKARGS( io_pArgs ); - TRACDCOMP( g_trac_hwas, "apply_pr_keyword_data" ); - //printkd("apply_pr_keyword_data\n"); + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); +} +void apply_pr_keyword_data( void *io_pArgs ) +{ + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); - TASKARGS_WAIT_AND_ENDTASK(); - } + TRACDCOMP( g_trac_hwas, "apply_pr_keyword_data" ); - void apply_partial_bad( void *io_pArgs ) - { - TASKARGS_INIT_TASKARGS( io_pArgs ); - TRACDCOMP( g_trac_hwas, "apply_partial_bad entry" ); - //printkd("apply_partial_bad\n"); + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); +} +void apply_partial_bad( void *io_pArgs ) +{ + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); - TASKARGS_WAIT_AND_ENDTASK(); - } + TRACDCOMP( g_trac_hwas, "apply_partial_bad entry" ); - void apply_gard( void *io_pArgs ) - { - TASKARGS_INIT_TASKARGS( io_pArgs ); - TRACDCOMP( g_trac_hwas, "apply_gard entry" ); - //printkd("apply_gard\n"); + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); +} +void apply_gard( void *io_pArgs ) +{ + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); - TASKARGS_WAIT_AND_ENDTASK(); - } + TRACDCOMP( g_trac_hwas, "apply_gard entry" ); + + + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); +} }; // end namespace diff --git a/src/usr/hwas/testHWP.C b/src/usr/hwas/testHWP.C index 6bb0f851f..febd985a4 100644 --- a/src/usr/hwas/testHWP.C +++ b/src/usr/hwas/testHWP.C @@ -69,7 +69,8 @@ extern trace_desc_t *g_trac_hwas; void testHWP( void * io_pArgs ) { - TASKARGS_INIT_TASKARGS(io_pArgs); + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_pArgs ); errlHndl_t l_err = NULL; // Get the master processor chip @@ -86,9 +87,12 @@ void testHWP( void * io_pArgs ) { TRACFCOMP( g_trac_hwas, "testHWP failed, committing errorlog"); errlCommit(l_err,HWAS_COMP_ID); + pTaskArgs->postReturnCode( 0x1234 ); } - TASKARGS_WAIT_AND_ENDTASK(); + // wait here on the barrier, then end the task. + pTaskArgs->waitChildSync(); + task_end(); } diff --git a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C index 418ab484f..7df1dbed3 100644 --- a/src/usr/hwpf/hwp/fapiHwpExecInitFile.C +++ b/src/usr/hwpf/hwp/fapiHwpExecInitFile.C @@ -342,7 +342,7 @@ fapi::ReturnCode hwpExecInitFile(const fapi::Target & i_Target, // Unload the initfile l_tmpRc = fapiUnloadInitFile(i_file, l_ifAddr, l_ifSize); - + // return code from executeScoms takes precedence if (l_rc.ok()) { @@ -1244,7 +1244,7 @@ fapi::ReturnCode writeScom(const ifData_t & i_ifData, const uint32_t i_scomNum, { //Perform a PutScomUnderMask operation on the target - #ifdef HWPEXECINITFILE_DEBUG + #ifdef HWPEXECINITFILE_DEBUG l_rc = fapiGetScom(l_target, l_addr, l_scomData); FAPI_DBG("hwpExecInitFile: writeScom: Data read 0x%.16llX", l_scomData.getDoubleWord(0)); diff --git a/src/usr/initservice/baseinitsvc/initservice.C b/src/usr/initservice/baseinitsvc/initservice.C index e97df2c3b..d9f1a630a 100644 --- a/src/usr/initservice/baseinitsvc/initservice.C +++ b/src/usr/initservice/baseinitsvc/initservice.C @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -77,21 +78,20 @@ errlHndl_t InitService::startTask( const TaskInfo *i_ptask, // task failed to launch, post an errorlog and dump some trace /*@ errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM - * @moduleid see task list + * @moduleid INITSVC_START_TASK_MOD_ID * @reasoncode START_TASK_FAILED - * @userdata1 task id or task return code - * @userdata2 0 + * @userdata1 task module id + * @userdata2 task id or task return code * * @devdesc Initialization Service failed to start a task. - * The module id will identify the task. * */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - i_ptask->taskflags.module_id, + INITSERVICE::INITSVC_START_TASK_MOD_ID, INITSERVICE::START_TASK_FAILED, - l_tidrc, - 0 ); + i_ptask->taskflags.module_id, + l_tidrc ); } // endif tidrc else { @@ -123,22 +123,21 @@ errlHndl_t InitService::executeFn( const TaskInfo *i_ptask, { /*@ errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM - * @moduleid see task list + * @moduleid INITSVC_START_FN_MOD_ID * @reasoncode START_FN_FAILED - * @userdata1 task id or task return code - * @userdata2 0 + * @userdata1 task module id + * @userdata2 task id or task return code * * @devdesc Initialization Service attempted to start a * function within a module but the function * failed to launch - * The module id will identify the task. */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - i_ptask->taskflags.module_id, + INITSERVICE::INITSVC_START_FN_MOD_ID, INITSERVICE::START_FN_FAILED, - l_tidrc, - 0 ); + i_ptask->taskflags.module_id, + l_tidrc ); } // endif tidrc else @@ -224,7 +223,7 @@ errlHndl_t InitService::dispatchTask( const TaskInfo *i_ptask, } -void InitService::init( void *i_ptr ) +void InitService::init( void *io_ptr ) { errlHndl_t l_errl = NULL; uint64_t l_task = 0; @@ -232,11 +231,9 @@ void InitService::init( void *i_ptr ) TaskArgs::TaskArgs l_args; uint64_t l_childrc = 0; - TRACFCOMP( g_trac_initsvc, ENTER_MRK "Initialization Service is starting." ); - // loop through the task list and start up any tasks necessary for ( l_task=0; l_task < INITSERVICE::MAX_TASKS; @@ -247,7 +244,7 @@ void InitService::init( void *i_ptr ) if ( l_ptask->taskflags.task_type == END_TASK_LIST ) { TRACDCOMP( g_trac_initsvc, - "End of Initialization Service task list.\n" ); + "End of Initialization Service task list." ); break; } @@ -289,28 +286,28 @@ void InitService::init( void *i_ptr ) // Check child results for a valid nonzero return code. // If we have one, and no errorlog, then we create and // post our own errorlog here. - if ( ( l_childrc != TASKARGS_UNDEFINED64 ) - && ( l_childrc != 0 ) - ) + if ( l_childrc != 0 ) { TRACFCOMP( g_trac_initsvc, - "Child task returned 0x%llx, no errlog", + "IS: Child task %s returned 0x%llx, no errlog", + l_ptask->taskname, l_childrc ); /*@ errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM - * @moduleid see task list + * @moduleid INITSVC_TASK_RETURNED_ERROR_ID * @reasoncode INITSVC_FAILED_NO_ERRLOG * @userdata1 returncode from task * @userdata2 0 * * @devdesc The task returned with an error, * but there was no errorlog returned. + * See userdata1 for the return code. * */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - l_ptask->taskflags.module_id, + INITSVC_TASK_RETURNED_ERROR_ID, INITSERVICE::INITSVC_FAILED_NO_ERRLOG, l_childrc, 0 ); @@ -323,12 +320,13 @@ void InitService::init( void *i_ptr ) // die if we drop out with an error if ( l_errl ) { - // commit the log first, then stop right here. - TRACFCOMP( g_trac_initsvc, - "ERROR: extra errorlog found: %p", - l_errl ); + // commit the log first, then shutdown. + TRACFCOMP( g_trac_initsvc, "InitService: Committing errorlog." ); errlCommit( l_errl, INITSVC_COMP_ID ); - assert( 0 ); + + // Tell the kernel to shutdown. + shutdown( SHUTDOWN_STATUS_INITSVC_FAILED ); + } TRACFCOMP( g_trac_initsvc, diff --git a/src/usr/initservice/extinitsvc/extinitsvc.C b/src/usr/initservice/extinitsvc/extinitsvc.C index 2f8d5cb0d..342dad0e7 100644 --- a/src/usr/initservice/extinitsvc/extinitsvc.C +++ b/src/usr/initservice/extinitsvc/extinitsvc.C @@ -57,14 +57,16 @@ extern trace_desc_t *g_trac_initsvc; TASK_ENTRY_MACRO( ExtInitSvc::getTheInstance().init ); -void ExtInitSvc::init( void *i_ptr ) +void ExtInitSvc::init( void *io_ptr ) { errlHndl_t l_errl = NULL; uint64_t l_task = 0; const TaskInfo *l_ptask = NULL; TaskArgs::TaskArgs l_args; uint64_t l_childrc = 0; - + // set up pointer to our taskargs + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_ptr ); TRACFCOMP( g_trac_initsvc, "Extended Initialization Service is starting." ); @@ -95,8 +97,8 @@ void ExtInitSvc::init( void *i_ptr ) if ( l_errl ) { TRACFCOMP( g_trac_initsvc, - "ERROR: dispatching task, errlog=0x%p", - l_errl ); + "ERROR: dispatching task, errlog=0x%p", + l_errl ); // break out of loop with error. break; } @@ -106,12 +108,13 @@ void ExtInitSvc::init( void *i_ptr ) // this also clears the errorlog from the TaskArgs struct, so // use it or lose it ( see taskargs.H for details ). l_childrc = l_args.getReturnCode(); - l_errl = l_args.getErrorLog(); + l_errl = l_args.getErrorLog(); if ( l_errl ) { TRACFCOMP( g_trac_initsvc, - " Child task returned 0x%llx, errlog=0x%p", + " Child task %s returned 0x%llx, errlog=0x%p", + l_ptask->taskname, l_childrc, l_errl ); // break out of loop with error @@ -122,17 +125,16 @@ void ExtInitSvc::init( void *i_ptr ) // Check child results for a valid nonzero return code. // If we have one, and no errorlog, then we create and // post our own errorlog here. - if ( ( l_childrc != TASKARGS_UNDEFINED64 ) - && ( l_childrc != 0 ) - ) + if ( l_childrc != 0 ) { TRACFCOMP( g_trac_initsvc, - "Child task returned 0x%llx, no errlog", - l_childrc ); + "EIS: Child task %s returned 0x%llx, no errlog", + l_ptask->taskname, + l_childrc ); /*@ errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM - * @moduleid see task list + * @moduleid EXTINITSVC_TASK_RETURNED_ERROR_ID * @reasoncode EXTINITSVC_FAILED_NO_ERRLOG * @userdata1 returncode from task * @userdata2 0 @@ -143,7 +145,7 @@ void ExtInitSvc::init( void *i_ptr ) */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - l_ptask->taskflags.module_id, + EXTINITSVC_TASK_RETURNED_ERROR_ID, INITSERVICE::EXTINITSVC_FAILED_NO_ERRLOG, l_childrc, 0 ); @@ -160,122 +162,131 @@ void ExtInitSvc::init( void *i_ptr ) // dropped out of loop with error. // Commit the log first, then stop right here. TRACFCOMP( g_trac_initsvc, - "ERROR: extra errorlog found: %p", - l_errl ); + "ExtInitSvc: Committing errorlog..." ); errlCommit( l_errl, INITSVC_COMP_ID ); - assert( 0 ); + + // pass an error code to initsvc that we are shutting down. + pTaskArgs->postReturnCode( TASKARGS_SHUTDOWN_RC ); + // Tell the kernel to shutdown. + shutdown( SHUTDOWN_STATUS_EXTINITSVC_FAILED ); } TRACFCOMP( g_trac_initsvc, EXIT_MRK "ExtInitSvc finished."); - - - // ===================================================================== - // ----- Unit Tests ------------------------------------------------- - // ===================================================================== - /** - * @note run all of the unit tests after we finish the rest - * There are 2 images generated in the build: - * hbicore.bin (HostBoot shippable image) - * hbicore_test.bin (runs all unit tests) - * Only hbicore_test.bin has the libcxxtest.so module, so when - * we execute startTask() below on hbicore.bin, it will return -ENOENT, - * no module present. This is OK. - * - * @todo can we call call module_load() to see if libcxxtest.so exists? - * ask Doug or Patrick - * - */ - - // add a do-while loop so there is only one return at the bottom.... - do + // Test if the child posted an errorcode. If so, don't + // bother to run the unit tests. + if ( pTaskArgs->getReturnCode() == 0 ) { - // Pass it a set of args so we can wait on the barrier - errlHndl_t l_cxxerrl = NULL; - TaskArgs::TaskArgs l_cxxtestargs; - const TaskInfo *l_pcxxtask = &CXXTEST_TASK; - uint64_t l_cxxchildrc = 0; - errlHndl_t l_cxxchilderrl = NULL; + // ===================================================================== + // ----- Unit Tests ------------------------------------------------- + // ===================================================================== + /** + * @note run all of the unit tests after we finish the rest + * There are 2 images generated in the build: + * hbicore.bin (HostBoot shippable image) + * hbicore_test.bin (runs all unit tests) + * Only hbicore_test.bin has the libcxxtest.so module, so when + * we execute startTask() below on hbicore.bin, it will return -ENOENT, + * no module present. This is OK. + * + * @todo can we call call module_load() to see if libcxxtest.so exists? + * ask Doug or Patrick + * + */ + + // add a do-while loop so there is only one return at the bottom.... + do + { + // Pass it a set of args so we can wait on the barrier + errlHndl_t l_cxxerrl = NULL; + TaskArgs::TaskArgs l_cxxtestargs; + const TaskInfo *l_pcxxtask = &CXXTEST_TASK; + uint64_t l_cxxchildrc = 0; + errlHndl_t l_cxxchilderrl = NULL; - l_cxxtestargs.clear(); + l_cxxtestargs.clear(); - TRACDCOMP( g_trac_initsvc, - ENTER_MRK "Run Unit Tests (if libcxxtests.so is present): %s", - l_pcxxtask->taskname ); + TRACDCOMP( g_trac_initsvc, + ENTER_MRK "Run Unit Tests (if libcxxtests.so is present): %s", + l_pcxxtask->taskname ); - // If the test task does not exist then don't run it. - if(!VFS::module_exists(l_pcxxtask->taskname)) break; + // If the test task does not exist then don't run it. + if(!VFS::module_exists(l_pcxxtask->taskname)) break; - l_cxxerrl = InitService::getTheInstance().startTask( l_pcxxtask, - &l_cxxtestargs ); + l_cxxerrl = InitService::getTheInstance().startTask( l_pcxxtask, + &l_cxxtestargs ); - // process errorlogs returned from the task that was launched - // @TODO if we are running the non-test version of HostBoot, this - // will always post an extra errorlog. We need a way to know - // if we are running the _test version or not. - if ( l_cxxerrl ) - { - TRACFCOMP( g_trac_initsvc, - "Committing error from cxxtask launch" ); - errlCommit( l_cxxerrl, INITSVC_COMP_ID ); - break; // ERROR, break out of do-while. - } + // process errorlogs returned from the task that was launched + // @TODO if we are running the non-test version of HostBoot, this + // will always post an extra errorlog. We need a way to know + // if we are running the _test version or not. + if ( l_cxxerrl ) + { + TRACFCOMP( g_trac_initsvc, + "Committing error from cxxtask launch" ); + errlCommit( l_cxxerrl, INITSVC_COMP_ID ); + break; // ERROR, break out of do-while. + } - // make local copies of the values in TaskArgs that are returned from - // the child. - // this also clears the errorlog from the TaskArgs struct, so - // use it or lose it ( see taskargs.H for details ). - l_cxxchildrc = l_cxxtestargs.getReturnCode(); - l_cxxchilderrl = l_cxxtestargs.getErrorLog(); + // make local copies of the values in TaskArgs that are returned from + // the child. + // this also clears the errorlog from the TaskArgs struct, so + // use it or lose it ( see taskargs.H for details ). + l_cxxchildrc = l_cxxtestargs.getReturnCode(); + l_cxxchilderrl = l_cxxtestargs.getErrorLog(); - if ( l_cxxchilderrl ) - { - TRACFCOMP( g_trac_initsvc, - " Child task returned 0x%llx, errlog=0x%p", - l_cxxchildrc, - l_cxxchilderrl ); - errlCommit( l_cxxchilderrl, INITSVC_COMP_ID ); - } - else - { - // Check child results for a valid nonzero return code. - // If we have one, and no errorlog, then we create and - // post our own errorlog here. - if ( ( l_cxxchildrc != TASKARGS_UNDEFINED64 ) - && ( l_cxxchildrc != 0 ) - ) + if ( l_cxxchilderrl ) { TRACFCOMP( g_trac_initsvc, - "Child task returned 0x%llx, no errlog", - l_cxxchildrc ); - - /*@ errorlog tag - * @errortype ERRL_SEV_CRITICAL_SYS_TERM - * @moduleid see task list - * @reasoncode CXXTEST_FAILED_NO_ERRLOG - * @userdata1 returncode from istep - * @userdata2 0 - * - * @devdesc The unit test dispatcher returned with an - * error, but there was no errorlog returned. - */ - l_cxxerrl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - l_pcxxtask->taskflags.module_id, - INITSERVICE::CXXTEST_FAILED_NO_ERRLOG, + " Child task returned 0x%llx, errlog=0x%p", l_cxxchildrc, - 0 ); - errlCommit( l_cxxerrl, INITSVC_COMP_ID ); - } // end if - } // end else + l_cxxchilderrl ); + errlCommit( l_cxxchilderrl, INITSVC_COMP_ID ); + } + else + { + // Check child results for a valid nonzero return code. + // If we have one, and no errorlog, then we create and + // post our own errorlog here. + if ( l_cxxchildrc != 0 ) + { + TRACFCOMP( g_trac_initsvc, + "Child task returned 0x%llx, no errlog", + l_cxxchildrc ); + + /*@ errorlog tag + * @errortype ERRL_SEV_CRITICAL_SYS_TERM + * @moduleid CXXTEST_TASK_RETURNED_ERROR_ID + * @reasoncode CXXTEST_FAILED_NO_ERRLOG + * @userdata1 returncode from istep + * @userdata2 0 + * + * @devdesc The unit test dispatcher returned with an + * error, but there was no errorlog returned. + */ + l_cxxerrl = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, + CXXTEST_TASK_RETURNED_ERROR_ID, + INITSERVICE::CXXTEST_FAILED_NO_ERRLOG, + l_cxxchildrc, + 0 ); + errlCommit( l_cxxerrl, INITSVC_COMP_ID ); + + } // end if + } // end else + + } while(0); // end do-while - } while(0); // end do-while + } // ===================================================================== // ----- Shutdown all CPUs ----------------------------------------- // ===================================================================== + TRACFCOMP( g_trac_initsvc, + EXIT_MRK "CxxTests finished."); + uint64_t l_shutdownStatus = SHUTDOWN_STATUS_GOOD; if (CxxTest::g_FailedTests) diff --git a/src/usr/initservice/extinitsvc/extinitsvc.H b/src/usr/initservice/extinitsvc/extinitsvc.H index 5664a0359..eb56dd98c 100644 --- a/src/usr/initservice/extinitsvc/extinitsvc.H +++ b/src/usr/initservice/extinitsvc/extinitsvc.H @@ -57,17 +57,6 @@ namespace INITSERVICE // Typedef/Enumerations /******************************************************************************/ -/** - * @enum ShutdownStatus - */ -enum ShutdownStatus -{ - SHUTDOWN_STATUS_GOOD = 0x01230000, - SHUTDOWN_STATUS_UT_FAILED = 0x01230001, - SHUTDOWN_STATUS_ISTEP_FAILED = 0x01230002, -}; - - /******************************************************************************/ // ExtInitSvc Class /******************************************************************************/ diff --git a/src/usr/initservice/istepdispatcher/istepdispatcher.C b/src/usr/initservice/istepdispatcher/istepdispatcher.C index 36da4d544..1615c1b9e 100644 --- a/src/usr/initservice/istepdispatcher/istepdispatcher.C +++ b/src/usr/initservice/istepdispatcher/istepdispatcher.C @@ -38,14 +38,15 @@ #include #include -#include // tid_t, task_create, etc -#include // nanosleep +#include // tid_t, task_create, etc +#include // nanosleep +#include // shutdown #include // trace support #include // errlHndl_t #include // targeting #include // mmio_scratch_read() #include // TaskArgs structs - +#include // ErrlUserDetails base class #include "istepdispatcher.H" @@ -54,9 +55,62 @@ #include +namespace ERRORLOG +{ +/** + * @class IStepNameUserDetail + * + * report the failing IStepName. + * + * @todo: get rid of magic numbers in version and subsection. + * set up tags, plugins, include files, etc. + * For now we just want to report the failing istep string for debug. + * @todo: Expand this to report the istep / substep, error returned, etc. + */ + +class IStepNameUserDetail : public ErrlUserDetails +{ + +public: + + IStepNameUserDetail( + const char *i_istepname, + const uint16_t i_istep = 0, + const uint16_t i_substep = 0, + const uint64_t i_isteprc = 0 ) + { + + iv_CompId = INITSVC_COMP_ID; + iv_Version = 1; + iv_SubSection = 1; + + // Store the string in the internal buffer + char * l_pString = (char *)allocUsrBuf( strlen(i_istepname)+1 ); + strcpy(l_pString, i_istepname ); + } + +/** + * @brief Destructor + * + */ +virtual ~IStepNameUserDetail() {} + +private: + +// Disabled +IStepNameUserDetail(const IStepNameUserDetail &); +IStepNameUserDetail & operator=(const IStepNameUserDetail &); +}; + +} // end namespace ERRORLOG + + + namespace INITSERVICE { +using namespace ERRORLOG; // IStepNameUserDetails + /******************************************************************************/ // Globals/Constants /******************************************************************************/ @@ -91,6 +145,9 @@ const uint64_t SINGLESTEP_PAUSE_S = 1; const uint64_t SINGLESTEP_PAUSE_NS = 100000000; + + + /** * @brief set up _start() task entry procedure using the macro in taskargs.H */ @@ -167,10 +224,7 @@ const TaskInfo *IStepDispatcher::findTaskInfo( const uint16_t i_IStep, void IStepDispatcher::init( void * io_ptr ) { - - TRACFCOMP( g_trac_initsvc, - ENTER_MRK "starting IStepDispatcher, io_ptr=%p ", - io_ptr ); + // note, io_ptr will pass the TaskArgs struct through to runAllSteps, etc. if ( getIStepMode() ) { @@ -362,19 +416,9 @@ void IStepDispatcher::singleStepISteps( void * io_ptr ) const errlCommit( l_errl, INITSVC_COMP_ID); } - // massage the return code from the IStep - - // If the istep did not set an errorcode, - // then we report 0 - if ( l_isteprc == TASKARGS_UNDEFINED64 ) - { - l_istepStatus = 0; - } - else - { - // truncate IStep return status to 16 bits. - l_isteprc &= 0x000000000000ffff; - l_istepStatus = static_cast(l_isteprc); - } + // truncate IStep return status to 16 bits. + l_isteprc &= 0x000000000000ffff; + l_istepStatus = static_cast(l_isteprc); } // end else parent errlog @@ -435,10 +479,16 @@ void IStepDispatcher::runAllISteps( void * io_ptr ) const uint16_t l_IStep = 0; uint16_t l_SubStep = 0; const TaskInfo *l_pistep = NULL; - TaskArgs::TaskArgs l_args; uint64_t l_progresscode = 0; uint64_t l_isteprc = 0; + // taskargs struct for children + TaskArgs::TaskArgs l_args; + + // set up pointer to our taskargs, passed in from caller + INITSERVICE::TaskArgs *pTaskArgs = + static_cast( io_ptr ); + for ( l_IStep=0; l_ISteptaskname ); - l_errl = InitService::getTheInstance().executeFn( l_pistep, &l_args ); if ( l_errl ) @@ -494,12 +538,14 @@ void IStepDispatcher::runAllISteps( void * io_ptr ) const l_isteprc = l_args.getReturnCode(); l_errl = l_args.getErrorLog(); - TRACDCOMP( g_trac_initsvc, - "IStep TaskArgs returned 0x%llx, errlog=%p", - l_isteprc, - l_errl ); + if ( l_errl ) { + TRACFCOMP( g_trac_initsvc, + "ISD: istep %s returned 0x%llx, errlog=%p", + l_pistep->taskname, + l_isteprc, + l_errl ); // if we have an errorlog, break out of the inner loop // and handle it. break; @@ -509,31 +555,36 @@ void IStepDispatcher::runAllISteps( void * io_ptr ) const // Check child results for a valid nonzero return code. // If we have one, and no errorlog, then we create an // errorlog here. - if ( ( l_isteprc != TASKARGS_UNDEFINED64 ) - && ( l_isteprc != 0 ) - ) + if ( l_isteprc != 0 ) { TRACFCOMP( g_trac_initsvc, - "istep returned 0x%llx, no errlog", + "ISD: istep %s returned 0x%llx, no errlog", + l_pistep->taskname, l_isteprc ); /*@ errorlog tag * @errortype ERRL_SEV_CRITICAL_SYS_TERM - * @moduleid see task list + * @moduleid ISTEP_RETURNED_ERROR_ID * @reasoncode ISTEP_FAILED_NO_ERRLOG - * @userdata1 returncode from istep - * @userdata2 0 + * @userdata1 istep / substep + * @userdata2 returncode from istep * * @devdesc The Istep returned with an error, * but there was no errorlog posted - * from the IStep. + * from the IStep. Look at user1 data + * for the istep / substep, and + * user2 data for the returned errorcode. */ l_errl = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - l_pistep->taskflags.module_id, + ISTEP_RETURNED_ERROR_ID, INITSERVICE::ISTEP_FAILED_NO_ERRLOG, - l_isteprc, - 0 ); + ( l_IStep << 8 | l_SubStep ), + l_isteprc ); + // attach the istep name to the error log + // @todo + IStepNameUserDetail l_istepud( l_pistep->taskname ); + l_istepud.addToLog( l_errl ); // drop out of inner loop with errlog set. break; } // end if ( ) @@ -559,12 +610,17 @@ void IStepDispatcher::runAllISteps( void * io_ptr ) const if ( l_errl ) { TRACFCOMP( g_trac_initsvc, - "ERROR: istep=0x%x, substep=0x%x, committing errorlog %p", + "ERROR: istep=0x%x, substep=0x%x, isteprc=0x%x, committing errorlog and shutting down.", l_IStep, l_SubStep, - l_errl ); + l_isteprc ); errlCommit( l_errl, INITSVC_COMP_ID ); - assert( 0 ); + + // pass an error code on to extinitsvc that we are shutting down. + pTaskArgs->postReturnCode( TASKARGS_SHUTDOWN_RC ); + // Tell the kernel to shutdown. + shutdown( SHUTDOWN_STATUS_ISTEP_FAILED ); + } } diff --git a/src/usr/initservice/taskargs/taskargs.C b/src/usr/initservice/taskargs/taskargs.C index 073c33366..75cd7f828 100644 --- a/src/usr/initservice/taskargs/taskargs.C +++ b/src/usr/initservice/taskargs/taskargs.C @@ -77,7 +77,7 @@ void TaskArgs::postReturnCode( const uint64_t i_returncode ) { iv_taskreturncode = i_returncode; - return; + return; } @@ -124,8 +124,8 @@ errlHndl_t TaskArgs::getErrorLog( ) void TaskArgs::clear() { - iv_taskreturncode = TASKARGS_UNDEFINED64; // init iv_returncode to undefined - iv_taskcommand = TASKARGS_UNDEFINED64; // init iv_command to undefined + iv_taskreturncode = 0; // init iv_returncode + iv_taskcommand = 0; // init iv_command // this should not happen, should have been handled by the caller(s) // commit the errorlog here just to get rid of it @@ -143,8 +143,8 @@ void TaskArgs::clear() TaskArgs::TaskArgs() : iv_errl( NULL ), // init errorlog handle to NULL - iv_taskreturncode(TASKARGS_UNDEFINED64), // init iv_returncode to undefined - iv_taskcommand(TASKARGS_UNDEFINED64) // init iv_command to undefined + iv_taskreturncode(0), // init iv_returncode to undefined + iv_taskcommand(0) // init iv_command to undefined { // set barrier to wait for 2 tasks before releasing, // see notes above. -- cgit v1.2.1