summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorMark Wenning <wenning@us.ibm.com>2011-06-29 17:30:28 -0500
committerMark W. Wenning <wenning@us.ibm.com>2011-07-14 15:38:11 -0500
commit5530b7609c0351deb5d707c5950a56309842a325 (patch)
tree2382ef9aa2e3cfebe33d6d1737647be7325a94e0 /src/usr
parent2583b46750d1e1c062763eff204baa1460e7ae90 (diff)
downloadtalos-hostboot-5530b7609c0351deb5d707c5950a56309842a325.tar.gz
talos-hostboot-5530b7609c0351deb5d707c5950a56309842a325.zip
InitService changes for LLDD 0.7
- implement task flags - add barrier to unit tests - startTask returns errlog handle - factor taskargs.H - add STRICT mode and fix results - add tasktest2 to replace example.C - add cxxtest as an explicit task at the end - cleanup todo's - post-review fixes - merge problem Change-Id: I073bd154a64013553c1863f9eb674cda2bf40a8d Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/187 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Diffstat (limited to 'src/usr')
-rwxr-xr-xsrc/usr/cxxtest/TestSuite.C47
-rw-r--r--src/usr/cxxtest/cxxtestexec.C38
-rwxr-xr-xsrc/usr/cxxtest/cxxtestgen.pl27
-rw-r--r--src/usr/initservice/baseinitsvc/initservice.C233
-rw-r--r--src/usr/initservice/baseinitsvc/initservice.H220
-rw-r--r--src/usr/initservice/baseinitsvc/initservicetaskentry.C (renamed from src/usr/initservice/initservicetaskentry.C)34
-rw-r--r--src/usr/initservice/baseinitsvc/initsvctasks.H85
-rw-r--r--src/usr/initservice/baseinitsvc/makefile7
-rw-r--r--src/usr/initservice/extinitsvc/extinitsvc.C197
-rw-r--r--src/usr/initservice/extinitsvc/extinitsvc.H121
-rw-r--r--src/usr/initservice/extinitsvc/extinitsvctasks.H69
-rw-r--r--src/usr/initservice/extinitsvc/makefile6
-rw-r--r--src/usr/initservice/extinitsvc/test/makefile6
-rw-r--r--src/usr/initservice/initservice.C418
-rw-r--r--src/usr/initservice/initservice.H448
-rw-r--r--src/usr/initservice/initservicevfs1.C69
-rw-r--r--src/usr/initservice/initservicevfs2.C176
-rw-r--r--src/usr/initservice/initsvctasks.H79
-rw-r--r--src/usr/initservice/initsvcunittesttask2/makefile6
-rw-r--r--src/usr/initservice/initsvcunittesttask2/tasktest2.C62
-rw-r--r--src/usr/initservice/initsvcunittesttask2/tasktest2.H82
-rw-r--r--src/usr/initservice/makefile12
-rw-r--r--src/usr/initservice/taskargs/makefile6
-rw-r--r--src/usr/initservice/taskargs/taskargs.C111
-rw-r--r--src/usr/initservice/test/initservicetest.H76
-rw-r--r--src/usr/makefile2
-rw-r--r--src/usr/targeting/targetservice.C16
27 files changed, 1328 insertions, 1325 deletions
diff --git a/src/usr/cxxtest/TestSuite.C b/src/usr/cxxtest/TestSuite.C
index 99055d0cf..79677b83b 100755
--- a/src/usr/cxxtest/TestSuite.C
+++ b/src/usr/cxxtest/TestSuite.C
@@ -114,53 +114,6 @@ void reportTotalTests( const char *suitename, uint64_t numtests )
return;
}
-/**
- * @brief accessor to read global totaltests var
- * @TODO make these readonly accessors
- *
- * @return number of total tests
- */
-uint64_t getTotalTests(void)
-{
-
- return g_TotalTests;
-}
-
-/**
- * @brief accessor to read global failedtests var
- * @TODO make these readonly accessors
- *
- * @return total number off failures executed
- */
-uint64_t getFailedTests(void)
-{
-
- return g_FailedTests;
-}
-
-/**
- * @brief accessor to read global warnings var
- * @TODO make these readonly accessors
- *
- * @return total number of warnings executed
- */
-uint64_t getWarnings(void)
-{
-
- return g_Warnings;
-}
-
-/**
- * @brief accessor to read global tracecalls var
- * @TODO make these readonly accessors
- *
- * @return total number of trace calls executed
- */
-uint64_t getTraceCalls(void)
-{
-
- return g_TraceCalls;
-}
};
diff --git a/src/usr/cxxtest/cxxtestexec.C b/src/usr/cxxtest/cxxtestexec.C
index 5efb1827e..d79188e9e 100644
--- a/src/usr/cxxtest/cxxtestexec.C
+++ b/src/usr/cxxtest/cxxtestexec.C
@@ -3,22 +3,29 @@
#include <string.h>
#include <kernel/console.H>
#include <sys/time.h>
+#include <sys/sync.h>
+
+#include <cxxtest/TestSuite.H>
namespace CxxTest
{
- uint64_t g_ModulesStarted = 0;
- uint64_t g_ModulesCompleted = 0;
+ uint64_t g_ModulesStarted = 0;
+ uint64_t g_ModulesCompleted = 0;
}
-/* Iterate through all modules in the VFS named "libtest*" and create children
- * tasks to execute them.
+/**
+ * @brief _start()
+ * Iterate through all modules in the VFS named "libtest*" and create children
+ * tasks to execute them.
+ *
*/
extern "C"
-void _start(void*)
+void _start(void*)
{
VfsSystemModule* vfsItr = &VFS_MODULES[0];
+ tid_t tidrc = 0;
- printk( "Executing CxxTestExec module.\n");
+ printk( "Executing CxxTestExec.\n");
__sync_add_and_fetch(&CxxTest::g_ModulesStarted, 1);
while(vfsItr->module[0] != '\0')
@@ -28,9 +35,15 @@ void _start(void*)
if (NULL != vfsItr->start)
{
__sync_add_and_fetch(&CxxTest::g_ModulesStarted, 1);
- printk( "running %s, ModulesStarted=0x%ld\n",
- vfsItr->module, CxxTest::g_ModulesStarted );
- task_exec(vfsItr->module, NULL);
+
+ printk( "CxxTestExec %d : running %s, ModulesStarted=0x%ld\n",
+ __LINE__,
+ vfsItr->module,
+ CxxTest::g_ModulesStarted );
+ tidrc = task_exec( vfsItr->module, NULL );
+ printk( "CxxTestExec %d : tidrc=%d\n",
+ __LINE__, tidrc );
+
}
}
vfsItr++;
@@ -39,5 +52,12 @@ void _start(void*)
__sync_add_and_fetch(&CxxTest::g_ModulesCompleted, 1);
printk( " ModulesCompleted=0x%ld\n", CxxTest::g_ModulesCompleted );
+
+ printk( "total tests: %ld\n", CxxTest::g_TotalTests );
+ printk( "failed tests: %ld\n", CxxTest::g_FailedTests );
+ printk( "warnings: %ld\n", CxxTest::g_Warnings );
+ printk( "trace calls: %ld\n", CxxTest::g_TraceCalls );
+
+
task_end();
}
diff --git a/src/usr/cxxtest/cxxtestgen.pl b/src/usr/cxxtest/cxxtestgen.pl
index 701c98633..d21305250 100755
--- a/src/usr/cxxtest/cxxtestgen.pl
+++ b/src/usr/cxxtest/cxxtestgen.pl
@@ -616,7 +616,9 @@ sub writeHostBootPreamble() {
print "#include <sys/sync.h>\n";
print "#include <sys/vfs.h>\n";
print "#include <sys/task.h>\n";
+ print "#include <sys/sync.h>\n";
print "#include <trace/interface.H>\n";
+ ## $$TODO print "#include <taskargs/taskargs.H>\n";
print "#include <cxxtest/TestSuite.H>\n";
@@ -629,6 +631,8 @@ sub writeHostBootSuites() {
$suitecount = 1; # initialize suite count
$testcount = 0; # initialize test count
+
+ ## $$TODO print "\tTaskArgs *pTaskArgs = (TaskArgs *)ptr;\n";
foreach (@suites) {
$suite = $_;
@@ -654,7 +658,7 @@ sub writeHostBootSuites() {
## declare and instantiate a new instance of the suite
print "\t// Test Suite ", $suitecount, ": " , suiteName(), "\n";
- print "\tprintk(\"Executing test suite ", suiteName(), ".\\n\");\n";
+ if ( $debug ) { print "\tprintk(\"Executing test suite ", suiteName(), ".\\n\");\n"; }
print "\tTRACDCOMP( g_trac_test, \"Execute ", suiteName(), ".\");\n";
print "\t", suiteName(), "\t*", $suitevar, " = new ", suiteName(), ";\n";
@@ -669,7 +673,12 @@ sub writeHostBootSuites() {
printf "\t$suitevar->%s();\n\n", testName();
$testcount++;
}
-
+
+ ## $$TODO print "\n";
+ ## $$TODO print "\tif ( pTaskArgs )\n";
+ ## $$TODO print "\t{\n";
+ ## $$TODO print "\t\tpTaskArgs->waitChildSync();\n";
+ ## $$TODO print "\t}\n";
print "\n";
## delete the suite instance
@@ -689,6 +698,9 @@ sub writeHostBootSuites() {
sub write_start() {
print "\n";
+ ## $$TODO print "\tusing namespace TASKARGS;\n";
+
+ print "\n";
print "trace_desc_t *g_trac_test = NULL;\n";
## Use same trace buffer for all unit tests, i.e. "UNIT_TEST"
## print "TRAC_INIT(&g_trac_test, \"", suiteName(), "\", 4096);\n";
@@ -697,14 +709,17 @@ sub write_start() {
print "\n\n";
print "extern \"C\"\n";
- print "void _start(void*) {\n";
- print "\n";
-
- ## here's where the magic happens....
+ print "void _start(void *ptr) ";
+ print "{\n";
+
+
+ ## here's where the magic happens....
writeHostBootSuites();
print "\n";
print "\t__sync_add_and_fetch(&CxxTest::g_ModulesCompleted, 1);\n";
+
+ print "\n";
print "\ttask_end();\n";
print "}\n";
diff --git a/src/usr/initservice/baseinitsvc/initservice.C b/src/usr/initservice/baseinitsvc/initservice.C
new file mode 100644
index 000000000..0c3617023
--- /dev/null
+++ b/src/usr/initservice/baseinitsvc/initservice.C
@@ -0,0 +1,233 @@
+/**
+ * @file initservice.C
+ *
+ * Implements Initialization Service for Host boot.
+ * See initservice.H for details
+ *
+ */
+
+#include <kernel/console.H>
+#include <sys/vfs.h>
+#include <sys/task.h>
+#include <trace/interface.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <sys/sync.h>
+
+
+#include "initservice.H"
+#include "initsvctasks.H"
+
+
+
+namespace INITSERVICE
+{
+
+trace_desc_t *g_trac_initsvc = NULL;
+TRAC_INIT(&g_trac_initsvc, "INITSERVICE", 4096);
+
+
+/******************************************************************************/
+// InitService::getTheInstance return the only instance
+/******************************************************************************/
+InitService& InitService::getTheInstance()
+{
+ return Singleton<InitService>::instance();
+}
+
+/******************************************************************************/
+// InitService::Initservice constructor
+/******************************************************************************/
+InitService::InitService()
+{
+
+}
+
+/******************************************************************************/
+// InitService::~InitService destructor
+/******************************************************************************/
+InitService::~InitService()
+{
+
+}
+
+/**
+ * @todo mechanism to set taskcommand in TaskArgs struct
+ * @todo check taskreturncode inside of TaskArgs
+ * @todo test errorlog inside of Taskargs
+ */
+errlHndl_t InitService::startTask( const TaskInfo *i_ptask,
+ TaskArgs::TaskArgs *io_pargs,
+ errlHndl_t &io_rerrl ) const
+{
+ tid_t tidrc = 0;
+
+ assert(i_ptask->taskflags.task_type == START_TASK);
+
+ tidrc = task_exec( i_ptask->taskname, io_pargs ); // launch the child
+
+ if ( io_pargs )
+ {
+ io_pargs->waitParentSync(); // sync up childtask
+ }
+
+ if ( static_cast<int16_t>(tidrc) < 0 )
+ {
+ io_rerrl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, // severity
+ i_ptask->taskflags.module_id, // moduleid
+ INITSERVICE::START_TASK_FAILED, // reason Code
+ tidrc, // user1 = tidrc
+ 0
+ );
+ TRACDBIN( g_trac_initsvc,
+ "ERROR starting task:",
+ i_ptask->taskname,
+ strlen(i_ptask->taskname) );
+ TRACDCOMP( g_trac_initsvc,
+ "tidrc=%d, errlog p = %p" ,
+ (int16_t)tidrc, io_rerrl );
+
+ } // endif tidrc
+ else
+ {
+ TRACDBIN( g_trac_initsvc,
+ "Task finished OK :",
+ i_ptask->taskname,
+ strlen(i_ptask->taskname) );
+ TRACDCOMP( g_trac_initsvc,
+ "task number %d, errlog p = %p",
+ tidrc, io_rerrl );
+ }
+
+ return io_rerrl;
+}
+
+
+void InitService::reportError(errlHndl_t &io_rerrl ) const
+{
+
+ if ( io_rerrl == NULL )
+ {
+ // this is OK, do nothing
+ }
+ else
+ {
+
+ TRACDCOMP( g_trac_initsvc,
+ "Committing the error log %p.",
+ io_rerrl
+ );
+
+ errlCommit( io_rerrl );
+
+ }
+
+ return;
+}
+
+
+/**
+ * @todo this will make a system call to post the error code.
+ */
+void InitService::setProgressCode( uint64_t &i_progresscode ) const
+{
+
+ // do nothing for now
+}
+
+
+/**
+ * @note For task_type = NONE case, I'm assuming that trace will not crash
+ * if we have a NULL taskname string, printing it is useful for debug.
+ */
+void InitService::init( void *i_ptr )
+{
+ errlHndl_t errl = NULL; // steps will return an error handle if failure
+ uint64_t nextTask = 0;
+ const TaskInfo *ptask = NULL;
+ TaskArgs::TaskArgs args;
+
+ TRACFCOMP( g_trac_initsvc,
+ ENTER_MRK "Initialization Service is starting." );
+
+ // ----------------------------------------------------------------
+ // loop through the task list and start up any tasks necessary
+ // ----------------------------------------------------------------
+
+ for ( nextTask=0;
+ nextTask<INITSERVICE::MAX_TASKS;
+ nextTask++ )
+ {
+ // make a local copy of the base image task
+ ptask = &(iv_taskinfolist[nextTask]);
+ if ( ptask->taskflags.task_type == END_TASK_LIST )
+ {
+ TRACDCOMP( g_trac_initsvc,
+ "End of Initialization Service task list.\n" );
+ break;
+ }
+
+ // dispatch tasks...
+ switch ( ptask->taskflags.task_type)
+ {
+ case NONE:
+ // task is a place holder, skip
+ TRACDBIN( g_trac_initsvc,
+ "task_type==NONE",
+ ptask->taskname,
+ strlen( ptask->taskname) );
+ break;
+ case START_TASK:
+ TRACDBIN( g_trac_initsvc,
+ "task_type==START_TASK",
+ ptask->taskname,
+ strlen( ptask->taskname) );
+ errl = startTask( ptask, // task struct
+ &args, // args
+ errl ); // errlog
+ break;
+ case START_FN:
+ TRACDCOMP( g_trac_initsvc,
+ "task_type==START_FN : %p",
+ ptask->taskfn );
+ // $$TODO
+ break;
+ case BARRIER:
+ TRACDCOMP( g_trac_initsvc,
+ "task_type==BARRIER" );
+ // $$TODO
+ break;
+
+ default:
+ TRACDCOMP( g_trac_initsvc,
+ "Invalid task_type %d: ",
+ ptask->taskflags.task_type );
+ errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, // severity
+ BASE_INITSVC_ERRL_ID, // moduleid
+ INVALID_TASK_TYPE, // reason Code
+ 0, // user1 = tidrc
+ 0 );
+ break;
+
+ } // endswitch
+
+ // report an error
+ reportError( errl );
+
+ } // endfor
+
+ // die if we drop out with an error
+ assert( errl == NULL);
+
+
+ TRACFCOMP( g_trac_initsvc,
+ EXIT_MRK "Initilization Service finished.");
+
+ // return to _start(), which may end the task or die.
+ return;
+}
+
+
+} // namespace INITSERVICE
diff --git a/src/usr/initservice/baseinitsvc/initservice.H b/src/usr/initservice/baseinitsvc/initservice.H
new file mode 100644
index 000000000..dd0a7df32
--- /dev/null
+++ b/src/usr/initservice/baseinitsvc/initservice.H
@@ -0,0 +1,220 @@
+#ifndef __BASEINITSVC_INITSERVICE_H
+#define __BASEINITSVC_INITSERVICE_H
+/**
+ * @file initservice.H
+ *
+ * - Manage high-level host boot IPL flow
+ * - Perform can-continue processing
+ * - Perform automatic and manual Istep execution
+ * - Handle flow errors as appropriate.
+ *
+ */
+
+/**
+ * High-level todo list
+ *
+ * @todo SP3: move startTask() and reportError() to private
+ * @todo SP3: add (NULL) detection to printk
+ * @@todo Add more macros to trace, discuss with Andrew and Nick
+ */
+
+/******************************************************************************/
+// Includes
+/******************************************************************************/
+#include <stdint.h>
+#include <util/singleton.H>
+#include <sys/vfs.h> // VFS_MODULE_NAME_MAX
+
+#include <trace/interface.H>
+#include <initservice/taskargs.H>
+#include <errl/errlentry.H>
+#include <initservice/initsvcreasoncodes.H>
+
+
+namespace INITSERVICE
+{
+
+/******************************************************************************/
+// Globals/Constants
+/******************************************************************************/
+
+
+/******************************************************************************/
+// Typedef/Enumerations
+/******************************************************************************/
+
+/**
+ * @enum TaskType
+ * - NONE == placeholder, no task
+ * - START_TASK == task with _start() function entry point
+ * - START_FN == task with function pointer entry point
+ * - BARRIER == set barrier for next N tasks.
+ * - STOP_TASK == Execute the destructor on the task in extended image.
+ * ( not implemented yet)
+ * - END_TASK_LIST == last entry in the task list.
+ */
+enum TaskType
+{
+ UNDEFINED_TT = 0,
+ NONE,
+ START_TASK,
+ START_FN,
+ BARRIER,
+ STOP_TASK,
+ END_TASK_LIST,
+};
+/**
+ * @enum ModuleType
+ * - BASE_IMAGE == module in the base image
+ * - EXT_IMAGE == module in the extended image
+ */
+enum ModuleType
+{
+ UNDEFINED_MT = 0,
+ BASE_IMAGE,
+ EXT_IMAGE,
+};
+
+
+/**
+ * @struct TaskFlags
+ *
+ * - run _start() function on start
+ * - module type, BASE_MODULE or EXT_MODULE
+ * - module_id for errorlog if task fails
+ *
+ * @todo revisit these flags in sprint3
+ */
+struct TaskFlags
+{
+ TaskType task_type; // this is a task, run _start() function
+ ModuleType module_type; // BASE_IMAGE or EXT_IMAGE
+ InitServiceModuleID module_id; // module id for errorlog
+};
+
+/**
+ * @struct _TaskInfo
+ *
+ * Holds information on each task in the system.
+ * - taskname
+ * - execution flags, see TaskFlags above
+ *
+ */
+struct TaskInfo
+{
+ const char taskname[VFS_MODULE_NAME_MAX];
+ void (*taskfn)(void *ptr);
+ const TaskFlags taskflags;
+
+};
+
+
+/******************************************************************************/
+// InitService Class
+/******************************************************************************/
+
+// Singleton definition
+class InitService;
+typedef Singleton<InitService> theInitService;
+
+/**
+ * @class InitService Singleton Class
+ *
+ * This class is launched by _start() (see initservicetaskentry.C),
+ * which is launched by the kernel (init_main.C).
+ *
+ * Once started, it handles the rest of HostBoot Initialization.
+ *
+ * @returns none
+ */
+class InitService
+{
+
+public:
+
+ friend class InitServiceTest;
+
+ /**
+ * @brief Get singleton instance of this class.
+ *
+ * @return the (one and only) instance of InitService
+ */
+ static InitService& getTheInstance();
+
+ /**
+ * @brief Provide an entry function into the class, called from _start()
+ *
+ * @param[in] i_args pointer to any arguments passed in from
+ * _start() and by extension the kernel,
+ * currently this is NULL .
+ */
+ void init( void *i_args);
+
+ /**
+ * @todo InitServiceTest should be able to find protected functions.
+ */
+ // $$protected:
+
+ /**
+ * @brief start a task
+ *
+ * @param[in] i_ptask pointer to a TaskInfo struct
+ * @param[in] io_pargs pointer to a TaskArgs struct, or NULL
+ * @param[inout] io_rerrl reference to an errorlog handle.
+ * errorlog will be filled out if error,
+ * otherwise untouched.
+ *
+ * @return NULL if success, errorlog handle for failure
+ *
+ */
+ errlHndl_t startTask( const TaskInfo *i_ptask,
+ TaskArgs::TaskArgs *i_pargs,
+ errlHndl_t &io_rerrl ) const;
+
+
+ /**
+ * @brief report Error to the system.
+ *
+ * @param[in] io_rerrl - errlHndl_t pointer to a filled-out error entry
+ * errorlog will be committed, errorlog
+ * will be deleted, and pointer will be
+ * set to NULL on exit
+ *
+ * @return nothing
+ */
+ void reportError( errlHndl_t &io_rerrl) const;
+
+
+ /**
+ * @brief set progress code for task.
+ *
+ * @param[in] i_progresscode - 64-bit progress code.
+ *
+ * @return nothing
+ *
+ */
+ void setProgressCode( uint64_t &i_progresscode ) const;
+
+
+
+protected:
+
+ /**
+ * @brief Constructor for the InitService object.
+ */
+ InitService();
+
+ /**
+ * @brief Destructor for the InitService object.
+ */
+ ~InitService();
+
+
+private:
+
+
+}; // class InitService
+
+} // namespace INITSERVICE
+
+#endif
diff --git a/src/usr/initservice/initservicetaskentry.C b/src/usr/initservice/baseinitsvc/initservicetaskentry.C
index 0fb84e00d..62d531c07 100644
--- a/src/usr/initservice/initservicetaskentry.C
+++ b/src/usr/initservice/baseinitsvc/initservicetaskentry.C
@@ -20,6 +20,8 @@
namespace INITSERVICE
{
+extern trace_desc_t *g_trac_initsvc;
+
/**
* @brief task entry routine, called by init_main.C
*
@@ -28,38 +30,18 @@ namespace INITSERVICE
extern "C"
void _start(void *ptr)
{
- tid_t tidrc = 0;
-
- printk("===== Executing Initialization Service modules\n" );
+ TRACFCOMP( g_trac_initsvc,
+ ENTER_MRK "Executing Initialization Service module." );
// create an instance of InitService
- InitService::InitService& is = InitService::getTheInstance();
+ //InitService::InitService& is = InitService::getTheInstance();
// initialize the base modules in Hostboot.
- is.start( ptr );
-
-
-
- // ----- run unit tests and example code, if present ----------------
- /**
- * @todo remove this eventually, figure out where to run UnitTests.
- */
- printk("===== Executing Unit Tests\n" );
-
- // run unit tests if present (i.e. we are running hbicore_test.bin)
- tidrc = task_exec("libcxxtest.so", NULL);
-
- /**
- * @todo barrier here to wait for all the tests to finish...
- */
-
- printk( "===== Done, terminating Initialization service...");
-
- /**
- * @todo add assert(0) here???
- */
+ InitService::getTheInstance().init( ptr );
+ TRACFCOMP( g_trac_initsvc,
+ EXIT_MRK "return from Initialization Service module." );
task_end();
}
diff --git a/src/usr/initservice/baseinitsvc/initsvctasks.H b/src/usr/initservice/baseinitsvc/initsvctasks.H
new file mode 100644
index 000000000..ae3362d31
--- /dev/null
+++ b/src/usr/initservice/baseinitsvc/initsvctasks.H
@@ -0,0 +1,85 @@
+/**
+ * @file initsvctasks.H
+ *
+ * TaskInfo structs for each task that will run.
+ */
+
+#ifndef __INIT_SVC_TASKS_H
+#define __INIT_SVC_TASKS_H
+
+#include <initservice/initsvcreasoncodes.H>
+#include "initservice.H"
+
+namespace INITSERVICE
+{
+
+const uint64_t MAX_TASKS = 10;
+
+const TaskInfo iv_taskinfolist[] = {
+
+ /**
+ * @brief Errorlog Task
+ */
+ {
+ "liberrl.so" , // taskname
+ NULL, // no ptr to fn
+ {
+ NONE, // don't start
+ BASE_IMAGE, // Base Module
+ START_ERRL_ERRL_ID, // module id for errorlog
+
+ }
+ },
+
+
+ /**
+ * @brief PNOR Driver Task
+ */
+ {
+ "libpnordd.so" , // taskname
+ NULL, // no pointer to fn
+ {
+ NONE, // don't start
+ BASE_IMAGE, // Base Module
+ START_PNORDD_ERRL_ID, // module id for errorlog
+ }
+ },
+
+ // ----- Extended Image -----------------------------------------------------
+
+ /**
+ * @brief extinitsvc, initializes extended module area
+ */
+ {
+ "libextinitsvc.so" , // taskname
+ NULL, // no pointer to fn
+ {
+ START_TASK, // don't start
+ EXT_IMAGE, // Ext Module
+ START_EXTINITSVC_ERRL_ID, // module id for errorlog
+ }
+ },
+
+
+ // ---------------------------------------------------------------
+ // ----- END OF LIST!!! ---------------------------------------
+ // ---------------------------------------------------------------
+
+ /**
+ * @brief last task in the list
+ */
+ {
+ "end" , // dummy string
+ NULL, // pointer to fn
+ {
+ END_TASK_LIST, // end of list
+ UNDEFINED_MT, // dummy module type
+ UNDEFINED_MODULE_ERRL_ID, // dummy errorlog
+ }
+ },
+
+};
+
+
+}; // namespace INITSERVICE
+#endif // __INIT_SVC_TASKS_H
diff --git a/src/usr/initservice/baseinitsvc/makefile b/src/usr/initservice/baseinitsvc/makefile
new file mode 100644
index 000000000..45b83ef7d
--- /dev/null
+++ b/src/usr/initservice/baseinitsvc/makefile
@@ -0,0 +1,7 @@
+ROOTPATH = ../../../..
+MODULE = initservice
+
+OBJS = initservice.o \
+ initservicetaskentry.o
+
+include ${ROOTPATH}/config.mk
diff --git a/src/usr/initservice/extinitsvc/extinitsvc.C b/src/usr/initservice/extinitsvc/extinitsvc.C
new file mode 100644
index 000000000..d1df2427e
--- /dev/null
+++ b/src/usr/initservice/extinitsvc/extinitsvc.C
@@ -0,0 +1,197 @@
+/**
+ * @file extinitsvc.C
+ *
+ * Implements Initialization Service for Host boot in the extended image.
+ * See extinitsvc.H for details
+ *
+ */
+
+#include <kernel/console.H>
+#include <sys/vfs.h>
+#include <sys/task.h>
+#include <sys/sync.h>
+
+#include <trace/interface.H>
+#include <errl/errlentry.H>
+
+#include "extinitsvc.H"
+#include "extinitsvctasks.H"
+
+
+
+namespace INITSERVICE
+{
+
+extern trace_desc_t *g_trac_initsvc;
+
+/**
+ * @brief _start() - task entry point for this module
+ *
+ */
+extern "C"
+void _start( void *io_pArgs )
+{
+ TaskArgs::TaskArgs *pTaskArgs =
+ reinterpret_cast<TaskArgs::TaskArgs *>(io_pArgs);
+
+ // initialize the extended modules in Hostboot.
+ ExtInitSvc::getTheInstance().init( io_pArgs );
+
+ if ( pTaskArgs )
+ {
+ pTaskArgs->waitChildSync();
+ }
+
+ task_end();
+}
+
+
+/******************************************************************************/
+// ExtInitSvc::getTheInstance return the only instance
+/******************************************************************************/
+ExtInitSvc& ExtInitSvc::getTheInstance()
+{
+ return Singleton<ExtInitSvc>::instance();
+}
+
+/******************************************************************************/
+// ExtInitSvc::ExtInitSvc constructor
+/******************************************************************************/
+ExtInitSvc::ExtInitSvc()
+{
+
+}
+
+/******************************************************************************/
+// ExtInitSvc::~ExtInitSvc destructor
+/******************************************************************************/
+ExtInitSvc::~ExtInitSvc()
+{
+
+}
+
+
+errlHndl_t ExtInitSvc::startTask( const TaskInfo *i_ptask,
+ TaskArgs::TaskArgs *i_pargs,
+ errlHndl_t &io_rerrl ) const
+{
+ /**
+ * @todo run constructor on task here.
+ */
+
+ InitService::startTask( i_ptask, i_pargs, io_rerrl );
+
+ return io_rerrl;
+}
+
+
+
+void ExtInitSvc::init( void *i_ptr )
+{
+ errlHndl_t errl = NULL; // steps will return an error handle if failure
+ uint64_t nextTask = 0;
+ const TaskInfo *ptask = NULL;
+ TaskArgs::TaskArgs args;
+
+ TRACFCOMP( g_trac_initsvc,
+ "Extended Initialization Service is starting." );
+
+ // ----------------------------------------------------------------
+ // loop through the task list and start up any tasks necessary
+ // ----------------------------------------------------------------
+ for ( nextTask=0;
+ nextTask<MAX_EXT_TASKS;
+ nextTask++ )
+ {
+ // make a local copy of the extended image task
+ ptask = &(iv_exttaskinfolist[nextTask]);
+ if ( ptask->taskflags.task_type == END_TASK_LIST )
+ {
+ TRACDCOMP( g_trac_initsvc,
+ "End of ExtInitSvc task list.\n" );
+ break;
+ }
+
+ // dispatch tasks...
+ switch ( ptask->taskflags.task_type)
+ {
+ case NONE:
+ // task is a place holder, skip
+ TRACDBIN( g_trac_initsvc,
+ "task_type=NONE : ",
+ ptask->taskname,
+ strlen(ptask->taskname) );
+ break;
+ case START_TASK:
+ TRACDBIN( g_trac_initsvc,
+ "task_type=START_TASK : ",
+ ptask->taskname,
+ strlen(ptask->taskname) );
+ errl = startTask( ptask,
+ &args,
+ errl );
+ break;
+ case START_FN:
+ TRACDCOMP( g_trac_initsvc,
+ "task_type==START_FN : %p",
+ ptask->taskfn );
+ // $$TODO
+ break;
+ case BARRIER:
+ TRACDCOMP( g_trac_initsvc,
+ "task_type==BARRIER" );
+ // $$TODO
+ break;
+
+ default:
+ TRACDCOMP( g_trac_initsvc,
+ "Invalid task_type: %d",
+ ptask->taskflags.task_type );
+ errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, // severity
+ START_EXTINITSVC_ERRL_ID, // moduleid
+ INVALID_TASK_TYPE, // reason Code
+ 0, // user1 = tidrc
+ 0 );
+ break;
+ } // endswitch
+
+ // report an error
+ reportError( errl );
+
+
+ } // endfor
+
+
+ TRACFCOMP( g_trac_initsvc,
+ EXIT_MRK "ExtInitSvc finished.");
+
+
+
+ // =====================================================================
+ // ----- Unit Tests -------------------------------------------------
+ // =====================================================================
+ /**
+ * @note run all the unit tests after we finish the rest
+ */
+ TRACDBIN( g_trac_initsvc,
+ ENTER_MRK "Run Unit Tests: ",
+ CXXTEST_TASK.taskname,
+ strlen(CXXTEST_TASK.taskname) );
+
+ errl = startTask( &CXXTEST_TASK, // task struct
+ NULL, // no args
+ errl ); // pointer to errorlog
+ // report an error
+ reportError( errl );
+
+ TRACDCOMP( g_trac_initsvc,
+ EXIT_MRK "Unit Tests finished.");
+
+
+ // return to _start(), which may end the task or die.
+ return;
+}
+
+
+} // namespace EXTINITSVC
diff --git a/src/usr/initservice/extinitsvc/extinitsvc.H b/src/usr/initservice/extinitsvc/extinitsvc.H
new file mode 100644
index 000000000..8e7874fd2
--- /dev/null
+++ b/src/usr/initservice/extinitsvc/extinitsvc.H
@@ -0,0 +1,121 @@
+#ifndef __EXTINITSVC_EXTINITSVC_H
+#define __EXTINITSVC_EXTINITSVC_H
+/**
+ * @file extinitsvc.H
+ *
+ * Extended initialization service, inherited from initservice base class
+ * perform extended init service functions in the extended image.
+ * launched by initservice.
+ *
+ */
+
+
+/******************************************************************************/
+// Includes
+/******************************************************************************/
+#include <stdint.h>
+#include <util/singleton.H>
+#include <sys/vfs.h> // VFS_MODULE_NAME_MAX
+
+#include <errl/errlentry.H>
+#include <initservice/taskargs.H>
+#include <initservice/initsvcreasoncodes.H>
+
+#include "../baseinitsvc/initservice.H"
+
+namespace INITSERVICE
+{
+
+/******************************************************************************/
+// Globals/Constants
+/******************************************************************************/
+
+/******************************************************************************/
+// Typedef/Enumerations
+/******************************************************************************/
+
+
+
+/******************************************************************************/
+// InitService Class
+/******************************************************************************/
+
+// Singleton definition
+class ExtInitSvc;
+typedef Singleton<ExtInitSvc> theExtInitSvc;
+
+/**
+ * @class ExtInitSvc Singleton Class
+ *
+ * This extended image module is launched by InitService
+ *
+ */
+class ExtInitSvc : public InitService
+{
+
+public:
+
+ friend class ExtInitSvcTest;
+
+ /**
+ * @brief Get singleton instance of this class.
+ *
+ * @return the (one and only) instance of InitService
+ */
+ static ExtInitSvc& getTheInstance();
+
+ /**
+ * @brief Provide an entry function into the class, called from _start()
+ *
+ * @param[in] i_args pointer to any arguments passed in from
+ * _start() and by extension the kernel,
+ * currently this is NULL .
+ *
+ */
+ void init( void *i_args);
+
+
+ /**
+ * @todo ExtInitSvcTest should be able to find protected functions.
+ */
+ // $$protected:
+
+ /**
+ * @brief start a extended image task.
+ *
+ * @param[in] i_ptask pointer to a TaskInfo struct
+ * @param[in] i_pargs pointer to args struct
+ * @param[inout] i_rerrl reference to an errorlog handle.
+ * errorlog will be filled out if error,
+ * otherwise untouched.
+ *
+ * @return NULL if success, errorlog handle for failure
+ *
+ */
+ errlHndl_t startTask( const TaskInfo *i_ptask,
+ TaskArgs::TaskArgs *i_pargs,
+ errlHndl_t &i_rerrl ) const;
+
+
+protected:
+ /**
+ * @brief Constructor for the InitService object.
+ */
+ ExtInitSvc();
+
+ /**
+ * @brief Destructor for the InitService object.
+ */
+ ~ExtInitSvc();
+
+
+
+private:
+
+
+
+}; // class ExtInitSvc
+
+} // namespace EXTINITSVC
+
+#endif
diff --git a/src/usr/initservice/extinitsvc/extinitsvctasks.H b/src/usr/initservice/extinitsvc/extinitsvctasks.H
new file mode 100644
index 000000000..347d29ffa
--- /dev/null
+++ b/src/usr/initservice/extinitsvc/extinitsvctasks.H
@@ -0,0 +1,69 @@
+#ifndef __EXT_INIT_SVC_TASKS_H
+#define __EXT_INIT_SVC_TASKS_H
+/**
+ * @file extinitsvctasks.H
+ *
+ * TaskInfo structs for each task that will run in the extended image.
+ */
+
+#include <initservice/initsvcreasoncodes.H>
+#include "extinitsvc.H"
+
+namespace INITSERVICE
+{
+
+
+const uint64_t MAX_EXT_TASKS = 25;
+
+const TaskInfo iv_exttaskinfolist[] = {
+
+ // ----- Extended Image ------------------------------------------
+
+ /**
+ * @brief targeting task, initializes extended module area
+ */
+ {
+ "libtargeting.so" , // taskname
+ NULL, // no pointer to fn
+ {
+ START_TASK, // task type
+ EXT_IMAGE, // Extended Module
+ START_TARGETING_ERRL_ID, // module id
+ }
+ },
+
+ // ---------------------------------------------------------------
+ // ----- END OF LIST!!! ---------------------------------------
+ // ---------------------------------------------------------------
+
+ /**
+ * @brief last task in the list
+ */
+ {
+ "end" , // dummy string
+ NULL, // pointer to fn
+ {
+ END_TASK_LIST, // end of list
+ UNDEFINED_MT, // dummy module type
+ UNDEFINED_MODULE_ERRL_ID, // dummy errorlog
+ }
+ },
+
+};
+
+
+// ----- UNIT TESTS -------------------------------------------------
+const TaskInfo CXXTEST_TASK = {
+ "libcxxtest.so" , // taskname
+ NULL, // no pointer to fn
+ {
+ START_TASK, // task type
+ EXT_IMAGE, // Extended Module
+ START_CXXTEST_ERRL_ID, // module id
+ }
+ };
+
+
+}; // namespace EXTINITSVC
+
+#endif // __EXT_INIT_SVC_TASKS_H
diff --git a/src/usr/initservice/extinitsvc/makefile b/src/usr/initservice/extinitsvc/makefile
new file mode 100644
index 000000000..ab2881759
--- /dev/null
+++ b/src/usr/initservice/extinitsvc/makefile
@@ -0,0 +1,6 @@
+ROOTPATH = ../../../..
+MODULE = extinitsvc
+
+OBJS = extinitsvc.o
+
+include ${ROOTPATH}/config.mk
diff --git a/src/usr/initservice/extinitsvc/test/makefile b/src/usr/initservice/extinitsvc/test/makefile
new file mode 100644
index 000000000..89b5d2347
--- /dev/null
+++ b/src/usr/initservice/extinitsvc/test/makefile
@@ -0,0 +1,6 @@
+ROOTPATH = ../../../..
+
+MODULE = testextinitsvc
+TESTS = *.H
+
+include ${ROOTPATH}/config.mk
diff --git a/src/usr/initservice/initservice.C b/src/usr/initservice/initservice.C
deleted file mode 100644
index 6fe759ed0..000000000
--- a/src/usr/initservice/initservice.C
+++ /dev/null
@@ -1,418 +0,0 @@
-/**
- * @file initservice.C
- *
- * Implements Initialization Service for Host boot.
- * See initservice.H for details
- *
- */
-
-#include <kernel/console.H>
-#include <sys/vfs.h>
-#include <sys/task.h>
-#include <trace/interface.H>
-#include <errl/errlentry.H>
-
-#include "initservice.H"
-
-
-
-namespace INITSERVICE
-{
-
-// always set up a trace buffer
-trace_desc_t *g_trac_errl = NULL;
-TRAC_INIT(&g_trac_errl, "INITSERVICE", 4096);
-
-
-/******************************************************************************/
-// InitService::getTheInstance return the only instance
-/******************************************************************************/
-InitService& InitService::getTheInstance()
-{
- return Singleton<InitService>::instance();
-}
-
-/******************************************************************************/
-// InitService::Initservice constructor
-/******************************************************************************/
-InitService::InitService()
-{
-
-}
-
-/******************************************************************************/
-// InitService::~InitService destructor
-/******************************************************************************/
-InitService::~InitService()
-{
-
-}
-
-/**
- * @todo failure to start a task is considered FATAL, revisit later.
- */
-
-tid_t InitService::startTask( const TaskInfo &i_rtask, errlHndl_t &io_rerrl ) const
-{
- tid_t tidrc = 0;
-
-
- if ( i_rtask.taskflags.startflag )
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "startflag is on, starting task...\n" );
- printk( "startflag is on, starting task %s\n", i_rtask.taskname );
- tidrc = task_exec( i_rtask.taskname, NULL );
- if ( (int16_t)tidrc < 0 )
- {
-
- io_rerrl = new ERRORLOG::ErrlEntry(
- ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM,
- i_rtask.taskflags.module_id,
- INITSERVICE::START_TASK_FAILED,
- 0,
- 0
- );
- TRACFCOMP(INITSERVICE::g_trac_errl, "ERROR %d starting task, errlog p = %p\n",
- tidrc, io_rerrl );
-
- } // endif tidrc
- else
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "task number %d started. errlog p = %p\n",
- tidrc, io_rerrl );
- }
- }
-
- return tidrc;
-}
-
-/**
- * @todo commit the error log here, and then delete it
- * @todo dump some or all of the error log so we know who died.
- *
- */
-void InitService::reportError(errlHndl_t &io_rerrl ) const
-{
-
- TRACFCOMP(INITSERVICE::g_trac_errl, "reportError!!!");
-
- if ( io_rerrl == NULL )
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "ERROR: reportError was passed a NULL errorlog handle.\n");
- }
- else
- {
-
- TRACFCOMP(INITSERVICE::g_trac_errl,
- "TODO: commit the error log. delete errl and set to NULL for now.\n"
- );
- /**
-
- * @todo cannot commit an error log until the errorlog service is started up.
- * do some checking here
- * @todo commit the error log here, note that the commit should delete the log and
- * set the handle to NULL
- */
-
- delete( io_rerrl );
- io_rerrl = NULL; // $$TODO set errl back to NULL for now so all the tasks run
- }
-
- return;
-}
-
-
-void InitService::start( void *i_ptr )
-{
- errlHndl_t errl = NULL; // steps will return an error handle if failure
-
- TRACFCOMP(INITSERVICE::g_trac_errl, "+++++ Initialization Service is starting." );
-
- // ----------------------------------------------------------------
- // Start up any tasks necessary in the base modules...
- // ----------------------------------------------------------------
- do {
-
- // startTrace
- TRACFCOMP(INITSERVICE::g_trac_errl, "running startTrace...");
- startTrace( errl );
- if ( errl )
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "startTrace failed");
- break; // break out and report error
- }
-
- // startErrorLog
- TRACFCOMP(INITSERVICE::g_trac_errl, "running startErrLog...");
- startErrLog( errl );
- if ( errl )
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "startErrLog failed");
- break; // break out and report error
- }
-
- // startXSCOM
- TRACFCOMP(INITSERVICE::g_trac_errl, "running startXSCOM...");
- startXSCOMDD( errl );
- if ( errl )
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "startSCOMDD failed");
- break; // break out and report error
- }
-
- // startPNOR
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startPNORDD");
- startPNORDD( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startPNOR failed");
- break; // break out and report error
- }
-
- // startVFS_2
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startVFS_2");
- startVFS_2( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startVFS_2 failed");
- break; // break out and report error
- }
-
- } while( false );
-
-
- /**
- * @todo stop here now if someone posted an error log, revisit this
- * when we know what to do.
- */
- if ( errl )
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "Errorlog posted, commit and die.");
- reportError( errl );
- }
-
- assert( errl == NULL );
-
-
- // ----------------------------------------------------------------
- // start running the extended modules
- // ----------------------------------------------------------------
- do {
- // startTargetting
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startTargetting");
- startTargetting( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startTargetting failed");
-
- break; // break out and report error
- }
-
- // getMasterChipTarget
- TRACFCOMP( INITSERVICE::g_trac_errl, "running getMasterChipTarget");
- getMasterChipTarget( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "getMasterChipTarget failed");
-
- break; // break out and report error
- }
-
- // startMailboxDD
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startMailboxDD");
- startMailboxDD( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startMailboxDD failed");
-
- break; // break out and report error
- }
-
- // startSPComm
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startSPComm");
- startSPComm( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startSPComm failed");
-
- break; // break out and report error
- }
-
- // enableStreamingTrace
- TRACFCOMP( INITSERVICE::g_trac_errl, "running enableStreamingTrace");
- enableStreamingTrace( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "enableStreamingTrace failed");
-
- break; // break out and report error
- }
-
- // startProgressCodes
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startProgressCodes");
- startProgressCodes( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startProgressCodes failed");
-
- break; // break out and report error
- }
-
- // startFSIDD
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startFSIDD");
- startFSIDD( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startFSIDD failed");
-
- break; // break out and report error
- }
-
- // setupSlaveLinks
- TRACFCOMP( INITSERVICE::g_trac_errl, "running setupSlaveLinks");
- setupSlaveLinks( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "setupSlaveLinks failed");
-
- break; // break out and report error
- }
-
- // startFSISCOM
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startFSISCOM");
- startFSISCOM( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startFSISCOM failed");
-
- break; // break out and report error
- }
-
- // startFSII2C
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startFSII2C");
- startFSII2C( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startFSII2C failed");
-
- break; // break out and report error
- }
-
- // startHWP
- TRACFCOMP( INITSERVICE::g_trac_errl, "running startHWP");
- startHWPF( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "startHWP failed");
-
- break; // break out and report error
- }
-
- // readMaxConfigfromPNOR
- TRACFCOMP( INITSERVICE::g_trac_errl, "running readMaxConfigfromPNOR");
- readMaxConfigfromPNOR( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "readMaxConfigfromPNOR failed");
-
- break; // break out and report error
- }
-
- // applyPresenceDetect
- TRACFCOMP( INITSERVICE::g_trac_errl, "running applyPresenceDetect");
- applyPresenceDetect( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "applyPresenceDetect failed");
-
- break; // break out and report error
- }
-
- // applyPartialBad
- TRACFCOMP( INITSERVICE::g_trac_errl, "running applyPartialBad");
- applyPartialBad( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "applyPartialBad failed");
-
- break; // break out and report error
- }
-
- // applyGard
- TRACFCOMP( INITSERVICE::g_trac_errl, "running applyGard...");
- applyGard( errl );
- if ( errl )
- {
-
- TRACFCOMP( INITSERVICE::g_trac_errl, "applyGard failed");
- break; // break out and report error
- }
-
- // collectHWIDEC
- TRACFCOMP( INITSERVICE::g_trac_errl, "running collectHWIDEC...");
- collectHWIDEC( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "collectHWIDEC failed");
-
- break; // break out and report error
- }
-
- // verifyIDEC
- TRACFCOMP( INITSERVICE::g_trac_errl, "running verifyIDEC");
- verifyIDEC( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "verifyIDEC failed");
-
- break; // break out and report error
- }
-
- // disableWatchDog
- TRACFCOMP( INITSERVICE::g_trac_errl, "running disableWatchDog");
- disableWatchDog( errl );
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "disableWatchDog failed");
-
- break; // break out and report error
- }
-
-
- } while ( false );
-
-
- /**
- * @todo stop here now if someone posted an error log, revisit this
- * when we know what to do.
- */
- if ( errl )
- {
- TRACFCOMP(INITSERVICE::g_trac_errl, "Errorlog posted, commit and die.");
- reportError( errl );
- }
-
- assert( errl == NULL );
-
-
-
- // executeISteps
- TRACFCOMP( INITSERVICE::g_trac_errl, "running executeISteps");
- executeISteps( errl );
-
- if ( errl )
- {
- TRACFCOMP( INITSERVICE::g_trac_errl, "executeISteps failed");
- reportError( errl );
- assert( errl == NULL );
- }
-
-
- TRACFCOMP( INITSERVICE::g_trac_errl, "+++++ Initilization Service finished. IN THE REAL CODE WE WILL NEVER GET HERE");
-
- // return to _start(), which may end the task or die.
- return;
-}
-
-
-} // namespace INITSERVICE
diff --git a/src/usr/initservice/initservice.H b/src/usr/initservice/initservice.H
deleted file mode 100644
index 0e880de1a..000000000
--- a/src/usr/initservice/initservice.H
+++ /dev/null
@@ -1,448 +0,0 @@
-/**
- * @file initservice.H
- *
- * - Manage high-level host boot IPL flow
- * - Perform can-continue processing
- * - Perform automatic and manual Istep execution
- * - Handle flow errors as appropriate.
- *
- */
-
-/**
- * High-level todo list
- *
- * @todo SP3: move startTask() and reportError() to private
- * @todo SP3: remove ADUDD, not used
- * @todo SP3: add (NULL) detection to printk
- * @todo SP3: reevaluate all trace calls - TRACF are field traces, - ERR_MRK etc macros
- * @todo SP3: change InitService::start() to init(), document this as a standard.
- * @todo SP3: initservice/makefile remove trailing tabs
- * @todo SP3: Disable copy CTOR/assignment operator; this would have caught an illegal copy by assignment elsewhere
- * @@todo Add more macros to trace, discuss with Andrew and Nick
- *
- *
- */
-
-#ifndef __INIT_SERVICE_H
-#define __INIT_SERVICE_H
-
-/******************************************************************************/
-// Includes
-/******************************************************************************/
-#include <stdint.h>
-#include <util/singleton.H>
-#include <sys/vfs.h> // VFS_MODULE_NAME_MAX
-
-#include <errl/errlentry.H>
-#include <initservice/initsvcreasoncodes.H>
-
-namespace INITSERVICE
-{
-
-/******************************************************************************/
-// Globals/Constants
-/******************************************************************************/
-
-/******************************************************************************/
-// Typedef/Enumerations
-/******************************************************************************/
-/**
- * @enum ModuleType
- * - BASE_MODULE == module in the base image
- * - EXT_MODULE == module in the extended image
- */
-enum ModuleType
-{
- BASE_MODULE = 0,
- EXT_MODULE,
-};
-
-
-/**
- * @struct TaskFlags
- *
- * - run _start() function on start
- * - module type, BASE_MODULE or EXT_MODULE
- * - module_id for errorlog if task fails
- *
- * @todo revisit these flags in sprint3
- */
-struct TaskFlags
-{
- bool startflag; // this is a task, run _start() function
- ModuleType module_type; // BASE_MODULE_TYPE or EXT_MODULE_TYPE
- InitServiceModuleID module_id; // module id for errorlog
-};
-
-/**
- * @struct _TaskInfo
- *
- * Holds information on each task in the system.
- * - taskname
- * - execution flags, see TaskFlags above
- *
- */
-struct TaskInfo
-{
- const char taskname[VFS_MODULE_NAME_MAX];
- TaskFlags taskflags;
-
-} PACKED;
-
-
-/******************************************************************************/
-// InitService Class
-/******************************************************************************/
-
-// Singleton definition
-class InitService;
-typedef Singleton<InitService> theInitService;
-
-/**
- * @class InitService Singleton Class
- *
- * This class is launched by _start() (see initservicetaskentry.C),
- * which is launched by the kernel (init_main.C).
- *
- * Once started, it handles the rest of HostBoot Initialization.
- *
- * @returns none
- */
-class InitService
-{
-
-public:
-
- friend class InitServiceTest;
-
- /**
- * @brief Get singleton instance of this class.
- *
- * @return the (one and only) instance of InitService
- */
- static InitService& getTheInstance();
-
- /**
- * @brief Provide an entry function into the class, called from _start()
- *
- * @param[in] i_args pointer to any arguments passed in from
- * _start() and by extension the kernel,
- * currently this is NULL .
- *
- * @todo Sprint 3: pass in ptr to errorlog struct?
- * @todo document any changes for args
- */
- void start( void *i_args);
-
- /**
- * @brief Constructor for the InitService object.
- */
- InitService();
-
- /**
- * @brief Destructor for the InitService object.
- */
- ~InitService();
-
- /**
- * @brief start a task
- *
- * @param[in] i_rtask reference to a TaskInfo struct
- * @param[inout] i_rerrl reference to an errorlog struct.
- * struct will be filled out if error,
- * otherwise untouched.
- *
- * @return child id if success, < 0 for failure
- *
- * @todo return errorlog handle in sprint3
- */
- tid_t startTask( const TaskInfo &i_rtask, errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief report Error to the system.
- *
- * @param[in] io_errl - errlHndl_t pointer to a filled-out error entry
- * errorlog will be committed, errorlog
- * will be deleted, and pointer will be
- * set to NULL on exit
- *
- * @return nothing
- */
- void reportError( errlHndl_t &io_rerrl) const;
-
-
-private:
-
-
-
- /**
- * @brief Initialize the Trace module
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startTrace( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize the ErrorLog module
- *
- * *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startErrLog( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize the XSCOM Device Driver module
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startXSCOMDD( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize the PNOR Device Driver module
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startPNORDD( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize the second stage of VFS module
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
-
- void startVFS_2( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize the Targetting DD module
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startTargetting( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief get the Master Chip Target
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void getMasterChipTarget( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize the Mailbox Device Driver
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startMailboxDD( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize SP Communications
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startSPComm( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Turn on Streaming Trace, if the PNOR flag is set
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void enableStreamingTrace( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Start reporting progress codes.
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startProgressCodes( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize the FSI Device Driver module
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startFSIDD( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Set up links to the slaves
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void setupSlaveLinks( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize FSI SCOM
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startFSISCOM( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize FSI I2C
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startFSII2C( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Initialize HWP
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void startHWPF( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Read Configuration from PNOR
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void readMaxConfigfromPNOR( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief apply Presence Detect
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void applyPresenceDetect( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief apply Partial Bad
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void applyPartialBad( errlHndl_t &i_rerrl ) const;
- /**
- * @brief apply Gard
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void applyGard( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Collect HW IDEC info
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void collectHWIDEC( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief verify the IDEC info
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void verifyIDEC( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Disable the HW watchdog
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void disableWatchDog( errlHndl_t &i_rerrl ) const;
-
- /**
- * @brief Execute the IStep module to communicate with SP and run
- * the isteps.
- *
- * @param[in,out] i_rerrl - errorlog handle.
- * Success: handle is untouched
- * Failure: will point to a filled-out errorlog
- *
- * @return none
- */
- void executeISteps( errlHndl_t &i_rerrl ) const;
-
-
-}; // class InitService
-
-} // namespace INITSERVICE
-
-#endif
diff --git a/src/usr/initservice/initservicevfs1.C b/src/usr/initservice/initservicevfs1.C
deleted file mode 100644
index 691fef197..000000000
--- a/src/usr/initservice/initservicevfs1.C
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * @file initservicevfs1.C
- *
- * Private functions for VFS1 phase.
- */
-
-#include <kernel/console.H>
-#include <sys/vfs.h>
-#include <sys/task.h>
-#include <trace/interface.H>
-
-#include "initservice.H"
-
-#include "initsvctasks.H"
-
-
-namespace INITSERVICE
-{
-
-/******************************************************************************/
-// private functions for VFS 1 phase
-/******************************************************************************/
-
-void InitService::startTrace( errlHndl_t &io_rerrl ) const
-{
-
- // start up the task
- startTask( TASK_TRACE, io_rerrl );
-
- return;
-}
-
-
-void InitService::startErrLog( errlHndl_t &io_rerrl ) const
-{
-
- startTask( TASK_ERRORLOG, io_rerrl );
-
- return;
-}
-
-
-void InitService::startXSCOMDD( errlHndl_t &io_rerrl ) const
-{
-
- startTask( TASK_XSCOMDD, io_rerrl );
-
- return;
-}
-
-
-void InitService::startPNORDD( errlHndl_t &io_rerrl ) const
-{
-
- startTask( TASK_PNORDD, io_rerrl );
-
- return;
-}
-
-
-void InitService::startVFS_2( errlHndl_t &io_rerrl ) const
-{
-
- startTask( TASK_VFS_2, io_rerrl );
-
- return;
-}
-
-} // namespace INITSERVICE
diff --git a/src/usr/initservice/initservicevfs2.C b/src/usr/initservice/initservicevfs2.C
deleted file mode 100644
index 46c49e988..000000000
--- a/src/usr/initservice/initservicevfs2.C
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * @file initservicevfs2.C
- *
- * Private functions for VFS2 phase.
- */
-
-#include <kernel/console.H>
-#include <sys/vfs.h>
-#include <sys/task.h>
-#include <trace/interface.H>
-
-#include "initservice.H"
-
-#include "initsvctasks.H"
-
-
-namespace INITSERVICE
-{
-
-
-/******************************************************************************/
-// private functions for VFS 2 phase
-/******************************************************************************/
-
-
-void InitService::startTargetting( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::getMasterChipTarget( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::startMailboxDD( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::startSPComm( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::enableStreamingTrace( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::startProgressCodes( errlHndl_t &io_rerrl ) const
-{
-
- return;
-
-}
-
-
- void InitService::startFSIDD( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::setupSlaveLinks( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::startFSISCOM( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::startFSII2C( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::startHWPF( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::readMaxConfigfromPNOR( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
-void InitService::applyPresenceDetect( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::applyPartialBad( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-void InitService::applyGard( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
-void InitService::collectHWIDEC( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::verifyIDEC( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::disableWatchDog( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-
- void InitService::executeISteps( errlHndl_t &io_rerrl ) const
-{
-
-
- return;
-}
-
-} // namespace INITSERVICE
diff --git a/src/usr/initservice/initsvctasks.H b/src/usr/initservice/initsvctasks.H
deleted file mode 100644
index 4f8c48656..000000000
--- a/src/usr/initservice/initsvctasks.H
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * @file initsvctasks.H
- *
- * TaskInfo structs for each task that will run.
- */
-
-#ifndef __INIT_SVC_TASKS_H
-#define __INIT_SVC_TASKS_H
-
-#include <initservice/initsvcreasoncodes.H>
-#include "initservice.H"
-
-namespace INITSERVICE
-{
-
-
-/**
- * @brief Trace Task
- */
-const TaskInfo TASK_TRACE = {
- "libtrace.so" , // taskname
- { false, // don't start
- BASE_MODULE, // Base Module
- START_TRACE_ID, // module id for errorlog
- },
-};
-
-
-/**
- * @brief Errorlog Task
- */
-const TaskInfo TASK_ERRORLOG = {
- "liberrl.so" , // taskname
- { false, // don't start
- BASE_MODULE, // Base Module
- START_ERRL_ID, // module id for errorlog
-
- },
-};
-
-
-/**
- * @brief XSCOM Task
- */
-const TaskInfo TASK_XSCOMDD = {
- "libscom.so" , // taskname
- { false, // don't start
- BASE_MODULE, // Base Module
- START_XSCOMDD_ID, // module id for errorlog
- },
-};
-
-
-/**
- * @brief PNOR Driver Task
- */
-const TaskInfo TASK_PNORDD = {
- "libpnordd.so" , // taskname
- { false, // don't start
- BASE_MODULE, // Base Module
- START_PNORDD_ID, // module id for errorlog
- },
-};
-
-
-/**
- * @brief VFS 2 task, initializes extended module area
- */
-const TaskInfo TASK_VFS_2 = {
- "vfs2.so" , // taskname
- { false, // don't start
- BASE_MODULE, // Base Module
- START_VFS_2_ID // module id for errorlog
- },
-};
-
-
-}; // namespace INITSERVICE
-#endif // __INIT_SVC_TASKS_H
diff --git a/src/usr/initservice/initsvcunittesttask2/makefile b/src/usr/initservice/initsvcunittesttask2/makefile
new file mode 100644
index 000000000..e00f9eb02
--- /dev/null
+++ b/src/usr/initservice/initsvcunittesttask2/makefile
@@ -0,0 +1,6 @@
+ROOTPATH = ../../../..
+MODULE = tasktest2
+
+OBJS = tasktest2.o
+
+include ${ROOTPATH}/config.mk
diff --git a/src/usr/initservice/initsvcunittesttask2/tasktest2.C b/src/usr/initservice/initsvcunittesttask2/tasktest2.C
new file mode 100644
index 000000000..08d4c2d5d
--- /dev/null
+++ b/src/usr/initservice/initsvcunittesttask2/tasktest2.C
@@ -0,0 +1,62 @@
+/**
+ * @file tasktest2.H
+ *
+ */
+
+/******************************************************************************/
+// Includes
+/******************************************************************************/
+#include <stdint.h>
+#include <sys/task.h>
+#include <trace/interface.H>
+#include <initservice/taskargs.H>
+
+#include "tasktest2.H"
+
+namespace INITSVCTASKTEST2
+{
+
+
+/******************************************************************************/
+// Globals/Constants
+/******************************************************************************/
+
+/******************************************************************************/
+// InitService::getTheInstance return the only instance
+/******************************************************************************/
+InitSvcTaskTest2& InitSvcTaskTest2::getTheInstance()
+{
+ return Singleton<InitSvcTaskTest2>::instance();
+}
+
+
+/**
+ * @brief _start() - task entry point for this module
+ *
+ */
+extern "C"
+void _start( void *io_pArgs )
+{
+ INITSERVICE::TaskArgs::TaskArgs *pTaskArgs = (INITSERVICE::TaskArgs::TaskArgs *)io_pArgs;
+
+ // create an instance of InitService
+ InitSvcTaskTest2::InitSvcTaskTest2& tt = InitSvcTaskTest2::getTheInstance();
+
+ // initialize the base modules in Hostboot.
+ tt.init( io_pArgs );
+
+ if ( pTaskArgs )
+ {
+ pTaskArgs->waitChildSync();
+ }
+
+ task_end();
+}
+
+void InitSvcTaskTest2::init( void *i_args )
+{
+
+ return;
+};
+
+} // namespace
diff --git a/src/usr/initservice/initsvcunittesttask2/tasktest2.H b/src/usr/initservice/initsvcunittesttask2/tasktest2.H
new file mode 100644
index 000000000..57f00db32
--- /dev/null
+++ b/src/usr/initservice/initsvcunittesttask2/tasktest2.H
@@ -0,0 +1,82 @@
+#ifndef __INITSVC_TASK_TEST_2_H
+#define __INITSVC_TASK_TEST_2_H
+
+/**
+ * @file initsvctasktest2.H
+ *
+ */
+
+/******************************************************************************/
+// Includes
+/******************************************************************************/
+#include <stdint.h>
+#include <kernel/console.H> // printk
+#include <util/singleton.H>
+
+namespace INITSVCTASKTEST2
+{
+
+/******************************************************************************/
+// Globals/Constants
+/******************************************************************************/
+
+/******************************************************************************/
+// Typedef/Enumerations
+/******************************************************************************/
+
+/******************************************************************************/
+// InitService Class
+/******************************************************************************/
+// Singleton definition
+class InitSvcTaskTest2;
+typedef Singleton<InitSvcTaskTest2> theTask2;
+
+/**
+ * @class InitSvcTestTask2 Class
+ *
+ * test module launched
+ */
+class InitSvcTaskTest2
+{
+
+public:
+
+ /**
+ * @brief Constructor for the InitService object.
+ */
+ InitSvcTaskTest2()
+ { }
+
+ /**
+ * @brief Destructor for the InitService object.
+ */
+ ~InitSvcTaskTest2()
+ { }
+
+ /**
+ * @brief Get singleton instance of this class.
+ *
+ * @return the (one and only) instance of InitService
+ */
+ static InitSvcTaskTest2& getTheInstance();
+
+ /**
+ * @brief Provide an entry function into the class, called from _start()
+ *
+ * @param[in] i_args pointer to any arguments passed in from
+ * _start() and by extension the kernel,
+ * currently this is NULL .
+ *
+ * @todo document any changes for args
+ */
+ void init( void *i_args);
+
+
+private:
+
+
+}; // class InitSvcTaskTest2
+
+} // namespace INITSVCTASKTEST2
+
+#endif
diff --git a/src/usr/initservice/makefile b/src/usr/initservice/makefile
index 085805786..3c57f7178 100644
--- a/src/usr/initservice/makefile
+++ b/src/usr/initservice/makefile
@@ -1,11 +1,11 @@
ROOTPATH = ../../..
-MODULE = initservice
+# MODULE =
-OBJS = initservice.o \
- initservicetaskentry.o \
- initservicevfs1.o \
- initservicevfs2.o
+# OBJS =
-SUBDIRS = test.d
+# NOTE: initsvcunittesttask2 is a dummy module that is executed by
+# unit test 2 in the test directory. Please do not rename.
+SUBDIRS = baseinitsvc.d extinitsvc.d taskargs.d \
+ test.d initsvcunittesttask2.d
include ${ROOTPATH}/config.mk
diff --git a/src/usr/initservice/taskargs/makefile b/src/usr/initservice/taskargs/makefile
new file mode 100644
index 000000000..722fa5b0e
--- /dev/null
+++ b/src/usr/initservice/taskargs/makefile
@@ -0,0 +1,6 @@
+ROOTPATH = ../../../..
+MODULE = taskargs
+
+OBJS = taskargs.o
+
+include ${ROOTPATH}/config.mk
diff --git a/src/usr/initservice/taskargs/taskargs.C b/src/usr/initservice/taskargs/taskargs.C
new file mode 100644
index 000000000..bfb50056a
--- /dev/null
+++ b/src/usr/initservice/taskargs/taskargs.C
@@ -0,0 +1,111 @@
+/**
+ * @file taskargs.C
+ *
+ * common file to hold arguments passed onto tasks.
+ * will also hold macros, etc to manage arguments
+ *
+ * @note Notes on barrier:
+ * barrier_init() will initialize the barrier to the number of threads to
+ * wait on.
+ * "barrier_wait() function shall synchronize participating threads at
+ * the barrier referenced by barrier.
+ * The calling thread shall block until the required number of threads
+ * have called pthread_barrier_wait specifying the barrier."
+ *
+ * So in this case, the barrier is initialized to 2 (through barrier_init()
+ * in the constructor).
+ * When InitSvc launches the child, it calls barrier wait() (through
+ * waitChildSync() ) which adds 1 task to the "waitlist", blocks, and
+ * returns to InitSvc. InitSvc then calls waitParentSync() which adds
+ * its' task to the "waitlist". When the second task is added, both task
+ * are unblocked.
+ *
+ * The barrier is destroyed when TaskArgs goes out of scope by calling
+ * barrier_destroy() in the destructor.
+ *
+ */
+
+#include <initservice/taskargs.H>
+
+
+namespace INITSERVICE
+{
+
+extern trace_desc_t *g_trac_initsvc;
+
+
+void TaskArgs::waitParentSync( )
+{
+
+ TRACDCOMP( g_trac_initsvc,
+ "Parent: wait for barrier %p", &iv_sync_barrier );
+
+ barrier_wait( &iv_sync_barrier);
+
+ TRACDCOMP( g_trac_initsvc,
+ "Parent: returned from barrier %p", &iv_sync_barrier );
+
+}
+
+
+void TaskArgs::waitChildSync( )
+{
+
+ TRACDCOMP( g_trac_initsvc,
+ "Child: wait for barrier %p", &iv_sync_barrier );
+
+ barrier_wait( &iv_sync_barrier);
+
+ TRACDCOMP( g_trac_initsvc,
+ "Child: returned from barrier %p", &iv_sync_barrier );
+
+}
+
+
+void TaskArgs::postReturnCode( const uint64_t &i_returncode )
+{
+ iv_taskreturncode = i_returncode;
+
+ return;
+}
+
+
+uint64_t TaskArgs::getReturnCode( ) const
+{
+
+ return iv_taskreturncode;
+}
+
+
+void TaskArgs::setCommand( const uint64_t &i_command )
+{
+
+ iv_taskcommand = i_command;
+
+ return;
+}
+
+
+uint64_t TaskArgs::getCommand( ) const
+{
+
+ return iv_taskcommand;
+}
+
+
+TaskArgs::TaskArgs()
+: iv_taskreturncode(TASKARGS_UNDEFINED64),
+ iv_taskcommand(TASKARGS_UNDEFINED64)
+{
+ // set barrier to wait for 2 tasks before releasing,
+ // see notes above.
+ barrier_init( &iv_sync_barrier, 2 );
+}
+
+
+TaskArgs::~TaskArgs()
+{
+ barrier_destroy( &iv_sync_barrier );
+}
+
+}; // namespace TASKARGS
diff --git a/src/usr/initservice/test/initservicetest.H b/src/usr/initservice/test/initservicetest.H
index d05dbd583..31fe457a2 100644
--- a/src/usr/initservice/test/initservicetest.H
+++ b/src/usr/initservice/test/initservicetest.H
@@ -15,7 +15,7 @@
#include <cxxtest/TestSuite.H>
-#include "../initservice.H"
+#include "../baseinitsvc/initservice.H"
/**
* @brief set up a dummy TaskInfo struct for test 1.
@@ -24,26 +24,27 @@
*/
const INITSERVICE::TaskInfo TASK_TEST1 = {
"libtestinitsvc_noexist.so" , // taskname
+ NULL, // ptr to fn
{
- true, // startflag=true, try to start
- INITSERVICE::BASE_MODULE, // Base Module
- INITSERVICE::INIT_SVC_TEST1_ID, // module id for errorlog
+ INITSERVICE::START_TASK, // startflag=true, try to start
+ INITSERVICE::BASE_IMAGE, // Base Module
+ INITSERVICE::INIT_SVC_TEST1_ERRL_ID, // module id for errorlog
},
};
/**
* @brief set up a dummy TaskInfo struct for test 2.
- * example.C does indeed have a _start() function so this should return OK.
+ * tasktest2 does indeed have a _start() function so this should return OK.
*
- * @todo this needs to be replaced with a test module
*/
const INITSERVICE::TaskInfo TASK_TEST2 = {
- "libexample.so" , // taskname
+ "libtasktest2.so" , // taskname
+ NULL, // ptr to fn
{
- true, // startflag=true, try to start
- INITSERVICE::BASE_MODULE, // Base Module
- INITSERVICE::INIT_SVC_TEST2_ID, // module id for errorlog
+ INITSERVICE::START_TASK, // startflag=true, try to start
+ INITSERVICE::BASE_IMAGE, // Base Module
+ INITSERVICE::INIT_SVC_TEST2_ERRL_ID, // module id for errorlog
},
};
@@ -55,11 +56,12 @@ const INITSERVICE::TaskInfo TASK_TEST2 = {
* @todo this needs to be replaced with a test module
*/
const INITSERVICE::TaskInfo TASK_TEST3 = {
- "libtrace.so" , // taskname
+ "libtrace.so" , // taskname
+ NULL, // ptr to fn
{
- true, // startflag=true, try to start
- INITSERVICE::BASE_MODULE, // Base Module
- INITSERVICE::INIT_SVC_TEST3_ID, // module id for errorlog
+ INITSERVICE::START_TASK, // startflag=true, try to start
+ INITSERVICE::BASE_IMAGE, // Base Module
+ INITSERVICE::INIT_SVC_TEST3_ERRL_ID, // module id for errorlog
},
};
@@ -81,18 +83,18 @@ public:
*/
void testInitServiceStartTask1(void)
{
+
errlHndl_t errl = NULL;
/**
* @todo use a separate instance here, not the singleton
*/
- INITSERVICE::InitService &l_is = INITSERVICE::InitService::getTheInstance();
- tid_t tidrc = 0;
+ INITSERVICE::InitService &l_is = INITSERVICE::InitService::getTheInstance();
-
- TS_TRACE( "=====>Attempt to run a nonexistent task.\n ");
- tidrc = l_is.startTask( TASK_TEST1, errl );
- printk( "testInitServiceStartTask1: startTask returned %d: errl=%p\n", tidrc, errl );
- if ( (int16_t)tidrc < 0 )
+ TS_TRACE( "=====>Attempt to run a nonexistent task, expect an ERROR.");
+ errl = l_is.startTask( &TASK_TEST1, // task struct
+ NULL, // args
+ errl ); // errlog
+ if ( errl )
{
TS_TRACE( "SUCCESS: startTask returned an errorlog.\n");
}
@@ -116,20 +118,19 @@ public:
/**
* @todo use a separate instance here, not the singleton
*/
- INITSERVICE::InitService &l_is = INITSERVICE::InitService::getTheInstance();
- tid_t tidrc = 0;
-
+ INITSERVICE::InitService &l_is = INITSERVICE::InitService::getTheInstance();
- TS_TRACE( "=====>Attempt to run a task with a _start() function.\n ");
- tidrc = l_is.startTask( TASK_TEST2, errl );
- printk( "testInitServiceStartTask2: startTask returned %d: errl=%p\n", tidrc, errl );
- if ( (int16_t)tidrc >= 0 )
+ TS_TRACE( "=====>Attempt to run a task with a _start() function, expect SUCCESS.");
+ errl = l_is.startTask( &TASK_TEST2, // task struct
+ NULL, // args
+ errl ); // errlog
+ if ( errl )
{
- TS_TRACE( "SUCCESS: startTask returned OK.\n");
+ TS_FAIL( "ERROR: StartTask returned an error log.\n");
}
else
{
- TS_FAIL( "ERROR: StartTask returned an error log.\n");
+ TS_TRACE( "SUCCESS: startTask returned OK.\n");
}
@@ -149,13 +150,12 @@ public:
* @todo use a separate instance here, not the singleton
*/
INITSERVICE::InitService &l_is = INITSERVICE::InitService::getTheInstance();
- tid_t tidrc = 0;
-
- TS_TRACE( "====>Attempt to run a task with NO _start() function.\n ");
- tidrc = l_is.startTask( TASK_TEST3, errl );
- printk( "testInitServiceStartTask3: startTask returned %d: errl=%p\n", tidrc, errl );
- if ( (int16_t)tidrc < 0 )
+ TS_TRACE( "====>Attempt to run a task with NO _start() function, expect an ERROR.");
+ errl = l_is.startTask( &TASK_TEST3, // task struct
+ NULL, // args
+ errl ); // errlog
+ if ( errl )
{
TS_TRACE( "SUCCESS: startTask returned an error log.\n");
}
@@ -214,13 +214,13 @@ public:
errl = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_INFORMATIONAL,
- INITSERVICE::INIT_SVC_TEST5_ID,
+ INITSERVICE::INIT_SVC_TEST5_ERRL_ID,
INITSERVICE::START_TASK_FAILED,
0,
0
);
- TS_TRACE( "====> call reportError with good error handle, should commit and then delete\n ");
+ TS_TRACE( "====> call reportError with good error handle, should commit and then delete ");
l_is.reportError( errl );
if ( errl !=NULL )
{
diff --git a/src/usr/makefile b/src/usr/makefile
index 015970ebc..3cf04b4ea 100644
--- a/src/usr/makefile
+++ b/src/usr/makefile
@@ -3,6 +3,6 @@ ROOTPATH = ../..
OBJS = module_init.o
SUBDIRS = example.d trace.d cxxtest.d testcore.d errl.d devicefw.d \
- scom.d xscom.d targeting.d initservice.d hwpf.d ecmddatabuffer.d
+ scom.d xscom.d targeting.d initservice.d hwpf.d ecmddatabuffer.d
include ${ROOTPATH}/config.mk
diff --git a/src/usr/targeting/targetservice.C b/src/usr/targeting/targetservice.C
index de9acd0ab..305e96ca7 100644
--- a/src/usr/targeting/targetservice.C
+++ b/src/usr/targeting/targetservice.C
@@ -17,6 +17,7 @@
// Other components
#include <sys/task.h>
#include <trace/interface.H>
+#include <initservice/taskargs.H>
// This component
#include <targeting/targetservice.H>
@@ -30,24 +31,30 @@
namespace TARGETING
{
+
#define TARG_NAMESPACE "TARGETING::"
+
//******************************************************************************
// _start
//******************************************************************************
#define TARG_CLASS ""
+
/**
* @brief Entry point for initialization service to initialize the targeting
- * code
+ * code
*
- * @note: Link register is configured to automatically invoke task_end() when
+ * @note: Link register is configured to automatically invoke task_end() when
* this routine returns
*/
extern "C"
void _start(void* io_pArgs)
{
+ INITSERVICE::TaskArgs::TaskArgs *pTaskArgs =
+ reinterpret_cast<INITSERVICE::TaskArgs::TaskArgs *>(io_pArgs);
+
#define TARG_FN "_start(...)"
TARG_ENTER();
@@ -57,6 +64,11 @@ void _start(void* io_pArgs)
TARG_EXIT();
+ if ( pTaskArgs )
+ {
+ pTaskArgs->waitChildSync();
+ }
+
task_end();
#undef TARG_FN
OpenPOWER on IntegriCloud