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.
5 // OBSOLETE This file is part of GDB.
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.
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.
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. */
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>
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>
38 // OBSOLETE static struct target_ops sparclite_ops;
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;
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);
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,
73 // OBSOLETE static void sparclite_download (char *filename, int from_tty);
75 // OBSOLETE #define DDA2_SUP_ASI 0xb000000
76 // OBSOLETE #define DDA1_SUP_ASI 0xb0000
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
96 // OBSOLETE sparclite_insert_watchpoint (CORE_ADDR addr, int len, int type)
98 // OBSOLETE CORE_ADDR dcr;
100 // OBSOLETE dcr = read_register (DCR_REGNUM);
102 // OBSOLETE if (!(dcr & DDA1_ENABLE))
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)
109 // OBSOLETE write_register (DDV1_REGNUM, 0);
110 // OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
111 // OBSOLETE dcr |= (DDV_TYPE_LOAD & (~DDV_COND & ~DDV_MASK));
113 // OBSOLETE else if (type == 0)
115 // OBSOLETE write_register (DDV1_REGNUM, 0);
116 // OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
117 // OBSOLETE dcr |= (DDV_TYPE_STORE & (~DDV_COND & ~DDV_MASK));
121 // OBSOLETE write_register (DDV1_REGNUM, 0);
122 // OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
123 // OBSOLETE dcr |= (DDV_TYPE_ACCESS);
125 // OBSOLETE write_register (DCR_REGNUM, dcr);
127 // OBSOLETE else if (!(dcr & DDA2_ENABLE))
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)
134 // OBSOLETE write_register (DDV1_REGNUM, 0);
135 // OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
136 // OBSOLETE dcr |= (DDV_TYPE_LOAD & ~DDV_COND & ~DDV_MASK);
138 // OBSOLETE else if (type == 0)
140 // OBSOLETE write_register (DDV1_REGNUM, 0);
141 // OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
142 // OBSOLETE dcr |= (DDV_TYPE_STORE & ~DDV_COND & ~DDV_MASK);
146 // OBSOLETE write_register (DDV1_REGNUM, 0);
147 // OBSOLETE write_register (DDV2_REGNUM, 0xffffffff);
148 // OBSOLETE dcr |= (DDV_TYPE_ACCESS);
150 // OBSOLETE write_register (DCR_REGNUM, dcr);
153 // OBSOLETE return -1;
155 // OBSOLETE return 0;
159 // OBSOLETE sparclite_remove_watchpoint (CORE_ADDR addr, int len, int type)
161 // OBSOLETE CORE_ADDR dcr, dda1, dda2;
163 // OBSOLETE dcr = read_register (DCR_REGNUM);
164 // OBSOLETE dda1 = read_register (DDA1_REGNUM);
165 // OBSOLETE dda2 = read_register (DDA2_REGNUM);
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));
172 // OBSOLETE return -1;
174 // OBSOLETE return 0;
178 // OBSOLETE sparclite_insert_hw_breakpoint (CORE_ADDR addr, int len)
180 // OBSOLETE CORE_ADDR dcr;
182 // OBSOLETE dcr = read_register (DCR_REGNUM);
184 // OBSOLETE if (!(dcr & DIA1_ENABLE))
186 // OBSOLETE write_register (DIA1_REGNUM, addr);
187 // OBSOLETE write_register (DCR_REGNUM, (dcr | DIA1_ENABLE | DIA1_SUP_MODE));
189 // OBSOLETE else if (!(dcr & DIA2_ENABLE))
191 // OBSOLETE write_register (DIA2_REGNUM, addr);
192 // OBSOLETE write_register (DCR_REGNUM, (dcr | DIA2_ENABLE | DIA2_SUP_MODE));
195 // OBSOLETE return -1;
197 // OBSOLETE return 0;
201 // OBSOLETE sparclite_remove_hw_breakpoint (CORE_ADDR addr, int shadow)
203 // OBSOLETE CORE_ADDR dcr, dia1, dia2;
205 // OBSOLETE dcr = read_register (DCR_REGNUM);
206 // OBSOLETE dia1 = read_register (DIA1_REGNUM);
207 // OBSOLETE dia2 = read_register (DIA2_REGNUM);
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));
214 // OBSOLETE return -1;
216 // OBSOLETE return 0;
220 // OBSOLETE sparclite_check_watch_resources (int type, int cnt, int ot)
222 // OBSOLETE /* Watchpoints not supported on simulator. */
223 // OBSOLETE if (strcmp (target_shortname, "sim") == 0)
224 // OBSOLETE return 0;
226 // OBSOLETE if (type == bp_hardware_breakpoint)
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;
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;
242 // OBSOLETE return -1;
245 // OBSOLETE CORE_ADDR
246 // OBSOLETE sparclite_stopped_data_address (void)
248 // OBSOLETE CORE_ADDR dsr, dda1, dda2;
250 // OBSOLETE dsr = read_register (DSR_REGNUM);
251 // OBSOLETE dda1 = read_register (DDA1_REGNUM);
252 // OBSOLETE dda2 = read_register (DDA2_REGNUM);
254 // OBSOLETE if (dsr & 0x10)
255 // OBSOLETE return dda1;
256 // OBSOLETE else if (dsr & 0x20)
257 // OBSOLETE return dda2;
259 // OBSOLETE return 0;
262 // OBSOLETE static struct serial *
263 // OBSOLETE open_tty (char *name)
265 // OBSOLETE struct serial *desc;
267 // OBSOLETE desc = serial_open (name);
268 // OBSOLETE if (!desc)
269 // OBSOLETE perror_with_name (name);
271 // OBSOLETE if (baud_rate != -1)
273 // OBSOLETE if (serial_setbaudrate (desc, baud_rate))
275 // OBSOLETE serial_close (desc);
276 // OBSOLETE perror_with_name (name);
280 // OBSOLETE serial_raw (desc);
282 // OBSOLETE serial_flush_input (desc);
284 // OBSOLETE return desc;
287 // OBSOLETE /* Read a single character from the remote end, masking it down to 7 bits. */
289 // OBSOLETE static int
290 // OBSOLETE readchar (struct serial *desc, int timeout)
293 // OBSOLETE char s[10];
295 // OBSOLETE ch = serial_readchar (desc, timeout);
297 // OBSOLETE switch (ch)
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");
306 // OBSOLETE if (remote_debug > 0)
308 // OBSOLETE sprintf (s, "[%02x]", ch & 0xff);
309 // OBSOLETE puts_debug ("read -->", s, "<--");
311 // OBSOLETE return ch;
315 // OBSOLETE static void
316 // OBSOLETE debug_serial_write (struct serial *desc, char *buf, int len)
318 // OBSOLETE char s[10];
320 // OBSOLETE serial_write (desc, buf, len);
321 // OBSOLETE if (remote_debug > 0)
323 // OBSOLETE while (len-- > 0)
325 // OBSOLETE sprintf (s, "[%02x]", *buf & 0xff);
326 // OBSOLETE puts_debug ("Sent -->", s, "<--");
333 // OBSOLETE static int
334 // OBSOLETE send_resp (struct serial *desc, char c)
336 // OBSOLETE debug_serial_write (desc, &c, 1);
337 // OBSOLETE return readchar (desc, remote_timeout);
340 // OBSOLETE static void
341 // OBSOLETE close_tty (void *ignore)
343 // OBSOLETE if (!remote_desc)
346 // OBSOLETE serial_close (remote_desc);
348 // OBSOLETE remote_desc = NULL;
351 // OBSOLETE #ifdef HAVE_SOCKETS
352 // OBSOLETE static int
353 // OBSOLETE recv_udp_buf (int fd, unsigned char *buf, int len, int timeout)
356 // OBSOLETE fd_set readfds;
358 // OBSOLETE FD_ZERO (&readfds);
359 // OBSOLETE FD_SET (fd, &readfds);
361 // OBSOLETE if (timeout >= 0)
363 // OBSOLETE struct timeval timebuf;
365 // OBSOLETE timebuf.tv_sec = timeout;
366 // OBSOLETE timebuf.tv_usec = 0;
367 // OBSOLETE cc = select (fd + 1, &readfds, 0, 0, &timebuf);
370 // OBSOLETE cc = select (fd + 1, &readfds, 0, 0, 0);
372 // OBSOLETE if (cc == 0)
373 // OBSOLETE return 0;
375 // OBSOLETE if (cc != 1)
376 // OBSOLETE perror_with_name ("recv_udp_buf: Bad return value from select:");
378 // OBSOLETE cc = recv (fd, buf, len, 0);
380 // OBSOLETE if (cc < 0)
381 // OBSOLETE perror_with_name ("Got an error from recv: ");
384 // OBSOLETE static int
385 // OBSOLETE send_udp_buf (int fd, unsigned char *buf, int len)
389 // OBSOLETE cc = send (fd, buf, len, 0);
391 // OBSOLETE if (cc == len)
394 // OBSOLETE if (cc < 0)
395 // OBSOLETE perror_with_name ("Got an error from send: ");
397 // OBSOLETE error ("Short count in send: tried %d, sent %d\n", len, cc);
399 // OBSOLETE #endif /* HAVE_SOCKETS */
401 // OBSOLETE static void
402 // OBSOLETE sparclite_open (char *name, int from_tty)
404 // OBSOLETE struct cleanup *old_chain;
408 // OBSOLETE if (!name)
409 // OBSOLETE error ("You need to specify what device or hostname is associated with the SparcLite board.");
411 // OBSOLETE target_preopen (from_tty);
413 // OBSOLETE unpush_target (&sparclite_ops);
415 // OBSOLETE if (remote_target_name)
416 // OBSOLETE xfree (remote_target_name);
418 // OBSOLETE remote_target_name = xstrdup (name);
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) */
425 // OBSOLETE p = strchr (name, ' ');
429 // OBSOLETE *p++ = '\000';
430 // OBSOLETE while ((*p != '\000') && isspace (*p))
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;
438 // OBSOLETE error ("Must specify either `serial' or `udp'.");
442 // OBSOLETE p = name;
444 // OBSOLETE if (!strchr (name, ':'))
445 // OBSOLETE serial_flag = 1; /* No colon is unambiguous (local device) */
447 // OBSOLETE error ("Usage: target sparclite serial /dev/ttyb\n\
448 // OBSOLETE or: target sparclite udp host");
451 // OBSOLETE if (serial_flag)
453 // OBSOLETE remote_desc = open_tty (p);
455 // OBSOLETE old_chain = make_cleanup (close_tty, 0 /*ignore*/);
457 // OBSOLETE c = send_resp (remote_desc, 0x00);
459 // OBSOLETE if (c != 0xaa)
460 // OBSOLETE error ("Unknown response (0x%x) from SparcLite. Try resetting the board.",
463 // OBSOLETE c = send_resp (remote_desc, 0x55);
465 // OBSOLETE if (c != 0x55)
466 // OBSOLETE error ("Sparclite appears to be ill.");
470 // OBSOLETE #ifdef HAVE_SOCKETS
471 // OBSOLETE struct hostent *he;
472 // OBSOLETE struct sockaddr_in sockaddr;
473 // OBSOLETE unsigned char buffer[100];
476 // OBSOLETE /* Setup the socket. Must be raw UDP. */
478 // OBSOLETE he = gethostbyname (p);
481 // OBSOLETE error ("No such host %s.", p);
483 // OBSOLETE udp_fd = socket (PF_INET, SOCK_DGRAM, 0);
485 // OBSOLETE old_chain = make_cleanup (close, udp_fd);
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));
491 // OBSOLETE if (connect (udp_fd, &sockaddr, sizeof (sockaddr)))
492 // OBSOLETE perror_with_name ("Connect failed");
494 // OBSOLETE buffer[0] = 0x5;
495 // OBSOLETE buffer[1] = 0;
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.");
502 // OBSOLETE if (cc < 3)
503 // OBSOLETE error ("SPARClite appears to be ill.");
505 // OBSOLETE error ("UDP downloading is not supported for DOS hosts.");
506 // OBSOLETE #endif /* HAVE_SOCKETS */
509 // OBSOLETE printf_unfiltered ("[SPARClite appears to be alive]\n");
511 // OBSOLETE push_target (&sparclite_ops);
513 // OBSOLETE discard_cleanups (old_chain);
518 // OBSOLETE static void
519 // OBSOLETE sparclite_close (int quitting)
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);
529 // OBSOLETE #define LOAD_ADDRESS 0x40000000
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))
537 // OBSOLETE struct cleanup *old_chain;
538 // OBSOLETE asection *section;
539 // OBSOLETE bfd *pbfd;
540 // OBSOLETE bfd_vma entry;
542 // OBSOLETE #define WRITESIZE 1024
543 // OBSOLETE char *filename;
544 // OBSOLETE int quiet;
545 // OBSOLETE int nostart;
547 // OBSOLETE quiet = 0;
548 // OBSOLETE nostart = 0;
549 // OBSOLETE filename = NULL;
551 // OBSOLETE while (*args != '\000')
553 // OBSOLETE char *arg;
555 // OBSOLETE while (isspace (*args))
558 // OBSOLETE arg = args;
560 // OBSOLETE while ((*args != '\000') && !isspace (*args))
563 // OBSOLETE if (*args != '\000')
564 // OBSOLETE *args++ = '\000';
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;
573 // OBSOLETE error ("unknown option `%s'", arg);
576 // OBSOLETE if (!filename)
577 // OBSOLETE filename = get_exec_file (1);
579 // OBSOLETE pbfd = bfd_openr (filename, gnutarget);
580 // OBSOLETE if (pbfd == NULL)
582 // OBSOLETE perror_with_name (filename);
585 // OBSOLETE old_chain = make_cleanup_bfd_close (pbfd);
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 ()));
591 // OBSOLETE for (section = pbfd->sections; section; section = section->next)
593 // OBSOLETE if (bfd_get_section_flags (pbfd, section) & SEC_LOAD)
595 // OBSOLETE bfd_vma section_address;
596 // OBSOLETE bfd_size_type section_size;
597 // OBSOLETE file_ptr fptr;
598 // OBSOLETE const char *section_name;
600 // OBSOLETE section_name = bfd_get_section_name (pbfd, section);
602 // OBSOLETE section_address = bfd_get_section_vma (pbfd, section);
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)
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)
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
617 // OBSOLETE char signature[4]; /* 'DaTa' */
618 // OBSOLETE unsigned char sdata[4]; /* &sdata */
621 // OBSOLETE bfd_get_section_contents (pbfd, section, &marker, 0,
622 // OBSOLETE sizeof (marker));
623 // OBSOLETE if (strncmp (marker.signature, "DaTa", 4) == 0)
625 // OBSOLETE if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
626 // OBSOLETE section_address = bfd_getb32 (marker.sdata);
628 // OBSOLETE section_address = bfd_getl32 (marker.sdata);
633 // OBSOLETE section_size = bfd_get_section_size_before_reloc (section);
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);
641 // OBSOLETE fptr = 0;
642 // OBSOLETE while (section_size > 0)
644 // OBSOLETE int count;
645 // OBSOLETE static char inds[] = "|/-\\";
646 // OBSOLETE static int k = 0;
650 // OBSOLETE count = min (section_size, WRITESIZE);
652 // OBSOLETE write_routine (pbfd, section, fptr, section_address, count);
654 // OBSOLETE if (!quiet)
656 // OBSOLETE printf_unfiltered ("\r%c", inds[k++ % 4]);
657 // OBSOLETE gdb_flush (gdb_stdout);
660 // OBSOLETE section_address += count;
661 // OBSOLETE fptr += count;
662 // OBSOLETE section_size -= count;
667 // OBSOLETE if (!nostart)
669 // OBSOLETE entry = bfd_get_start_address (pbfd);
671 // OBSOLETE if (!quiet)
672 // OBSOLETE printf_unfiltered ("[Starting %s at 0x%x]\n", filename, entry);
674 // OBSOLETE start_routine (entry);
677 // OBSOLETE do_cleanups (old_chain);
680 // OBSOLETE static void
681 // OBSOLETE sparclite_serial_start (bfd_vma entry)
683 // OBSOLETE char buffer[5];
686 // OBSOLETE buffer[0] = 0x03;
687 // OBSOLETE store_unsigned_integer (buffer + 1, 4, entry);
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);
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)
699 // OBSOLETE char buffer[4 + 4 + WRITESIZE]; /* addr + len + data */
700 // OBSOLETE unsigned char checksum;
703 // OBSOLETE store_unsigned_integer (buffer, 4, to_addr); /* Address */
704 // OBSOLETE store_unsigned_integer (buffer + 4, 4, len); /* Length */
706 // OBSOLETE bfd_get_section_contents (from_bfd, from_sec, buffer + 8, from_addr, len);
708 // OBSOLETE checksum = 0;
709 // OBSOLETE for (i = 0; i < len; i++)
710 // OBSOLETE checksum += buffer[8 + i];
712 // OBSOLETE i = send_resp (remote_desc, 0x01);
714 // OBSOLETE if (i != 0x5a)
715 // OBSOLETE error ("Bad response from load command (0x%x)", i);
717 // OBSOLETE debug_serial_write (remote_desc, buffer, 4 + 4 + len);
718 // OBSOLETE i = readchar (remote_desc, remote_timeout);
720 // OBSOLETE if (i != checksum)
721 // OBSOLETE error ("Bad checksum from load command (0x%x)", i);
724 // OBSOLETE #ifdef HAVE_SOCKETS
726 // OBSOLETE static unsigned short
727 // OBSOLETE calc_checksum (unsigned char *buffer, int count)
729 // OBSOLETE unsigned short checksum;
731 // OBSOLETE checksum = 0;
732 // OBSOLETE for (; count > 0; count -= 2, buffer += 2)
733 // OBSOLETE checksum += (*buffer << 8) | *(buffer + 1);
735 // OBSOLETE if (count != 0)
736 // OBSOLETE checksum += *buffer << 8;
738 // OBSOLETE return checksum;
741 // OBSOLETE static void
742 // OBSOLETE sparclite_udp_start (bfd_vma entry)
744 // OBSOLETE unsigned char buffer[6];
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;
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 */
757 // OBSOLETE if (i < 1 || buffer[0] != 0x55)
758 // OBSOLETE error ("Failed to take start address.");
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)
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;
771 // OBSOLETE while (1)
773 // OBSOLETE if (to_addr != old_addr)
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;
782 // OBSOLETE checksum = 0;
783 // OBSOLETE for (i = 0; i < 6; i++)
784 // OBSOLETE checksum += buffer[i];
785 // OBSOLETE checksum &= 0xff;
787 // OBSOLETE send_udp_buf (udp_fd, buffer, 6);
788 // OBSOLETE i = recv_udp_buf (udp_fd, buffer, sizeof buffer, -1);
790 // OBSOLETE if (i < 1)
791 // OBSOLETE error ("Got back short checksum for load addr.");
793 // OBSOLETE if (checksum != buffer[0])
794 // OBSOLETE error ("Got back bad checksum for load addr.");
796 // OBSOLETE pkt_num = 0; /* Load addr resets packet seq # */
797 // OBSOLETE old_addr = to_addr;
800 // OBSOLETE bfd_get_section_contents (from_bfd, from_sec, buffer + 6, from_addr,
803 // OBSOLETE checksum = calc_checksum (buffer + 6, len);
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;
812 // OBSOLETE send_udp_buf (udp_fd, buffer, len + 6);
813 // OBSOLETE i = recv_udp_buf (udp_fd, buffer, sizeof buffer, 3);
815 // OBSOLETE if (i == 0)
817 // OBSOLETE fprintf_unfiltered (gdb_stderr, "send_data: timeout sending %d bytes to address 0x%x retrying\n", len, to_addr);
818 // OBSOLETE continue;
821 // OBSOLETE if (buffer[0] != 0xff)
822 // OBSOLETE error ("Got back bad response for load data.");
824 // OBSOLETE old_addr += len;
825 // OBSOLETE pkt_num++;
831 // OBSOLETE #endif /* HAVE_SOCKETS */
833 // OBSOLETE static void
834 // OBSOLETE sparclite_download (char *filename, int from_tty)
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);
841 // OBSOLETE internal_error (__FILE__, __LINE__, "failed internal consistency check"); /* sparclite_open should prevent this! */
844 // OBSOLETE download (remote_target_name, filename, from_tty, sparclite_serial_write,
845 // OBSOLETE sparclite_serial_start);
848 // OBSOLETE /* Set up the sparclite target vector. */
850 // OBSOLETE static void
851 // OBSOLETE init_sparclite_ops (void)
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;
865 // OBSOLETE _initialize_sparcl_tdep (void)
867 // OBSOLETE init_sparclite_ops ();
868 // OBSOLETE add_target (&sparclite_ops);
This page took 0.049465 seconds and 4 git commands to generate.