1
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
4
# This file is part of DejaGnu.
6
# DejaGnu is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# DejaGnu is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with DejaGnu; if not, write to the Free Software Foundation,
18
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
# This file was originally written by Rob Savoye. (rob@welcomehome.org)
21
# and modified by Bob Manson (manson@cygnus.com)
24
# Try to boot the machine into the requested OS.
26
proc ${board}_init { dest } {
27
# This is not the right way to determine the required OS...
29
set shell_prompt [board_info $dest shell_prompt]
32
set desired_kernel [board_info $dest "kernel,$target_os"]
34
if { $desired_kernel == "" } {
35
vxworks_final_init $dest
36
# Nothing to see here, nothing to do. Move along.
40
remote_raw_open $dest raw
41
remote_send $dest "\n"
42
remote_expect $dest 5 {
46
-re "Press any key to stop auto-boot" {
47
remote_send $dest "\n"
52
set boot_mon_prompt "VxWorks Boot"
54
-re "\[0-9\]\[\r\n\]+ *\[0-9\]\[\r\n\]" {
55
remote_send $dest "\n"
69
remote_send $dest "\n\n"
70
remote_expect $dest 3 {
72
-re ".+" { exp_continue }
74
remote_send $dest "p\n"
75
remote_expect $dest 20 {
76
-re "file name\[ \t\]+: (\[^ \r\n\]+)\[ \r\n\]+" {
77
set curr_file $expect_out(1,string)
80
-re "$boot_mon_prompt" { }
82
if ![info exists curr_file] {
87
if { $curr_file != $desired_kernel } {
88
verbose "$curr_file != '$desired_kernel'"
90
remote_send $dest "c\n"
91
remote_expect $dest 20 {
92
-re "file name\[ \t\]+:.*$" {
93
remote_send $dest "$desired_kernel\n"
96
-re "\[a-z() \t\]+:.*$" {
97
remote_send $dest "\n"
100
-re "$boot_mon_prompt" {}
103
remote_send $dest "@\n"
104
remote_expect $dest 30 {
105
-re "(^|\[\r\n\])$shell_prompt" {}
110
vxworks_final_init $dest
114
proc vxworks_final_init { dest } {
115
if [board_info $dest exists preload_obj] {
116
if { [target_compile [board_info $dest preload_obj] foo.out object [board_info $dest preload_obj_flags]] == "" } {
117
vxworks_ld $dest foo.out
119
remote_file build delete foo.out
123
# Execute the command PROGRAM on VxWorks.
126
proc vxworks_exec { dest program pargs inp outp } {
129
set shell_id [vxworks_open $dest]
130
if { $shell_id < 0 } {
131
return [list -1 "open failure"]
135
set inp [remote_download $dest $inp]
141
set shell_prompt [board_info $dest shell_prompt]
142
remote_send $dest "${program} ${pargs}$suffix\n"
143
# FIXME: The value 300 below should probably be a parameter passed in.
144
remote_expect $dest 300 {
145
-re "\\\[VxWorks Boot\\\]:" {
146
remote_send $dest "@\n"
150
-re "(.*)value = (-*$decimal) = $hex\[^\r\n\]*\[\r\n\]+$shell_prompt" {
151
set result [list $expect_out(2,string) $expect_out(1,string)]
153
-re "undefined symbol: .*$shell_prompt" {
154
set result [list 1 "unknown command"]
156
-re "syntax error.*$shell_prompt" {
157
set result [list -1 "syntax error in command"]
160
set result [list -1 "unable to execute command"]
163
if { $suffix != "" } {
164
remote_file $dest delete $inp
169
proc vxworks_download { dest localfile remotefile } {
170
if [board_info $dest exists vxworks_homedir] {
171
set rfile "[board_info $dest vxworks_homedir]/$remotefile"
172
remote_download build $localfile $rfile
175
return [remote_raw_download $dest $localfile $remotefile]
178
proc vxworks_file { dest op args } {
179
set file [lindex $args 0]
180
if [board_info $dest exists vxworks_homedir] {
181
set dir "[board_info $dest vxworks_homedir]"
184
set file "${dir}/[file tail $file]"
185
return [file exists $file]
189
set x "${dir}/[file tail $x]"
190
if { [file exists $x] && [file isfile $x] } {
198
return [eval remote_raw_file \"$dest\" \"$op\" $args]
201
proc vxworks_send { dest string } {
202
# Convert LFs to CRs, 'cause that is what VxWorks wants to see.
203
regsub -all "\n" $string "\r" string
204
verbose "Sending '$string' to $dest" 2
205
return [remote_raw_send $dest "$string"]
208
proc vxworks_open { dest args } {
209
if [board_info $dest exists fileid] {
210
return [board_info $dest fileid]
213
set shell_prompt [board_info $dest shell_prompt]
215
set shell_id [remote_raw_open $dest]
217
if { $shell_id == "" || $shell_id < 0 } {
221
if [board_info $dest exists logname] {
222
set logname [board_info $dest logname]
223
if [board_info $dest exists password] {
224
remote_send $dest "iam \"$logname\",\"[board_info $dest passwd]\"\r"
226
remote_send $dest "iam \"$logname\"\r"
229
remote_expect $dest 30 {
230
"iam*value = 0 = 0x0*$shell_prompt" {
231
verbose "Set default user." 2
234
# ??? This is really an error. It's not clear whether `perror'
235
# or `warning' should be used here. There are *lots* of other
237
perror "Couldn't set default user."
244
if [board_info $dest exists ftp_directory] {
245
set dir [board_info $dest ftp_directory]
247
if [board_info $dest exists vxworks_homedir] {
248
set dir [board_info $dest vxworks_homedir]
251
set status [remote_exec $dest "cd" "\"$dir\""]
252
if [lindex $status 0] {
253
perror "Error in cd to $dir--[lindex $status 1]"
260
# Load a file into vxworks
264
# 1 - failed (eg: link failed so testcase should fail)
265
# -1 - unresolved (eg: timeout), may be fixed by rebooting
267
proc vxworks_ld { dest prog } {
275
set shell_id [remote_open $dest]
277
if { $shell_id < 0 } {
281
set prog [remote_download $dest $prog]
283
set shell_prompt [board_info $dest shell_prompt]
285
# We always want to exit the program via the code at the end.
286
# If the load fails we want `expect_out' stored in the log and this
287
# saves duplicating that code.
289
for { set x 0 } { $x < 3 } { incr x } {
290
remote_send $dest "\n"
291
remote_expect $dest 30 {
292
-re ".*$shell_prompt $" { set x 20 }
293
-re "\\\[VxWorks Boot\\\]:" {
294
remote_send $dest "@\n"
298
timeout { return -1 }
304
set result -7 ;# -7 is a local value meaning "not done"
306
while { $result == -7 && $tries < $maxtries } {
307
verbose "Loading $prog into vxworks."
308
remote_send $dest "ld < $prog\n"
310
remote_expect $dest 300 {
311
-re "USER.*command not understood" {
312
perror "Need to set the user and password."
315
-re "Stale NFS file handle.*$shell_prompt $" {
318
-re "undefined symbol:.*$shell_prompt $" {
319
# This is an error in the testcase, don't call perror.
320
warning "Undefined symbol, $prog not loaded."
323
-re "memPartAlloc: block too.*$shell_prompt $" {
324
perror "Not enough memory to load $prog."
327
-re "can't open input.*$shell_prompt $" {
328
perror "Can't access $prog."
331
-re "value = (-*${decimal}) = ${hex}.*$shell_prompt $" {
332
verbose "Loaded $prog into vxworks."
333
set board_info([board_info $dest name],vx_module) $expect_out(1,string)
336
-re "(.*)$shell_prompt $" {
337
warning "Load failed: $expect_out(1,string)"
340
warning "Timed out trying load $prog."
346
if { $result && [info exists expect_out(buffer)] } {
347
send_log "$expect_out(buffer)"
350
remote_file $dest delete $prog
355
# Start a thread (process) executing
359
# 1 - failed (eg: testcase aborted)
360
# -1 - unresolved, may be fixed by rebooting
362
proc vxworks_run { dest function pargs inp outp } {
365
set shell_prompt [board_info $dest shell_prompt]
368
# There isn't a command to wait for a thread to finish, so we have to keep
369
# polling. Instead, we expect the status wrapper to return an exit
372
set status [remote_exec $dest "sp" "$function $pargs" $inp $outp]
374
set tid [lindex $status 0]
376
# Bad task id, reboot and try again.
377
if { $tid == -1 || $tid == 0 } {
382
# FIXME: The value 300 below should be a parameter.
383
remote_expect $dest 300 {
384
-re "task ${hex} - aborted.*$shell_prompt $" {
385
# FIXME: It's not clear we'll ever get here.
386
verbose "$function aborted"
389
-re "\[\r\n\]syntax error\[\r\n\]" {
390
verbose "weirdness after task started"
393
-re "(.*)\\*\\*\\* EXIT code ($decimal)\[\r\n\]" {
394
set output "$expect_out(1,string)"
395
set exit_code "$expect_out(2,string)"
396
if { ($exit_code + 0) != 0 } {
402
-re "Operation Fault.*fault type:" {
406
# This is here to try to cope with apparently flaky h/w.
407
# This is potentially an error in the testcase, but we don't
408
# really know, do we?
411
set output "Bus Error"
415
# Infinite loop? probably.
416
remote_exec $dest "td" "$tid"
421
return [list $result $output]
425
# Unload the last executable that we loaded, so we can free up its memory.
427
proc vxworks_unld { dest } {
430
if [board_info $dest exists vx_module] {
431
# Vxworks5.0 does not have the unld command.
432
if { [board_info $dest os] != "vxworks5.0" } {
433
remote_exec $dest "unld" "[board_info $dest vx_module]"
435
unset board_info([board_info $dest name],vx_module)
440
# We loop around rebooting the box until either the load and run
441
# "work" or we give up.
443
proc vxworks_load {dest prog args} {
447
if { [llength $args] > 0 } {
448
set pargs "[lindex $args 0]"
453
if { [llength $args] > 1 } {
454
set inp "[lindex $args 1]"
459
if { [llength $args] > 2 } {
460
set outp "[lindex $args 2]"
465
for { set x 0 } { $x < 3 } { incr x } {
466
set status [vxworks_ld $dest $prog]
467
if { $status >= 0 } {
471
set out [vxworks_run $dest __wrap_main $pargs $inp $outp]
472
set status [lindex $out 0]
473
set output [lindex $out 1]
474
# Get rid of the carriage returns, because they confuse
475
# callers that try to parse the result.
476
regsub -all "\r" $output "" output
477
if { $status != 0 } {
486
if { $result != "" } {
488
return [list $result $output]
492
return [list "fail" ""]
495
set_board_info protocol "vxworks"
496
# -lm under vxworks isn't needed.
497
set_board_info mathlib ""
498
set_board_info shell_prompt "->"
499
set_board_info needs_status_wrapper 1
500
# FTP doesn't work in passive mode to this board.
501
set_board_info ftp_no_passive 1
502
# Wait 15 seconds after powercycling.
503
set_board_info reboot_delay 15
505
# We don't have sys/unistd.h.
506
set_board_info wrap_compile_flags "-DNO_UNISTD_H"
508
set_board_info gdb_prompt "\[(\]vxgdb\[)\]"
510
set_board_info is_vxworks 1
511
set_board_info gdb,nosignals 1