2003-07-16 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / sparcl-tdep.c
CommitLineData
f81824a9
AC
1// OBSOLETE /* Target dependent code for the Fujitsu SPARClite for GDB, the GNU debugger.
2// OBSOLETE Copyright 1994, 1995, 1996, 1998, 1999, 2000, 2001
3// OBSOLETE Free Software Foundation, Inc.
4// OBSOLETE
5// OBSOLETE This file is part of GDB.
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 of the License, or
10// OBSOLETE (at your option) 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
18// OBSOLETE along with this program; if not, write to the Free Software
19// OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
20// OBSOLETE Boston, MA 02111-1307, USA. */
21// OBSOLETE
22// OBSOLETE #include "defs.h"
23// OBSOLETE #include "gdbcore.h"
24// OBSOLETE #include "breakpoint.h"
25// OBSOLETE #include "target.h"
26// OBSOLETE #include "serial.h"
27// OBSOLETE #include "regcache.h"
28// OBSOLETE #include <sys/types.h>
29// OBSOLETE
30// OBSOLETE #if (!defined(__GO32__) && !defined(_WIN32)) || defined(__CYGWIN__)
31// OBSOLETE #define HAVE_SOCKETS
32// OBSOLETE #include <sys/time.h>
33// OBSOLETE #include <sys/socket.h>
34// OBSOLETE #include <netinet/in.h>
35// OBSOLETE #include <netdb.h>
36// OBSOLETE #endif
37// OBSOLETE
38// OBSOLETE static struct target_ops sparclite_ops;
39// OBSOLETE
40// OBSOLETE static char *remote_target_name = NULL;
41// OBSOLETE static struct serial *remote_desc = NULL;
42// OBSOLETE static int serial_flag;
43// OBSOLETE #ifdef HAVE_SOCKETS
44// OBSOLETE static int udp_fd = -1;
45// OBSOLETE #endif
46// OBSOLETE
47// OBSOLETE static struct serial *open_tty (char *name);
48// OBSOLETE static int send_resp (struct serial *desc, char c);
49// OBSOLETE static void close_tty (void * ignore);
50// OBSOLETE #ifdef HAVE_SOCKETS
51// OBSOLETE static int recv_udp_buf (int fd, unsigned char *buf, int len, int timeout);
52// OBSOLETE static int send_udp_buf (int fd, unsigned char *buf, int len);
53// OBSOLETE #endif
54// OBSOLETE static void sparclite_open (char *name, int from_tty);
55// OBSOLETE static void sparclite_close (int quitting);
56// OBSOLETE static void download (char *target_name, char *args, int from_tty,
57// OBSOLETE void (*write_routine) (bfd * from_bfd,
58// OBSOLETE asection * from_sec,
59// OBSOLETE file_ptr from_addr,
60// OBSOLETE bfd_vma to_addr, int len),
61// OBSOLETE void (*start_routine) (bfd_vma entry));
62// OBSOLETE static void sparclite_serial_start (bfd_vma entry);
63// OBSOLETE static void sparclite_serial_write (bfd * from_bfd, asection * from_sec,
64// OBSOLETE file_ptr from_addr,
65// OBSOLETE bfd_vma to_addr, int len);
66// OBSOLETE #ifdef HAVE_SOCKETS
67// OBSOLETE static unsigned short calc_checksum (unsigned char *buffer, int count);
68// OBSOLETE static void sparclite_udp_start (bfd_vma entry);
69// OBSOLETE static void sparclite_udp_write (bfd * from_bfd, asection * from_sec,
70// OBSOLETE file_ptr from_addr, bfd_vma to_addr,
71// OBSOLETE int len);
72// OBSOLETE #endif
73// OBSOLETE static void sparclite_download (char *filename, int from_tty);
74// OBSOLETE
75// OBSOLETE #define DDA2_SUP_ASI 0xb000000
76// OBSOLETE #define DDA1_SUP_ASI 0xb0000
77// OBSOLETE
78// OBSOLETE #define DDA2_ASI_MASK 0xff000000
79// OBSOLETE #define DDA1_ASI_MASK 0xff0000
80// OBSOLETE #define DIA2_SUP_MODE 0x8000
81// OBSOLETE #define DIA1_SUP_MODE 0x4000
82// OBSOLETE #define DDA2_ENABLE 0x100
83// OBSOLETE #define DDA1_ENABLE 0x80
84// OBSOLETE #define DIA2_ENABLE 0x40
85// OBSOLETE #define DIA1_ENABLE 0x20
86// OBSOLETE #define DSINGLE_STEP 0x10 /* not used */
87// OBSOLETE #define DDV_TYPE_MASK 0xc
88// OBSOLETE #define DDV_TYPE_LOAD 0x0
89// OBSOLETE #define DDV_TYPE_STORE 0x4
90// OBSOLETE #define DDV_TYPE_ACCESS 0x8
91// OBSOLETE #define DDV_TYPE_ALWAYS 0xc
92// OBSOLETE #define DDV_COND 0x2
93// OBSOLETE #define DDV_MASK 0x1
94// OBSOLETE
95// OBSOLETE int
96// OBSOLETE sparclite_insert_watchpoint (CORE_ADDR addr, int len, int type)
97// OBSOLETE {
98// OBSOLETE CORE_ADDR dcr;
99// OBSOLETE
100// OBSOLETE dcr = read_register (DCR_REGNUM);
101// OBSOLETE
102// OBSOLETE if (!(dcr & DDA1_ENABLE))
103// OBSOLETE {
104// OBSOLETE write_register (DDA1_REGNUM, addr);
105// OBSOLETE dcr &= ~(DDA1_ASI_MASK | DDV_TYPE_MASK);
106// OBSOLETE dcr |= (DDA1_SUP_ASI | DDA1_ENABLE);
107// OBSOLETE if (type == 1)
108// OBSOLETE {
109// OBSOLETE write_register (DDV1_REGNUM, 0);
110// OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
111// OBSOLETE dcr |= (DDV_TYPE_LOAD & (~DDV_COND & ~DDV_MASK));
112// OBSOLETE }
113// OBSOLETE else if (type == 0)
114// OBSOLETE {
115// OBSOLETE write_register (DDV1_REGNUM, 0);
116// OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
117// OBSOLETE dcr |= (DDV_TYPE_STORE & (~DDV_COND & ~DDV_MASK));
118// OBSOLETE }
119// OBSOLETE else
120// OBSOLETE {
121// OBSOLETE write_register (DDV1_REGNUM, 0);
122// OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
123// OBSOLETE dcr |= (DDV_TYPE_ACCESS);
124// OBSOLETE }
125// OBSOLETE write_register (DCR_REGNUM, dcr);
126// OBSOLETE }
127// OBSOLETE else if (!(dcr & DDA2_ENABLE))
128// OBSOLETE {
129// OBSOLETE write_register (DDA2_REGNUM, addr);
130// OBSOLETE dcr &= ~(DDA2_ASI_MASK & DDV_TYPE_MASK);
131// OBSOLETE dcr |= (DDA2_SUP_ASI | DDA2_ENABLE);
132// OBSOLETE if (type == 1)
133// OBSOLETE {
134// OBSOLETE write_register (DDV1_REGNUM, 0);
135// OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
136// OBSOLETE dcr |= (DDV_TYPE_LOAD & ~DDV_COND & ~DDV_MASK);
137// OBSOLETE }
138// OBSOLETE else if (type == 0)
139// OBSOLETE {
140// OBSOLETE write_register (DDV1_REGNUM, 0);
141// OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
142// OBSOLETE dcr |= (DDV_TYPE_STORE & ~DDV_COND & ~DDV_MASK);
143// OBSOLETE }
144// OBSOLETE else
145// OBSOLETE {
146// OBSOLETE write_register (DDV1_REGNUM, 0);
147// OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
148// OBSOLETE dcr |= (DDV_TYPE_ACCESS);
149// OBSOLETE }
150// OBSOLETE write_register (DCR_REGNUM, dcr);
151// OBSOLETE }
152// OBSOLETE else
153// OBSOLETE return -1;
154// OBSOLETE
155// OBSOLETE return 0;
156// OBSOLETE }
157// OBSOLETE
158// OBSOLETE int
159// OBSOLETE sparclite_remove_watchpoint (CORE_ADDR addr, int len, int type)
160// OBSOLETE {
161// OBSOLETE CORE_ADDR dcr, dda1, dda2;
162// OBSOLETE
163// OBSOLETE dcr = read_register (DCR_REGNUM);
164// OBSOLETE dda1 = read_register (DDA1_REGNUM);
165// OBSOLETE dda2 = read_register (DDA2_REGNUM);
166// OBSOLETE
167// OBSOLETE if ((dcr & DDA1_ENABLE) && addr == dda1)
168// OBSOLETE write_register (DCR_REGNUM, (dcr & ~DDA1_ENABLE));
169// OBSOLETE else if ((dcr & DDA2_ENABLE) && addr == dda2)
170// OBSOLETE write_register (DCR_REGNUM, (dcr & ~DDA2_ENABLE));
171// OBSOLETE else
172// OBSOLETE return -1;
173// OBSOLETE
174// OBSOLETE return 0;
175// OBSOLETE }
176// OBSOLETE
177// OBSOLETE int
178// OBSOLETE sparclite_insert_hw_breakpoint (CORE_ADDR addr, int len)
179// OBSOLETE {
180// OBSOLETE CORE_ADDR dcr;
181// OBSOLETE
182// OBSOLETE dcr = read_register (DCR_REGNUM);
183// OBSOLETE
184// OBSOLETE if (!(dcr & DIA1_ENABLE))
185// OBSOLETE {
186// OBSOLETE write_register (DIA1_REGNUM, addr);
187// OBSOLETE write_register (DCR_REGNUM, (dcr | DIA1_ENABLE | DIA1_SUP_MODE));
188// OBSOLETE }
189// OBSOLETE else if (!(dcr & DIA2_ENABLE))
190// OBSOLETE {
191// OBSOLETE write_register (DIA2_REGNUM, addr);
192// OBSOLETE write_register (DCR_REGNUM, (dcr | DIA2_ENABLE | DIA2_SUP_MODE));
193// OBSOLETE }
194// OBSOLETE else
195// OBSOLETE return -1;
196// OBSOLETE
197// OBSOLETE return 0;
198// OBSOLETE }
199// OBSOLETE
200// OBSOLETE int
201// OBSOLETE sparclite_remove_hw_breakpoint (CORE_ADDR addr, int shadow)
202// OBSOLETE {
203// OBSOLETE CORE_ADDR dcr, dia1, dia2;
204// OBSOLETE
205// OBSOLETE dcr = read_register (DCR_REGNUM);
206// OBSOLETE dia1 = read_register (DIA1_REGNUM);
207// OBSOLETE dia2 = read_register (DIA2_REGNUM);
208// OBSOLETE
209// OBSOLETE if ((dcr & DIA1_ENABLE) && addr == dia1)
210// OBSOLETE write_register (DCR_REGNUM, (dcr & ~DIA1_ENABLE));
211// OBSOLETE else if ((dcr & DIA2_ENABLE) && addr == dia2)
212// OBSOLETE write_register (DCR_REGNUM, (dcr & ~DIA2_ENABLE));
213// OBSOLETE else
214// OBSOLETE return -1;
215// OBSOLETE
216// OBSOLETE return 0;
217// OBSOLETE }
218// OBSOLETE
219// OBSOLETE int
220// OBSOLETE sparclite_check_watch_resources (int type, int cnt, int ot)
221// OBSOLETE {
222// OBSOLETE /* Watchpoints not supported on simulator. */
223// OBSOLETE if (strcmp (target_shortname, "sim") == 0)
224// OBSOLETE return 0;
225// OBSOLETE
226// OBSOLETE if (type == bp_hardware_breakpoint)
227// OBSOLETE {
228// OBSOLETE if (TARGET_HW_BREAK_LIMIT == 0)
229// OBSOLETE return 0;
230// OBSOLETE else if (cnt <= TARGET_HW_BREAK_LIMIT)
231// OBSOLETE return 1;
232// OBSOLETE }
233// OBSOLETE else
234// OBSOLETE {
235// OBSOLETE if (TARGET_HW_WATCH_LIMIT == 0)
236// OBSOLETE return 0;
237// OBSOLETE else if (ot)
238// OBSOLETE return -1;
239// OBSOLETE else if (cnt <= TARGET_HW_WATCH_LIMIT)
240// OBSOLETE return 1;
241// OBSOLETE }
242// OBSOLETE return -1;
243// OBSOLETE }
244// OBSOLETE
245// OBSOLETE CORE_ADDR
246// OBSOLETE sparclite_stopped_data_address (void)
247// OBSOLETE {
248// OBSOLETE CORE_ADDR dsr, dda1, dda2;
249// OBSOLETE
250// OBSOLETE dsr = read_register (DSR_REGNUM);
251// OBSOLETE dda1 = read_register (DDA1_REGNUM);
252// OBSOLETE dda2 = read_register (DDA2_REGNUM);
253// OBSOLETE
254// OBSOLETE if (dsr & 0x10)
255// OBSOLETE return dda1;
256// OBSOLETE else if (dsr & 0x20)
257// OBSOLETE return dda2;
258// OBSOLETE else
259// OBSOLETE return 0;
260// OBSOLETE }
261// OBSOLETE \f
262// OBSOLETE static struct serial *
263// OBSOLETE open_tty (char *name)
264// OBSOLETE {
265// OBSOLETE struct serial *desc;
266// OBSOLETE
267// OBSOLETE desc = serial_open (name);
268// OBSOLETE if (!desc)
269// OBSOLETE perror_with_name (name);
270// OBSOLETE
271// OBSOLETE if (baud_rate != -1)
272// OBSOLETE {
273// OBSOLETE if (serial_setbaudrate (desc, baud_rate))
274// OBSOLETE {
275// OBSOLETE serial_close (desc);
276// OBSOLETE perror_with_name (name);
277// OBSOLETE }
278// OBSOLETE }
279// OBSOLETE
280// OBSOLETE serial_raw (desc);
281// OBSOLETE
282// OBSOLETE serial_flush_input (desc);
283// OBSOLETE
284// OBSOLETE return desc;
285// OBSOLETE }
286// OBSOLETE
287// OBSOLETE /* Read a single character from the remote end, masking it down to 7 bits. */
288// OBSOLETE
289// OBSOLETE static int
290// OBSOLETE readchar (struct serial *desc, int timeout)
291// OBSOLETE {
292// OBSOLETE int ch;
293// OBSOLETE char s[10];
294// OBSOLETE
295// OBSOLETE ch = serial_readchar (desc, timeout);
296// OBSOLETE
297// OBSOLETE switch (ch)
298// OBSOLETE {
299// OBSOLETE case SERIAL_EOF:
300// OBSOLETE error ("SPARClite remote connection closed");
301// OBSOLETE case SERIAL_ERROR:
302// OBSOLETE perror_with_name ("SPARClite communication error");
303// OBSOLETE case SERIAL_TIMEOUT:
304// OBSOLETE error ("SPARClite remote timeout");
305// OBSOLETE default:
306// OBSOLETE if (remote_debug > 0)
307// OBSOLETE {
308// OBSOLETE sprintf (s, "[%02x]", ch & 0xff);
309// OBSOLETE puts_debug ("read -->", s, "<--");
310// OBSOLETE }
311// OBSOLETE return ch;
312// OBSOLETE }
313// OBSOLETE }
314// OBSOLETE
315// OBSOLETE static void
316// OBSOLETE debug_serial_write (struct serial *desc, char *buf, int len)
317// OBSOLETE {
318// OBSOLETE char s[10];
319// OBSOLETE
320// OBSOLETE serial_write (desc, buf, len);
321// OBSOLETE if (remote_debug > 0)
322// OBSOLETE {
323// OBSOLETE while (len-- > 0)
324// OBSOLETE {
325// OBSOLETE sprintf (s, "[%02x]", *buf & 0xff);
326// OBSOLETE puts_debug ("Sent -->", s, "<--");
327// OBSOLETE buf++;
328// OBSOLETE }
329// OBSOLETE }
330// OBSOLETE }
331// OBSOLETE
332// OBSOLETE
333// OBSOLETE static int
334// OBSOLETE send_resp (struct serial *desc, char c)
335// OBSOLETE {
336// OBSOLETE debug_serial_write (desc, &c, 1);
337// OBSOLETE return readchar (desc, remote_timeout);
338// OBSOLETE }
339// OBSOLETE
340// OBSOLETE static void
341// OBSOLETE close_tty (void *ignore)
342// OBSOLETE {
343// OBSOLETE if (!remote_desc)
344// OBSOLETE return;
345// OBSOLETE
346// OBSOLETE serial_close (remote_desc);
347// OBSOLETE
348// OBSOLETE remote_desc = NULL;
349// OBSOLETE }
350// OBSOLETE
351// OBSOLETE #ifdef HAVE_SOCKETS
352// OBSOLETE static int
353// OBSOLETE recv_udp_buf (int fd, unsigned char *buf, int len, int timeout)
354// OBSOLETE {
355// OBSOLETE int cc;
356// OBSOLETE fd_set readfds;
357// OBSOLETE
358// OBSOLETE FD_ZERO (&readfds);
359// OBSOLETE FD_SET (fd, &readfds);
360// OBSOLETE
361// OBSOLETE if (timeout >= 0)
362// OBSOLETE {
363// OBSOLETE struct timeval timebuf;
364// OBSOLETE
365// OBSOLETE timebuf.tv_sec = timeout;
366// OBSOLETE timebuf.tv_usec = 0;
367// OBSOLETE cc = select (fd + 1, &readfds, 0, 0, &timebuf);
368// OBSOLETE }
369// OBSOLETE else
370// OBSOLETE cc = select (fd + 1, &readfds, 0, 0, 0);
371// OBSOLETE
372// OBSOLETE if (cc == 0)
373// OBSOLETE return 0;
374// OBSOLETE
375// OBSOLETE if (cc != 1)
376// OBSOLETE perror_with_name ("recv_udp_buf: Bad return value from select:");
377// OBSOLETE
378// OBSOLETE cc = recv (fd, buf, len, 0);
379// OBSOLETE
380// OBSOLETE if (cc < 0)
381// OBSOLETE perror_with_name ("Got an error from recv: ");
382// OBSOLETE }
383// OBSOLETE
384// OBSOLETE static int
385// OBSOLETE send_udp_buf (int fd, unsigned char *buf, int len)
386// OBSOLETE {
387// OBSOLETE int cc;
388// OBSOLETE
389// OBSOLETE cc = send (fd, buf, len, 0);
390// OBSOLETE
391// OBSOLETE if (cc == len)
392// OBSOLETE return;
393// OBSOLETE
394// OBSOLETE if (cc < 0)
395// OBSOLETE perror_with_name ("Got an error from send: ");
396// OBSOLETE
397// OBSOLETE error ("Short count in send: tried %d, sent %d\n", len, cc);
398// OBSOLETE }
399// OBSOLETE #endif /* HAVE_SOCKETS */
400// OBSOLETE
401// OBSOLETE static void
402// OBSOLETE sparclite_open (char *name, int from_tty)
403// OBSOLETE {
404// OBSOLETE struct cleanup *old_chain;
405// OBSOLETE int c;
406// OBSOLETE char *p;
407// OBSOLETE
408// OBSOLETE if (!name)
409// OBSOLETE error ("You need to specify what device or hostname is associated with the SparcLite board.");
410// OBSOLETE
411// OBSOLETE target_preopen (from_tty);
412// OBSOLETE
413// OBSOLETE unpush_target (&sparclite_ops);
414// OBSOLETE
415// OBSOLETE if (remote_target_name)
416// OBSOLETE xfree (remote_target_name);
417// OBSOLETE
418// OBSOLETE remote_target_name = xstrdup (name);
419// OBSOLETE
420// OBSOLETE /* We need a 'serial' or 'udp' keyword to disambiguate host:port, which can
421// OBSOLETE mean either a serial port on a terminal server, or the IP address of a
422// OBSOLETE SPARClite demo board. If there's no colon, then it pretty much has to be
423// OBSOLETE a local device (except for DOS... grrmble) */
424// OBSOLETE
425// OBSOLETE p = strchr (name, ' ');
426// OBSOLETE
427// OBSOLETE if (p)
428// OBSOLETE {
429// OBSOLETE *p++ = '\000';
430// OBSOLETE while ((*p != '\000') && isspace (*p))
431// OBSOLETE p++;
432// OBSOLETE
433// OBSOLETE if (strncmp (name, "serial", strlen (name)) == 0)
434// OBSOLETE serial_flag = 1;
435// OBSOLETE else if (strncmp (name, "udp", strlen (name)) == 0)
436// OBSOLETE serial_flag = 0;
437// OBSOLETE else
438// OBSOLETE error ("Must specify either `serial' or `udp'.");
439// OBSOLETE }
440// OBSOLETE else
441// OBSOLETE {
442// OBSOLETE p = name;
443// OBSOLETE
444// OBSOLETE if (!strchr (name, ':'))
445// OBSOLETE serial_flag = 1; /* No colon is unambiguous (local device) */
446// OBSOLETE else
447// OBSOLETE error ("Usage: target sparclite serial /dev/ttyb\n\
448// OBSOLETE or: target sparclite udp host");
449// OBSOLETE }
450// OBSOLETE
451// OBSOLETE if (serial_flag)
452// OBSOLETE {
453// OBSOLETE remote_desc = open_tty (p);
454// OBSOLETE
455// OBSOLETE old_chain = make_cleanup (close_tty, 0 /*ignore*/);
456// OBSOLETE
457// OBSOLETE c = send_resp (remote_desc, 0x00);
458// OBSOLETE
459// OBSOLETE if (c != 0xaa)
460// OBSOLETE error ("Unknown response (0x%x) from SparcLite. Try resetting the board.",
461// OBSOLETE c);
462// OBSOLETE
463// OBSOLETE c = send_resp (remote_desc, 0x55);
464// OBSOLETE
465// OBSOLETE if (c != 0x55)
466// OBSOLETE error ("Sparclite appears to be ill.");
467// OBSOLETE }
468// OBSOLETE else
469// OBSOLETE {
470// OBSOLETE #ifdef HAVE_SOCKETS
471// OBSOLETE struct hostent *he;
472// OBSOLETE struct sockaddr_in sockaddr;
473// OBSOLETE unsigned char buffer[100];
474// OBSOLETE int cc;
475// OBSOLETE
476// OBSOLETE /* Setup the socket. Must be raw UDP. */
477// OBSOLETE
478// OBSOLETE he = gethostbyname (p);
479// OBSOLETE
480// OBSOLETE if (!he)
481// OBSOLETE error ("No such host %s.", p);
482// OBSOLETE
483// OBSOLETE udp_fd = socket (PF_INET, SOCK_DGRAM, 0);
484// OBSOLETE
485// OBSOLETE old_chain = make_cleanup (close, udp_fd);
486// OBSOLETE
487// OBSOLETE sockaddr.sin_family = PF_INET;
488// OBSOLETE sockaddr.sin_port = htons (7000);
489// OBSOLETE memcpy (&sockaddr.sin_addr.s_addr, he->h_addr, sizeof (struct in_addr));
490// OBSOLETE
491// OBSOLETE if (connect (udp_fd, &sockaddr, sizeof (sockaddr)))
492// OBSOLETE perror_with_name ("Connect failed");
493// OBSOLETE
494// OBSOLETE buffer[0] = 0x5;
495// OBSOLETE buffer[1] = 0;
496// OBSOLETE
497// OBSOLETE send_udp_buf (udp_fd, buffer, 2); /* Request version */
498// OBSOLETE cc = recv_udp_buf (udp_fd, buffer, sizeof (buffer), 5); /* Get response */
499// OBSOLETE if (cc == 0)
500// OBSOLETE error ("SPARClite isn't responding.");
501// OBSOLETE
502// OBSOLETE if (cc < 3)
503// OBSOLETE error ("SPARClite appears to be ill.");
504// OBSOLETE #else
505// OBSOLETE error ("UDP downloading is not supported for DOS hosts.");
506// OBSOLETE #endif /* HAVE_SOCKETS */
507// OBSOLETE }
508// OBSOLETE
509// OBSOLETE printf_unfiltered ("[SPARClite appears to be alive]\n");
510// OBSOLETE
511// OBSOLETE push_target (&sparclite_ops);
512// OBSOLETE
513// OBSOLETE discard_cleanups (old_chain);
514// OBSOLETE
515// OBSOLETE return;
516// OBSOLETE }
517// OBSOLETE
518// OBSOLETE static void
519// OBSOLETE sparclite_close (int quitting)
520// OBSOLETE {
521// OBSOLETE if (serial_flag)
522// OBSOLETE close_tty (0);
523// OBSOLETE #ifdef HAVE_SOCKETS
524// OBSOLETE else if (udp_fd != -1)
525// OBSOLETE close (udp_fd);
526// OBSOLETE #endif
527// OBSOLETE }
528// OBSOLETE
529// OBSOLETE #define LOAD_ADDRESS 0x40000000
530// OBSOLETE
531// OBSOLETE static void
532// OBSOLETE download (char *target_name, char *args, int from_tty,
533// OBSOLETE void (*write_routine) (bfd *from_bfd, asection *from_sec,
534// OBSOLETE file_ptr from_addr, bfd_vma to_addr, int len),
535// OBSOLETE void (*start_routine) (bfd_vma entry))
536// OBSOLETE {
537// OBSOLETE struct cleanup *old_chain;
538// OBSOLETE asection *section;
539// OBSOLETE bfd *pbfd;
540// OBSOLETE bfd_vma entry;
541// OBSOLETE int i;
542// OBSOLETE #define WRITESIZE 1024
543// OBSOLETE char *filename;
544// OBSOLETE int quiet;
545// OBSOLETE int nostart;
546// OBSOLETE
547// OBSOLETE quiet = 0;
548// OBSOLETE nostart = 0;
549// OBSOLETE filename = NULL;
550// OBSOLETE
551// OBSOLETE while (*args != '\000')
552// OBSOLETE {
553// OBSOLETE char *arg;
554// OBSOLETE
555// OBSOLETE while (isspace (*args))
556// OBSOLETE args++;
557// OBSOLETE
558// OBSOLETE arg = args;
559// OBSOLETE
560// OBSOLETE while ((*args != '\000') && !isspace (*args))
561// OBSOLETE args++;
562// OBSOLETE
563// OBSOLETE if (*args != '\000')
564// OBSOLETE *args++ = '\000';
565// OBSOLETE
566// OBSOLETE if (*arg != '-')
567// OBSOLETE filename = arg;
568// OBSOLETE else if (strncmp (arg, "-quiet", strlen (arg)) == 0)
569// OBSOLETE quiet = 1;
570// OBSOLETE else if (strncmp (arg, "-nostart", strlen (arg)) == 0)
571// OBSOLETE nostart = 1;
572// OBSOLETE else
573// OBSOLETE error ("unknown option `%s'", arg);
574// OBSOLETE }
575// OBSOLETE
576// OBSOLETE if (!filename)
577// OBSOLETE filename = get_exec_file (1);
578// OBSOLETE
579// OBSOLETE pbfd = bfd_openr (filename, gnutarget);
580// OBSOLETE if (pbfd == NULL)
581// OBSOLETE {
582// OBSOLETE perror_with_name (filename);
583// OBSOLETE return;
584// OBSOLETE }
585// OBSOLETE old_chain = make_cleanup_bfd_close (pbfd);
586// OBSOLETE
587// OBSOLETE if (!bfd_check_format (pbfd, bfd_object))
588// OBSOLETE error ("\"%s\" is not an object file: %s", filename,
589// OBSOLETE bfd_errmsg (bfd_get_error ()));
590// OBSOLETE
591// OBSOLETE for (section = pbfd->sections; section; section = section->next)
592// OBSOLETE {
593// OBSOLETE if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)
594// OBSOLETE {
595// OBSOLETE bfd_vma section_address;
596// OBSOLETE bfd_size_type section_size;
597// OBSOLETE file_ptr fptr;
598// OBSOLETE const char *section_name;
599// OBSOLETE
600// OBSOLETE section_name = bfd_get_section_name (pbfd, section);
601// OBSOLETE
602// OBSOLETE section_address = bfd_get_section_vma (pbfd, section);
603// OBSOLETE
604// OBSOLETE /* Adjust sections from a.out files, since they don't
605// OBSOLETE carry their addresses with. */
606// OBSOLETE if (bfd_get_flavour (pbfd) == bfd_target_aout_flavour)
607// OBSOLETE {
608// OBSOLETE if (strcmp (section_name, ".text") == 0)
609// OBSOLETE section_address = bfd_get_start_address (pbfd);
610// OBSOLETE else if (strcmp (section_name, ".data") == 0)
611// OBSOLETE {
612// OBSOLETE /* Read the first 8 bytes of the data section.
613// OBSOLETE There should be the string 'DaTa' followed by
614// OBSOLETE a word containing the actual section address. */
615// OBSOLETE struct data_marker
616// OBSOLETE {
617// OBSOLETE char signature[4]; /* 'DaTa' */
618// OBSOLETE unsigned char sdata[4]; /* &sdata */
619// OBSOLETE }
620// OBSOLETE marker;
621// OBSOLETE bfd_get_section_contents (pbfd, section, &marker, 0,
622// OBSOLETE sizeof (marker));
623// OBSOLETE if (strncmp (marker.signature, "DaTa", 4) == 0)
624// OBSOLETE {
625// OBSOLETE if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
626// OBSOLETE section_address = bfd_getb32 (marker.sdata);
627// OBSOLETE else
628// OBSOLETE section_address = bfd_getl32 (marker.sdata);
629// OBSOLETE }
630// OBSOLETE }
631// OBSOLETE }
632// OBSOLETE
633// OBSOLETE section_size = bfd_get_section_size_before_reloc (section);
634// OBSOLETE
635// OBSOLETE if (!quiet)
636// OBSOLETE printf_filtered ("[Loading section %s at 0x%x (%d bytes)]\n",
637// OBSOLETE bfd_get_section_name (pbfd, section),
638// OBSOLETE section_address,
639// OBSOLETE section_size);
640// OBSOLETE
641// OBSOLETE fptr = 0;
642// OBSOLETE while (section_size > 0)
643// OBSOLETE {
644// OBSOLETE int count;
645// OBSOLETE static char inds[] = "|/-\\";
646// OBSOLETE static int k = 0;
647// OBSOLETE
648// OBSOLETE QUIT;
649// OBSOLETE
650// OBSOLETE count = min (section_size, WRITESIZE);
651// OBSOLETE
652// OBSOLETE write_routine (pbfd, section, fptr, section_address, count);
653// OBSOLETE
654// OBSOLETE if (!quiet)
655// OBSOLETE {
656// OBSOLETE printf_unfiltered ("\r%c", inds[k++ % 4]);
657// OBSOLETE gdb_flush (gdb_stdout);
658// OBSOLETE }
659// OBSOLETE
660// OBSOLETE section_address += count;
661// OBSOLETE fptr += count;
662// OBSOLETE section_size -= count;
663// OBSOLETE }
664// OBSOLETE }
665// OBSOLETE }
666// OBSOLETE
667// OBSOLETE if (!nostart)
668// OBSOLETE {
669// OBSOLETE entry = bfd_get_start_address (pbfd);
670// OBSOLETE
671// OBSOLETE if (!quiet)
672// OBSOLETE printf_unfiltered ("[Starting %s at 0x%x]\n", filename, entry);
673// OBSOLETE
674// OBSOLETE start_routine (entry);
675// OBSOLETE }
676// OBSOLETE
677// OBSOLETE do_cleanups (old_chain);
678// OBSOLETE }
679// OBSOLETE
680// OBSOLETE static void
681// OBSOLETE sparclite_serial_start (bfd_vma entry)
682// OBSOLETE {
683// OBSOLETE char buffer[5];
684// OBSOLETE int i;
685// OBSOLETE
686// OBSOLETE buffer[0] = 0x03;
687// OBSOLETE store_unsigned_integer (buffer + 1, 4, entry);
688// OBSOLETE
689// OBSOLETE debug_serial_write (remote_desc, buffer, 1 + 4);
690// OBSOLETE i = readchar (remote_desc, remote_timeout);
691// OBSOLETE if (i != 0x55)
692// OBSOLETE error ("Can't start SparcLite. Error code %d\n", i);
693// OBSOLETE }
694// OBSOLETE
695// OBSOLETE static void
696// OBSOLETE sparclite_serial_write (bfd *from_bfd, asection *from_sec, file_ptr from_addr,
697// OBSOLETE bfd_vma to_addr, int len)
698// OBSOLETE {
699// OBSOLETE char buffer[4 + 4 + WRITESIZE]; /* addr + len + data */
700// OBSOLETE unsigned char checksum;
701// OBSOLETE int i;
702// OBSOLETE
703// OBSOLETE store_unsigned_integer (buffer, 4, to_addr); /* Address */
704// OBSOLETE store_unsigned_integer (buffer + 4, 4, len); /* Length */
705// OBSOLETE
706// OBSOLETE bfd_get_section_contents (from_bfd, from_sec, buffer + 8, from_addr, len);
707// OBSOLETE
708// OBSOLETE checksum = 0;
709// OBSOLETE for (i = 0; i < len; i++)
710// OBSOLETE checksum += buffer[8 + i];
711// OBSOLETE
712// OBSOLETE i = send_resp (remote_desc, 0x01);
713// OBSOLETE
714// OBSOLETE if (i != 0x5a)
715// OBSOLETE error ("Bad response from load command (0x%x)", i);
716// OBSOLETE
717// OBSOLETE debug_serial_write (remote_desc, buffer, 4 + 4 + len);
718// OBSOLETE i = readchar (remote_desc, remote_timeout);
719// OBSOLETE
720// OBSOLETE if (i != checksum)
721// OBSOLETE error ("Bad checksum from load command (0x%x)", i);
722// OBSOLETE }
723// OBSOLETE
724// OBSOLETE #ifdef HAVE_SOCKETS
725// OBSOLETE
726// OBSOLETE static unsigned short
727// OBSOLETE calc_checksum (unsigned char *buffer, int count)
728// OBSOLETE {
729// OBSOLETE unsigned short checksum;
730// OBSOLETE
731// OBSOLETE checksum = 0;
732// OBSOLETE for (; count > 0; count -= 2, buffer += 2)
733// OBSOLETE checksum += (*buffer << 8) | *(buffer + 1);
734// OBSOLETE
735// OBSOLETE if (count != 0)
736// OBSOLETE checksum += *buffer << 8;
737// OBSOLETE
738// OBSOLETE return checksum;
739// OBSOLETE }
740// OBSOLETE
741// OBSOLETE static void
742// OBSOLETE sparclite_udp_start (bfd_vma entry)
743// OBSOLETE {
744// OBSOLETE unsigned char buffer[6];
745// OBSOLETE int i;
746// OBSOLETE
747// OBSOLETE buffer[0] = 0x3;
748// OBSOLETE buffer[1] = 0;
749// OBSOLETE buffer[2] = entry >> 24;
750// OBSOLETE buffer[3] = entry >> 16;
751// OBSOLETE buffer[4] = entry >> 8;
752// OBSOLETE buffer[5] = entry;
753// OBSOLETE
754// OBSOLETE send_udp_buf (udp_fd, buffer, 6); /* Send start addr */
755// OBSOLETE i = recv_udp_buf (udp_fd, buffer, sizeof (buffer), -1); /* Get response */
756// OBSOLETE
757// OBSOLETE if (i < 1 || buffer[0] != 0x55)
758// OBSOLETE error ("Failed to take start address.");
759// OBSOLETE }
760// OBSOLETE
761// OBSOLETE static void
762// OBSOLETE sparclite_udp_write (bfd *from_bfd, asection *from_sec, file_ptr from_addr,
763// OBSOLETE bfd_vma to_addr, int len)
764// OBSOLETE {
765// OBSOLETE unsigned char buffer[2000];
766// OBSOLETE unsigned short checksum;
767// OBSOLETE static int pkt_num = 0;
768// OBSOLETE static unsigned long old_addr = -1;
769// OBSOLETE int i;
770// OBSOLETE
771// OBSOLETE while (1)
772// OBSOLETE {
773// OBSOLETE if (to_addr != old_addr)
774// OBSOLETE {
775// OBSOLETE buffer[0] = 0x1; /* Load command */
776// OBSOLETE buffer[1] = 0x1; /* Loading address */
777// OBSOLETE buffer[2] = to_addr >> 24;
778// OBSOLETE buffer[3] = to_addr >> 16;
779// OBSOLETE buffer[4] = to_addr >> 8;
780// OBSOLETE buffer[5] = to_addr;
781// OBSOLETE
782// OBSOLETE checksum = 0;
783// OBSOLETE for (i = 0; i < 6; i++)
784// OBSOLETE checksum += buffer[i];
785// OBSOLETE checksum &= 0xff;
786// OBSOLETE
787// OBSOLETE send_udp_buf (udp_fd, buffer, 6);
788// OBSOLETE i = recv_udp_buf (udp_fd, buffer, sizeof buffer, -1);
789// OBSOLETE
790// OBSOLETE if (i < 1)
791// OBSOLETE error ("Got back short checksum for load addr.");
792// OBSOLETE
793// OBSOLETE if (checksum != buffer[0])
794// OBSOLETE error ("Got back bad checksum for load addr.");
795// OBSOLETE
796// OBSOLETE pkt_num = 0; /* Load addr resets packet seq # */
797// OBSOLETE old_addr = to_addr;
798// OBSOLETE }
799// OBSOLETE
800// OBSOLETE bfd_get_section_contents (from_bfd, from_sec, buffer + 6, from_addr,
801// OBSOLETE len);
802// OBSOLETE
803// OBSOLETE checksum = calc_checksum (buffer + 6, len);
804// OBSOLETE
805// OBSOLETE buffer[0] = 0x1; /* Load command */
806// OBSOLETE buffer[1] = 0x2; /* Loading data */
807// OBSOLETE buffer[2] = pkt_num >> 8;
808// OBSOLETE buffer[3] = pkt_num;
809// OBSOLETE buffer[4] = checksum >> 8;
810// OBSOLETE buffer[5] = checksum;
811// OBSOLETE
812// OBSOLETE send_udp_buf (udp_fd, buffer, len + 6);
813// OBSOLETE i = recv_udp_buf (udp_fd, buffer, sizeof buffer, 3);
814// OBSOLETE
815// OBSOLETE if (i == 0)
816// OBSOLETE {
817// OBSOLETE fprintf_unfiltered (gdb_stderr, "send_data: timeout sending %d bytes to address 0x%x retrying\n", len, to_addr);
818// OBSOLETE continue;
819// OBSOLETE }
820// OBSOLETE
821// OBSOLETE if (buffer[0] != 0xff)
822// OBSOLETE error ("Got back bad response for load data.");
823// OBSOLETE
824// OBSOLETE old_addr += len;
825// OBSOLETE pkt_num++;
826// OBSOLETE
827// OBSOLETE return;
828// OBSOLETE }
829// OBSOLETE }
830// OBSOLETE
831// OBSOLETE #endif /* HAVE_SOCKETS */
832// OBSOLETE
833// OBSOLETE static void
834// OBSOLETE sparclite_download (char *filename, int from_tty)
835// OBSOLETE {
836// OBSOLETE if (!serial_flag)
837// OBSOLETE #ifdef HAVE_SOCKETS
838// OBSOLETE download (remote_target_name, filename, from_tty, sparclite_udp_write,
839// OBSOLETE sparclite_udp_start);
840// OBSOLETE #else
841// OBSOLETE internal_error (__FILE__, __LINE__, "failed internal consistency check"); /* sparclite_open should prevent this! */
842// OBSOLETE #endif
843// OBSOLETE else
844// OBSOLETE download (remote_target_name, filename, from_tty, sparclite_serial_write,
845// OBSOLETE sparclite_serial_start);
846// OBSOLETE }
847// OBSOLETE \f
848// OBSOLETE /* Set up the sparclite target vector. */
849// OBSOLETE
850// OBSOLETE static void
851// OBSOLETE init_sparclite_ops (void)
852// OBSOLETE {
853// OBSOLETE sparclite_ops.to_shortname = "sparclite";
854// OBSOLETE sparclite_ops.to_longname = "SPARClite download target";
855// OBSOLETE sparclite_ops.to_doc = "Download to a remote SPARClite target board via serial of UDP.\n\
856// OBSOLETE Specify the device it is connected to (e.g. /dev/ttya).";
857// OBSOLETE sparclite_ops.to_open = sparclite_open;
858// OBSOLETE sparclite_ops.to_close = sparclite_close;
859// OBSOLETE sparclite_ops.to_load = sparclite_download;
860// OBSOLETE sparclite_ops.to_stratum = download_stratum;
861// OBSOLETE sparclite_ops.to_magic = OPS_MAGIC;
862// OBSOLETE }
863// OBSOLETE
864// OBSOLETE void
865// OBSOLETE _initialize_sparcl_tdep (void)
866// OBSOLETE {
867// OBSOLETE init_sparclite_ops ();
868// OBSOLETE add_target (&sparclite_ops);
869// OBSOLETE }
This page took 0.088244 seconds and 4 git commands to generate.