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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [dejagnu/] [lib/] [mondfe.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Copyright (C) 92, 93, 94, 95, 96, 97, 98, 1999 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 
17
# Please email any bugs, comments, and/or additions to this file to:
18
# bug-dejagnu@prep.ai.mit.edu
19
 
20
# This file was written by Rob Savoye. (rob@cygnus.com)
21
 
22
#
23
# Connect to udi using mondfe
24
#
25
# HOSTNAME can be `iss' to talk to the simulator.
26
# The result is the value of `spawn_id' or -1 for failure.
27
#
28
proc mondfe_open { hostname } {
29
    global spawn_id
30
    global board_info
31
 
32
    set retries 0
33
    set result  -1
34
 
35
    set shell_prompt [board_info $hostname shell_prompt]
36
    if ![board_info $hostname exists mondfe,name] {
37
        perror "Must set board_info(${hostname},mondfe,name)"
38
        return -1;
39
    }
40
    if [board_info $hostname exists mondfe] {
41
        set mondfe [board_info $hostname mondfe];
42
    } else {
43
        set mondfe "mondfe"
44
    }
45
 
46
    set remote_host [board_info $hostname mondfe,name];
47
 
48
    if [board_info $hostname exists mondfe_host] {
49
        set rh [board_info $hostname mondfe_host];
50
    } else {
51
        verbose "Attempting to connect to $hostname via mondfe."
52
        set rh "host";
53
    }
54
 
55
    set shell_id [remote_spawn $rh "$mondfe -D -TIP $remote_host"];
56
 
57
    remote_expect $rh 60 {
58
        "$shell_prompt" {
59
            verbose "Got prompt"
60
            set result 0
61
        }
62
        "*server bind*failed: Address already in use*" {
63
            warning "Socket file already exists."
64
            incr retries
65
            if { $retries <= 2 } {
66
                exp_continue;
67
            }
68
        }
69
        -indices -re ".*(UDIERROR\[^\r\n\]*)\[\r\n\]" {
70
            warning "$expect_out(1,string)"
71
            exp_continue;
72
        }
73
        -indices -re ".*(DFEERROR\[^\r\n\]*)\[\r\n\]" {
74
            warning "$expect_out(1,string)"
75
            exp_continue;
76
        }
77
        timeout {
78
            warning "Timed out trying to connect."
79
            set result -1
80
            incr retries
81
            if { $retries <= 2 } {
82
                remote_send $rh "\n"
83
                exp_continue;
84
            }
85
        }
86
    }
87
 
88
    if { $result < 0 } {
89
        perror "Couldn't connect after $retries retries."
90
        remote_close $rh;
91
        return -1
92
    } else {
93
        set board_info($hostname,fileid) $shell_id;
94
        return $shell_id;
95
    }
96
}
97
 
98
#
99
# Downloads using the y (yank) command in mondfe
100
#
101
# FILE is a full path name to the file to download.
102
# Returns 1 if an error occured, 0 otherwise.
103
#
104
proc mondfe_ld { dest_machine file } {
105
    global decimal              # Regexp to match a decimal number.
106
 
107
    if ![file exists $file] {
108
        perror "$file doesn't exist."
109
        return ""
110
    }
111
 
112
    set shell_prompt [board_info $dest_machine shell_prompt]
113
 
114
    if [board_info $dest_machine exists mondfe_host] {
115
        set remote_host [board_info $dest_machine mondfe_host];
116
        set file [remote_download $remote_host $file montest]
117
    } else {
118
        set remote_host "host";
119
    }
120
 
121
    verbose "Downloading $file." 2
122
    verbose "Shell prompt is $shell_prompt." 3
123
    set result 1
124
    remote_send $remote_host "y $file\n"
125
    remote_expect $remote_host 60 {
126
        "y $file" {
127
            exp_continue;
128
        }
129
        -re "loading $file\[\r\n\]+" {
130
            exp_continue;
131
        }
132
        -re "Load(ing|ed) *TEXT section from\[^\r\n\]*\[\r\n\]+" {
133
            verbose -n "." 2
134
            exp_continue;
135
        }
136
        -re "Load(ing|ed) *LIT section from\[^\r\n\]*\[\r\n\]+" {
137
            verbose -n "." 2
138
            exp_continue;
139
        }
140
        -re "Load(ing|ed) *DATA section from\[^\r\n\]*\[\r\n\]+" {
141
            verbose -n "." 2
142
            exp_continue;
143
        }
144
        -re "Clear(ing|ed) *BSS section from\[^\r\n\]*\[\r\n\]+" {
145
            verbose -n "." 2
146
            exp_continue;
147
        }
148
        -re "(^|\[\r\n\]+)$shell_prompt$" {
149
            verbose "Downloaded $file successfully." 2
150
            set result 0
151
        }
152
        -re "Command failed.*$shell_prompt$" {
153
            set result 1
154
        }
155
        -re "DFEWARNING: $decimal : EMMAGIC:  Bad COFF file magic number.*Command failed.*$shell_prompt$" {
156
            warning "Bad COFF file magic number"
157
            set result 1
158
        }
159
        -re "Ignoring COMMENT section \($decimal bytes\)\[^\r\n\]*\[\r\n\]+" {
160
            verbose "Ignoring COMMENT section" 2
161
            exp_continue;
162
        }
163
        timeout {
164
            perror "Timed out trying to download $file."
165
            set result 1
166
        }
167
    }
168
 
169
    if { $result && [info exists expect_out(buffer)] } {
170
        send_log $expect_out(buffer)
171
    }
172
 
173
    if [board_info $dest_machine exists mondfe_host] {
174
        remote_file $remote_machine delete $file
175
    }
176
 
177
    return $result
178
}
179
 
180
#
181
# Exit the remote shell
182
#
183
proc mondfe_close { hostname } {
184
    global board_info
185
 
186
    if [board_info $hostname exists mondfe_host] {
187
        set remote_host [board_info $hostname mondfe_host];
188
    } else {
189
        set remote_host "host";
190
    }
191
 
192
    if ![board_info $hostname exists fileid] {
193
        return 0;
194
    }
195
 
196
    if [board_info $remote_host exists fileid] {
197
        remote_send $remote_host "q\n"
198
        remote_expect $remote_host 30 {
199
            "Goodbye." {
200
                verbose "Exited mondfe."
201
            }
202
            timeout {
203
                warning "mondfe didn't exit cleanly."
204
            }
205
        }
206
 
207
        remote_close $remote_host;
208
    }
209
 
210
    unset board_info($hostname,fileid);
211
 
212
    return 0;
213
}

powered by: WebSVN 2.1.0

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