3 # Script for running PROMs and LINUX kernwls on medusa.
4 # Type "sim -H" for instructions.
6 MEDUSA=${MEDUSA:-/home/rickc/official_medusa/medusa}
8 # ------------------ err -----------------------
14 # ---------------- help ----------------------
17 Script for running a PROM or LINUX kernel under medusa.
18 This script creates a control file, creates links to the appropriate
19 linux/prom files, and/or calls medusa to make simulation runs.
23 sim [-c <config_file>] <-p> | <-k> [<work_dir>]
24 -p Create PROM control file & links
25 -k Create LINUX control file & links
26 -c<cf> Control file name [Default: cf]
27 <work_dir> Path to directory that contains the linux or PROM files.
28 The directory can be any of the following:
32 any directory with vmlinux, vmlinux.sym & fprom files
35 worktree/stand/arcs/IP37prom/dev
36 any directory with fw.bin & fw.sim files
39 sim [-X <n>] [-o <output>] [-M] [<config_file>]
40 -c<cf> Control file name [Default: cf]
41 -M Pipe output thru fmtmedusa
42 -o Output filename (copy of all commands/output) [Default: simout]
43 -X Specifies number of instructions to execute [Default: 0]
44 (Used only in auto test mode - not described here)
47 sim -p <promtree> # create control file (cf) & links for prom simulations
48 sim -k <linuxtree> # create control file (cf) & links for linux simulations
49 sim -p -c cfprom # create a prom control file (cfprom) only. No links are made.
51 sim # run medusa using previously created links &
57 # ----------------------- create control file header --------------------
61 # Template for a control file for running linux kernels under medusa.
62 # You probably want to make mods here but this is a good starting point.
67 setenv exceptionPrint off
68 setenv interrupt_messages off
69 setenv lastPCsize 100000
70 setenv low_power_mode on
71 setenv partialIntelChipSet on
72 setenv printIntelMessages off
73 setenv prom_write_action halt
74 setenv prom_write_messages on
75 setenv step_quantum 100
82 setenv diskCylinders 611
85 setenv diskPath idedisk
90 setenv coherency_type nasid
91 setenv cpu_cache_type default
92 setenv synergy_cache_type syn_cac_64m_8w
93 setenv l4_uc_snoop off
96 setenv route_enable on
97 setenv network_type router # Select [xbar|router]
98 setenv network_warning 0xff
104 # ------------------ create control file entries for linux simulations -------------
107 # Kernel specific options
109 setenv mca_on_memory_failure off
110 setenv LOADPC 0x00100000 # FPROM load address/entry point (8 digits!)
111 setenv symbol_table vmlinux.sym
115 # Useful breakpoints to always have set. Add more if desired.
116 break 0xe000000000505e00 all # dispatch_to_fault_handler
117 break panic all # stop on panic
118 break die_if_kernel all # may as well stop
123 # ------------------ create control file entries for prom simulations ---------------
126 ADDR="0x80000000ff800000"
127 [ "$EMBEDDED_LINUX" != "0" ] || SYM2="setenv symbol_table2 vmlinux.sym"
128 [ "$SIZE" = "8MB" ] || ADDR="0x80000000ffc00000"
130 # PROM specific options
131 setenv mca_on_memory_failure on
132 setenv LOADPC 0x80000000ffffffb0
133 setenv promFile fw.bin
134 setenv promAddr $ADDR
135 setenv symbol_table fw.sym
138 # Useful breakpoints to always have set. Add more if desired.
141 break PROM_Panic_Spin all
143 break PROM_C_Panic all
152 # ------------------ create control file entries for memory configuration -------------
155 # CPU/Memory map format:
156 # setenv nodeN_memory_config 0xBSBSBSBS
157 # B=banksize (0=unused, 1=64M, 2=128M, .., 5-1G, c=8M, d=16M, e=32M)
158 # S=bank enable (0=both disable, 3=both enable, 2=bank1 enable, 1=bank0 enable)
159 # rightmost digits are for bank 0, the lowest address.
160 # setenv nodeN_nasid <nasid>
161 # specifies the NASID for the node. This is used ONLY if booting the kernel.
162 # On PROM configurations, set to 0 - PROM will change it later.
163 # setenv nodeN_cpu_config <cpu_mask>
164 # Set bit number N to 1 to enable cpu N. Ex., a value of 5 enables cpu 0 & 2.
166 # Repeat the above 3 commands for each node.
168 # For kernel, default to 32MB. Although this is not a valid hardware configuration,
169 # it runs faster on medusa. For PROM, 64MB is smallest allowed value.
171 setenv node0_cpu_config 0x1 # Enable only cpu 0 on the node
174 if [ $LINUX -eq 1 ] ; then
176 setenv node0_nasid 0 # cnode 0 has NASID 0
177 setenv node0_memory_config 0xe1 # 32MB
181 setenv node0_memory_config 0x31 # 256MB
186 # -------------------- set links to linux files -------------------------
188 if [ -d $D/linux/arch ] ; then
190 elif [ -d $D/arch -o -e vmlinux.sym -o -e $D/vmlinux ] ; then
193 err "cant determine directory for linux binaries"
195 rm -rf vmlinux vmlinux.sym fprom
196 ln -s $D/vmlinux vmlinux
197 if [ -f $D/vmlinux.sym ] ; then
198 ln -s $D/vmlinux.sym vmlinux.sym
199 elif [ -f $D/System.map ] ; then
200 ln -s $D/System.map vmlinux.sym
202 if [ -d $D/arch ] ; then
203 ln -s $D/arch/ia64/sn/fprom/fprom fprom
207 echo " .. Created links to linux files"
210 # -------------------- set links to prom files -------------------------
212 if [ -d $D/stand ] ; then
213 D=$D/stand/arcs/IP37prom/dev
214 elif [ -d $D/sal ] ; then
217 err "cant determine directory for PROM binaries"
221 sed 's/export/setenv/' < $D/../../../../.setup | sed 's/=/ /' >$SETUP
222 egrep -q '^ *setenv *PROMSIZE *8MB|^ *export' $SETUP
223 if [ $? -eq 0 ] ; then
228 grep -q '^ *setenv *LAUNCH_VMLINUX' $SETUP
230 PRODUCT=`grep '^ *setenv *PRODUCT' $SETUP | cut -d" " -f3`
231 rm -f fw.bin fw.map fw.sym vmlinux vmlinux.sym fprom $SETUP
232 SDIR="${PRODUCT}${SIZE}.O"
233 BIN="${PRODUCT}ip37prom${SIZE}"
234 ln -s $D/$SDIR/$BIN.bin fw.bin
235 ln -s $D/$SDIR/$BIN.map fw.map
236 ln -s $D/$SDIR/$BIN.sym fw.sym
237 echo " .. Created links to $SIZE prom files"
238 if [ $EMBEDDED_LINUX -eq 0 ] ; then
239 ln -s $D/linux/vmlinux vmlinux
240 ln -s $D/linux/vmlinux.sym vmlinux.sym
241 if [ -d linux/arch ] ; then
242 ln -s $D/linux/arch/ia64/sn/fprom/fprom fprom
244 ln -s $D/linux/fprom fprom
246 echo " .. Created links to embedded linux files in prom tree"
250 # --------------- start of shell script --------------------------------
257 while getopts "HMX:c:o:pk" c ; do
261 X) STEPCNT=${OPTARG};;
269 shift `expr ${OPTIND} - 1`
271 # Check if command is for creating control file and/or links to images.
272 if [ $PROM -eq 1 -o $LINUX -eq 1 ] ; then
274 [ ! -f $CF ] || err "wont overwrite an existing control file ($CF)"
275 if [ $# -gt 0 ] ; then
277 [ -d $D ] || err "cannot find directory $D"
278 [ $PROM -eq 0 ] || set_prom_links
279 [ $LINUX -eq 0 ] || set_linux_links
282 [ $PROM -eq 0 ] || create_cf_prom
283 [ $LINUX -eq 0 ] || create_cf_linux
284 [ ! -f ../idedisk ] || ln -s ../idedisk .
286 echo " .. Basic control file created (in $CF). You might want to edit"
287 echo " this file (at least, look at it)."
291 # Verify that the control file exists
293 [ -f $CF ] || err "No control file exists. For help, type: $0 -H"
295 # Build the .cf files from the user control file. The .cf file is
296 # identical except that the actual start & load addresses are inserted
297 # into the file. In addition, the FPROM commands for configuring memory
298 # and LIDs are generated.
302 function strtonum(n) {
303 if (substr(n,1,2) != "0x")
307 while (length(n) > 0) {
308 r = r*16+(index("0123456789abcdef", substr(n,1,1))-1)
315 /^setenv *LOADPC/ {loadpc = $3; next}
316 /^setenv *node.._cpu_config/ {n=int(substr($2,5,2)); cpuconf[n] = strtonum($3); print; next}
317 /^setenv *node.._memory_config/ {n=int(substr($2,5,2)); memconf[n] = strtonum($3); print; next}
318 /^setenv *node.._nasid/ {n=int(substr($2,5,2)); nasid[n] = strtonum($3); print; next}
319 /^setenv *node._cpu_config/ {n=int(substr($2,5,1)); cpuconf[n] = strtonum($3); print; next}
320 /^setenv *node._memory_config/ {n=int(substr($2,5,1)); memconf[n] = strtonum($3); print; next}
321 /^setenv *node._nasid/ {n=int(substr($2,5,1)); nasid[n] = strtonum($3); print; next}
324 # Generate the memmap info that starts at the beginning of
325 # the node the kernel was loaded on.
328 for (i=0; i<128; i++) {
329 if (memconf[i] != "") {
330 printf "sm 0x%x%08x 0x%x%04x%04x\n",
331 2*loadnasid, 8*cnodes+8, memconf[i], cpuconf[i], nasid[i]
333 cpus += substr("0112122312232334", cpuconf[i]+1,1)
336 printf "sm 0x%x00000000 0x%x%08x\n", 2*loadnasid, cnodes, cpus
337 printf "setenv number_of_nodes %d\n", cnodes
339 # Now set the starting PC for each cpu.
342 for (i=0; i<128; i++) {
343 if (memconf[i] != "") {
344 printf "setnode %d\n", cnode
346 for (j=0; j<4; j++) {
347 if (conf != int(conf/2)*2) {
348 printf "setcpu %d\n", j
349 if (length(loadpc) == 18)
350 printf "sr pc %s\n", loadpc
352 printf "sr pc 0x%x%s\n", 2*loadnasid, substr(loadpc,3)
362 printf "setcpu %d\n", lowcpu
366 # Now build the .cf1 & .cf2 control files.
367 CF2_LINES="^sm |^break |^run |^si |^quit |^symbols "
368 egrep "$CF2_LINES" .cf >.cf2
369 egrep -v "$CF2_LINES" .cf >.cf1
370 if [ $STEPCNT -ne 0 ] ; then
371 echo "s $STEPCNT" >>.cf2
372 echo "lastpc 1000" >>.cf2
375 if [ -f vmlinux.sym ] ; then
376 awk '/ _start$/ {print "sr g 9 0x" $3}' < vmlinux.sym >> .cf2
378 echo "script-on $OUT" >>.cf2
380 # Now start medusa....
381 if [ $FMTMED -ne 0 ] ; then
382 $MEDUSA -system mpsn1 -c .cf1 -i .cf2 | fmtmedusa
383 elif [ $STEPCNT -eq 0 ] ; then
384 $MEDUSA -system mpsn1 -c .cf1 -i .cf2
386 $MEDUSA -system mpsn1 -c .cf1 -i .cf2 2>&1