Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | #!/bin/sh |
2 | ||
3 | tool=$0 | |
4 | ||
5 | usage() | |
6 | { | |
7 | echo "" | |
8 | echo "usage: `/bin/basename $tool` -s <sam start method> <installdir>" | |
9 | echo "" | |
10 | echo ' -s <sam start method> : td(traditonal) for "$build/bin/sam -c $RC -R $ckpt"' | |
11 | echo ' sb(simulate boot) for "$build/bin/simulate -p n2 -s -Dpop= -c $RC -I system.rc"' | |
12 | echo ' sr(simulate restore) for "$build/bin/simulate -Dpop= -R $ckpt"' | |
13 | echo "" | |
14 | echo " Get the start.ver file with the specified 'sam start method' and put it in directory <installdir>." | |
15 | echo "" | |
16 | } | |
17 | ||
18 | ||
19 | while getopts hs: OPT; do | |
20 | case $OPT in | |
21 | s) | |
22 | startmethod="$OPTARG" | |
23 | ;; | |
24 | h) | |
25 | usage | |
26 | exit 0 | |
27 | ;; | |
28 | *) | |
29 | usage | |
30 | exit 2 | |
31 | ;; | |
32 | esac | |
33 | done | |
34 | ||
35 | shift `/bin/expr $OPTIND - 1` | |
36 | ||
37 | if [ "$startmethod" = " " ]; then | |
38 | echo "Error: I need one -s argument." | |
39 | usage | |
40 | exit 2 | |
41 | fi | |
42 | ||
43 | installfile=$1/start.ver | |
44 | ||
45 | cat >$installfile <<EOF | |
46 | timeout 600 | |
47 | ||
48 | expect | |
49 | set build [lindex \$argv 0] | |
50 | set RC [lindex \$argv 1] | |
51 | set ckpt [lindex \$argv 2] | |
52 | end_expect | |
53 | ||
54 | EOF | |
55 | ||
56 | case $startmethod in | |
57 | td) | |
58 | echo 'open SAM "$build/bin/sam -c $RC -R $ckpt"' >>$installfile | |
59 | ;; | |
60 | sb) | |
61 | echo 'open SAM "$build/bin/simulate -p n2 -s -Dpop= -c $RC -I system.rc"' >>$installfile | |
62 | ;; | |
63 | sr) | |
64 | echo 'open SAM "$build/bin/simulate -Dpop= -R $ckpt"' >>$installfile | |
65 | ;; | |
66 | *) | |
67 | usage | |
68 | exit 2 | |
69 | ;; | |
70 | esac | |
71 | ||
72 | cat >>$installfile <<EOF | |
73 | log_user SAM 1 | |
74 | ||
75 | pattern SAM "(guest|hyper)\[^\r]* /dev/(\[^\r]*)\r\n" | |
76 | if { "\$expect_out(1,string)" == "guest" } { | |
77 | set guest_tty "/dev/\$expect_out(2,string)" | |
78 | } elseif { "\$expect_out(1,string)" == "hyper" } { | |
79 | set hyper_tty "/dev/\$expect_out(2,string)" | |
80 | } else { | |
81 | send_error "Bad tty parse: \$expect_out(1,string)\n" | |
82 | exit 2 | |
83 | } | |
84 | exp_continue | |
85 | end_pattern SAM | |
86 | ||
87 | set_prompt SAM 'stop: |sam>>> ' | |
88 | wait_prompt SAM | |
89 | clear SAM patterns | |
90 | ||
91 | open HYPER "-noecho /usr/bin/tip \$hyper_tty" | |
92 | log_user HYPER 0 | |
93 | open GUEST "-noecho /usr/bin/tip \$guest_tty" | |
94 | log_user GUEST 0 | |
95 | ||
96 | error HYPER "\[Pp]anic" | |
97 | error GUEST "\[Pp]anic" | |
98 | EOF |