summaryrefslogtreecommitdiffstats
path: root/src/build/vpo/hb-istep
blob: b12e80ec5b1e4b4e8b9a9fce1a896328ce75bf31 (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
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
#!/usr/bin/perl
#  IBM_PROLOG_BEGIN_TAG
#  This is an automatically generated prolog.
#
#  $Source: src/build/vpo/hb-istep $
#
#  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
#
# Purpose:  This perl script works in concert with do_p8vbu_script_hbi_* to 
#           implement isteps on AWAN.
#
# Description:
#           The do.. script will run first to set up the AWAN environment, 
#           then call hb_istep  twice:
#           1) hb_istep --istepmode
#               called after loading but before starting HostBoot
#               this will check to see if the user has set istep mode, if so
#               it will write the Istep_mode signature to L3 memory to put 
#               HostBoot mode into single-step mode.
#           2) hb_istep --command
#               Periodically call RunClocks() to step through HostBoot.
#               Checks for status from previous Isteps, and reports status.
#            
# Comments:
#               
#
# Author: Mark Wenning
#

#------------------------------------------------------------------------------
# Specify perl modules to use
#------------------------------------------------------------------------------
use strict;
use warnings;
use POSIX;
use Getopt::Long;
use File::Basename;
use lib dirname (__FILE__);

## 64-bit input
##  argh, not compatable with GetOpt!! use bigint;
no  warnings    'portable';

#   read/write cachelines to L3
use VBU_Cacheline;

#------------------------------------------------------------------------------
# Forward Declaration
#------------------------------------------------------------------------------
sub main;
sub printUsage;
sub get_istep_list;
sub print_istep_list;
sub find_in_inlist;
sub parse_command;
sub setMode;
sub resume_istep;
sub getShutDownStatus;

#------------------------------------------------------------------------------
#   Constants
#------------------------------------------------------------------------------
my  $CORE       =   "-c3";
my  $ISTEP_MODE_ON_SIGNATURE    =   "4057b0074057b007";
my  $ISTEP_MODE_OFF_SIGNATURE   =   "700b7504700b7504";


#------------------------------------------------------------------------------
# Globals
#------------------------------------------------------------------------------
my  $opt_debug      =   0;
my  $opt_istepmode  =   0;
my  $opt_normalmode =   0;
my  $opt_command    =   "";
my  $opt_list       =   0;
my  $opt_help       =   0;
my  $opt_resume     =   0;          ## resume istep from break point
my  $opt_clear_trace    =   0;          ##  submit command 01    
my  $opt_cmdfile    =   0;          ## batchmode, later   
my  $opt_setup          =   "";         ##  run Jim's script to start up the model         

my  @inList;
$inList[10][10]     =   ();
##  initialize inList to "undefined"
for( my $i = 0; $i <= $#inList; $i++)
{
    for(my $j = 0; $j <= $#inList; $j++)
    {
        undef( $inList[$i][$j] );
    }
}    

my  $g_SeqNum   =   0; 


#==============================================================================
# MAIN
#==============================================================================
##  get any environment variables

## Assume that all the tools, files, etc are in the same directory that 
##  we are in.


my  $pgmDir  =   `dirname $0`;
chomp( $pgmDir );

my $hbDir = $ENV{'HBDIR'};
if ( ! defined( $hbDir) || ( $hbDir eq "" ) )
{
    $hbDir = $pgmDir;               ##  Set to tool directory
}     

##  Future - VBUTOOLS is not used yet, but will be.  
##  from Jim McGuire 
# my  $vbuToolsDir    =   "/gsa/ausgsa/projects/h/hostboot/vbutools/latest";
my $vbuToolsDir = $ENV{'VBUTOOLS'};
if (defined ($vbuToolsDir))
{
    unless ($vbuToolsDir ne "")
    {
        $vbuToolsDir = "/gsa/ausgsa/projects/h/hostboot/vbutools/dev";
    }
}


my $CSVfile     =   "$hbDir/isteplist.csv";
my $hbSymsFile  =   "$hbDir/hbicore.syms";                #Use hbicore.syms
    
## print   $#ARGV;       
if ( $#ARGV < 0 )
{
    printUsage();
    exit    0 ;
}   
#------------------------------------------------------------------------------
# Parse optional input arguments
#------------------------------------------------------------------------------
GetOptions( "help|?"        =>  \$opt_help,
            "istepmode"     =>  \$opt_istepmode,
            "normalmode"    =>  \$opt_normalmode,
            "list"          =>  \$opt_list,
            "command=s"     =>  \$opt_command,
            "resume"        =>  \$opt_resume,
            "clear-trace"   =>  \$opt_clear_trace, 
            "cmdfile"       =>  \$opt_cmdfile,           
            "setup=s"       =>  \$opt_setup,

            "debug"         =>  \$opt_debug,
          );  
          
##----------------------------------------------------------------------------- 
##  check for access to the files we need.
##-----------------------------------------------------------------------------
if ( ! -e "$hbSymsFile" )  { die "Can't find symbols file $hbSymsFile\n";   }
if ( ! -e "$CSVfile" )  { die "Can't find isteplist file $hbSymsFile\n";   }   

##
##  find the istep mode, command, and status registers in the syms file
##  find the location of clear_trace in HostBoot
##
my $istepmodereg = `grep "SPLESS::g_SPLess_IStepMode_Reg" $hbSymsFile | awk -F"," '{print \$2}'`;
chomp   $istepmodereg;

my  $commandreg = `grep "SPLESS::g_SPLess_Command_Reg" $hbSymsFile | awk -F"," '{print \$2}'`;
chomp   $commandreg;

my $statusreg = `grep "SPLESS::g_SPLess_Status_Reg" $hbSymsFile | awk -F"," '{print \$2}'` ;
chomp   $statusreg;

my $shutdownflag = `grep "CpuManager::cv_shutdown_requested" $hbSymsFile | awk -F"," '{print \$2}'` ;
chomp   $shutdownflag;

my $shutdownsts = `grep "CpuManager::cv_shutdown_status" $hbSymsFile | awk -F"," '{print \$2}'` ;
chomp   $shutdownsts;


##-----------------------------------------------------------------------------
##  Start processing options
##-----------------------------------------------------------------------------          
if  ( $opt_debug )
{
    print   STDERR  "\n-----    DEBUG:  ----------------------------------- \n";
    print   STDERR  "help               =   $opt_help\n";
    print   STDERR  "istepmode          =   $opt_istepmode\n";
    print   STDERR  "normalmode         =   $opt_normalmode\n"; 
    print   STDERR  "list               =   $opt_list\n";   
    print   STDERR  "command            =   $opt_command\n";
    print   STDERR  "cmdfile            =   $opt_cmdfile\n";
    print   STDERR  "setup              =   $opt_setup\n";
    print   STDERR  "clear-trace        =   $opt_clear_trace\n";
    print   STDERR  "debug              =   $opt_debug\n";
    
    print   STDERR  "pgmDir             =   $pgmDir\n";
    print   STDERR  "hbDir              =   $hbDir\n"; 
    print   STDERR  "hbSymsFile         =   $hbSymsFile\n";   
    print   STDERR  "istepmodereg       =   $istepmodereg\n";
    print   STDERR  "commandreg         =   $commandreg\n";
    print   STDERR  "statusreg          =   $statusreg\n";
    print   STDERR  "shutdownflag reg   =   $shutdownflag\n";
    print   STDERR  "shutdownsts  reg   =   $shutdownsts\n";
    
    VBU_Cacheline::SetFlags( 1, 0 );
    
}

if  ( $opt_help )
{
    printUsage();
    exit;
}

##
##  run the main loop.  Yes, I did this on purpose.  
##  Idea is (later) to pass this an array / hash of options and use 
##  GetOptionsFromArray() to parse them.
##  That way I can either pass it @ARGV or an array processed from the cmdfile 
##
main();         



#==============================================================================
# SUBROUTINES
#==============================================================================
sub main()
{
    print   STDOUT  "\n";

    ##  fetch the ISTEP csv list
    get_istep_list();       

    if ( $opt_list )
    {
        print_istep_list();
        exit;
    }


    ## VPO cannot be running when we start.
    my  $qstr   =   VBU_Cacheline::P8_Ins_Query();
    if ( $qstr  ne "STOPPED" )
    {
        print STDOUT "Setting P8 Instructions to STOPPED.\n";
        VBU_Cacheline::P8_Ins_Stop();
    }
    
    ( my $flag, my $sts ) = getShutDownStatus();
    if ( $flag )
    {
        print   STDOUT  "Sorry, HostBoot has already shut down with status $sts, cannot run isteps.\n";
        exit;
    }

    ##
    ## Process resume
    ##
    if ( $opt_resume )
    {
        resume_istep();
        ## exit; ??
    }

    ##
    ##  process --Istep Mode command
    ##      IStepModeStr    = "cpu0_0_0_3->scratch=0x4057b007_4057b007"
    ##      NormalModeStr   = "cpu0_0_0_3->scratch=0x700b7504_700b7504"
    ##
    if ( $opt_istepmode ==  1   )
    {
        my $result = VBU_Cacheline::CLread( $istepmodereg );
        if ( $opt_debug )   { print STDERR __LINE__, "-- Entry:   IStep Mode Reg = $result";  }
        if  ( $result =~ /^.*$ISTEP_MODE_OFF_SIGNATURE/ )
        {
            print STDOUT "Sorry, HostBoot has already started in automatic mode.  Please restart and then try again.\n";
            exit;
        }     

        print STDOUT  "ENable istepmode\n";
        setMode( "istep" );
    }


    if  ( $opt_normalmode ==  1 )
    {
        print STDOUT  "DISable istepmode\n";
        setMode( "normal" );
    }


    ##
    ##  Process other commands
    ##
    if ( $opt_command ne "" )
    {
        if ( $opt_debug ) {   print   STDERR  "== __LINE__ process command \"$opt_command\" \n"; }
        parse_command( $opt_command ); 
    }
        
}   ##  end main


#------------------------------------------------------------------------------
# Print command line help
#------------------------------------------------------------------------------
sub printUsage()
{
    print STDOUT "\nUsage: hb-istep   [--help]\n";
    print STDOUT "    [--istepmode]             (enable istep mode)\n" ;
    print STDOUT "    [--normalmode]            (disable istep mode)\n" ;
    print STDOUT "    [--command sN]            (run istep N)\n" ;
    print STDOUT "    [--command sN..M]         (run isteps N through M)\n" ;
    print STDOUT "    [--command <foo>]         (run named istep \"foo\")\n" ;
    print STDOUT "    [--command <foo>..<bar>]  (run named isteps \"foo\" through \"bar\")\n" ;
    print STDOUT "    [--resume]                (resume an istep that is at a break point)\n" ;
    print STDOUT "\n" ;
##    print STDOUT "  [--cmdfile]                 (get commands from a batchfile)\n";
##    print STDOUT "  [--setup]                   (bring up AWAN and wait for further commands)\n";
##    print STDOUT "  [--clear-trace]             (clear trace buffers before starting)\n";    
##    print STDOUT "\n" ;

}


##
##  read in file with csv istep list and store in inList
##
sub get_istep_list()
{
    my $istep, my $substep, my $name ;
   
    open( FH, "< $CSVfile") or die "can't open $CSVfile : $!";

    while( <FH> )
    {
        chomp;

        ( $istep, $substep, $name) =   split( ",", $_ ); 
        ## print STDERR    "$_, $istep, $substep, $name\n" ;
         
        $inList[$istep][$substep]    =   $name; 
    }         
    
    close( FH );     
}

##
##  print the istep list to the screen.
##
sub print_istep_list( )
{
    my  $hdrflag    =   1;

    ##  print   STDOUT  "IStep\tSubStep\tName\n";
    print   STDOUT  " IStep Name\n";    
    print   STDOUT  "---------------------------------------------------\n";
    
    for(my $i = 4; $i <= $#inList; $i++)
    {
        for(my $j = 0; $j <= $#inList; $j++)
        {
            ## print all substeps
            # print "==$inList[$i][$j] \n";
            if ( defined( $inList[$i][$j] ) )
            {
                if ( $hdrflag )  
                { 
                    printf  STDOUT  " -- IStep $i --  \n"; 
                    $hdrflag = 0;
                }
                ## printf  STDOUT  "%d\t%d\t%s\n", $i, $j, $inList[$i][$j] ; 
                printf  STDOUT  " %s\n", $inList[$i][$j] ; 
            }  
        }   ## end for $j
        $hdrflag=1;
    }   ##  end for $i     
}


##
##  
##
sub find_in_inList( $ ) 
{
    my  ( $substepname )    =   @_;
    
    for(my $i = 0; $i <= $#inList; $i++)
    {
        for(my $j = 0; $j <= $#inList; $j++)
        {
            ## if ( defined($inList[$i][$j]) ) {   print ".$inList[$i][$j]?$substepname. \n";   }
            
            if ( defined($inList[$i][$j]) && ($inList[$i][$j] eq $substepname ) )
            {
                ## print "== $i $j $inList[$i][$j] \n";
                return  ($i, $j, 1 );
            }  
        }
    }     

    return ( $#inList, $#inList, 0 )  
} 

##
##  Check if HostBoot has already run and shutdown.  
sub getShutDownStatus()
{

    my $flag    =   VBU_Cacheline::CLread( $shutdownflag );
    my $status  =   VBU_Cacheline::CLread( $shutdownsts );
    
    if ( $opt_debug )   
    {   
        print   STDERR "Shutdown Flag   =   $flag\n";
        print   STDERR "Shutdown Status =   $status\n";       
    }

    return ( $flag, $status );
}

##
##  keep trying to get status until seqnum syncs up 
##
sub getSyncStatus( )
{
    # set # of retries
    my  $count  =   100;
    my  $result =   0; 
    my  $seqnum =   0;  
    
    ##  get response.  sendCmd() should have bumped g_SeqNum, so we will sit
    ##  here for a reasonable amount of time waiting for the correct sequence
    ##  number to come back.  
    while(1)
    {
    
        ##  advance HostBoot code by a certain # of cycles, then check the 
        ##  sequence number to see if it has changed.  rinse and repeat.
        VBU_Cacheline::RunClocks();
        
        ##  dump printk similar to the Jim McGuire's script
        ##  NOPE, CRASHES AWAN dumpPrintk();

        $result = VBU_Cacheline::CLread( $statusreg );
        $seqnum  = ( ( $result & 0x3f00000000000000 ) >> 56 );
        if ( $seqnum == $g_SeqNum )
        {
            return $result;
        }
        
        if ( $count <= 0 )
        {
            print STDOUT    "TIMEOUT waiting for seqnum=$g_SeqNum\n";
            return -1;
        }
        $count--;
    }   ##  endwhile    
          
} 

##
##  Run an istep
##
sub runIStep( $$ )
{
    my  ( $istep, $substep)  = @_;
    my  $byte0, my $command;
    my  $cmd;
    my  $result;
    
    
    ##  bump the seqnum
    $g_SeqNum++;
    
    printf   STDOUT  "run  %d.%d %s:\n", $istep, $substep, $inList[$istep][$substep];
    
    $byte0   =   0x80 + $g_SeqNum;      ## gobit + seqnum
    $command =   0x00;
    $cmd = sprintf( "0x%2.2x%2.2x%2.2x%2.2x00000000", $byte0, $command, $istep, $substep );
    VBU_Cacheline::CLwrite( $commandreg, $cmd );
    
    $result  =   getSyncStatus();
    
    ## if result is -1 we have a timeout
    if ( $result == -1 )
    {
        print   "-----------------------------------------------------------------\n";
    }
    else
    {
        my $taskStatus  =   ( ( $result & 0x00ff000000000000 ) >> 48 );
        my $stsIStep    =   ( ( $result & 0x0000ff0000000000 ) >> 40 );
        my $stsSubstep  =   ( ( $result & 0x000000ff00000000 ) >> 32 );
        my $istepStatus =   ( ( $result & 0x00000000ffffffff )  );

        print   STDOUT "-----------------------------------------------------------------\n";
        ## printf STDOUT "Istep %d.%d Status: 0x%x\n", $stsIStep, $stsSubstep, $istepStatus ; 
        if ( $taskStatus != 0 )
        {
            printf STDOUT "Istep %d.%d FAILED to launch, task status is %d\n", $stsIStep, $stsSubstep, $taskStatus ;
        }
        else
        {            
            printf STDOUT "Istep %d.%d returned Status: 0x%x\n", $stsIStep, $stsSubstep, $istepStatus ;
        }
        print STDOUT "-----------------------------------------------------------------\n";
    }     
}   
    
##    
##  run command = "sN"
##    
sub sCommand( $ )
{
    my  ( $scommand )   =   @_;
    
    my  $i   =   $scommand;
    my  $j   =   0;
    
    # sanity check
    if ( !defined($inList[$i][0]) )
    {
        printf  STDOUT  "IStep %d.0 does not exist.\n", $i;
        return -1;
    }
        
    #   execute all the substeps in the IStep
    for( $j=0; $j<$#inList; $j++ )
    {
        ## print   "-----------------" 
        ##print STDOUT  "run IStep %d %s  ...\n", $i, $inList[$i][$j] );
        ##print   "-----------------" 
        if ( defined( $inList[$i][$j] ) )
        {
            runIStep( $i, $j );
        }
    }
}
     
##
##  parse --command [command] option and execute it.
##
sub parse_command( $ )
{
    my  ( $command ) =   @_;
    my  @execlist;
    my  $istepM, my $substepM, my $foundit, my $istepN, my $substepN;
    my  $M, my $N, my $scommand;
    my  @ss_list;
    
    ## check to see if we have an 's' command (string starts with 's' and a number) 
    chomp( $command);   
    if ( $command =~ m/^s+[0-9].*/ )
    {
        ## run "s" command
        if ($opt_debug) {   print STDERR __LINE__, "===== s command : ", $command, ":\n";   } 
        substr( $command, 0, 1, "" );
 
        if ( isdigit( $command ) )
        {
            # command = "sN"
            if ($opt_debug) {   print STDERR __LINE__, "===== single IStep: ", $command, "\n";  }
            sCommand( $command ); 
        }
        else
        {
            #   list of substeps = "sM..N"
            ( $M, $N )  =   split( /\.\./, $command );
            
            if ($opt_debug) {   print STDERR "===== multiple ISteps: ", $M, "-", $N, "\n";    } 
            for ( my $x=$M; $x<$N+1; $x++ )
            {
                sCommand( $x );
            }          
        }                   
    }
    else
    {  
        ## <substep name>, or <substep name>..<substep name>
        @ss_list    =   split( /\.\./, $command );        
        
        if ($opt_debug) {   print STDERR __LINE__, "===== named commands : ", @ss_list, "\n";    } 
            
        ( $istepM, $substepM, $foundit) = find_in_inList( $ss_list[0] );
        $istepN      =   $istepM;
        $substepN    =   $substepM;
        if ( ! $foundit )
        {
            print STDOUT "Invalid substep ", $ss_list[0], "\n" ;
            return -1;
        }
        
            
        if ( $#ss_list > 0 )
        {    
            ( $istepN, $substepN, $foundit) = find_in_inList( $ss_list[1] );
            if ( ! $foundit )
            {
                print STDOUT "Invalid substep %s", $ss_list[1], "\n" ;
                return -1;
            }
        }
        
        ## print "got it, running isteps:\n";
        for( my $x=$istepM; $x<$istepN+1; $x++ )
        {
            for( my $y=$substepM; $y<$substepN+1; $y++ )
            {
                ## print STDOUT "run $x $y $inList[$x][$y]\n";
                runIStep( $x, $y );
            }
        }
        
    }   
}

##
##  write to scratch reg 3 to set istep or normal mode, check return status 
##       
sub setMode( $ )
{
    my  ( $cmd )    =   @_;
    my  $count      =   0;
    my  $expected   =   0;
    my  $readybit   =   0;
    my  $result     =   0;
   

    if ( $cmd eq "istep" )
    {
        VBU_Cacheline::CLwrite( $istepmodereg, "0x4057b0074057b007" );
        $expected    =   1;    
    }
    elsif   ( $cmd eq "normal" )
    {
        VBU_Cacheline::CLwrite( $istepmodereg, "0x700b7504700b7504" );
        $expected    =   0;
    }
    else
    {      
        print "invalid setMode command: %s\n", $cmd ;
        return  -1;
    }        
    
    if ( $opt_debug )   
    {
        ##  readback and display 
        $result = VBU_Cacheline::CLread( $istepmodereg );
        printf STDERR __LINE__,   "=====  istepmodereg readback:  0x%lx\n", $result ;
    }
 

    ##  Loop, advancing clock, and wait for readybit
    $count  =   30;
    while(1)
    {
        ##  advance HostBoot code by a certain # of cycles, then check the 
        ##  sequence number to see if it has changed.  rinse and repeat.
        VBU_Cacheline::RunClocks();
        
        $result = VBU_Cacheline::CLread( $statusreg );
        
        $readybit    =   ( ( $result & 0x4000000000000000 ) >> 62 );
        
        if ($opt_debug)   
            { printf  STDERR __LINE__,  "===== setMode:  count=%d, result=0x%lx, readybit=0x%x\n", $count, $result, $readybit  } 

        if ( $readybit == $expected )
        {
            print STDOUT "Set $cmd Mode success.\n" ;
            return 0;
        }
            
        if ( $count <= 0 )
        {
            print STDOUT "TIMEOUT waiting for readybit, status=0x%x\n", $result ;
            return -1;
        }
            
        $count--;
    } 
}


sub resume_istep()
{
    my $byte0;
    my $command;
    my $cmd;
    my $result;

    $g_SeqNum++;        ## bump

    printf STDOUT "resume istep\n";

    $byte0 = 0x80 + $g_SeqNum;      ## gobit + seqnum
    $command = 0x01;
    $cmd = sprintf( "0x%2.2x%2.2x000000000000", $byte0, $command );
    VBU_Cacheline::CLwrite( $commandreg, $cmd );

    $result = getSyncStatus();

    ## if result is -1 we have a timeout
    if ( $result == -1 )
    {
        print   "-----------------------------------------------------------------\n";
    }
    else
    {
        my $taskStatus  =   ( ( $result & 0x00ff000000000000 ) >> 48 );

        print   STDOUT "-----------------------------------------------------------------\n";
        if ( $taskStatus != 0 )
        {
            # This probably means istep was not at a breakpoint.
            printf STDOUT "resume istep FAILED, task status is %d\n", $taskStatus ;
        }
        else
        {            
            printf STDOUT "resume istep returned success\n" ;
        }
        print STDOUT "-----------------------------------------------------------------\n";
    }
}

__END__

OpenPOWER on IntegriCloud