summaryrefslogtreecommitdiffstats
path: root/src/usr/initservice/baseinitsvc
diff options
context:
space:
mode:
authorMark Wenning <wenning@us.ibm.com>2011-07-10 21:14:46 -0500
committerMark W. Wenning <wenning@us.ibm.com>2011-07-14 16:54:12 -0500
commit353cc0391b0982b936fe0437fbaa0439f775a6dd (patch)
treedd892737420cecffec8104a0eeef3dd2282a23a5 /src/usr/initservice/baseinitsvc
parent5530b7609c0351deb5d707c5950a56309842a325 (diff)
downloadtalos-hostboot-353cc0391b0982b936fe0437fbaa0439f775a6dd.tar.gz
talos-hostboot-353cc0391b0982b936fe0437fbaa0439f775a6dd.zip
IStep Dispatcher
- remove refs to include/src/usr/taskargs/ dir - use _start() macro in IStepDispatcher - post-review fixes - fixed - inadvertently ran copyright script on staged files Change-Id: I2b256524746d0eb25ed04e0835450e220dc65492 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/191 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Diffstat (limited to 'src/usr/initservice/baseinitsvc')
-rw-r--r--src/usr/initservice/baseinitsvc/initservice.C83
-rw-r--r--src/usr/initservice/baseinitsvc/initservice.H97
-rw-r--r--src/usr/initservice/baseinitsvc/initservicetaskentry.C1
3 files changed, 104 insertions, 77 deletions
diff --git a/src/usr/initservice/baseinitsvc/initservice.C b/src/usr/initservice/baseinitsvc/initservice.C
index 0c3617023..de96ea922 100644
--- a/src/usr/initservice/baseinitsvc/initservice.C
+++ b/src/usr/initservice/baseinitsvc/initservice.C
@@ -65,14 +65,9 @@ errlHndl_t InitService::startTask( const TaskInfo *i_ptask,
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 )
{
+ // task failed to launch, post an errorlog and dump some trace
io_rerrl = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, // severity
i_ptask->taskflags.module_id, // moduleid
@@ -91,6 +86,7 @@ errlHndl_t InitService::startTask( const TaskInfo *i_ptask,
} // endif tidrc
else
{
+ // task launched OK.
TRACDBIN( g_trac_initsvc,
"Task finished OK :",
i_ptask->taskname,
@@ -98,12 +94,85 @@ errlHndl_t InitService::startTask( const TaskInfo *i_ptask,
TRACDCOMP( g_trac_initsvc,
"task number %d, errlog p = %p",
tidrc, io_rerrl );
- }
+
+ if ( io_pargs )
+ {
+ io_pargs->waitParentSync(); // sync up childtask
+ }
+
+ }
return io_rerrl;
}
+errlHndl_t InitService::executeFn( const TaskInfo *i_ptask,
+ TaskArgs *io_pargs
+) const
+{
+ tid_t tidrc = 0;
+ errlHndl_t errl = NULL;
+
+ if ( i_ptask->taskfn == NULL )
+ {
+ TRACDBIN( g_trac_initsvc,
+ "ERROR: NULL function pointer:",
+ i_ptask->taskname,
+ strlen(i_ptask->taskname) );
+
+ errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, // severity
+ i_ptask->taskflags.module_id, // moduleid
+ INITSERVICE::NULL_FN_PTR, // reason Code
+ 0,
+ 0 );
+
+ return errl;
+ }
+
+
+ // valid function, launch it
+ tidrc = task_create( i_ptask->taskfn, io_pargs );
+ if ( static_cast<int16_t>(tidrc) < 0 )
+ {
+ errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM, // severity
+ i_ptask->taskflags.module_id, // moduleid
+ INITSERVICE::START_FN_FAILED, // reason Code
+ tidrc, // user1 = tidrc
+ 0 );
+
+ TRACDBIN( g_trac_initsvc,
+ ENTER_MRK "ERROR starting function:",
+ i_ptask->taskname,
+ strlen(i_ptask->taskname) );
+ TRACDCOMP( g_trac_initsvc,
+ EXIT_MRK "tidrc=%d, errlog p = %p" ,
+ (int16_t)tidrc, errl );
+
+ } // endif tidrc
+ else
+ {
+ TRACDBIN( g_trac_initsvc,
+ ENTER_MRK "function launched OK :",
+ i_ptask->taskname,
+ strlen(i_ptask->taskname) );
+ TRACDCOMP( g_trac_initsvc,
+ EXIT_MRK "task number %d, errlog p = %p",
+ tidrc, errl );
+
+ // task launched OK.
+ if ( io_pargs )
+ {
+ io_pargs->waitParentSync(); // sync up parent task
+ }
+ }
+
+ return errl;
+
+}
+
+
void InitService::reportError(errlHndl_t &io_rerrl ) const
{
diff --git a/src/usr/initservice/baseinitsvc/initservice.H b/src/usr/initservice/baseinitsvc/initservice.H
index dd0a7df32..db16ede89 100644
--- a/src/usr/initservice/baseinitsvc/initservice.H
+++ b/src/usr/initservice/baseinitsvc/initservice.H
@@ -26,10 +26,11 @@
#include <sys/vfs.h> // VFS_MODULE_NAME_MAX
#include <trace/interface.H>
-#include <initservice/taskargs.H>
#include <errl/errlentry.H>
#include <initservice/initsvcreasoncodes.H>
+#include <initservice/taskargs.H>
+#include "../common/initsvcstructs.H"
namespace INITSERVICE
{
@@ -38,77 +39,10 @@ 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
/******************************************************************************/
@@ -156,7 +90,17 @@ public:
// $$protected:
/**
- * @brief start a task
+ * @brief start a task using the taskname string in the TaskInfo struct.
+ * taskname string will be something like "libtargeting.so", which
+ * is the name of the compiled and linked targetting module.
+ * The module is expected to have implemented a extern "C"
+ * function called "void _start(void *args)" which is considered
+ * to be the "task entry point". When _start is called, its
+ * parameter will be set to point to a TaskArgs struct which
+ * can be used to pass information back and forth. See the
+ * comments in TaskArgs.H for more info.
+ * See initsvctasks.H and the unit tests for some examples of
+ * how this is used.
*
* @param[in] i_ptask pointer to a TaskInfo struct
* @param[in] io_pargs pointer to a TaskArgs struct, or NULL
@@ -171,6 +115,21 @@ public:
TaskArgs::TaskArgs *i_pargs,
errlHndl_t &io_rerrl ) const;
+ /**
+ * @brief executeFn
+ * Execute an function
+ *
+ * @param[in] i_ptask - pointer to an TaskInfo struct
+ * @param[in,out] i_pargs - pointer to a TaskArgs struct
+ *
+ * @return errlHndl_t handle, NULL if success, filled out errorlog
+ * if failure
+ */
+ errlHndl_t executeFn( const TaskInfo *i_ptask,
+ TaskArgs *i_pargs
+ ) const;
+
+
/**
* @brief report Error to the system.
diff --git a/src/usr/initservice/baseinitsvc/initservicetaskentry.C b/src/usr/initservice/baseinitsvc/initservicetaskentry.C
index 62d531c07..b27ca6a44 100644
--- a/src/usr/initservice/baseinitsvc/initservicetaskentry.C
+++ b/src/usr/initservice/baseinitsvc/initservicetaskentry.C
@@ -33,7 +33,6 @@ void _start(void *ptr)
TRACFCOMP( g_trac_initsvc,
ENTER_MRK "Executing Initialization Service module." );
-
// create an instance of InitService
//InitService::InitService& is = InitService::getTheInstance();
OpenPOWER on IntegriCloud