summaryrefslogtreecommitdiffstats
path: root/src/occ/tools/occ_simics_debug.py
blob: 63cee85b1eaa7541761dbd47cceccb61089f6a41 (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
# @file - occ_simics_debug.py
# @brief Create Simics Generic Commands
# 
#   Flag    Def/Fea    Userid    Date        Description
#   ------- ---------- --------  ----------  ----------------------------------
#                      thallet   03/28/2012  Created


from time import sleep
from random import randint
import sys
import re

G_occ_list = []

##############################################################################
###########################################################
#   Functions
###########################################################
##############################################################################
def print_sym_as_hex( str ):
  tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"')
  splitter = re.compile(r' (\d+)')
  p_sym = tick[1].rstrip('\n')
  r_sym = splitter.split(p_sym)
  out_str = ''
  for item in r_sym:
     if item.isdigit():
         if (int(item) > 0xffffffff):
            out_str += "0x%016x" % int(item)
         else:
            out_str += "0x%08x" % int(item)
     else:
         out_str += `item`
  
  print out_str
  return

def print_sym_as_hex64( str ):
  tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"')
  splitter = re.compile(r' (\d+)')
  p_sym = tick[1].rstrip('\n')
  r_sym = splitter.split(p_sym)
  out_str = ''
  for item in r_sym:
     if item.isdigit():
            out_str += "0x%016x" % int(item)
     else:
         out_str += `item`
  
  print out_str
  return


def print_simics_attr_as_hex64( str ):
  tick = cli.quiet_run_command(str)
  splitter = re.compile(r'(\d+)')
  p_sym = tick[0]
  print "0x%016x" % p_sym
  return


def getscom( int ):
  tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->address = " + str(int))
  tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->data")
  p_sym = tick[0]
  print "0x%016x" % p_sym
  return

def putscom( addr, data ):
  tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->address = " + str(addr))
  tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->data = " + str(data))
  getscom(addr)
  return

def generate_occlist():
    tick = cli.quiet_run_command("$occc[0]=0; $b=0; foreach $c in (get-object-list -all occ_simple) {$occc[$b] = $c; $b = $b + 1}")
    num = cli.quiet_run_command("print -d $b")
    for idx in range(int(num[1].rstrip('\n'))):
        tick = cli.quiet_run_command("echo $occc[" + str(idx) + "]")
        G_occ_list.insert(idx,tick[1].rstrip('\n'))
    G_occ_list.sort()
    for idx in range(int(num[1].rstrip('\n'))):
        print str(idx) + ": " + G_occ_list[idx]

    return


generate_occlist()

##############################################################################
###########################################################
# Register some New Simics Commands
###########################################################
##############################################################################


#----------------------------------------------------------
#
#
new_command("hsym", print_sym_as_hex,
  args = [arg(str_t, "symbol-name")],
  alias = "hsym",
  type = "occ-fw-module-commands",
  short = "Print a symbol as hex (uint64 or uint32) for all structure members",
  doc_items = [("NOTE", "This command is best")],
  see_also = ["h64sym"],
  doc = """
  <b>hsym</b> is best.
  This is its documentation. <i>arg</i>
  is the first argument...""")

#----------------------------------------------------------
#
#
new_command("h64sym", print_sym_as_hex64,
  args = [arg(str_t, "symbol-name")],
  alias = "hsym64",
  type = "occ-fw-module-commands",
  short = "Print a symbol as hex (uint64) for all structure members",
  doc_items = [("NOTE", "This command is best")],
  see_also = ["hsym"],
  doc = """
  <b>h64sym</b> is best.
  This is its documentation. <i>arg</i>
  is the first argument...""")

 
#----------------------------------------------------------
#
#
new_command("h64attr", print_simics_attr_as_hex64,
  args = [arg(str_t, "simics-attribute")],
  alias = "hattr",
  type = "occ-fw-module-commands",
  short = "Print a simics attribute as hex (uint64) for all structure members",
  doc_items = [("NOTE", "This command is best")],
  see_also = ["hsym","h64sym"],
  doc = """
  <b>h64attr</b> is best.
  This is its documentation. <i>arg</i>
  is the first argument...""")

#----------------------------------------------------------
#
#
new_command("getscom", getscom,
  args = [arg(int_t, "scomAddress")],
  alias = "gs",
  type = "occ-fw-module-commands",
  short = "Do a getscom",
  doc_items = [("NOTE", "This command is best")],
  see_also = ["hsym","h64sym"],
  doc = """
  <b>h64attr</b> is best.
  This is its documentation. <i>arg</i>
  is the first argument...""")


#----------------------------------------------------------
#
#
new_command("putscom", putscom,
  args = [arg(int_t, "scomAddress"),arg(int_t, "data")],
  alias = "ps",
  type = "occ-fw-module-commands",
  short = "Do a getscom",
  doc_items = [("NOTE", "This command is best")],
  see_also = ["hsym","h64sym"],
  doc = """
  <b>h64attr</b> is best.
  This is its documentation. <i>arg</i>
  is the first argument...""")

OpenPOWER on IntegriCloud