summaryrefslogtreecommitdiffstats
path: root/src/build/vpo/hb-printk
blob: 95ad98e2615113a25441df5f24084b6867579ea5 (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
#!/usr/bin/perl
#  IBM_PROLOG_BEGIN_TAG
#  This is an automatically generated prolog.
#
#  $Source: src/build/vpo/hb-printk $
#
#  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 on VBU and will dump kernel printk buffer
#
# Author: CamVan Nguyen
# Last Updated: 09/07/2011
#

#------------------------------------------------------------------------------
# Specify perl modules to use
#------------------------------------------------------------------------------
use strict;
use warnings;


#------------------------------------------------------------------------------
# Forward Declaration
#------------------------------------------------------------------------------
sub printUsage;


#==============================================================================
# MAIN
#==============================================================================

#------------------------------------------------------------------------------
# Parse optional input arguments
#------------------------------------------------------------------------------
my $numArgs = $#ARGV + 1;
#print "num args = $numArgs\n";
#print "argument list = @ARGV\n";

my $hbDir = $ENV{'HBDIR'};
if (defined ($hbDir))
{
    unless ($hbDir ne "")
    {
        $hbDir = '.';             #Set to current directory
    }
}
else
{
    $hbDir = '.';                 #Set to current directory
}

for (my $i=0; $i<$numArgs; $i++)
{
    if (($ARGV[$i] eq "--help") || ($ARGV[$i] eq "-h"))
    {
        #Print command line help
        printUsage();
        exit (0);
    }
    elsif ($ARGV[$i] eq "--in")
    {
        if (($i + 1) >= $numArgs)
        {
            die "No value given for --in parameter.\n";
        }
        $i++;
        $hbDir = $ARGV[$i];
    }
    elsif ($ARGV[$i] eq "--out")
    {
        if (($i + 1) >= $numArgs)
        {
            die "No value given for --out parameter.\n";
        }
        $i++;
    }
    elsif (($ARGV[$i] ne "--test") && ($ARGV[$i] !~ m/^-[cknsp]\d+/))
    {
        print "Invalid argument entered:  $ARGV[$i]\n";
        printUsage();
        exit(1);
    }
}


#------------------------------------------------------------------------------
# Dump the kernel printk buffer
#------------------------------------------------------------------------------
my $command = "$hbDir/hb-virtdebug.pl --printk @ARGV";
system($command);


#==============================================================================
# SUBROUTINES
#==============================================================================

#------------------------------------------------------------------------------
# Print command line help
#------------------------------------------------------------------------------
sub printUsage()
{
    print ("\nUsage: hb-printk [--help] | [--in <path to .syms file & hb-virtdebug.pl>]\n");
    print ("                 [--out <path to save output data>]\n");
    print ("                 [--test] [-k#] [-n#] [-s#] [-p#] [-c#]\n\n");
    print ("  This program retrieves the kernel printk buffer from L3.\n");
    print ("  User should copy the relevant .syms file & hb-virtdebug.pl to the\n");
    print ("  current directory or set the env variable HBDIR to the path of the files.\n\n");
    print ("  --help            Prints usage information.\n");
    print ("  --in              Overrides the automatically detected .syms file &\n");
    print ("                    hb-virtebug.pl in HBDIR or the current directory.\n");
    print ("                    This program will search for the files in the ");
    print ("following order:\n");
    print ("                        1.  from the path specified by the user\n");
    print ("                        2.  from HBDIR if it is defined\n");
    print ("                        3.  from the current directory\n");
    print ("  --out             Directory where the output data will be saved.\n");
    print ("                    Default path is the current directory.\n");
    print ("  --test            Use the hbicore_test.syms file vs the hbicore.syms file\n");
    print ("  -k#               Specify which cage to act on (default = 0).\n");
    print ("  -n#               Specify which node to act on (default = 0).\n");
    print ("  -s#               Specify which slot to act on (default = 0).\n");
    print ("  -p#               Specify which chip position to act on (default = 0).\n");
    print ("  -c#               Specify which core/chipUnit to act on (default = 3).\n");
    print ("\n  NOTE:  This program will not work if user has not stopped instructions\n");
    print ("         prior to running this program.\n");
}

OpenPOWER on IntegriCloud