OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [remote-nrom.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
// OBSOLETE /* Remote debugging with the XLNT Designs, Inc (XDI) NetROM.
2
// OBSOLETE    Copyright 1990, 1991, 1992, 1995, 1998, 1999, 2000
3
// OBSOLETE    Free Software Foundation, Inc.
4
// OBSOLETE    Contributed by:
5
// OBSOLETE    Roger Moyers 
6
// OBSOLETE    XLNT Designs, Inc.
7
// OBSOLETE    15050 Avenue of Science, Suite 106
8
// OBSOLETE    San Diego, CA  92128
9
// OBSOLETE    (619)487-9320
10
// OBSOLETE    roger@xlnt.com
11
// OBSOLETE    Adapted from work done at Cygnus Support in remote-nindy.c,
12
// OBSOLETE    later merged in by Stan Shebs at Cygnus.
13
// OBSOLETE 
14
// OBSOLETE    This file is part of GDB.
15
// OBSOLETE 
16
// OBSOLETE    This program is free software; you can redistribute it and/or modify
17
// OBSOLETE    it under the terms of the GNU General Public License as published by
18
// OBSOLETE    the Free Software Foundation; either version 2 of the License, or
19
// OBSOLETE    (at your option) any later version.
20
// OBSOLETE 
21
// OBSOLETE    This program is distributed in the hope that it will be useful,
22
// OBSOLETE    but WITHOUT ANY WARRANTY; without even the implied warranty of
23
// OBSOLETE    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
// OBSOLETE    GNU General Public License for more details.
25
// OBSOLETE 
26
// OBSOLETE    You should have received a copy of the GNU General Public License
27
// OBSOLETE    along with this program; if not, write to the Free Software
28
// OBSOLETE    Foundation, Inc., 59 Temple Place - Suite 330,
29
// OBSOLETE    Boston, MA 02111-1307, USA.  */
30
// OBSOLETE 
31
// OBSOLETE #include "defs.h"
32
// OBSOLETE #include "gdbcmd.h"
33
// OBSOLETE #include "serial.h"
34
// OBSOLETE #include "target.h"
35
// OBSOLETE 
36
// OBSOLETE /* Default ports used to talk with the NetROM.  */
37
// OBSOLETE 
38
// OBSOLETE #define DEFAULT_NETROM_LOAD_PORT    1236
39
// OBSOLETE #define DEFAULT_NETROM_CONTROL_PORT 1237
40
// OBSOLETE 
41
// OBSOLETE static void nrom_close (int quitting);
42
// OBSOLETE 
43
// OBSOLETE /* New commands.  */
44
// OBSOLETE 
45
// OBSOLETE static void nrom_passthru (char *, int);
46
// OBSOLETE 
47
// OBSOLETE /* We talk to the NetROM over these sockets.  */
48
// OBSOLETE 
49
// OBSOLETE static struct serial *load_desc = NULL;
50
// OBSOLETE static struct serial *ctrl_desc = NULL;
51
// OBSOLETE 
52
// OBSOLETE static int load_port = DEFAULT_NETROM_LOAD_PORT;
53
// OBSOLETE static int control_port = DEFAULT_NETROM_CONTROL_PORT;
54
// OBSOLETE 
55
// OBSOLETE static char nrom_hostname[100];
56
// OBSOLETE 
57
// OBSOLETE /* Forward data declaration. */
58
// OBSOLETE 
59
// OBSOLETE extern struct target_ops nrom_ops;
60
// OBSOLETE 
61
// OBSOLETE /* Scan input from the remote system, until STRING is found.  Print chars that
62
// OBSOLETE    don't match.  */
63
// OBSOLETE 
64
// OBSOLETE static int
65
// OBSOLETE expect (char *string)
66
// OBSOLETE {
67
// OBSOLETE   char *p = string;
68
// OBSOLETE   int c;
69
// OBSOLETE 
70
// OBSOLETE   immediate_quit++;
71
// OBSOLETE 
72
// OBSOLETE   while (1)
73
// OBSOLETE     {
74
// OBSOLETE       c = serial_readchar (ctrl_desc, 5);
75
// OBSOLETE 
76
// OBSOLETE       if (c == *p++)
77
// OBSOLETE     {
78
// OBSOLETE       if (*p == '\0')
79
// OBSOLETE         {
80
// OBSOLETE           immediate_quit--;
81
// OBSOLETE           return 0;
82
// OBSOLETE         }
83
// OBSOLETE     }
84
// OBSOLETE       else
85
// OBSOLETE     {
86
// OBSOLETE       fputc_unfiltered (c, gdb_stdout);
87
// OBSOLETE       p = string;
88
// OBSOLETE       if (c == *p)
89
// OBSOLETE         p++;
90
// OBSOLETE     }
91
// OBSOLETE     }
92
// OBSOLETE }
93
// OBSOLETE 
94
// OBSOLETE static void
95
// OBSOLETE nrom_kill (void)
96
// OBSOLETE {
97
// OBSOLETE   nrom_close (0);
98
// OBSOLETE }
99
// OBSOLETE 
100
// OBSOLETE static struct serial *
101
// OBSOLETE open_socket (char *name, int port)
102
// OBSOLETE {
103
// OBSOLETE   char sockname[100];
104
// OBSOLETE   struct serial *desc;
105
// OBSOLETE 
106
// OBSOLETE   sprintf (sockname, "%s:%d", name, port);
107
// OBSOLETE   desc = serial_open (sockname);
108
// OBSOLETE   if (!desc)
109
// OBSOLETE     perror_with_name (sockname);
110
// OBSOLETE 
111
// OBSOLETE   return desc;
112
// OBSOLETE }
113
// OBSOLETE 
114
// OBSOLETE static void
115
// OBSOLETE load_cleanup (void)
116
// OBSOLETE {
117
// OBSOLETE   serial_close (load_desc);
118
// OBSOLETE   load_desc = NULL;
119
// OBSOLETE }
120
// OBSOLETE 
121
// OBSOLETE /* Download a file specified in ARGS to the netROM.  */
122
// OBSOLETE 
123
// OBSOLETE static void
124
// OBSOLETE nrom_load (char *args, int fromtty)
125
// OBSOLETE {
126
// OBSOLETE   int fd, rd_amt, fsize;
127
// OBSOLETE   bfd *pbfd;
128
// OBSOLETE   asection *section;
129
// OBSOLETE   char *downloadstring = "download 0\n";
130
// OBSOLETE   struct cleanup *old_chain;
131
// OBSOLETE 
132
// OBSOLETE   /* Tell the netrom to get ready to download. */
133
// OBSOLETE   if (serial_write (ctrl_desc, downloadstring, strlen (downloadstring)))
134
// OBSOLETE     error ("nrom_load: control_send() of `%s' failed", downloadstring);
135
// OBSOLETE 
136
// OBSOLETE   expect ("Waiting for a connection...\n");
137
// OBSOLETE 
138
// OBSOLETE   load_desc = open_socket (nrom_hostname, load_port);
139
// OBSOLETE 
140
// OBSOLETE   old_chain = make_cleanup (load_cleanup, 0);
141
// OBSOLETE 
142
// OBSOLETE   pbfd = bfd_openr (args, 0);
143
// OBSOLETE 
144
// OBSOLETE   if (pbfd)
145
// OBSOLETE     {
146
// OBSOLETE       make_cleanup (bfd_close, pbfd);
147
// OBSOLETE 
148
// OBSOLETE       if (!bfd_check_format (pbfd, bfd_object))
149
// OBSOLETE     error ("\"%s\": not in executable format: %s",
150
// OBSOLETE            args, bfd_errmsg (bfd_get_error ()));
151
// OBSOLETE 
152
// OBSOLETE       for (section = pbfd->sections; section; section = section->next)
153
// OBSOLETE     {
154
// OBSOLETE       if (bfd_get_section_flags (pbfd, section) & SEC_ALLOC)
155
// OBSOLETE         {
156
// OBSOLETE           bfd_vma section_address;
157
// OBSOLETE           unsigned long section_size;
158
// OBSOLETE           const char *section_name;
159
// OBSOLETE 
160
// OBSOLETE           section_name = bfd_get_section_name (pbfd, section);
161
// OBSOLETE           section_address = bfd_get_section_vma (pbfd, section);
162
// OBSOLETE           section_size = bfd_section_size (pbfd, section);
163
// OBSOLETE 
164
// OBSOLETE           if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)
165
// OBSOLETE             {
166
// OBSOLETE               file_ptr fptr;
167
// OBSOLETE 
168
// OBSOLETE               printf_filtered ("[Loading section %s at %x (%d bytes)]\n",
169
// OBSOLETE                                section_name, section_address,
170
// OBSOLETE                                section_size);
171
// OBSOLETE 
172
// OBSOLETE               fptr = 0;
173
// OBSOLETE 
174
// OBSOLETE               while (section_size > 0)
175
// OBSOLETE                 {
176
// OBSOLETE                   char buffer[1024];
177
// OBSOLETE                   int count;
178
// OBSOLETE 
179
// OBSOLETE                   count = min (section_size, 1024);
180
// OBSOLETE 
181
// OBSOLETE                   bfd_get_section_contents (pbfd, section, buffer, fptr,
182
// OBSOLETE                                             count);
183
// OBSOLETE 
184
// OBSOLETE                   serial_write (load_desc, buffer, count);
185
// OBSOLETE                   section_address += count;
186
// OBSOLETE                   fptr += count;
187
// OBSOLETE                   section_size -= count;
188
// OBSOLETE                 }
189
// OBSOLETE             }
190
// OBSOLETE           else
191
// OBSOLETE             /* BSS and such */
192
// OBSOLETE             {
193
// OBSOLETE               printf_filtered ("[section %s: not loading]\n",
194
// OBSOLETE                                section_name);
195
// OBSOLETE             }
196
// OBSOLETE         }
197
// OBSOLETE     }
198
// OBSOLETE     }
199
// OBSOLETE   else
200
// OBSOLETE     error ("\"%s\": Could not open", args);
201
// OBSOLETE 
202
// OBSOLETE   do_cleanups (old_chain);
203
// OBSOLETE }
204
// OBSOLETE 
205
// OBSOLETE /* Open a connection to the remote NetROM devices.  */
206
// OBSOLETE 
207
// OBSOLETE static void
208
// OBSOLETE nrom_open (char *name, int from_tty)
209
// OBSOLETE {
210
// OBSOLETE   int errn;
211
// OBSOLETE 
212
// OBSOLETE   if (!name || strchr (name, '/') || strchr (name, ':'))
213
// OBSOLETE     error (
214
// OBSOLETE         "To open a NetROM connection, you must specify the hostname\n\
215
// OBSOLETE or IP address of the NetROM device you wish to use.");
216
// OBSOLETE 
217
// OBSOLETE   strcpy (nrom_hostname, name);
218
// OBSOLETE 
219
// OBSOLETE   target_preopen (from_tty);
220
// OBSOLETE 
221
// OBSOLETE   unpush_target (&nrom_ops);
222
// OBSOLETE 
223
// OBSOLETE   ctrl_desc = open_socket (nrom_hostname, control_port);
224
// OBSOLETE 
225
// OBSOLETE   push_target (&nrom_ops);
226
// OBSOLETE 
227
// OBSOLETE   if (from_tty)
228
// OBSOLETE     printf_filtered ("Connected to NetROM device \"%s\"\n", nrom_hostname);
229
// OBSOLETE }
230
// OBSOLETE 
231
// OBSOLETE /* Close out all files and local state before this target loses control. */
232
// OBSOLETE 
233
// OBSOLETE static void
234
// OBSOLETE nrom_close (int quitting)
235
// OBSOLETE {
236
// OBSOLETE   if (load_desc)
237
// OBSOLETE     serial_close (load_desc);
238
// OBSOLETE   if (ctrl_desc)
239
// OBSOLETE     serial_close (ctrl_desc);
240
// OBSOLETE }
241
// OBSOLETE 
242
// OBSOLETE /* Pass arguments directly to the NetROM. */
243
// OBSOLETE 
244
// OBSOLETE static void
245
// OBSOLETE nrom_passthru (char *args, int fromtty)
246
// OBSOLETE {
247
// OBSOLETE   char buf[1024];
248
// OBSOLETE 
249
// OBSOLETE   sprintf (buf, "%s\n", args);
250
// OBSOLETE   if (serial_write (ctrl_desc, buf, strlen (buf)))
251
// OBSOLETE     error ("nrom_reset: control_send() of `%s'failed", args);
252
// OBSOLETE }
253
// OBSOLETE 
254
// OBSOLETE static void
255
// OBSOLETE nrom_mourn (void)
256
// OBSOLETE {
257
// OBSOLETE   unpush_target (&nrom_ops);
258
// OBSOLETE   generic_mourn_inferior ();
259
// OBSOLETE }
260
// OBSOLETE 
261
// OBSOLETE /* Define the target vector. */
262
// OBSOLETE 
263
// OBSOLETE struct target_ops nrom_ops;
264
// OBSOLETE 
265
// OBSOLETE static void
266
// OBSOLETE init_nrom_ops (void)
267
// OBSOLETE {
268
// OBSOLETE   nrom_ops.to_shortname = "nrom";
269
// OBSOLETE   nrom_ops.to_longname = "Remote XDI `NetROM' target";
270
// OBSOLETE   nrom_ops.to_doc = "Remote debug using a NetROM over Ethernet";
271
// OBSOLETE   nrom_ops.to_open = nrom_open;
272
// OBSOLETE   nrom_ops.to_close = nrom_close;
273
// OBSOLETE   nrom_ops.to_attach = NULL;
274
// OBSOLETE   nrom_ops.to_post_attach = NULL;
275
// OBSOLETE   nrom_ops.to_require_attach = NULL;
276
// OBSOLETE   nrom_ops.to_detach = NULL;
277
// OBSOLETE   nrom_ops.to_require_detach = NULL;
278
// OBSOLETE   nrom_ops.to_resume = NULL;
279
// OBSOLETE   nrom_ops.to_wait = NULL;
280
// OBSOLETE   nrom_ops.to_post_wait = NULL;
281
// OBSOLETE   nrom_ops.to_fetch_registers = NULL;
282
// OBSOLETE   nrom_ops.to_store_registers = NULL;
283
// OBSOLETE   nrom_ops.to_prepare_to_store = NULL;
284
// OBSOLETE   nrom_ops.to_xfer_memory = NULL;
285
// OBSOLETE   nrom_ops.to_files_info = NULL;
286
// OBSOLETE   nrom_ops.to_insert_breakpoint = NULL;
287
// OBSOLETE   nrom_ops.to_remove_breakpoint = NULL;
288
// OBSOLETE   nrom_ops.to_terminal_init = NULL;
289
// OBSOLETE   nrom_ops.to_terminal_inferior = NULL;
290
// OBSOLETE   nrom_ops.to_terminal_ours_for_output = NULL;
291
// OBSOLETE   nrom_ops.to_terminal_ours = NULL;
292
// OBSOLETE   nrom_ops.to_terminal_info = NULL;
293
// OBSOLETE   nrom_ops.to_kill = nrom_kill;
294
// OBSOLETE   nrom_ops.to_load = nrom_load;
295
// OBSOLETE   nrom_ops.to_lookup_symbol = NULL;
296
// OBSOLETE   nrom_ops.to_create_inferior = NULL;
297
// OBSOLETE   nrom_ops.to_post_startup_inferior = NULL;
298
// OBSOLETE   nrom_ops.to_acknowledge_created_inferior = NULL;
299
// OBSOLETE   nrom_ops.to_clone_and_follow_inferior = NULL;
300
// OBSOLETE   nrom_ops.to_post_follow_inferior_by_clone = NULL;
301
// OBSOLETE   nrom_ops.to_insert_fork_catchpoint = NULL;
302
// OBSOLETE   nrom_ops.to_remove_fork_catchpoint = NULL;
303
// OBSOLETE   nrom_ops.to_insert_vfork_catchpoint = NULL;
304
// OBSOLETE   nrom_ops.to_remove_vfork_catchpoint = NULL;
305
// OBSOLETE   nrom_ops.to_has_forked = NULL;
306
// OBSOLETE   nrom_ops.to_has_vforked = NULL;
307
// OBSOLETE   nrom_ops.to_can_follow_vfork_prior_to_exec = NULL;
308
// OBSOLETE   nrom_ops.to_post_follow_vfork = NULL;
309
// OBSOLETE   nrom_ops.to_insert_exec_catchpoint = NULL;
310
// OBSOLETE   nrom_ops.to_remove_exec_catchpoint = NULL;
311
// OBSOLETE   nrom_ops.to_has_execd = NULL;
312
// OBSOLETE   nrom_ops.to_reported_exec_events_per_exec_call = NULL;
313
// OBSOLETE   nrom_ops.to_has_exited = NULL;
314
// OBSOLETE   nrom_ops.to_mourn_inferior = nrom_mourn;
315
// OBSOLETE   nrom_ops.to_can_run = NULL;
316
// OBSOLETE   nrom_ops.to_notice_signals = 0;
317
// OBSOLETE   nrom_ops.to_thread_alive = 0;
318
// OBSOLETE   nrom_ops.to_stop = 0;
319
// OBSOLETE   nrom_ops.to_pid_to_exec_file = NULL;
320
// OBSOLETE   nrom_ops.to_stratum = download_stratum;
321
// OBSOLETE   nrom_ops.DONT_USE = NULL;
322
// OBSOLETE   nrom_ops.to_has_all_memory = 1;
323
// OBSOLETE   nrom_ops.to_has_memory = 1;
324
// OBSOLETE   nrom_ops.to_has_stack = 1;
325
// OBSOLETE   nrom_ops.to_has_registers = 1;
326
// OBSOLETE   nrom_ops.to_has_execution = 0;
327
// OBSOLETE   nrom_ops.to_sections = NULL;
328
// OBSOLETE   nrom_ops.to_sections_end = NULL;
329
// OBSOLETE   nrom_ops.to_magic = OPS_MAGIC;
330
// OBSOLETE }
331
// OBSOLETE 
332
// OBSOLETE void
333
// OBSOLETE _initialize_remote_nrom (void)
334
// OBSOLETE {
335
// OBSOLETE   init_nrom_ops ();
336
// OBSOLETE   add_target (&nrom_ops);
337
// OBSOLETE 
338
// OBSOLETE   add_show_from_set (
339
// OBSOLETE   add_set_cmd ("nrom_load_port", no_class, var_zinteger, (char *) &load_port,
340
// OBSOLETE            "Set the port to use for NetROM downloads\n", &setlist),
341
// OBSOLETE                   &showlist);
342
// OBSOLETE 
343
// OBSOLETE   add_show_from_set (
344
// OBSOLETE                   add_set_cmd ("nrom_control_port", no_class, var_zinteger, (char *) &control_port,
345
// OBSOLETE         "Set the port to use for NetROM debugger services\n", &setlist),
346
// OBSOLETE                   &showlist);
347
// OBSOLETE 
348
// OBSOLETE   add_cmd ("nrom", no_class, nrom_passthru,
349
// OBSOLETE        "Pass arguments as command to NetROM",
350
// OBSOLETE        &cmdlist);
351
// OBSOLETE }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.