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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
// IBM_PROLOG_BEGIN_TAG
// This is an automatically generated prolog.
//
// $Source: src/usr/initservice/extinitsvc/extinitsvc.C $
//
// IBM CONFIDENTIAL
//
// COPYRIGHT International Business Machines Corp. 2011
//
// p1
//
// Object Code Only (OCO) source materials
// Licensed Internal Code Source Materials
// IBM HostBoot Licensed Internal Code
//
// 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.
//
// Origin: 30
//
// IBM_PROLOG_END
/**
* @file extinitsvc.C
*
* Implements Initialization Service for Host boot in the extended image.
* See extinitsvc.H for details
*
*/
#include <kernel/console.H>
#include <vfs/vfs.H>
#include <sys/task.h>
#include <sys/sync.h>
#include <sys/misc.h>
#include <sys/time.h>
#include <usr/cxxtest/TestSuite.H>
#include <trace/interface.H>
#include <errl/errlentry.H>
#include <initservice/taskargs.H> // task entry routine
#include "extinitsvc.H"
#include "extinitsvctasks.H"
namespace INITSERVICE
{
extern trace_desc_t *g_trac_initsvc;
/**
* @brief set up _start() task entry procedure using the macro in taskargs.H
*/
TASK_ENTRY_MACRO( ExtInitSvc::getTheInstance().init );
void ExtInitSvc::init( void *i_ptr )
{
errlHndl_t l_errl = NULL;
uint64_t l_task = 0;
const TaskInfo *l_ptask = NULL;
TaskArgs::TaskArgs l_args;
uint64_t l_childrc = 0;
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++ )
{
// make a local copy of the extended image task
l_ptask = &(g_exttaskinfolist[l_task]);
if ( l_ptask->taskflags.task_type == END_TASK_LIST )
{
TRACDCOMP( g_trac_initsvc,
"End of ExtInitSvc task list." );
break;
}
l_args.clear();
// dispatch the task
l_errl = InitService::getTheInstance().dispatchTask( l_ptask,
&l_args );
// 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 returned 0x%llx, errlog=0x%p",
l_childrc,
l_errl );
// 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 != TASKARGS_UNDEFINED64 )
&& ( l_childrc != 0 )
)
{
TRACFCOMP( g_trac_initsvc,
"Child task returned 0x%llx, no errlog",
l_childrc );
/*@ errorlog tag
* @errortype ERRL_SEV_CRITICAL_SYS_TERM
* @moduleid see task list
* @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,
l_ptask->taskflags.module_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.
TRACFCOMP( g_trac_initsvc,
"ERROR: extra errorlog found: %p",
l_errl );
errlCommit( l_errl, INITSVC_COMP_ID );
assert( 0 );
}
TRACFCOMP( g_trac_initsvc,
EXIT_MRK "ExtInitSvc finished.");
// =====================================================================
// ----- Unit Tests -------------------------------------------------
// =====================================================================
/**
* @note run all of the unit tests after we finish the rest
* There are 2 images generated in the build:
* hbicore.bin (HostBoot shippable image)
* hbicore_test.bin (runs all unit tests)
* Only hbicore_test.bin has the libcxxtest.so module, so when
* we execute startTask() below on hbicore.bin, it will return -ENOENT,
* no module present. This is OK.
*
* @todo can we call call module_load() to see if libcxxtest.so exists?
* ask Doug or Patrick
*
*/
// add a do-while loop so there is only one return at the bottom....
do
{
// Pass it a set of args so we can wait on the barrier
errlHndl_t l_cxxerrl = NULL;
TaskArgs::TaskArgs l_cxxtestargs;
const TaskInfo *l_pcxxtask = &CXXTEST_TASK;
uint64_t l_cxxchildrc = 0;
errlHndl_t l_cxxchilderrl = NULL;
l_cxxtestargs.clear();
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 != TASKARGS_UNDEFINED64 )
&& ( 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 see task list
* @reasoncode CXXTEST_FAILED_NO_ERRLOG
* @userdata1 returncode from istep
* @userdata2 0
*
* @devdesc The unit test dispatcher returned with an
* error, but there was no errorlog returned.
*/
l_cxxerrl = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_CRITICAL_SYS_TERM,
l_pcxxtask->taskflags.module_id,
INITSERVICE::CXXTEST_FAILED_NO_ERRLOG,
l_cxxchildrc,
0 );
errlCommit( l_cxxerrl, INITSVC_COMP_ID );
} // end if
} // end else
} while(0); // end do-while
// =====================================================================
// ----- Shutdown all CPUs -----------------------------------------
// =====================================================================
uint64_t l_shutdownStatus = SHUTDOWN_STATUS_GOOD;
if (CxxTest::g_FailedTests)
{
l_shutdownStatus = SHUTDOWN_STATUS_UT_FAILED;
}
shutdown(l_shutdownStatus);
// return to _start(), which may end the task or die.
return;
}
ExtInitSvc& ExtInitSvc::getTheInstance()
{
return Singleton<ExtInitSvc>::instance();
}
ExtInitSvc::ExtInitSvc()
{ }
ExtInitSvc::~ExtInitSvc()
{ }
} // namespace
|