]>
Commit | Line | Data |
---|---|---|
a325a02e SC |
1 | /* run front end support for arm |
2 | Copyright (C) 1995 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of ARM SIM | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
18 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ | |
19 | ||
20 | #include <stdio.h> | |
21 | #include <stdarg.h> | |
22 | #include <armdefs.h> | |
23 | #include <bfd.h> | |
24 | #include <signal.h> | |
25 | #include "callback.h" | |
26 | #include "remote-sim.h" | |
27 | static struct ARMul_State *state; | |
28 | ||
29 | static void | |
30 | init () | |
31 | { | |
32 | static int done; | |
33 | if (!done) | |
34 | { | |
35 | ARMul_EmulateInit(); | |
36 | state = ARMul_NewState (); | |
37 | ARMul_MemoryInit(state, 1<<21); | |
38 | ARMul_OSInit(state); | |
39 | ARMul_CoProInit(state); | |
40 | done = 1; | |
41 | } | |
42 | ||
43 | } | |
44 | void | |
45 | ARMul_ConsolePrint (ARMul_State * state, const char *format,...) | |
46 | { | |
47 | va_list ap; | |
48 | va_start (ap, format); | |
49 | vprintf (format, ap); | |
50 | va_end (ap); | |
51 | } | |
52 | ||
53 | ARMword | |
54 | ARMul_Debug (ARMul_State * state, ARMword pc, ARMword instr) | |
55 | { | |
56 | ||
57 | } | |
58 | ||
59 | void | |
60 | sim_size (size) | |
61 | int size; | |
62 | { | |
63 | init (); | |
64 | ARMul_MemoryInit (state, 1 << size); | |
65 | } | |
66 | ||
67 | ||
68 | void | |
69 | sim_set_profile () | |
70 | { | |
71 | } | |
72 | void | |
73 | sim_set_profile_size () | |
74 | { | |
75 | } | |
76 | ||
77 | int | |
78 | sim_write (addr, buffer, size) | |
79 | SIM_ADDR addr; | |
80 | unsigned char *buffer; | |
81 | int size; | |
82 | { | |
83 | int i; | |
84 | init (); | |
85 | for (i = 0; i < size; i++) | |
86 | { | |
87 | ARMul_WriteByte (state, addr+i, buffer[i]); | |
88 | } | |
89 | return size; | |
90 | } | |
91 | ||
92 | int | |
93 | sim_read (addr, buffer, size) | |
94 | SIM_ADDR addr; | |
95 | unsigned char *buffer; | |
96 | int size; | |
97 | { | |
98 | int i; | |
99 | init (); | |
100 | for (i = 0; i < size; i++) | |
101 | { | |
102 | buffer[i] = ARMul_ReadByte (state, addr + i); | |
103 | } | |
104 | return size; | |
105 | } | |
106 | ||
107 | void | |
108 | sim_trace () | |
109 | { | |
110 | } | |
111 | ||
112 | static int rc; | |
113 | void | |
114 | sim_resume (step, siggnal) | |
115 | int step, siggnal; | |
116 | { | |
117 | if (step) | |
118 | { | |
119 | rc = SIGTRAP; | |
120 | state->Reg[15] = ARMul_DoInstr (state); | |
121 | } | |
122 | else | |
123 | { | |
124 | state->Reg[15] = ARMul_DoProg (state); | |
125 | } | |
126 | } | |
127 | ||
128 | void | |
129 | sim_create_inferior (start_address, argv, env) | |
130 | SIM_ADDR start_address; | |
131 | char **argv; | |
132 | char **env; | |
133 | { | |
134 | ARMul_SetPC(state, start_address); | |
135 | } | |
136 | ||
137 | void | |
138 | sim_info (verbose) | |
139 | int verbose; | |
140 | { | |
141 | } | |
142 | ||
143 | ||
144 | int | |
145 | frommem (state, memory) | |
146 | struct ARMul_State *state; | |
147 | unsigned char *memory; | |
148 | { | |
149 | if (state->bigendSig == HIGH) | |
150 | { | |
151 | return (memory[0] << 24) | |
152 | | (memory[1] << 16) | |
153 | | (memory[2] << 8) | |
154 | | (memory[3] << 0); | |
155 | } | |
156 | else | |
157 | { | |
158 | return (memory[3] << 24) | |
159 | | (memory[2] << 16) | |
160 | | (memory[1] << 8) | |
161 | | (memory[0] << 0); | |
162 | } | |
163 | } | |
164 | ||
165 | ||
166 | void | |
167 | tomem (state, memory, val) | |
168 | struct ARMul_State *state; | |
169 | unsigned char *memory; | |
170 | int val; | |
171 | { | |
172 | if (state->bigendSig == HIGH) | |
173 | { | |
174 | memory[0] = val >> 24; | |
175 | memory[1] = val >> 16; | |
176 | memory[2] = val >> 8; | |
177 | memory[3] = val >> 0; | |
178 | } | |
179 | else | |
180 | { | |
181 | memory[3] = val >> 24; | |
182 | memory[2] = val >> 16; | |
183 | memory[1] = val >> 8; | |
184 | memory[0] = val >> 0; | |
185 | } | |
186 | } | |
187 | ||
188 | void | |
189 | sim_store_register (rn, memory) | |
190 | int rn; | |
191 | unsigned char *memory; | |
192 | { | |
193 | init (); | |
194 | ARMul_SetReg(state, state->Mode, rn, frommem (state, memory)); | |
195 | } | |
196 | ||
197 | void | |
198 | sim_fetch_register (rn, memory) | |
199 | int rn; | |
200 | unsigned char *memory; | |
201 | { | |
202 | init (); | |
203 | tomem (state, memory, ARMul_GetReg(state, state->Mode, rn)); | |
204 | } | |
205 | ||
206 | ||
207 | ||
208 | ||
209 | void | |
210 | sim_open (name) | |
211 | char *name; | |
212 | { | |
213 | /* nothing to do */ | |
214 | } | |
215 | ||
216 | void | |
217 | sim_close (quitting) | |
218 | int quitting; | |
219 | { | |
220 | /* nothing to do */ | |
221 | } | |
222 | ||
223 | int | |
224 | sim_load (prog, from_tty) | |
225 | char *prog; | |
226 | int from_tty; | |
227 | { | |
228 | /* Return nonzero so GDB will handle it. */ | |
229 | return 1; | |
230 | } | |
231 | ||
232 | void | |
233 | sim_stop_reason (reason, sigrc) | |
234 | enum sim_stop *reason; | |
235 | int *sigrc; | |
236 | { | |
237 | *reason = sim_stopped; | |
238 | *sigrc = rc; | |
239 | } | |
240 | void | |
241 | sim_kill () | |
242 | { | |
243 | /* nothing to do */ | |
244 | } | |
245 | ||
246 | void | |
247 | sim_do_command (cmd) | |
248 | char *cmd; | |
249 | { | |
250 | printf_filtered ("This simulator does not accept any commands.\n"); | |
251 | } | |
252 | ||
253 | ||
254 | void | |
255 | sim_set_callbacks (ptr) | |
256 | struct host_callback_struct *ptr; | |
257 | { | |
258 | ||
259 | } |