aboutsummaryrefslogtreecommitdiff
path: root/config/tic80.exp
blob: 9b980c4daab837256413453bc21314b654d70159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
# Foundation, Inc.
#
# This file is part of DejaGnu.
#
# DejaGnu is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# DejaGnu is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DejaGnu; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.

#
# Nasty ugly stuff.
#
# We have to maintain two connections to the DOS box where the board
# is being held. One of them runs an I/O monitor process, while the other
# is used to actually start the program under test running on the board.
#

proc tic80_load { dest prog args } {
    set dos_box [board_info $dest dos_host]

    remote_spawn $dos_box [board_info $dest io_program]

    set status [remote_ld $dest $prog]

    if { $status != "pass" } {
	return $status
    }

    set result [remote_wait $dos_box 300]
    set output [lindex $result 1]
    if { [lindex $result 0] < 0 } {
	if [board_info $dos_box exists fileid] {
	    dos_interrupt_job $dos_box
	} else {
	    remote_close $dos_box
	}
    }

    set status "fail"
    regsub "(\\*\\*\\* EXIT code \[0-9\]+\[\r\n]+).*$" "$output" "\\1" output
    verbose "board out is $output"
    set bstatus [check_for_board_status output]
    if { [lindex $result 0] >= 0 } {
	if { $bstatus == 0 } {
	    set status "pass"
	}
    }
    remote_file build delete "a.fix"
    return [list $status $output]
}

proc tic80_ld { dest prog } {
    set dos_box [board_info $dest dos_host]
    set dopush 0

    if { [remote_swap_conn $dos_box] == "fail" } {
	if { [remote_push_conn $dos_box] == "fail" } {
	    set dopush 1
	}
	remote_open $dos_box
    }
    set prog [remote_download $dos_box $prog "a.fix"]

    remote_spawn $dos_box "[board_info $dest start_program] $prog"
    remote_expect $dos_box 10 {
	-re "file\[(\]s\[)\] copied" {}
    }
    sleep 3
    dos_interrupt_job $dos_box
    if { $dopush } {
	remote_push_conn $dos_box
    } else {
	remote_swap_conn $dos_box
    }
    return "pass"
}
#
# Close the connection to the DOS box.
#
proc tic80_close { host } {
    set dos_box [board_info $host dos_host]

    return [remote_close $dos_box]
}

set_board_info protocol "tic80"
set_board_info gdb,use_standard_load 1
set_board_info gdb,no_push_conn 1
set_board_info gdb,do_reload_on_run 1
set_board_info gdb,use_breakpoint_for_stub 1