1 |
1181 |
sfurman |
// OBSOLETE /* Main simulator entry points specific to the FR30.
|
2 |
|
|
// OBSOLETE Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
3 |
|
|
// OBSOLETE Contributed by Cygnus Solutions.
|
4 |
|
|
// OBSOLETE
|
5 |
|
|
// OBSOLETE This file is part of the GNU simulators.
|
6 |
|
|
// OBSOLETE
|
7 |
|
|
// OBSOLETE This program is free software; you can redistribute it and/or modify
|
8 |
|
|
// OBSOLETE it under the terms of the GNU General Public License as published by
|
9 |
|
|
// OBSOLETE the Free Software Foundation; either version 2, or (at your option)
|
10 |
|
|
// OBSOLETE any later version.
|
11 |
|
|
// OBSOLETE
|
12 |
|
|
// OBSOLETE This program is distributed in the hope that it will be useful,
|
13 |
|
|
// OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
// OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
// OBSOLETE GNU General Public License for more details.
|
16 |
|
|
// OBSOLETE
|
17 |
|
|
// OBSOLETE You should have received a copy of the GNU General Public License along
|
18 |
|
|
// OBSOLETE with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
|
|
// OBSOLETE 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
20 |
|
|
// OBSOLETE
|
21 |
|
|
// OBSOLETE #include "sim-main.h"
|
22 |
|
|
// OBSOLETE #ifdef HAVE_STDLIB_H
|
23 |
|
|
// OBSOLETE #include <stdlib.h>
|
24 |
|
|
// OBSOLETE #endif
|
25 |
|
|
// OBSOLETE #include "sim-options.h"
|
26 |
|
|
// OBSOLETE #include "libiberty.h"
|
27 |
|
|
// OBSOLETE #include "bfd.h"
|
28 |
|
|
// OBSOLETE
|
29 |
|
|
// OBSOLETE static void free_state (SIM_DESC);
|
30 |
|
|
// OBSOLETE static void print_fr30_misc_cpu (SIM_CPU *cpu, int verbose);
|
31 |
|
|
// OBSOLETE
|
32 |
|
|
// OBSOLETE /* Records simulator descriptor so utilities like fr30_dump_regs can be
|
33 |
|
|
// OBSOLETE called from gdb. */
|
34 |
|
|
// OBSOLETE SIM_DESC current_state;
|
35 |
|
|
// OBSOLETE
|
36 |
|
|
// OBSOLETE /* Cover function of sim_state_free to free the cpu buffers as well. */
|
37 |
|
|
// OBSOLETE
|
38 |
|
|
// OBSOLETE static void
|
39 |
|
|
// OBSOLETE free_state (SIM_DESC sd)
|
40 |
|
|
// OBSOLETE {
|
41 |
|
|
// OBSOLETE if (STATE_MODULES (sd) != NULL)
|
42 |
|
|
// OBSOLETE sim_module_uninstall (sd);
|
43 |
|
|
// OBSOLETE sim_cpu_free_all (sd);
|
44 |
|
|
// OBSOLETE sim_state_free (sd);
|
45 |
|
|
// OBSOLETE }
|
46 |
|
|
// OBSOLETE
|
47 |
|
|
// OBSOLETE /* Create an instance of the simulator. */
|
48 |
|
|
// OBSOLETE
|
49 |
|
|
// OBSOLETE SIM_DESC
|
50 |
|
|
// OBSOLETE sim_open (kind, callback, abfd, argv)
|
51 |
|
|
// OBSOLETE SIM_OPEN_KIND kind;
|
52 |
|
|
// OBSOLETE host_callback *callback;
|
53 |
|
|
// OBSOLETE struct _bfd *abfd;
|
54 |
|
|
// OBSOLETE char **argv;
|
55 |
|
|
// OBSOLETE {
|
56 |
|
|
// OBSOLETE char c;
|
57 |
|
|
// OBSOLETE int i;
|
58 |
|
|
// OBSOLETE SIM_DESC sd = sim_state_alloc (kind, callback);
|
59 |
|
|
// OBSOLETE
|
60 |
|
|
// OBSOLETE /* The cpu data is kept in a separately allocated chunk of memory. */
|
61 |
|
|
// OBSOLETE if (sim_cpu_alloc_all (sd, 1, cgen_cpu_max_extra_bytes ()) != SIM_RC_OK)
|
62 |
|
|
// OBSOLETE {
|
63 |
|
|
// OBSOLETE free_state (sd);
|
64 |
|
|
// OBSOLETE return 0;
|
65 |
|
|
// OBSOLETE }
|
66 |
|
|
// OBSOLETE
|
67 |
|
|
// OBSOLETE #if 0 /* FIXME: pc is in mach-specific struct */
|
68 |
|
|
// OBSOLETE /* FIXME: watchpoints code shouldn't need this */
|
69 |
|
|
// OBSOLETE {
|
70 |
|
|
// OBSOLETE SIM_CPU *current_cpu = STATE_CPU (sd, 0);
|
71 |
|
|
// OBSOLETE STATE_WATCHPOINTS (sd)->pc = &(PC);
|
72 |
|
|
// OBSOLETE STATE_WATCHPOINTS (sd)->sizeof_pc = sizeof (PC);
|
73 |
|
|
// OBSOLETE }
|
74 |
|
|
// OBSOLETE #endif
|
75 |
|
|
// OBSOLETE
|
76 |
|
|
// OBSOLETE if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
|
77 |
|
|
// OBSOLETE {
|
78 |
|
|
// OBSOLETE free_state (sd);
|
79 |
|
|
// OBSOLETE return 0;
|
80 |
|
|
// OBSOLETE }
|
81 |
|
|
// OBSOLETE
|
82 |
|
|
// OBSOLETE #if 0 /* FIXME: 'twould be nice if we could do this */
|
83 |
|
|
// OBSOLETE /* These options override any module options.
|
84 |
|
|
// OBSOLETE Obviously ambiguity should be avoided, however the caller may wish to
|
85 |
|
|
// OBSOLETE augment the meaning of an option. */
|
86 |
|
|
// OBSOLETE if (extra_options != NULL)
|
87 |
|
|
// OBSOLETE sim_add_option_table (sd, extra_options);
|
88 |
|
|
// OBSOLETE #endif
|
89 |
|
|
// OBSOLETE
|
90 |
|
|
// OBSOLETE /* getopt will print the error message so we just have to exit if this fails.
|
91 |
|
|
// OBSOLETE FIXME: Hmmm... in the case of gdb we need getopt to call
|
92 |
|
|
// OBSOLETE print_filtered. */
|
93 |
|
|
// OBSOLETE if (sim_parse_args (sd, argv) != SIM_RC_OK)
|
94 |
|
|
// OBSOLETE {
|
95 |
|
|
// OBSOLETE free_state (sd);
|
96 |
|
|
// OBSOLETE return 0;
|
97 |
|
|
// OBSOLETE }
|
98 |
|
|
// OBSOLETE
|
99 |
|
|
// OBSOLETE #if 0
|
100 |
|
|
// OBSOLETE /* Allocate a handler for the control registers and other devices
|
101 |
|
|
// OBSOLETE if no memory for that range has been allocated by the user.
|
102 |
|
|
// OBSOLETE All are allocated in one chunk to keep things from being
|
103 |
|
|
// OBSOLETE unnecessarily complicated. */
|
104 |
|
|
// OBSOLETE if (sim_core_read_buffer (sd, NULL, read_map, &c, FR30_DEVICE_ADDR, 1) == 0)
|
105 |
|
|
// OBSOLETE sim_core_attach (sd, NULL,
|
106 |
|
|
// OBSOLETE 0 /*level*/,
|
107 |
|
|
// OBSOLETE access_read_write,
|
108 |
|
|
// OBSOLETE 0 /*space ???*/,
|
109 |
|
|
// OBSOLETE FR30_DEVICE_ADDR, FR30_DEVICE_LEN /*nr_bytes*/,
|
110 |
|
|
// OBSOLETE 0 /*modulo*/,
|
111 |
|
|
// OBSOLETE &fr30_devices,
|
112 |
|
|
// OBSOLETE NULL /*buffer*/);
|
113 |
|
|
// OBSOLETE #endif
|
114 |
|
|
// OBSOLETE
|
115 |
|
|
// OBSOLETE /* Allocate core managed memory if none specified by user.
|
116 |
|
|
// OBSOLETE Use address 4 here in case the user wanted address 0 unmapped. */
|
117 |
|
|
// OBSOLETE if (sim_core_read_buffer (sd, NULL, read_map, &c, 4, 1) == 0)
|
118 |
|
|
// OBSOLETE sim_do_commandf (sd, "memory region 0,0x%lx", FR30_DEFAULT_MEM_SIZE);
|
119 |
|
|
// OBSOLETE
|
120 |
|
|
// OBSOLETE /* check for/establish the reference program image */
|
121 |
|
|
// OBSOLETE if (sim_analyze_program (sd,
|
122 |
|
|
// OBSOLETE (STATE_PROG_ARGV (sd) != NULL
|
123 |
|
|
// OBSOLETE ? *STATE_PROG_ARGV (sd)
|
124 |
|
|
// OBSOLETE : NULL),
|
125 |
|
|
// OBSOLETE abfd) != SIM_RC_OK)
|
126 |
|
|
// OBSOLETE {
|
127 |
|
|
// OBSOLETE free_state (sd);
|
128 |
|
|
// OBSOLETE return 0;
|
129 |
|
|
// OBSOLETE }
|
130 |
|
|
// OBSOLETE
|
131 |
|
|
// OBSOLETE /* Establish any remaining configuration options. */
|
132 |
|
|
// OBSOLETE if (sim_config (sd) != SIM_RC_OK)
|
133 |
|
|
// OBSOLETE {
|
134 |
|
|
// OBSOLETE free_state (sd);
|
135 |
|
|
// OBSOLETE return 0;
|
136 |
|
|
// OBSOLETE }
|
137 |
|
|
// OBSOLETE
|
138 |
|
|
// OBSOLETE if (sim_post_argv_init (sd) != SIM_RC_OK)
|
139 |
|
|
// OBSOLETE {
|
140 |
|
|
// OBSOLETE free_state (sd);
|
141 |
|
|
// OBSOLETE return 0;
|
142 |
|
|
// OBSOLETE }
|
143 |
|
|
// OBSOLETE
|
144 |
|
|
// OBSOLETE /* Open a copy of the cpu descriptor table. */
|
145 |
|
|
// OBSOLETE {
|
146 |
|
|
// OBSOLETE CGEN_CPU_DESC cd = fr30_cgen_cpu_open_1 (STATE_ARCHITECTURE (sd)->printable_name,
|
147 |
|
|
// OBSOLETE CGEN_ENDIAN_BIG);
|
148 |
|
|
// OBSOLETE for (i = 0; i < MAX_NR_PROCESSORS; ++i)
|
149 |
|
|
// OBSOLETE {
|
150 |
|
|
// OBSOLETE SIM_CPU *cpu = STATE_CPU (sd, i);
|
151 |
|
|
// OBSOLETE CPU_CPU_DESC (cpu) = cd;
|
152 |
|
|
// OBSOLETE CPU_DISASSEMBLER (cpu) = sim_cgen_disassemble_insn;
|
153 |
|
|
// OBSOLETE }
|
154 |
|
|
// OBSOLETE fr30_cgen_init_dis (cd);
|
155 |
|
|
// OBSOLETE }
|
156 |
|
|
// OBSOLETE
|
157 |
|
|
// OBSOLETE /* Initialize various cgen things not done by common framework.
|
158 |
|
|
// OBSOLETE Must be done after fr30_cgen_cpu_open. */
|
159 |
|
|
// OBSOLETE cgen_init (sd);
|
160 |
|
|
// OBSOLETE
|
161 |
|
|
// OBSOLETE /* Store in a global so things like sparc32_dump_regs can be invoked
|
162 |
|
|
// OBSOLETE from the gdb command line. */
|
163 |
|
|
// OBSOLETE current_state = sd;
|
164 |
|
|
// OBSOLETE
|
165 |
|
|
// OBSOLETE return sd;
|
166 |
|
|
// OBSOLETE }
|
167 |
|
|
// OBSOLETE
|
168 |
|
|
// OBSOLETE void
|
169 |
|
|
// OBSOLETE sim_close (sd, quitting)
|
170 |
|
|
// OBSOLETE SIM_DESC sd;
|
171 |
|
|
// OBSOLETE int quitting;
|
172 |
|
|
// OBSOLETE {
|
173 |
|
|
// OBSOLETE fr30_cgen_cpu_close (CPU_CPU_DESC (STATE_CPU (sd, 0)));
|
174 |
|
|
// OBSOLETE sim_module_uninstall (sd);
|
175 |
|
|
// OBSOLETE }
|
176 |
|
|
// OBSOLETE
|
177 |
|
|
// OBSOLETE SIM_RC
|
178 |
|
|
// OBSOLETE sim_create_inferior (sd, abfd, argv, envp)
|
179 |
|
|
// OBSOLETE SIM_DESC sd;
|
180 |
|
|
// OBSOLETE struct _bfd *abfd;
|
181 |
|
|
// OBSOLETE char **argv;
|
182 |
|
|
// OBSOLETE char **envp;
|
183 |
|
|
// OBSOLETE {
|
184 |
|
|
// OBSOLETE SIM_CPU *current_cpu = STATE_CPU (sd, 0);
|
185 |
|
|
// OBSOLETE SIM_ADDR addr;
|
186 |
|
|
// OBSOLETE
|
187 |
|
|
// OBSOLETE if (abfd != NULL)
|
188 |
|
|
// OBSOLETE addr = bfd_get_start_address (abfd);
|
189 |
|
|
// OBSOLETE else
|
190 |
|
|
// OBSOLETE addr = 0;
|
191 |
|
|
// OBSOLETE sim_pc_set (current_cpu, addr);
|
192 |
|
|
// OBSOLETE
|
193 |
|
|
// OBSOLETE #if 0
|
194 |
|
|
// OBSOLETE STATE_ARGV (sd) = sim_copy_argv (argv);
|
195 |
|
|
// OBSOLETE STATE_ENVP (sd) = sim_copy_argv (envp);
|
196 |
|
|
// OBSOLETE #endif
|
197 |
|
|
// OBSOLETE
|
198 |
|
|
// OBSOLETE return SIM_RC_OK;
|
199 |
|
|
// OBSOLETE }
|
200 |
|
|
// OBSOLETE
|
201 |
|
|
// OBSOLETE void
|
202 |
|
|
// OBSOLETE sim_do_command (sd, cmd)
|
203 |
|
|
// OBSOLETE SIM_DESC sd;
|
204 |
|
|
// OBSOLETE char *cmd;
|
205 |
|
|
// OBSOLETE {
|
206 |
|
|
// OBSOLETE if (sim_args_command (sd, cmd) != SIM_RC_OK)
|
207 |
|
|
// OBSOLETE sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
|
208 |
|
|
// OBSOLETE }
|