e7a0e5c8b5eeedca368e07ae3cf69faa24dacac4
# ========== Copyright Header Begin ==========================================
# OpenSPARC T2 Processor File: Pfe_Shell.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 ============================================
from optparse
import OptionParser
, Option
, OptionValueError
from Pfe_Slicer
import Slicer
histfile
= os
.path
.join(os
.environ
["HOME"],name
)
readline
.read_history_file(histfile
)
atexit
.register(readline
.write_history_file
, histfile
)
def check_slice(option
,opt
,value
):
for s
in value
.split(','):
eval('slice('+join(s
.split(':'),',')+')')
except NameError, ValueError:
raise OptionValueError("option %s: invalid slice: %r" % (opt
, value
))
class SliceOption (Option
):
TYPES
= Option
.TYPES
+ ("slice",)
TYPE_CHECKER
= copy(Option
.TYPE_CHECKER
)
TYPE_CHECKER
["slice"] = check_slice
args
= [] # The script files to execute
argv
= [] # The arguments after --
argv_parser
= OptionParser(usage
="usage: "+prog
+" [options]",
version
=Pfe_Version
.version(),
option_class
=SliceOption
)
argv_parser
.disable_interspersed_args()
action
="store_true",dest
="interactive",default
=False,
help="switch to interactive (inspect) mode")
#action="append",type="string",dest="file",default=[],
#metavar="FILE",help="load one or more elf or memory image files")
action
="store_true",dest
="lstmode",default
=False,
help="switch to lstmode, default is runmode")
#action="store",type="int",dest="steps",
#metavar="STEPS",help="step the simulator STEPS instructions per strand")
#action="store",type="slice",dest="available",default="0",
#metavar="SLICE",help="CMP: Make the SLICE of strands available for stepping (default=0)")
#action="store",type="slice",dest="enable",default="0",
#metavar="SLICE",help="CMP: Set the SLICE of strands to enabled for stepping (default=0)")
#action="store",type="slice",dest="running",default="0",
#metavar="SLICE",help="CMP: Put the SLICE of strands in running mode for stepping (default=0)")
#action="store",type="slice",dest="stepping",default="0",
#metavar="SLICE",help="Enable the SLICE of strands for stepping (default=0)")
(opts
,args_argv
) = argv_parser
.parse_args()
# Split the file arguments around the '--' if it is present.
# There is one problem "-- no pyfile" fails, while
# "pyfile -- no pyfile" succeeds. Awel, that;'s not a big
# issue as anything after '--' is means for the pyfile anyways.
#for strand in eval('Slicer(sim.s)['+opts.available+']'):
#for strand in eval('Slicer(sim.s)['+opts.enable+']'):
#for strand in eval('Slicer(sim.s)['+opts.running+']'):
#for strand in eval('Slicer(sim.s)['+opts.stepping+']'):
strand
.lstmode(opts
.lstmode
and 1 or 0)
if opts
.interactive
or len(args
) == 0:
os
.environ
['PYTHONINSPECT'] = 'x'