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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
|
/* IBM_PROLOG_BEGIN_TAG
* This is an automatically generated prolog.
*
* $Source: src/usr/initservice/istepdispatcher/istepdispatcher.C $
*
* IBM CONFIDENTIAL
*
* COPYRIGHT International Business Machines Corp. 2011,2012
*
* 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_TAG
*/
/**
* @file istepdispatcher.C
*
* IStep Dispatcher code. Launched from Extended Initialization Service
*
* PNOR Driver and Trace should be available by the time this is launched.
*
*/
/******************************************************************************/
// Includes
/******************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <kernel/console.H> // printk status
#include <sys/task.h> // tid_t, task_create, etc
#include <errl/errlentry.H> // errlHndl_t
#include <devicefw/userif.H> // targeting
#include <initservice/isteps_trace.H> // ISTEPS_TRACE buffer
#include <initservice/initsvcudistep.H> // InitSvcUserDetailsIstep
#include <initservice/taskargs.H> // TASK_ENTRY_MACRO
#include <targeting/common/attributes.H> // ISTEP_MODE attribute
#include <targeting/common/targetservice.H>
#include <mbox/mbox_queues.H> // HB_ISTEP_MSGQ
#include <mbox/mboxif.H> // register mailbox
#include <isteps/istepmasterlist.H>
#include "istepdispatcher.H"
#include "istepWorker.H"
#include "splesscommon.H"
// ----- namespace ISTEPS_TRACE ---------------------------------------
namespace ISTEPS_TRACE
{
// declare storage for isteps_trace!
trace_desc_t *g_trac_isteps_trace = NULL;
} // end namespace
// ----- end namespace ISTEPS_TRACE -----------------------------------
// ----- namespace INITSERVICE -------------------------------------------
namespace INITSERVICE
{
using namespace ERRORLOG; // IStepNameUserDetails
using namespace SPLESS; // SingleStepMode
/******************************************************************************/
// Globals/Constants
/******************************************************************************/
extern trace_desc_t *g_trac_initsvc;
const MBOX::queue_id_t HWSVRQ = MBOX::IPL_SERVICE_QUEUE;
/**
* _start() task entry procedure using the macro in taskargs.H
*/
TASK_ENTRY_MACRO( IStepDispatcher::getTheInstance().init );
// ----------------------------------------------------------------------------
// IstepDispatcher()
// ----------------------------------------------------------------------------
IStepDispatcher::IStepDispatcher ()
: iv_workerMsg( NULL )
{
SPLESS::initIStepMode();
mutex_init( &iv_bkPtMutex );
mutex_init( &iv_syncMutex );
mutex_init( &iv_stepMutex );
sync_cond_init( &iv_syncHit );
iv_curIStep = 0x0;
iv_curSubStep = 0x0;
iv_sync = false;
// init mailbox / message Q.
iv_msgQ = msg_q_create();
}
// ----------------------------------------------------------------------------
// ~IstepDispatcher()
// ----------------------------------------------------------------------------
IStepDispatcher::~IStepDispatcher ()
{
}
// ----------------------------------------------------------------------------
// IstepDispatcher::getTheInstance()
// ----------------------------------------------------------------------------
IStepDispatcher& IStepDispatcher::getTheInstance ()
{
return Singleton<IStepDispatcher>::instance();
}
// ----------------------------------------------------------------------------
// IStepDispatcher::init()
// ----------------------------------------------------------------------------
void IStepDispatcher::init ( errlHndl_t &io_rtaskRetErrl )
{
errlHndl_t err = NULL;
// initialize (and declare) ISTEPS_TRACE here, the rest of the isteps will
// use it.
ISTEPS_TRACE::g_trac_isteps_trace = NULL;
TRAC_INIT(&ISTEPS_TRACE::g_trac_isteps_trace, "ISTEPS_TRACE", 2048 );
printk( "IstepDispatcher entry.\n" );
TRACFCOMP( g_trac_initsvc,
"IStep Dispatcher entry." );
do
{
if( !(SPLESS::SPLessAttached()) )
{
// register message Q with FSP Mailbox - only if Fsp attached.
err = MBOX::msgq_register( MBOX::HB_ISTEP_MSGQ,
iv_msgQ );
if( err )
{
break;
}
}
// Spawn off the Worker thread
tid_t l_workerTid = task_create( startIStepWorkerThread,
iv_msgQ );
assert( l_workerTid > 0 );
// Check for SPLess operation
if( SPLESS::SPLessAttached() )
{
// SPless user console is attached,
// launch SPTask.
TRACFCOMP( g_trac_initsvc,
"IStep single-step enable (SPLESS)" );
tid_t l_spTaskTid = task_create( spTask,
iv_msgQ );
assert( l_spTaskTid > 0 );
}
if( err )
{
TRACFCOMP( g_trac_initsvc,
"ERROR: Failed to register mailbox, terminating" );
break;
}
if( getIStepMode() )
{
printk( "IStep single-step\n" );
TRACFCOMP( g_trac_initsvc,
"IStep single-step" );
err = msgHndlr();
if( err )
{
break;
}
}
else
{
printk( "IStep run-all\n" );
TRACFCOMP( g_trac_initsvc,
"IStep run all" );
// Execute all Isteps sequentially in 'normal' mode
err = executeAllISteps();
if( err )
{
break;
}
}
} while( 0 );
TRACFCOMP( g_trac_initsvc,
"IStepDispatcher finished.");
printk( "IStepDispatcher exit.\n" );
io_rtaskRetErrl= err;
}
// ----------------------------------------------------------------------------
// IStepDispatcher::executeAllISteps()
// ----------------------------------------------------------------------------
errlHndl_t IStepDispatcher::executeAllISteps ( void )
{
errlHndl_t err = NULL;
msg_t * theMsg = NULL;
TRACFCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::executeAllISteps()" );
do
{
// Sequentially loop through all isteps, executing each by replying to
// work needed msg from worker thread.
uint32_t prevIstep = 0;
uint32_t prevSubStep = 0;
for( size_t istep = 0;
istep < MaxISteps;
istep++ )
{
// Run until num items +1, to be sure we know the last step
// finished
for( size_t substep = 0;
substep < (g_isteps[istep].numitems + 1);
substep++ )
{
#if 1
// $$ please save, need to fix for
// $$ IPL service not returning error on invalid isteps
#else
// If the istep/substep doesn't exist, skip it.
if ( findTaskInfo( istep, substep ) == NULL )
{
TRACFCOMP( g_trac_initsvc,
INFO_MRK"Empty istep %d.%d, continuing...",
istep,
substep );
continue;
}
#endif
// Before we can do anything, we need to be sure the worker thread is
// ready to start
theMsg = msg_wait( iv_msgQ );
// check for sync msgs
if( theMsg->type == SYNC_POINT_REACHED )
{
TRACFCOMP( g_trac_initsvc,
INFO_MRK"Got sync msg (0x%08x)",
theMsg->type );
handleSyncPointReachedMsg();
// We didn't really do anything for this substep
substep--;
continue;
}
// If we just got the msg that the last step finished, break
// out
if( substep == (g_isteps[istep].numitems + 1) )
{
TRACFCOMP( g_trac_initsvc,
INFO_MRK"Last Step, exit" );
break;
}
// Look for an errlog in extra_data
if( NULL != theMsg->extra_data )
{
TRACFCOMP( g_trac_initsvc,
ERR_MRK"Error returned from istep(%d), substep(%d)",
prevIstep, prevSubStep );
err = ((errlHndl_t)theMsg->extra_data);
break;
}
TRACFCOMP( g_trac_initsvc,
INFO_MRK"executeAllSteps(0x%08x), istep: %d, substep: %d",
theMsg->type, istep, substep );
// Set the Istep info
prevIstep = istep;
prevSubStep = substep;
uint16_t istepInfo = ((istep << 8 ) | substep);
setIstepInfo( istepInfo );
// Put the step/substep into data[0] for the worker thread
theMsg->data[0] = istepInfo;
msg_respond( iv_msgQ,
theMsg );
theMsg = NULL;
}
if( err )
{
break;
}
}
if( err )
{
break;
}
} while ( 0 );
TRACFCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::executeAllISteps()" );
return err;
}
// ----------------------------------------------------------------------------
// IStepDispatcher::msgHndlr()
// ----------------------------------------------------------------------------
errlHndl_t IStepDispatcher::msgHndlr ( void )
{
errlHndl_t err = NULL;
msg_t * theMsg = NULL;
// TODO - Issue 45012
// There is enough common code between this path and executeAllISteps()
// that the issue above will be used to combine the 2 paths into one
// commone code path.
TRACFCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::msgHndlr()" );
// We will stay in this loop unless there is a failure or other reason to
// exit out and terminate. This loop is the main handler for the Istep
// Dispatcher. It receives all messages from the Fsp, Child worker
// thread, and the SPLess task.
while( 1 )
{
theMsg = msg_wait( iv_msgQ );
TRACDCOMP( g_trac_initsvc,
"msgHndlr: rcvmsg t=0x%08x, d0=0x%016x, d1=0x%016x, x=%p",
theMsg->type,
theMsg->data[0],
theMsg->data[1],
theMsg->extra_data );
switch( theMsg->type )
{
case SYNC_POINT_REACHED:
TRACDCOMP( g_trac_initsvc,
"msgHndlr : SYNC_POINT_REACHED" );
// Sync point reached from Fsp
iv_Msg = theMsg;
handleSyncPointReachedMsg();
break;
case MORE_WORK_NEEDED:
TRACDCOMP( g_trac_initsvc,
"msgHndlr : MORE_WORK_NEEDED" );
// Worker thread is ready for more work.
iv_workerMsg = theMsg;
// The very first MORE_WORK_NEEDED message will
// have theMsg->data[0] set to 1. It is set to 0
// for subsequent messages. handleMoreWorkNeededMsg
// needs to know the very first MORE_WORK_NEEDED msg
// to handle the case that a msg is queued in the
// mbox msg queue before this first MORE_WORK_NEEDED
// is received.
handleMoreWorkNeededMsg( (theMsg->data[0] == 1) );
break;
default:
// Default Message
// This SHOULD be a message from the Fsp with the Step/substep
// to be executed.
// Gotta check to make sure Fsp hadn't sent us a 2nd Istep
// request for some reason, if so, its an error.
if( iv_Msg )
{
TRACFCOMP( g_trac_initsvc,
ERR_MRK"ERROR: IStep Dispatcher already has another "
"Istep request for step: 0x%02x, substep: 0x%02x",
((iv_Msg->type & 0xFF00) >> 8),
(iv_Msg->type & 0xFF) );
/*@
* @errortype
* @reasoncode ISTEP_MULTIPLE_ISTEP_REQ
* @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
* @moduleid ISTEP_INITSVC_MOD_ID
* @userdata1 Current Istep
* @userdata2 Current SubStep
* @devdesc A Second Istep request has been made
* and we are still working on a
* previous Istep.
*/
err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
ISTEP_INITSVC_MOD_ID,
ISTEP_MULTIPLE_ISTEP_REQ,
((iv_Msg->type & 0xFF00) >> 8),
(iv_Msg->type & 0xFF) );
break;
}
TRACDCOMP( g_trac_initsvc,
"msgHndlr : default" );
iv_Msg = theMsg;
handleIStepRequestMsg();
break;
}; // end switch
if( err )
{
TRACFCOMP( g_trac_initsvc,
"istepDispatcher, recieved errorlog, PLID = 0x%x",
err->plid() );
// Breaking here will be a BAD thing... It means that we are
// exiting not just Istep Dispatcher, but all of Hostboot.
// This should only happen if there is an error during an Istep.
errlCommit( err,
INITSVC_COMP_ID );
}
} // end while(1)
TRACFCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::msgHndlr()" );
return err;
}
// ----------------------------------------------------------------------------
// waitForSyncPoint()
// IStepDispatcher::waitForSyncPoint()
// ----------------------------------------------------------------------------
void waitForSyncPoint ( void )
{
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"waitForSyncPoint()" );
IStepDispatcher::getTheInstance().waitForSyncPoint();
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"waitForSyncPoint()" );
}
void IStepDispatcher::waitForSyncPoint ( void )
{
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::waitForSyncPoint()" );
if( getIStepMode() ||
spLess() )
{
TRACFCOMP( g_trac_initsvc,
INFO_MRK"Istep mode or SPless, no wait for sync point allowed" );
return;
}
// Lock here to hold off all additional callers
TRACFCOMP( g_trac_initsvc,
INFO_MRK"Wait for sync point" );
mutex_lock( &iv_syncMutex );
while( !iv_sync )
{
sync_cond_wait( &iv_syncHit,
&iv_syncMutex );
}
iv_sync = false;
mutex_unlock( &iv_syncMutex );
TRACDCOMP( g_trac_initsvc,
INFO_MRK"Sync point hit." );
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::waitForSyncPoint()" );
}
// ----------------------------------------------------------------------------
// sendSyncPoint()
// IStepDispatcher::sendSyncPoint()
// ----------------------------------------------------------------------------
errlHndl_t sendSyncPoint ( void )
{
TRACFCOMP( g_trac_initsvc,
ENTER_MRK"sendSyncPoint()" );
return IStepDispatcher::getTheInstance().sendSyncPoint();
}
errlHndl_t IStepDispatcher::sendSyncPoint ( void )
{
errlHndl_t err = NULL;
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::sendSyncPoint()" );
if( getIStepMode() )
{
TRACFCOMP( g_trac_initsvc,
INFO_MRK"Istep mode, no sending sync point allowed" );
return err;
}
msg_t * myMsg = msg_allocate();
myMsg->type = SYNC_POINT_REACHED;
uint64_t tmpVal = iv_curIStep;
tmpVal = tmpVal << 32;
tmpVal |= iv_curSubStep;
myMsg->data[0] = tmpVal;
myMsg->data[1] = 0x0;
myMsg->extra_data = NULL;
err = sendMboxMsg( ISTEP_ASYNC,
myMsg );
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::sendSyncPoint()" );
return err;
}
// ----------------------------------------------------------------------------
// sendIstepCompleteMsg()
// IStepDispatcher::sendIstepCompleteMsg()
// ----------------------------------------------------------------------------
errlHndl_t sendIstepCompleteMsg ( void )
{
TRACFCOMP( g_trac_initsvc,
ENTER_MRK"sendIstepCompleteMsg()" );
return IStepDispatcher::getTheInstance().sendIstepCompleteMsg();
}
errlHndl_t IStepDispatcher::sendIstepCompleteMsg ( void )
{
errlHndl_t err = NULL;
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::sendIstepCompleteMsg()" );
do
{
// We just need to respond back to the outstanding iv_Msg we should
// already have
if( iv_Msg )
{
iv_Msg->data[0] = 0x0;
msg_respond( iv_msgQ,
iv_Msg );
iv_Msg = NULL;
}
else
{
TRACFCOMP( g_trac_initsvc,
ERR_MRK"Request to send Istep complete, but no outstanding "
"message from Fsp found!!" );
/*@
* @errortype
* @reasoncode NO_MSG_PRESENT
* @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE
* @moduleid ISTEP_INITSVC_MOD_ID
* @userdata1 Current Istep
* @userdata2 Current SubStep
* @devdesc Request to send Istep Complete msg to Fsp, but no
* outstanding message from Fsp found.
*/
err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE,
ISTEP_INITSVC_MOD_ID,
NO_MSG_PRESENT,
iv_curIStep,
iv_curSubStep );
break;
}
} while( 0 );
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::sendIstepCompleteMsg()" );
return err;
}
// ----------------------------------------------------------------------------
// IStepDispatcher::sendMboxMsg()
// ----------------------------------------------------------------------------
errlHndl_t IStepDispatcher::sendMboxMsg ( IStepSync_t i_sendSync,
msg_t * i_msg )
{
errlHndl_t err = NULL;
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::sendMboxMsg()" );
do
{
if( ISTEP_SYNC == i_sendSync )
{
err = MBOX::sendrecv( HWSVRQ,
i_msg );
}
else if( ISTEP_ASYNC == i_sendSync )
{
err = MBOX::send( HWSVRQ,
i_msg );
}
else
{
// should never get here, but if we do, just return back...
// Nothing to send.
}
if( err )
{
break;
}
} while( 0 );
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::sendMboxMsg()" );
return err;
}
// ----------------------------------------------------------------------------
// IStepDispatcher::getIstepInfo()
// ----------------------------------------------------------------------------
void IStepDispatcher::getIstepInfo ( uint8_t & o_iStep,
uint8_t & o_subStep )
{
mutex_lock( &iv_stepMutex );
o_iStep = iv_curIStep;
o_subStep = iv_curSubStep;
mutex_unlock( &iv_stepMutex );
}
// ----------------------------------------------------------------------------
// IStepDispatcher::setIstepInfo()
// ----------------------------------------------------------------------------
void IStepDispatcher::setIstepInfo ( uint16_t i_type )
{
mutex_lock( &iv_stepMutex );
iv_curIStep = ((i_type & 0xFF00) >> 8);
iv_curSubStep = (i_type & 0xFF);
mutex_unlock( &iv_stepMutex );
}
// ----------------------------------------------------------------------------
// IStepDispatcher::handleSyncPointReachedMsg()
// ----------------------------------------------------------------------------
void IStepDispatcher::handleSyncPointReachedMsg ( void )
{
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::handleSyncPointReachedMsg()" );
do
{
// Indicate we hit a sync point, and get anyone waiting moving.
mutex_lock( &iv_syncMutex );
iv_sync = true;
sync_cond_signal( &iv_syncHit );
mutex_unlock( &iv_syncMutex );
} while( 0 );
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::handleSyncPointReachedMsg()" );
}
// ----------------------------------------------------------------------------
// IStepDispatcher::handleMoreWorkNeededMsg()
// ----------------------------------------------------------------------------
void IStepDispatcher::handleMoreWorkNeededMsg ( bool i_first )
{
uint32_t l_plid = 0;
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::handleMoreWorkNeededMsg()" );
// Clear out current Istep/substep values. Since worker thread told us
// its done, nothing is running right now.
iv_curIStep = 0x0;
iv_curSubStep = 0x0;
// Only something to do if we've gotten a request from Fsp or SPLESS
if( iv_Msg )
{
if (i_first)
{
handleIStepRequestMsg();
}
// Send response back to caller?
else if( !msg_is_async( iv_Msg ) )
{
// if the istep failed, istepWorker will return the errorlog
// in iv_WorkerMsg->extra_data. Commit the error here and then
// return the plid as status to the FSP/spless in iv_Msg.
// Note that there are 2 messages in transit here, iv_WorkerMsg
// and iv_Msg .
if ( iv_workerMsg->extra_data != NULL )
{
errlHndl_t tmpErr = static_cast<errlHndl_t>(iv_workerMsg->extra_data);
l_plid = tmpErr->plid();
errlCommit( tmpErr,
INITSVC_COMP_ID );
// pass the plid back to FSP/spless as status.
}
// status is returned in the high 32 bits of data[0] .
// I'm not sure what the lower 32 bits are.
iv_Msg->data[0] = ( static_cast<uint64_t>(l_plid) << 32 );
iv_Msg->data[1] = 0x0;
iv_Msg->extra_data = NULL;
TRACDCOMP( g_trac_initsvc,
"MoreWorkNeeded: sendmsg t=0x%08x, d0=0x%016x, d1=0x%016x, x=%p",
iv_Msg->type,
iv_Msg->data[0],
iv_Msg->data[1],
iv_Msg->extra_data );
msg_respond( iv_msgQ,
iv_Msg );
iv_Msg = NULL;
}
}
else
{
// We should never be here... Worker message should only be doing
// something if it got a request from outside.
}
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::handleMoreWorkNeededMsg()" );
}
// ----------------------------------------------------------------------------
// iStepBreakPoint()
// ----------------------------------------------------------------------------
void iStepBreakPoint ( uint32_t i_info )
{
TRACFCOMP( g_trac_initsvc,
ENTER_MRK"handleBreakpointMsg()" );
IStepDispatcher::getTheInstance().handleBreakpoint( i_info );
}
// ----------------------------------------------------------------------------
// IStepDispatcher::handleBreakpoint()
// ----------------------------------------------------------------------------
void IStepDispatcher::handleBreakpoint ( uint32_t i_info )
{
// Throttle the breakpoints by locking here.
mutex_lock( &iv_bkPtMutex );
errlHndl_t err = NULL;
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::handleBreakpointMsg()" );
// Send Breakpoint msg to Fsp.
msg_t * myMsg = msg_allocate();
myMsg->type = BREAKPOINT;
uint64_t tmpVal = 0x0;
tmpVal = tmpVal & i_info;
myMsg->data[0] = (tmpVal << 32); // TODO - Is this really a Fsp requirement?
myMsg->data[1] = 0x0;
myMsg->extra_data = NULL;
if( !(SPLESS::SPLessAttached()) )
{
// FSP Attached
// Wait for Fsp to respond.
err = sendMboxMsg( ISTEP_SYNC,
myMsg );
// TODO - Do we care what they sent back? Not sure... HwSvr
// has no documentation on this...
if( err )
{
errlCommit( err,
INITSVC_COMP_ID );
}
}
else
{
// SPLESS
msg_respond( iv_msgQ,
myMsg );
// Now wait for spless code to respond that we're done with the
// breakpoint
msg_t * rspMsg;
rspMsg = msg_wait( iv_msgQ );
}
msg_free( myMsg );
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::handleBreakpointMsg()" );
mutex_unlock( &iv_bkPtMutex );
}
// ----------------------------------------------------------------------------
// IStepDispatcher::handleIStepRequestMsg()
// ----------------------------------------------------------------------------
void IStepDispatcher::handleIStepRequestMsg ( void )
{
TRACDCOMP( g_trac_initsvc,
ENTER_MRK"IStepDispatcher::handleIStepRequestMsg()" );
// Only something to do, if the worker thread is ready for work
if( iv_workerMsg )
{
// debug
TRACDCOMP( g_trac_initsvc,
"handleIstepRequestMsg: iv_Msg: t=0x%08x, d0=0x%016x, d1=0x%016x, x=%p",
iv_Msg->type,
iv_Msg->data[0],
iv_Msg->data[1],
iv_Msg->extra_data );
// Set new istep/substep info
uint16_t stepInfo = ((iv_Msg->data[0] & 0x000000FF00000000) >> 24);
stepInfo = (stepInfo | (iv_Msg->data[0] & 0xFF) );
setIstepInfo( stepInfo );
TRACDCOMP( g_trac_initsvc,
INFO_MRK"handleIstepRequestMsg: Istep req: 0x%04x",
stepInfo );
// Set step/substep in data[0];
iv_workerMsg->data[0] = stepInfo;
msg_respond( iv_msgQ,
iv_workerMsg );
iv_workerMsg = NULL;
}
TRACDCOMP( g_trac_initsvc,
EXIT_MRK"IStepDispatcher::handleIStepRequestMsg()" );
}
// ----------------------------------------------------------------------------
// IStepDispatcher::getIStepMode()
// ----------------------------------------------------------------------------
bool IStepDispatcher::getIStepMode( ) const
{
using namespace TARGETING;
Target* l_pTopLevel = NULL;
bool l_istepmodeflag = false;
TargetService& l_targetService = targetService();
(void)l_targetService.getTopLevelTarget( l_pTopLevel );
if( l_pTopLevel == NULL )
{
TRACFCOMP( g_trac_initsvc,
"Top level handle was NULL" );
l_istepmodeflag = false;
}
else
{
l_istepmodeflag = l_pTopLevel->getAttr<ATTR_ISTEP_MODE> ();
}
return l_istepmodeflag;
}
// ----------------------------------------------------------------------------
// IStepDispatcher::spLess()
// ----------------------------------------------------------------------------
bool IStepDispatcher::spLess ( void )
{
bool spless = true;
TARGETING::Target * sys = NULL;
TARGETING::targetService().getTopLevelTarget( sys );
TARGETING::SpFunctions spfuncs;
if( sys &&
sys->tryGetAttr<TARGETING::ATTR_SP_FUNCTIONS>(spfuncs) &&
spfuncs.mailboxEnabled )
{
spless = false;
}
return spless;
}
} // namespace
|