1# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
2# Foundation, Inc.
3#
4# This file is part of DejaGnu.
5#
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.
10#
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.
15#
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.
19
20# This is a HACKED version of mcore-sim.exp that is intended to
21# support running tests on Motorola's proprietry MCore simulator.
22
23# It is quite likely that thia file will need to be modified in
24# order for you to use Motorola's simulator.
25
26# This is a list of toolchains that are supported on this board.
27set_board_info target_install {mcore-elf, mcore-pe}
28
29# Do general config stuff but do not load anything.  "jim" was
30# chosen because it does not exist.
31load_generic_config "jim"
32
33process_multilib_options ""
34
35# We only support newlib on this target. We assume that all multilib
36# options have been specified before we get here.
37set_board_info compiler  "[find_gcc]"
38set_board_info cflags    "[libgloss_include_flags] [newlib_include_flags]"
39set_board_info ldflags   "[libgloss_link_flags] [newlib_link_flags]"
40
41# No linker script needed.
42set_board_info ldscript ""
43
44# The simulator doesn't return exit statuses and we need to indicate this;
45# the standard GCC wrapper will work with this target.
46set_board_info needs_status_wrapper  1
47
48# Doesn't pass arguments or signals, can't return results, and doesn't
49# do inferiorio.
50set_board_info noargs 1
51set_board_info gdb,nosignals 1
52set_board_info gdb,noresults 1
53set_board_info gdb,noinferiorio 1
54
55# Rather than include the normal simulator support files,
56# their functions are reproduced (and modified) here.
57# --------------------------------------------------------------
58proc sim_spawn { dest cmdline args } {
59
60    # Choose whoch simulator to run
61    ## XXX - fixme - this should be automatic based on the
62    ## multilib option.
63    ## XXX - fixme - this should not be hardcoded.
64    set sim "/home/nickc/bin/linux/sim-be"
65    #   set sim "/home/nickc/bin/linux/sim-le"
66
67    set simflags "-m abi"
68
69    # Create a script to run the program
70    set handle [open doit w]
71    puts $handle "load $cmdline"
72    puts $handle "reset"
73    puts $handle "g 28"
74    puts $handle "quit"
75    close $handle
76
77    return [eval remote_spawn host \{ $sim $simflags "-sdoit" \} $args]
78}
79
80proc sim_wait { dest timeout } {
81    return [remote_wait host $timeout]
82}
83
84proc sim_load { dest prog args } {
85
86    if ![file exists $prog] then {
87	perror "sim.exp: $prog to be downloaded does not exist."
88	verbose -log "$prog to be downloaded does not exist." 3
89	return [list "untested" ""]
90    }
91
92    set sim_time_limit 240
93
94    set output ""
95
96    set res [remote_spawn target "${prog}"]
97
98    if { $res <= 0 } {
99	return [list "fail" "remote_spawn failed"]
100    }
101
102    set state [remote_wait target $sim_time_limit]
103    set status [lindex $state 0]
104    set output [lindex $state 1]
105    verbose "Output is $output"
106
107    set status2 [check_for_board_status output]
108    if { $status2 >= 0 } {
109	set status $status2
110    }
111
112    # FIXME: Do we need to examine $status?
113    # Yes, we do--what if the simulator itself gets an error and coredumps?
114
115    verbose "Return status was: $status" 2
116    if { $status == 0 } {
117	set result "pass"
118    } else {
119	set result "fail"
120    }
121    return [list $result $output]
122}
123
124set_board_info protocol  "sim"
125
126# By default, assume the simulator is slow.  This causes some tests
127# to either be simplified or skipped completely.
128set_board_info slow_simulator 1
129
130# -----------------------------------------------------------
131# find_sim -- find a usable simulator
132# This proc is local to this file and is used to locate a simulator to use.
133# First we see if SIM=foo was specified on the command line.
134# Otherwise we search the build tree, then $PATH.
135
136proc find_sim { target_alias sim_dir sim_name } {
137
138    ## XXX - fixme - this should not be hardcoded.
139    ## XXX - fixme - this should vary depending upon endianism selected.
140
141    return "/home/nickc/bin/linux/sim-be"
142}
143
144set_board_info is_simulator 1
145