Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / n2 / api / sam / src / SamCmd.py
CommitLineData
920dae64
AT
1# ========== Copyright Header Begin ==========================================
2#
3# OpenSPARC T2 Processor File: SamCmd.py
4# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6#
7# The above named program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public
9# License version 2 as published by the Free Software Foundation.
10#
11# The above named program is distributed in the hope that it will be
12# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public
17# License along with this work; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19#
20# ========== Copyright Header End ============================================
21#
22# execfile('sam.py')
23#
24import sam
25
26# print all sam py commands
27def help_sam ():
28 print "version ()"
29 print "quit ()"
30 print "run (mode=" ")"
31 print "stop ()"
32 print "stepi (n=1,cpu=-1,file=" ")"
33 print "mem (start_addr=0,size=8)"
34 print "mem_dis (sstart_addr=0,size=8)"
35 print "mem_va (start_addr=0,size=8)"
36 print "mem_va_dis (start_addr=0,size=8)"
37 print "conf (arg=" ")"
38 print "write (value,addr)"
39 print "setreg (regname,value)"
40 print "sam_help (command=" ")"
41 print "pc ()"
42 print "rg (cpu= 0, gl = -1)"
43 print "rw (cpu= 0, wp = -1)"
44 print "rtr (cpu= 0, tl = -1)"
45 print "rfp (cpu= 0)"
46 print "rdf (cpu= 0)"
47 print "rpr (cpu= 0)"
48 print "rasr (cpu= 0)"
49 print "rhpr (cpu= 0)"
50
51 print "mips (<#|off>)"
52 print "break_pc (pc_va, cpu_id|all) - set a breakpoint on pc value"
53 print "break_opcode (opcode, cpu_id|all) - set a breakpoint on opcode"
54 print "bplist() -list all breakpoints"
55 print "dbreak (bp_id='all', cpu='all') - delete a breakpoint"
56
57
58 """
59
60 print "file - run <script file name>"
61 print "load - load <mode> <addr> <value>"
62 print "console-send - console-send <string>"}
63 print "dbg - dbg on|off"
64 print "exper - exper <N>"
65 print "stepim - stepim <N>"
66 print "stept - stept <Msecs>"
67 print "on - on STOP <command>"
68 print "rdt - rdt [<FILE>]"
69 print "diskdelay - diskdelay [ddelay[/wrddelay]] [start_cycle]"
70 print "time - time start | stop"
71 print "sync - on|off"
72 print "resume - back to prev sync mode"
73 print "alias - alias [<old cmd>] [<new cmd>] "
74 print "penable - penable [-all | <thN>]"
75 print "pdisable -pdisable [-all | <thN>]"
76 print "pty - pty"
77
78 """
79
80
81
82# simulator current version
83def version ():
84 sam.ui_exec("version")
85
86# quit sim
87def quit ():
88 sam.ui_exec("quit");
89
90
91# run <mode>
92def run (mode=" "):
93 sam.ui_exec("run "+mode)
94
95# stop sim
96def stop ():
97 sam.ui_exec("stop")
98
99
100# stepi [<ninstr>] [-t [cpuid]] [-o <file_name>]
101def stepi (n=1,cpu=-1,file=" "):
102 cmd = "stepi "+str(n)
103 if cpu >= 0 :
104 cmd += " -t "+str(cpu)
105 if file != " " :
106 cmd += " -o "+file
107 sam.ui_exec(cmd)
108
109# read mem from physical start_addr, Size bytes
110def mem (start_addr=0,size=8):
111 cmd = "mem -a "+str(start_addr)+" -s "+str(size)
112 sam.ui_exec(cmd)
113
114# read mem from virtual start_addr, Size bytes
115def mem_va (start_addr=0,size=8):
116 cmd = "mem -a "+str(start_addr)+" -s "+str(size)+" -va"
117 sam.ui_exec(cmd)
118
119# disassemble mem from virtual start_addr, Size bytes
120def mem_va_dis (start_addr=0,size=8):
121 cmd = "mem -a "+str(start_addr)+" -s "+str(size)+" -va -dis"
122 sam.ui_exec(cmd)
123
124# disassemble mem from physical start_addr, Size bytes
125def mem_dis (start_addr=0,size=8):
126 cmd = "mem -a "+str(start_addr)+" -s "+str(size)+" -dis"
127 sam.ui_exec(cmd)
128
129# conf <name> <value>
130def conf (arg=" "):
131 sam.ui_exec("conf "+arg)
132
133# write word <value> <paddr>
134def write (value,addr):
135 cmd = "write word "+str(value)+" "+str(addr)
136 sam.ui_exec(cmd)
137
138# setreg <regname> <value>
139def setreg (regname,value):
140 cmd = "setreg "+regname+" "+str(value)
141 sam.ui_exec(cmd)
142
143
144# help <command>
145def sam_help (command=" "):
146 sam.ui_exec("help "+command);
147
148
149# display current pc values
150def pc ():
151 sam.ui_exec("pc")
152
153# display cpu global regs
154def rg (cpu= 0, gl = -1):
155 cmd = "r -cpu "+str(cpu)+" -g "+str(gl)
156 sam.ui_exec(cmd)
157
158# display windowed regs
159def rw (cpu= 0, wp = -1):
160 cmd = "r -cpu "+str(cpu)+" -w "+str(wp)
161 sam.ui_exec(cmd)
162
163# display trap regs
164def rtr (cpu= 0, tl = -1):
165 cmd = "r -cpu "+str(cpu)+" -w "+str(tl)
166 sam.ui_exec(cmd)
167
168# display floating point regs
169def rfp (cpu= 0):
170 cmd = "r -cpu "+str(cpu)+" -f"
171 sam.ui_exec(cmd)
172
173
174# display double floating point regs
175def rdf (cpu= 0):
176 cmd = "r -cpu "+str(cpu)+" -df"
177 sam.ui_exec(cmd)
178
179# display proc regs
180def rpr (cpu= 0):
181 cmd = "r -cpu "+str(cpu)+" -pr"
182 sam.ui_exec(cmd)
183
184# display asr regs
185def rasr (cpu= 0):
186 cmd = "r -cpu "+str(cpu)+" -asr"
187 sam.ui_exec(cmd)
188
189# display hypervisor regs
190def rhpr (cpu= 0):
191 cmd = "r -cpu "+str(cpu)+" -hpr"
192 sam.ui_exec(cmd)
193
194
195# mips log on/off
196def mips (mode):
197 cmd = "mips "+str(mode)
198 sam.ui_exec(cmd)
199
200
201# set a breakpoint on pc value
202def break_pc (pc, cpu = 0):
203 cmd = "break cpu="+str(cpu)+" pc="+str(pc)
204 sam.ui_exec(cmd)
205
206
207# set a breakpoint on opcode value
208def break_opcode (opcode, cpu = 0):
209 cmd = "break cpu="+str(cpu)+" opcode="+str(opcode)
210 sam.ui_exec(cmd)
211
212# list breakpoints
213def bplist ():
214 cmd = "break ?"
215 sam.ui_exec(cmd)
216
217
218# delete a breakpoint
219def dbreak (bp_id="all", cpu="all"):
220 cmd = "dbreak cpu="+str(cpu)
221 if bp_id != "all" :
222 cmd += " bp_id="+str(bp_id)
223 sam.ui_exec(cmd)
224
225