summaryrefslogtreecommitdiffstats
path: root/src/build/simics/hb-simdebug.py
blob: 74347e8a0153f254d432c8478695ecd01e44b94a (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
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/build/simics/hb-simdebug.py $
#
# OpenPOWER HostBoot Project
#
# COPYRIGHT International Business Machines Corp. 2011,2014
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG
import os,sys
import conf
import configuration
import cli
import binascii
import datetime
import commands     ## getoutput, getstatusoutput
import random

#===============================================================================
#   HOSTBOOT Commands
#===============================================================================
default_syms  = "hbicore.syms"
default_stringFile = "hbotStringFile"

#------------------------------------------------
#------------------------------------------------
new_command("hb-trace",
    (lambda comp: run_hb_debug_framework("Trace",
                                         ("components="+comp) if comp else "",
                                         outputFile = "hb-trace.output")),
    [arg(str_t, "comp", "?", None),
    ],
    #alias = "hbt",
    type = ["hostboot-commands"],
    #see_also = ["hb_printk"],
    see_also = [ ],
    short = "Display the hostboot trace",
    doc = """
Parameters: \n
        in = component name(s) \n

Defaults: \n
        'comp' = all buffers \n
        'syms' = './hbicore.syms' \n
        'stringFile' = './hbotStringFile' \n\n

Examples: \n
    hb-trace \n
    hb-trace ERRL\n
    hb-trace "ERRL,INITSERVICE" \n
    """)

#------------------------------------------------
#------------------------------------------------
new_command("hb-printk",
    lambda: run_hb_debug_framework("Printk", outputFile = "hb-printk.output"),
    #alias = "hbt",
    type = ["hostboot-commands"],
    #see_also = ["hb-trace"],
    see_also = [ ],
    short = "Display the kernel printk buffer",
    doc = """
Parameters: \n

Defaults: \n
        'syms' = './hbicore.syms' \n\n

Examples: \n
    hb-printk \n
    """)

#------------------------------------------------
#------------------------------------------------
new_command("hb-dump",
    lambda: run_hb_debug_framework("Dump", outputFile = "hb-dump.output"),
    #alias = "hbt",
    type = ["hostboot-commands"],
    #see_also = ["hb-trace"],
    see_also = [ ],
    short = "Dumps HB memory to hbdump.<timestamp>",
    doc = """
Parameters: \n

Defaults: \n

Examples: \n
    hb-dump \n
    """)


#------------------------------------------------
#   Disable for now, need to pass in lots of options
#------------------------------------------------
new_command("hb-istep",
            lambda istep:  run_hb_debug_framework("Istep", istep,
            outputFile = "hb-istep.output"),
            [ arg( str_t, "istep", "?", "") ],
            type = ["hostboot-commands"],
            see_also = [ ],
            short = "Run IStep commands",
            doc = """
Parameters: \n

Defaults: \n

Examples: \n
    hb-istep    \n
    hb-istep    list \n
    hb-istep    splessmode \n
    hb-istep    fspmode \n
    hb-istep    clear-trace \n
    hb-istep    resume \n
    hb-istep    s4 \n
    hb-istep    s4..N \n
    hb-istep    poweron \n
    hb-istep    poweron..clock_frequency_set \n
    """)

#------------------------------------------------
#------------------------------------------------
new_command("hb-errl",
    (lambda logid, logidStr, flg_l, flg_d:
        run_hb_debug_framework("Errl",
                ("display="+(("0x%x" % logid) if logid else logidStr) if flg_d else ""
                ),
                outputFile = "hb-errl.output")),
    [ arg(int_t, "logid", "?", None),
     arg(str_t, "logidStr", "?", None),
     arg(flag_t, "-l"),
     arg(flag_t, "-d"),
    ],
    #alias = "hbt",
    type = ["hostboot-commands"],
    #see_also = ["hb_printk"],
    see_also = [ ],
    short = "Display the hostboot error logs",
    doc = """
Parameters: \n
        in = option for dumping error logs\n

Defaults: \n
        'flag' = '-l' \n

Examples: \n
    hb_errl [-l]\n
    hb-errl -d 1\n
    hb-errl -d [all]\n
    """)


#------------------------------------------------
#------------------------------------------------
def hb_singlethread():
    # Note: will default to using the currently selected cpu
    # emulates the SBE thread count register
    run_command("($hb_cpu).write-reg scratch7 0x0000800000000000");
    return

new_command("hb-singlethread",
    hb_singlethread,
    [],
    alias = "hb-st",
    type = ["hostboot-commands"],
    short = "Disable all threads except 1 - Must be run before starting sim.")


#------------------------------------------------
#------------------------------------------------
def hb_get_objects_by_class(classname):
    obj_list=[]
    obj_dict={}
    # Put objects into a dictionary, indexed by object name
    for obj in SIM_get_all_objects():
        if (obj.classname == classname):
            obj_dict[obj.name]=obj

    # Sort the dictionary by key (object name)
    obj_names=obj_dict.keys()
    obj_names.sort()
    for obj_name in obj_names:
        obj_list.append(obj_dict[obj_name])
        #print "object name=%s" % obj_name
    return obj_list

def hb_getallregs(regname):
    proc_list=[]
    proc_list=hb_get_objects_by_class("ppc-power8-mambo-core")
    for proc in proc_list:
        output = run_command("%s.read-reg %s"%(proc.name,regname))
        print ">> %s : " %(proc.name) + "%x" %output

new_command("hb-getallregs",
    (lambda reg: hb_getallregs(reg)),
    [ arg(str_t, "reg", "?", None),
    ],
    alias = "hb-gar",
    type = ["hostboot-commands"],
    short = "Read a reg from all cores.",
    doc = """
Examples: \n
    hb-getallregs <regname>\n
    hb-getallregs pc\n
    """)


#------------------------------------------------
#------------------------------------------------
OpenPOWER on IntegriCloud