summaryrefslogtreecommitdiffstats
path: root/src/usr/initservice/istepdispatcher/istepdispatcher.C
blob: 057cde2f9cd90c7b53b35071123a93cf9cb0223b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/****************************************************************************
 * $IBMCopyrightBlock:
 * 
 *  IBM Confidential
 * 
 *  Licensed Internal Code Source Materials
 * 
 *  IBM HostBoot Licensed Internal Code
 * 
 *  (C) Copyright IBM Corp. 2011
 * 
 *  The source code for this program is not published or other-
 *  wise divested of its trade secrets, irrespective of what has
 *  been deposited with the U.S. Copyright Office.
 * $
****************************************************************************/

/**
 *  @file istepdispatcher.C
 *
 *  IStep Dispatcher interface.  Launched from Extended Initialization Service
 *
 */


/******************************************************************************/
// Includes
/******************************************************************************/
#include    <stdint.h>
#include    <stdio.h>
#include    <string.h>

#include    <sys/task.h>                // tid_t, task_create, etc
#include    <trace/interface.H>         //  trace support
#include    <errl/errlentry.H>          //  errlHndl_t

#include    "istepdispatcher.H"
#include    "isteplist.H"


namespace   INITSERVICE
{

/******************************************************************************/
// Globals/Constants
/******************************************************************************/
extern trace_desc_t *g_trac_initsvc;

/**
 * @brief   set up _start() task entry procedure using the macro
 */
TASK_ENTRY_MACRO( IStepDispatcher::getTheInstance().init );


IStepDispatcher::IStepDispatcher()
:   iv_istepmodeflag(false),
    iv_nextistep( 0 ),
    iv_cancontinueflag(false)
{

}


IStepDispatcher::~IStepDispatcher()
{

}


IStepDispatcher& IStepDispatcher::getTheInstance()
{
    return Singleton<IStepDispatcher>::instance();
}


void IStepDispatcher::init( void * ptr )
{
    errlHndl_t          errl            =   NULL;
    uint64_t            nextIStep       =   0;
    const TaskInfo      *pistep         =   NULL;
    TaskArgs::TaskArgs  args;

    TRACFCOMP( g_trac_initsvc,
            ENTER_MRK "starting IStepDispatcher, ptr=%p. &args=%p",
            ptr, &args );

    for (   nextIStep=0;
            nextIStep<INITSERVICE::MAX_ISTEPS;
            nextIStep++ )
    {
        pistep    =   &(g_isteps[nextIStep]);
        if ( pistep->taskflags.task_type ==  END_TASK_LIST )
        {
            TRACDCOMP( g_trac_initsvc,
                    "End of IStep list.\n" );
            break;
        }


        args.clear();           // clear the args struct for the next istep
        errl = InitService::getTheInstance().executeFn( pistep,
                                                        &args );

        //  handle an errorlog from the parent, if it exists
        InitService::getTheInstance().reportError( errl );

        /**
         * @todo call getCanContinueProcedure when we have some ISteps that
         *          require them.
         */

        if ( args.getReturnCode() != TASKARGS_UNDEFINED64 )
        {
            TRACFCOMP( g_trac_initsvc,
                        ERR_MRK "IStep TaskArgs returned 0x%llx, errlog=%p",
                        args.getReturnCode(),
                        args.getErrorLog()
                        );
        }

        // report an error from the child, if it exists.
        reportIStepErrorLog( pistep, args.getErrorLog() );

    }   // endfor


    TRACFCOMP( g_trac_initsvc,
            EXIT_MRK "IStepDispatcher finished.");

}



/**
 * @note    IStep Mode is hardwired to false for now
 *
 * @todo    revisit this when PNOR Driver is implemented
 */
bool IStepDispatcher::getIStepMode( )  const
{

    return  false;
}



bool IStepDispatcher::getCanContinueProcedure(  const  TaskInfo &i_failingIStep,
                                                errlHndl_t      &i_failingError,
                                                TaskInfo        &io_nextIstep
                                                ) const
{

    return  false;
}

void IStepDispatcher::reportIStepErrorLog(  const TaskInfo  *i_failingIStep,
                                            errlHndl_t    io_errl )
{

    InitService::getTheInstance().reportError( io_errl );
}

} // namespace
OpenPOWER on IntegriCloud