diff options
author | Mark Wenning <wenning@us.ibm.com> | 2012-03-20 11:37:13 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-04-04 13:23:18 -0500 |
commit | dd7a32e1a27ecac1c8decaa958cbca7ef139c6bc (patch) | |
tree | 65706898117498bf0c280e772c3e850386b0c378 /src/usr/initservice/extinitsvc/extinitsvc.C | |
parent | 36123c3c9911bc6feefc27e17b4285f1079b569f (diff) | |
download | talos-hostboot-dd7a32e1a27ecac1c8decaa958cbca7ef139c6bc.tar.gz talos-hostboot-dd7a32e1a27ecac1c8decaa958cbca7ef139c6bc.zip |
Refactor InitService
Finish join() conversion, remove TaskArgs
Cleanup Initservice
Cleanup ExtInitService
Cleanup IStepDisp
Add SPLess Halt & Shutdown command.
Implements code for Tasks 35508, 3855, 36929 and 38870 .
RTC: 38196
Change-Id: I554655412b529ef6cd143fea361a39bd584d18b5
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/794
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/initservice/extinitsvc/extinitsvc.C')
-rw-r--r-- | src/usr/initservice/extinitsvc/extinitsvc.C | 312 |
1 files changed, 118 insertions, 194 deletions
diff --git a/src/usr/initservice/extinitsvc/extinitsvc.C b/src/usr/initservice/extinitsvc/extinitsvc.C index 2db1c44b6..0c42e9678 100644 --- a/src/usr/initservice/extinitsvc/extinitsvc.C +++ b/src/usr/initservice/extinitsvc/extinitsvc.C @@ -40,7 +40,7 @@ #include <trace/interface.H> #include <errl/errlentry.H> -#include <initservice/taskargs.H> // task entry routine +#include <initservice/taskargs.H> // task entry macro #include "extinitsvc.H" #include "extinitsvctasks.H" @@ -51,36 +51,31 @@ namespace INITSERVICE extern trace_desc_t *g_trac_initsvc; - /** - * @brief set up _start() task entry procedure using the macro in taskargs.H + * _start() task entry procedure using the macro in taskargs.H */ TASK_ENTRY_MACRO( ExtInitSvc::getTheInstance().init ); -void ExtInitSvc::init( void *io_ptr ) +void ExtInitSvc::init( errlHndl_t &io_rtaskRetErrl ) { 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<INITSERVICE::TaskArgs *>( io_ptr ); printk( "ExtInitSvc entry.\n" ); - TRACFCOMP( g_trac_initsvc, - "Extended Initialization Service is starting %p.", io_ptr ); - + // @todo detach from initservice + // task_detach(); + TRACFCOMP( g_trac_initsvc, + "Extended Initialization Service is starting." ); // ---------------------------------------------------------------- // loop through the task list and start up any tasks necessary // ---------------------------------------------------------------- for ( l_task=0; - l_task<INITSERVICE::MAX_EXT_TASKS; + l_task < ( sizeof(g_exttaskinfolist)/sizeof(TaskInfo) ) ; l_task++ ) { // make a local copy of the extended image task @@ -92,226 +87,155 @@ void ExtInitSvc::init( void *io_ptr ) break; } - l_args.clear(); - // dispatch the task l_errl = InitService::getTheInstance().dispatchTask( l_ptask, - &l_args ); + NULL ); // process errorlogs returned from the task that was launched if ( l_errl ) { TRACFCOMP( g_trac_initsvc, - "ERROR: dispatching task, errlog=0x%p", - l_errl ); - // break out of loop with error. - break; - } - - // 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_childrc = l_args.getReturnCode(); - l_errl = l_args.getErrorLog(); - - if ( l_errl ) - { - TRACFCOMP( g_trac_initsvc, - " Child task %s returned 0x%llx, errlog=0x%p", + "ERROR: task %s returned errlog=0x%p", l_ptask->taskname, - l_childrc, l_errl ); - // break out of loop with error + // break out of loop with error. break; } - 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_childrc != 0 ) - { - TRACFCOMP( g_trac_initsvc, - "EIS: Child task %s returned 0x%llx, no errlog", - l_ptask->taskname, - l_childrc ); - - /*@ errorlog tag - * @errortype ERRL_SEV_CRITICAL_SYS_TERM - * @moduleid EXTINITSVC_TASK_RETURNED_ERROR_ID - * @reasoncode EXTINITSVC_FAILED_NO_ERRLOG - * @userdata1 returncode from task - * @userdata2 0 - * - * @devdesc The task returned with an error, - * but there was no errorlog returned. - * - */ - l_errl = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, - EXTINITSVC_TASK_RETURNED_ERROR_ID, - INITSERVICE::EXTINITSVC_FAILED_NO_ERRLOG, - l_childrc, - 0 ); - - // break out of loop with error - break; - } // end if - } // end else } // endfor // die if we drop out with an error if ( l_errl ) { - // dropped out of loop with error. - // Commit the log first, then stop right here. + +#if 0 + // @todo detach this task and just do task_end() + // Commit the errorlog here. TRACFCOMP( g_trac_initsvc, - "ExtInitSvc: Committing errorlog..." ); + "ExtInitSvc ERROR: Committing errorlog %p & shutdown", + l_errl ); errlCommit( l_errl, INITSVC_COMP_ID ); - // pass an error code to initsvc that we are shutting down. - pTaskArgs->postReturnCode( TASKARGS_SHUTDOWN_RC ); - //Tell initservice to perform shutdown sequence + // Tell the kernel to shut down. This will not actually + // happen until the last thread has ended. InitService::getTheInstance().doShutdown( SHUTDOWN_STATUS_EXTINITSVC_FAILED); + + // end the task. + end_task(); +#endif + + // end the task and pass the errorlog to initservice to be committed. + // initservice should do the shutdown. + TRACFCOMP( g_trac_initsvc, + "ExtInitSvc: ERROR: return to initsvc with errlog %p", + l_errl ); + + task_end2( l_errl ); } TRACFCOMP( g_trac_initsvc, - EXIT_MRK "ExtInitSvc finished."); + "ExtInitSvc finished OK."); + - // Test if the child posted an errorcode. If so, don't - // bother to run the unit tests. - if ( pTaskArgs->getReturnCode() == 0 ) + // ===================================================================== + // ----- 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 that's + * how we test whether to run this. + */ + + // If the test task does not exist then don't run it. + if ( VFS::module_exists( cxxTestTask.taskname ) ) { - // ===================================================================== - // ----- 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 - * - */ - - printk( "start CxxTest.\n" ); - - // add a do-while loop so there is only one return at the bottom.... - do + printk( "CxxTest entry.\n" ); + + // Pass it a set of args so we can wait on the barrier + errlHndl_t l_cxxerrl = NULL; + const TaskInfo *l_pcxxtask = &cxxTestTask; + + TRACDCOMP( g_trac_initsvc, + "Run CxxTest Unit Tests: %s", + l_pcxxtask->taskname ); + + l_cxxerrl = InitService::getTheInstance().startTask( l_pcxxtask, + NULL ); + // process any errorlogs from cxxtestexec (not sure there are any...) + if ( l_cxxerrl ) { - // 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; +#if 0 + // @todo detach this task and just do task_end() + // First commit the errorlog... + TRACFCOMP( g_trac_initsvc, + "Committing errorlog %p from cxxtask", + l_cxxerrl ); + errlCommit( l_cxxerrl, INITSVC_COMP_ID ); - l_cxxtestargs.clear(); + // Tell the kernel to shut down. This will not actually + // happen until the last thread has ended. + InitService::getTheInstance().doShutdown( SHUTDOWN_STATUS_UT_FAILED); - 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; - - 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. - } - - // 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 != 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 - - printk( "finish CxxTest.\n" ); + // end the task. + end_task(); +#endif - } + // end the task and pass the errorlog to initservice to be committed. + // initservice should do the shutdown. + TRACFCOMP( g_trac_initsvc, + "CxxTest: ERROR: return to initsvc with errlog %p", + l_cxxerrl ); + task_end2( l_cxxerrl ); + } // endif l_cxxerrl - // ===================================================================== - // ----- Shutdown all CPUs ----------------------------------------- - // ===================================================================== - TRACFCOMP( g_trac_initsvc, - EXIT_MRK "CxxTests finished."); + // make up and post an errorlog if any tests failed. + if ( CxxTest::g_FailedTests ) + { + // some unit tests failed, post an errorlog + /*@ errorlog tag + * @errortype ERRL_SEV_CRITICAL_SYS_TERM + * @moduleid CXXTEST_MOD_ID + * @reasoncode CXXTEST_FAILED_TEST + * @userdata1 number of failed tests + * @userdata2 0 + * + * @devdesc One or more CxxTest Unit Tests failed. + * + */ + l_cxxerrl = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, + INITSERVICE::CXXTEST_MOD_ID, + INITSERVICE::CXXTEST_FAILED_TEST, + CxxTest::g_FailedTests, + 0 ); + TRACFCOMP( g_trac_initsvc, + "CxxTest ERROR: %d failed tests, build errlog %p.", + CxxTest::g_FailedTests, + l_cxxerrl ); - uint64_t l_shutdownStatus = SHUTDOWN_STATUS_GOOD; + // end the task and pass the errorlog to initservice to be committed. + // initservice should do the shutdown. + TRACFCOMP( g_trac_initsvc, "CxxTest: return to initsvc with errlog" ); - if (CxxTest::g_FailedTests) - { - l_shutdownStatus = SHUTDOWN_STATUS_UT_FAILED; - } + task_end2( l_cxxerrl ); + } // endif g_FailedTest - //Tell initservice to perform shutdown sequence - InitService::getTheInstance().doShutdown(l_shutdownStatus); + printk( "CxxTest exit.\n" ); - printk( "ExtInitSvc exit.\n" ); + } // endif cxxtest module exists. + // finish things up, return to initservice with goodness. + TRACFCOMP( g_trac_initsvc, + "ExtInitSvc finished OK, return to initsvc with NULL."); + + printk( "ExtInitSvc exit.\n" ); - // return to _start() + task_end2( NULL ); } |