Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / n2 / api / sam / src / SamCmd.py
# ========== Copyright Header Begin ==========================================
#
# OpenSPARC T2 Processor File: SamCmd.py
# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
#
# The above named program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License version 2 as published by the Free Software Foundation.
#
# The above named program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this work; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ========== Copyright Header End ============================================
#
# execfile('sam.py')
#
import sam
# print all sam py commands
def help_sam ():
print "version ()"
print "quit ()"
print "run (mode=" ")"
print "stop ()"
print "stepi (n=1,cpu=-1,file=" ")"
print "mem (start_addr=0,size=8)"
print "mem_dis (sstart_addr=0,size=8)"
print "mem_va (start_addr=0,size=8)"
print "mem_va_dis (start_addr=0,size=8)"
print "conf (arg=" ")"
print "write (value,addr)"
print "setreg (regname,value)"
print "sam_help (command=" ")"
print "pc ()"
print "rg (cpu= 0, gl = -1)"
print "rw (cpu= 0, wp = -1)"
print "rtr (cpu= 0, tl = -1)"
print "rfp (cpu= 0)"
print "rdf (cpu= 0)"
print "rpr (cpu= 0)"
print "rasr (cpu= 0)"
print "rhpr (cpu= 0)"
print "mips (<#|off>)"
print "break_pc (pc_va, cpu_id|all) - set a breakpoint on pc value"
print "break_opcode (opcode, cpu_id|all) - set a breakpoint on opcode"
print "bplist() -list all breakpoints"
print "dbreak (bp_id='all', cpu='all') - delete a breakpoint"
"""
print "file - run <script file name>"
print "load - load <mode> <addr> <value>"
print "console-send - console-send <string>"}
print "dbg - dbg on|off"
print "exper - exper <N>"
print "stepim - stepim <N>"
print "stept - stept <Msecs>"
print "on - on STOP <command>"
print "rdt - rdt [<FILE>]"
print "diskdelay - diskdelay [ddelay[/wrddelay]] [start_cycle]"
print "time - time start | stop"
print "sync - on|off"
print "resume - back to prev sync mode"
print "alias - alias [<old cmd>] [<new cmd>] "
print "penable - penable [-all | <thN>]"
print "pdisable -pdisable [-all | <thN>]"
print "pty - pty"
"""
# simulator current version
def version ():
sam.ui_exec("version")
# quit sim
def quit ():
sam.ui_exec("quit");
# run <mode>
def run (mode=" "):
sam.ui_exec("run "+mode)
# stop sim
def stop ():
sam.ui_exec("stop")
# stepi [<ninstr>] [-t [cpuid]] [-o <file_name>]
def stepi (n=1,cpu=-1,file=" "):
cmd = "stepi "+str(n)
if cpu >= 0 :
cmd += " -t "+str(cpu)
if file != " " :
cmd += " -o "+file
sam.ui_exec(cmd)
# read mem from physical start_addr, Size bytes
def mem (start_addr=0,size=8):
cmd = "mem -a "+str(start_addr)+" -s "+str(size)
sam.ui_exec(cmd)
# read mem from virtual start_addr, Size bytes
def mem_va (start_addr=0,size=8):
cmd = "mem -a "+str(start_addr)+" -s "+str(size)+" -va"
sam.ui_exec(cmd)
# disassemble mem from virtual start_addr, Size bytes
def mem_va_dis (start_addr=0,size=8):
cmd = "mem -a "+str(start_addr)+" -s "+str(size)+" -va -dis"
sam.ui_exec(cmd)
# disassemble mem from physical start_addr, Size bytes
def mem_dis (start_addr=0,size=8):
cmd = "mem -a "+str(start_addr)+" -s "+str(size)+" -dis"
sam.ui_exec(cmd)
# conf <name> <value>
def conf (arg=" "):
sam.ui_exec("conf "+arg)
# write word <value> <paddr>
def write (value,addr):
cmd = "write word "+str(value)+" "+str(addr)
sam.ui_exec(cmd)
# setreg <regname> <value>
def setreg (regname,value):
cmd = "setreg "+regname+" "+str(value)
sam.ui_exec(cmd)
# help <command>
def sam_help (command=" "):
sam.ui_exec("help "+command);
# display current pc values
def pc ():
sam.ui_exec("pc")
# display cpu global regs
def rg (cpu= 0, gl = -1):
cmd = "r -cpu "+str(cpu)+" -g "+str(gl)
sam.ui_exec(cmd)
# display windowed regs
def rw (cpu= 0, wp = -1):
cmd = "r -cpu "+str(cpu)+" -w "+str(wp)
sam.ui_exec(cmd)
# display trap regs
def rtr (cpu= 0, tl = -1):
cmd = "r -cpu "+str(cpu)+" -w "+str(tl)
sam.ui_exec(cmd)
# display floating point regs
def rfp (cpu= 0):
cmd = "r -cpu "+str(cpu)+" -f"
sam.ui_exec(cmd)
# display double floating point regs
def rdf (cpu= 0):
cmd = "r -cpu "+str(cpu)+" -df"
sam.ui_exec(cmd)
# display proc regs
def rpr (cpu= 0):
cmd = "r -cpu "+str(cpu)+" -pr"
sam.ui_exec(cmd)
# display asr regs
def rasr (cpu= 0):
cmd = "r -cpu "+str(cpu)+" -asr"
sam.ui_exec(cmd)
# display hypervisor regs
def rhpr (cpu= 0):
cmd = "r -cpu "+str(cpu)+" -hpr"
sam.ui_exec(cmd)
# mips log on/off
def mips (mode):
cmd = "mips "+str(mode)
sam.ui_exec(cmd)
# set a breakpoint on pc value
def break_pc (pc, cpu = 0):
cmd = "break cpu="+str(cpu)+" pc="+str(pc)
sam.ui_exec(cmd)
# set a breakpoint on opcode value
def break_opcode (opcode, cpu = 0):
cmd = "break cpu="+str(cpu)+" opcode="+str(opcode)
sam.ui_exec(cmd)
# list breakpoints
def bplist ():
cmd = "break ?"
sam.ui_exec(cmd)
# delete a breakpoint
def dbreak (bp_id="all", cpu="all"):
cmd = "dbreak cpu="+str(cpu)
if bp_id != "all" :
cmd += " bp_id="+str(bp_id)
sam.ui_exec(cmd)