# Each time the API changes we bump version by one
echo "usage: `/bin/basename $tool` [-p <processor>] [-c <config>] [-w <workers>] [-s|-r|-d|-R <chkpnt>] [-f <cmd_file> ...] [-a][-v] [-C <system>] [-L <image>] ..."
echo " -p <processor> : Create sam.rc file and run sam on processor <processor>"
echo " -c <config> : Configuration: config is say 1up, 1g2p, 1g4p, 1g8p, 1g16p, or 1g32p, etc"
echo " -w <workers> : Number of worker threads, default is 1"
echo " -s : Boot Solaris"
echo " -R <chkpnt> : Restore from checkpoint <chkpnt>"
echo " -f <cmd_file> : Pass -f <cmd_file> to sam"
echo " -a : Auto boot OBP (Solaris boot only): expects nvram1-auto file"
echo " -v : Boot solaris in verbose mode (more printfs to console): expects disk1.verbose"
echo " -I <system> : Include rc file <system> in the setup."
echo " -C <system> : Provide user version of system part of rc file (for advanced users)"
echo " -L <image> : Load <image> into memory. Image can be file,addr for binary or file for image format"
echo " -D <define> : Add m4 style define to control the rc file"
echo " -l <log_file> : Turn on sam output logging to file <log_file>"
# reserse returns the reverse of the argument list
while [ "$xs" != "" ]; do
# nibble2list(base,nibble) takes a hex nibble and returns
# a list of set bits. The bit numbers reported start from base.
7) list
="$bit0 $bit1 $bit2" ;;
a|A
) list
="$bit1 $bit3" ;;
b|B
) list
="$bit0 $bit1 $bit3" ;;
c|C
) list
="$bit2 $bit3" ;;
d|D
) list
="$bit0 $bit2 $bit3" ;;
e|E
) list
="$bit1 $bit2 $bit3" ;;
f|F
) list
="$bit0 $bit1 $bit2 $bit3" ;;
# bitset(mask) takes a hex value mask (no 0x prefix) and converts
# it into a list of set bits.
# First it turns mask into a list of nibbles: 12af => "1 2 a f ".
# Then it reverses the list of nibbles so nibble 0 (bit 0) is first.
# Next it turns the nibbles into bit lists and joins them.
xs
=$
(echo "$1" |
/bin
/sed -e 's/_//g' |
/bin
/sed -e 's/\(.\)/\1 /g')
while [ "$xs" != "" ]; do
bs
="$bs $(nibble2list $bv $hd)"
# Check we are on a USIII or above machine
isa
=$
(/bin
/isalist |
/usr
/xpg
4/bin
/grep -e 'sparcv9+vis2' -e 'amd64')
err
"need isa sparcv9+vis2 or above or amd64"
# In case of softlink follow the softlink back to the real binary.
# If people copy the binary out of the release then tough, don't do that.
sambin
=$
(/bin
/dirname $sam)
samexe
=$
(/bin
/ls -l $sam |
/bin
/awk '{print $11}')
while [ "$samexe" != "" ]; do
sambin
=$
(/bin
/dirname $sam)
samexe
=$
(/bin
/ls -l $sam |
/bin
/awk '{print $11}')
# Do a quick sanity check on the sambin location
if [ ! -x $sambin/sam
]; then
err
"$0 is not a link to proper release of SAM"
# Look for .simulate.sh script to feed info to wizard .
# .simulate.sh is part of the set of binaries that is
# obtained with getsolaris.
[ -r .simulate.sh
] && . .
/.simulate.sh
default_processor
=${processor:-}
require
=${require:-20070101}
virtual
=${virtual:-/bin/true} # false when scsi boot disk ...
# The simulate wizard protects itself from having to be
# compatible with future releases of solaris.
# This next line should compare $require against D A T E (w/o spaces)
# and not a actual timestamp. The timestamp will be inserted during
# the build/installation process.
if (($require > 20080105)); then
err
"Use simulate that has been build or released after $require"
# Parse the commandline options
while getopts p
:c
:w
:srdf
:avR
:C
:L
:I
:D
:Yl
: OPT
; do
if [ "$processor" != "" ]; then
err
"I'm confused, you already specified -p$processor"
validint
=$
(echo $workers |
/bin
/tr -d '[0-9]*')
if [ ! -z $validint ]; then
err
"$workers is not an integer: -w requires an integer argument"
cmd_files
="$cmd_files -f $OPTARG"
if [ "$boot" != "" ]; then
err
"I'm confused, you already specified $boot"
if [ "$boot" != "" ]; then
err
"I'm confused, you already specified $boot"
loadextra
="$loadextra $OPTARG"
if [ "$boot" != "" ]; then
err
"I'm confused, you already specified $boot"
defines
="$defines -D$OPTARG"
includes
="$includes $OPTARG"
if [ "$log_file" != "" ]; then
echo "Error: I'm confused, you already specified $log_file"
# Policy for solaris is that we need .simulate.sh
# For restore and diag modes we don't require it.
if [ ! -r .simulate.sh
]; then
err
"Cannot find .simulate.sh. Refresh your workarea with getsolaris."
# Check .simulate.sh again and exits if not there
# and we're not doing diag work
if [ ! -f .simulate.sh
]; then
echo "Error: the file .simulate.sh is missing"
echo "Please refresh your workarea with getsolaris"
# Make sure we have a processor to work with. Take into
# account the default we get from the .simulate.sh
if [ "$processor" = "" ]; then
processor
=$default_processor
if [ "$processor" = "" ]; then
err_usage
"I need exactly one -p argument."
if [ "$processor" != "$default_processor" -a "$default_processor" != "" ]; then
err_usage
"Default processor $default_processor and user specified processor $processor are conflicting."
# Now check that the selected processor is actually
# supported and part of the package used
if [ ! -r $sambin/..
/lib
/libriesling_
${processor}_vcpu.so
]; then
err
"Processor '$processor' is not supported in the SAM package you use"
# Check for existing system part rc file
if [ "$rcfile" = "" ]; then
rcfile
=$sambin/..
/etc
/${processor}.rc
if [ ! -r $rcfile ]; then
err
"Can not find user defined system rc file: '$rcfile'"
if [ "$restore" = "" ]; then
if [ "$boot" = "" ]; then
if [ "$boot" = "" ]; then
err_usage
"Expect -s, -r, -d, or -R option."
if [ "$boot" != "$default_boot" -a "$default_boot" != "" ]; then
err_usage
"Default boot $default_boot and user specified boot $boot are conflicting."
if [ "$(len $config)" != "1" ]; then
err_usage
"I need exactly one -c argument."
# Any remaining arguments are passed to the python interpreter
if [ "$arg" != "" ]; then
# Check that the configurarion is valid for the processor
# Each processor has it's own set of recognized configs and
# they are kept in $SAM/etc/${processor}/cfg .
strand_mask
=$
(/bin
/grep "^$config" $sambin/..
/etc
/${processor}.cfg |
/bin
/awk '{print $2}')
if [ "$strand_mask" = "" ]; then
if [ "$restore" = "" ]; then
err_usage
"Configuration -c $config unknown"
while [ "$bs" != "" ]; do
echo "sysconf cpu name=s$nr id=$nr cpu-type=riesling_${processor}_vcpu clock-frequency=ifdef(\`STICK_FREQ',STICK_FREQ,0x400000)"
# node_defs(strands_per_node,strand_mask) creates a list of
# defines -DNODE1 -DNODE2 ... one for each node that is required.
while [ "$bs" != "" ]; do
if [ $nr -ge $max_strands ] ; then
max_strands
=$
(($max_strands + $1))
if [ "$restore" = "" ]; then
# For solaris we have nvram that handles autoboot
# Alse select the main image to boot: solaris.
defines
="-DSOLARIS $defines"
if [ "$processor" = "xx" ]; then
files
="reset.bin q.bin openboot.bin $sram $hv_bin $md_bin $nvram1 $image"
defines
="-DDIAG $defines"
# Do some legwork to make sure we have no missing files
err
"Error: missing file: $f"
err
"Error: missing include file: $f"
if [ "$loadextra" != "" ]; then
err
"Error: missing file: $name"
# Generate the defines to enable multi node parts in rc files
defines
="$defines $(node_defs $strands_per_node $strand_mask)"
# Generate the sam.rc file
echo "# sam.rc generated by: $command_line"
echo "conf ramsize 1M" # Need this ?!?
echo "conf stickfreq ifdef(\`STICK_FREQ',STICK_FREQ,$stickfreq)"
echo "conf numthreads $workers"
generate_strands
$strand_mask
echo "load bin reset.bin BASE_RESET_BIN"
echo "load bin q.bin BASE_Q_BIN"
echo "load bin openboot.bin BASE_OPENBOOT_BIN"
echo "load bin $nvram1 BASE_NVRAM1"
echo "load bin $md_bin BASE_MD_BIN"
echo "load bin $hv_bin BASE_HV_BIN"
echo "load bin $disk1 BASE_DISK1"
# Generate the extra files to load: we accept name,addr
# as binary. If addr is blank: name, or if the comma is
# not present then load name as an image.
if [ "$loadextra" != "" ]; then
if [ "$f" = "$addr" -o "$addr" = "" ]; then
echo "load bin $name $addr"
# Now include all the user defined rc files extensions
# in the order given on the command line
# Generate the rc-file entries for our frontend
# If a file ${config}.py exists then we will assume that that
# file contains tweaks to make the particulare config work proper.
|
/usr
/ccs
/bin
/m4 $defines > sam.rc
# Grab the dumped rc file
# Now include all the user defined rc files extensions
# in the order given on the command line
|
/usr
/ccs
/bin
/m4 $defines > sam.rc
$PFEPRE $sambin/sam
$restore -c sam.rc
$cmd_files $log_file -py $arg