Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / bin / nas
CommitLineData
86530b38
AT
1#! /bin/sh
2#
3# nas
4#
5# Cloned from .common_tool_wrapper
6
7loginfo () {
8 echo "DATE: "`date`
9 echo "WRAPPER: /import/$TRE_PROJECT/exe/.ccad_tool_wrapper"
10 echo "USER: $user"
11 echo "HOST: "`uname -n`
12 echo "SYS: "`uname -s` `uname -r`
13 echo "PWD: "`pwd`
14 echo "ARGV: "$ARGV
15 echo "TOOL: "$tool
16 echo "VERSION: "$version
17 echo "TRE_SEARCH: "$TRE_SEARCH
18 echo "TRE_ENTRY: "$TRE_ENTRY
19}
20
21mailinfo () {
22 echo To: $1
23 echo Subject: TRE_LOG
24 echo "#"
25 loginfo
26}
27
28mailerr () {
29 echo "To: $1"
30 echo "Subject: TRE ERROR"
31 echo "#"
32 echo "ERROR: $2"
33 loginfo
34}
35
36log () {
37 # Log to TRE_LOG if it is set properly.
38 # It is STRONGLY recommended that TRE_LOG be an e-mail address
39 # in order to avoid problems with several people simultanously
40 # writing to the same file.
41 # TRE_LOG must be set, but it can be broken.
42 # TRE_ULOG is optional, for users who want their own logging.
43
44 if [ ! -z "$TRE_LOG_ENABLED" -a ! -z "$TRE_LOG" ] ; then
45 # Check first if TRE_LOG is a file (this is cheap).
46 if [ -f $TRE_LOG -a -w $TRE_LOG ] ; then
47 echo "#" >> $TRE_LOG
48 loginfo >> $TRE_LOG
49 elif /usr/lib/sendmail -bv $TRE_LOG 1>&- 2>&- ; then
50 mailinfo $TRE_LOG | /usr/lib/sendmail $TRE_LOG
51 else
52 mailerr $user "Can't log to TRE_LOG=$TRE_LOG. Fix environment." | /usr/lib/sendmail $user
53 fi
54 #else
55 # die "TRE_LOG environment variable is not set."
56 fi
57 # TRE_ULOG is optional user log. EMAIL address is recommended.
58 if [ ! -z "$TRE_ULOG" ] ; then
59 # Check first if TRE_ULOG is a file (this is cheap).
60 if [ -f $TRE_ULOG -a -w $TRE_ULOG ] ; then
61 echo "#" >> $TRE_ULOG
62 loginfo >> $TRE_ULOG
63 elif /usr/lib/sendmail -bv $TRE_ULOG 1>&- 2>&- ; then
64 mailinfo $TRE_ULOG | /usr/lib/sendmail $TRE_ULOG
65 else
66 mailerr $user "Can't log to TRE_ULOG=$TRE_ULOG. Fix environment." | /usr/lib/sendmail $user
67 fi
68 fi
69}
70
71die () {
72 message="$1"
73 echo "$tool -> .ccad_tool_wrapper: $message Exiting ..."
74 if [ ! -z "$TRE_LOG" ] ; then
75 if [ -f ${TRE_LOG} -a -w ${TRE_LOG} ] ; then
76 echo "#" >> $TRE_LOG
77 echo "ERROR: $message" >> $TRE_LOG
78 loginfo >> $TRE_LOG
79 elif /usr/lib/sendmail -bv $TRE_LOG 1>&- 2>&- ; then
80 mailerr $TRE_LOG "$message" | /usr/lib/sendmail $TRE_LOG
81 else
82 echo "Can not log to TRE_LOG=${TRE_LOG}. Logging to '$user.'"
83 mailerr $user "$message" | /usr/lib/sendmail $user
84 fi
85 fi
86 # TRE_ULOG is optional user log. EMAIL address is recommended.
87 if [ ! -z "$TRE_ULOG" ] ; then
88 if [ -f ${TRE_ULOG} -a -w ${TRE_ULOG} ] ; then
89 echo "#" >> $TRE_ULOG
90 echo "ERROR: $message" >> $TRE_ULOG
91 loginfo >> $TRE_ULOG
92 elif /usr/lib/sendmail -bv $TRE_ULOG 1>&- 2>&- ; then
93 mailerr $TRE_ULOG "$message" | /usr/lib/sendmail $TRE_ULOG
94 else
95 echo "Can not log to TRE_ULOG=${TRE_ULOG}. Logging to '$user.'"
96 mailerr $user "$message" | /usr/lib/sendmail $user
97 fi
98 fi
99 exit 1
100}
101
102############################ main ##############################
103
104tool=`basename $0`
105ARGV="$*"
106export tool
107
108TRE_ROOT=$DV_ROOT/tools/src
109export TRE_ROOT
110
111### Verify TRE_SEARCH and TRE_ENTRY are defined and non-null
112
113if [ -z "$TRE_SEARCH" ]; then
114 die "TRE_SEARCH not defined"
115fi
116if [ -z "$TRE_ENTRY" ]; then
117 die "TRE_ENTRY not defined"
118fi
119
120### Get version, based on tool invoked, and $TRE_ENTRY
121
122version=`configsrch $tool $TRE_ENTRY`
123if [ $? != 0 ] ; then
124 die "configsrch returned error code!"
125fi
126export version
127
128### Verify configsrch delivered a non-null version
129
130if [ -z "$version" ]; then
131 die "No version set by configsrch"
132fi
133
134 LD_LIBRARY_PATH=$TRE_ROOT/$tool,$version/lib:$LD_LIBRARY_PATH
135 export LD_LIBRARY_PATH
136 LD_LIBRARY_PATH_64=$TRE_ROOT/$tool,$version/lib:$LD_LIBRARY_PATH_64
137 export LD_LIBRARY_PATH_64
138
139 PYTHONPATH=$TRE_ROOT/$tool,$version/lib/:$TRE_ROOT/$tool,$version/lib/riesling:$PYTHONPATH
140 export PYTHONPATH
141
142 echo "----- Simulation running with riesling for OpenSparc T2----- "
143OS=`uname -s`
144if [ $OS = "SunOS" ] ; then
145 exe="$TRE_ROOT/$tool,$version/bin/start-riesling -x diag.simics -s $TRE_ROOT/$tool,$version/home/common/common.conf"
146fi
147if [ $OS = "Linux" ]; then
148 exe="$TRE_ROOT/$tool,$version/bin/start-riesling.LINUX -x diag.simics -s $TRE_ROOT/$tool,$version/home/common/common.conf"
149fi
150 echo $exe
151
152 if [ -x $exe ]; then
153 log
154 exec $exe $ARGV
155 else
156 die "$tool: executable not found!"
157 fi