OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [dejagnu/] [config/] [ddb-ether.exp] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2
 
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
 
17
# Please email any bugs, comments, and/or additions to this file to:
18
# DejaGnu@cygnus.com
19
 
20
# This file was written by Bob Manson (manson@cygnus.com)
21
 
22
# Reset the prompt to what GDB needs.
23
proc ${board}_init { dest } {
24
    global doing_ddb_init;
25
 
26
    if ![info exists doing_ddb_init] {
27
        set doing_ddb_init 1;
28
 
29
        remote_close $dest;
30
        for { set x 0; } { $x < 3 } { incr x; } {
31
            set shell_id [remote_open $dest];
32
            if { $shell_id == "" || $shell_id < 0 } {
33
                remote_reboot $dest;
34
            } else {
35
                break;
36
            }
37
        }
38
 
39
        set shell_prompt [board_info $dest shell_prompt];
40
 
41
        remote_send $dest "\n";
42
        remote_expect $dest 10 {
43
            -re ".*PMON> $" {
44
                remote_send $dest "set prompt \"$shell_prompt\"\n";
45
                exp_continue;
46
            }
47
            -re ".*${shell_prompt}$" { }
48
        }
49
        remote_close $dest;
50
        unset doing_ddb_init;
51
    } else {
52
        return;
53
    }
54
}
55
 
56
proc ddb_ether_load { dest prog args } {
57
    for { set x 0; } { $x < 3 } { incr x } {
58
        set result [eval remote_spawn \{$dest\} \{$prog\} $args];
59
        if { $result < 0 } {
60
            remote_reboot $dest;
61
        } else {
62
            set result [remote_wait $dest 300];
63
            set status [lindex $result 0];
64
            set output [lindex $result 1];
65
            if { $status >= 0 } {
66
                if { $status > 0 } {
67
                    return [list "fail" $output];
68
                } else {
69
                    return [list "pass" $output];
70
                }
71
            }
72
        }
73
    }
74
    return [list "fail" ""];
75
}
76
 
77
proc ddb_ether_ld { dest prog } {
78
    if ![board_info $dest exists tftpdir] {
79
        perror "Must set_board_info tftpdir for [board_info $dest name]";
80
        return "fail";
81
    }
82
 
83
    if ![board_info $dest exists fileid] {
84
        set spawn_id [remote_open $dest];
85
        if { $spawn_id == "" || $spawn_id < 0 } {
86
            return "retry";
87
        }
88
        remote_binary $dest;
89
    }
90
 
91
    set shell_prompt [board_info $dest shell_prompt];
92
 
93
    remote_send $dest "\n";
94
    remote_expect $dest 10 {
95
         -re ".*${shell_prompt}$" { }
96
         default {
97
            return "retry";
98
        }
99
    }
100
    set basename "a.out.[pid]";
101
    set file "[board_info $dest tftpdir]/$basename";
102
    set file [remote_download build $prog $file];
103
    if { $file == "" } {
104
        perror "download to tftp area failed";
105
        return "fail";
106
    }
107
    set state "pass";
108
 
109
    remote_send $dest "boot /$basename\n";
110
    set tries 0;
111
    remote_expect $dest 30 {
112
        -re "Loading.*Entry address is.*${shell_prompt}$" { }
113
        -re "invalid executable.*${shell_prompt}$" {
114
            incr tries;
115
            if { $tries < 3 } {
116
                sleep 2;
117
                remote_send $dest "boot /$basename\n";
118
                exp_continue;
119
            }
120
        }
121
        -re ".*${shell_prompt}$" {
122
            set state "fail";
123
        }
124
        default {
125
            set state "fail";
126
        }
127
    }
128
    remote_file build delete $file;
129
    if { $state == "fail" } {
130
        return $state;
131
    }
132
    return "pass";
133
}
134
 
135
proc ddb_ether_spawn { dest prog args } {
136
    set state [ddb_ether_ld $dest $prog];
137
 
138
    if { $state != "pass" } {
139
        return -1;
140
    }
141
    remote_send $dest "g\n";
142
    remote_expect $dest 5 {
143
        -re "g\[\r\n\]\[\r\n\]?" { }
144
        default { }
145
    }
146
 
147
    return [board_info $dest fileid];
148
}
149
 
150
proc ddb_ether_wait { dest timeout } {
151
    set output "";
152
    set shell_prompt [board_info $dest shell_prompt];
153
 
154
    remote_expect $dest $timeout {
155
        -re "^g\[\r\n\]\[\r\n\]?" {
156
            if { $output != "" } {
157
                append output $expect_out(buffer);
158
            }
159
            exp_continue;
160
        }
161
        -re "(.*)$shell_prompt" {
162
            append output $expect_out(1,string);
163
            set status [check_for_board_status output];
164
            if { $status > 0 } {
165
                return [list $status $output];
166
            } else {
167
                if [regexp "Exception Cause=" $output] {
168
                    remote_reboot $dest;
169
                    return [list -1 $output];
170
                }
171
                return [list 0 $output];
172
            }
173
        }
174
        -re "\[\r\n\]+" {
175
            append output $expect_out(buffer);
176
            if { [string length $output] < 512000 } {
177
                exp_continue;
178
            } else {
179
                return [list -1 ""];
180
            }
181
        }
182
        default {
183
            return [list -1 ""];
184
        }
185
    }
186
}
187
 
188
set_board_info send_initial_cr 1
189
set_board_info protocol "ddb_ether"
190
set_board_info shell_prompt "NEC010> "

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.