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