# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: sam.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 ============================================
### startup file for py interpreter
# get the system type defitions from vcpu.h
VCPU_IMPL_VER_SPITFIRE
= 0x00001000
VCPU_IMPL_VER_SPITFIRE
= 0x00001000
VCPU_IMPL_VER_BLACKBIRD
= 0x00001100
VCPU_IMPL_VER_SABRE
= 0x00001200
VCPU_IMPL_VER_SAPPHIRE
= 0x00001300
VCPU_IMPL_VER_CHEETAH
= 0x00001400
VCPU_IMPL_VER_CHPLUS
= 0x00001500
VCPU_IMPL_VER_SUN4U
= 0x00001000
VCPU_IMPL_VER_N1
= 0x00002300
VCPU_IMPL_VER_N2
= 0x00002410
VCPU_IMPL_VER_SUN4V
= 0x00002000
VCPU_IMPL_VER_MASK
= 0x00ffffff
VCPU_IMPL_SIM_BLAZE
= 0x01000000
VCPU_IMPL_SIM_RIESLING
= 0x02000000
VCPU_IMPL_SIM_VONK
= 0x03000000
VCPU_IMPL_SIM_MASK
= 0xff000000
sys_type
= sam
.sys_type()
# Vonk PFE stuff, only for N2, and others of the ilk
# Mask out the upper 8 bits
if (sys_type
& SAM_SysType
.VCPU_IMPL_VER_MASK
) >= SAM_SysType
.VCPU_IMPL_VER_N2
:
class SAM_Memory(Pfe_Memory
.Memory
):
Pfe_Memory
.Memory
.__init
__(self
)
def load(self
,filename
,base
=None):
sam
.ui_exec('load img '+filename
)
sam
.ui_exec('load bin '+filename
+' '+str(base
))
def save(self
,filename
,base
,size
):
sam
.ui_exec('memdump '+filename
+' '+str(base
)+' '+str(size
))
def __ldb__(self
,addr
): return sam
.mem_ld8(addr
)
def __ldh__(self
,addr
): return sam
.mem_ld16(addr
)
def __ldw__(self
,addr
): return sam
.mem_ld32(addr
)
def __ldx__(self
,addr
): return sam
.mem_ld64(addr
)
def __stb__(self
,addr
,data
): sam
.mem_st8(addr
,data
)
def __sth__(self
,addr
,data
): sam
.mem_st16(addr
,data
)
def __stw__(self
,addr
,data
): sam
.mem_st32(addr
,data
)
def __stx__(self
,addr
,data
): sam
.mem_st64(addr
,data
)
SAM_Model_Instance
= None
if sys_type
== SAM_SysType
.VCPU_IMPL_VER_N2
:
SAM_Python
= __import__('N2_Python')
SAM_Model
= __import__('N2_Model')
SAM_Model_Instance
= SAM_Python
.n2_model
sim
= SAM_Model
.Model(SAM_Memory(),SS_Io
.Io(SAM_Python
.get_io()),SAM_Model_Instance(sam
.sys_pntr(0)))
elif sys_type
== SAM_SysType
.VCPU_IMPL_VER_RK
:
SAM_Python
= __import__('Rk_Python')
SAM_Model
= __import__('Rk_Model')
SAM_Model_Instance
= SAM_Python
.rk_model
sim
= SAM_Model
.Model(SAM_Memory(),SAM_Model_Instance(sam
.sys_pntr(0)))
# import some functions from SAM_Model
decmode
= SAM_Model
.decmode
hexmode
= SAM_Model
.hexmode
# Import the SAM UI functions, they can be overridden by
cmd_dict
= sam
.get_cmd_dict()
for cmd
in cmd_dict
.keys():
exec('sam.'+cmd
+' = sam_'+cmd
)
# Define the add/delete UI functions
str = "def sam_%s(args=\"\"):\n" % (cmd
,)
str = str + " \"\"\"%s\n" % (help,)
str = str + " sam.ui_exec(\"%s \" + args)" % (cmd
,)
exec('sam.'+cmd
+' = sam_'+cmd
)
# register the command add and delete functions with sam
sam
.set_cmd_del_fn(del_ui
)
sam
.set_cmd_add_fn(add_ui
)