예제 #1
0
static void
sh3_load (struct serial *desc, char *file, int hashmark)
{
  if (parallel_in_use)
    {
      monitor_printf ("pl;s\r");
      load_srec (parallel, file, 0, 80, SREC_ALL, hashmark, NULL);
      monitor_expect_prompt (NULL, 0);
    }
  else
    {
      monitor_printf ("il;s:x\r");
      monitor_expect ("\005", NULL, 0);		/* Look for ENQ */
      serial_write (desc, "\006", 1);	/* Send ACK */
      monitor_expect ("LO x\r", NULL, 0);	/* Look for filename */

      load_srec (desc, file, 0, 80, SREC_ALL, hashmark, NULL);

      monitor_expect ("\005", NULL, 0);		/* Look for ENQ */
      serial_write (desc, "\006", 1);	/* Send ACK */
      monitor_expect_prompt (NULL, 0);
    }
}
예제 #2
0
static int
picobug_dumpregs (struct regcache *regcache)
{
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
  char buf[1024];
  int resp_len;
  char *p;

  /* Send the dump register command to the monitor and
     get the reply.  */
  monitor_printf (picobug_cmds.dump_registers);
  resp_len = monitor_expect_prompt (buf, sizeof (buf));

  p = strtok (buf, " \t\r\n");
  while (p)
    {
      if (strchr (p, '-'))
	{
	  /* Got a range.  Either r0-r7, r8-r15 or ss0-ss4.  */
	  if (strncmp (p, "r0", 2) == 0 || strncmp (p, "r8", 2) == 0)
	    {
	      int rn = (p[1] == '0' ? 0 : 8);
	      int i = 0;

	      /* Get the next 8 values and record them.  */
	      while (i < 8)
		{
		  p = strtok (NULL, " \t\r\n");
		  if (p)
		    monitor_supply_register (regcache, rn + i, p);
		  i++;
		}
	    }
	  else if (strncmp (p, "ss", 2) == 0)
	    {
	      /* Get the next five values, ignoring the first.  */
	      int rn;
	      p = strtok (NULL, " \t\r\n");
	      for (rn = 39; rn < 43; rn++)
		{
		  p = strtok (NULL, " \t\r\n");
		  if (p)
		    monitor_supply_register (regcache, rn, p);
		}
	    }
	  else
	    {
	      break;
	    }
	}
      else
	{
	  /* Simple register type, paired.  */
	  char *name = p;
	  int i;

	  /* Get and record value.  */
	  p = strtok (NULL, " \t\r\n");
	  if (p)
	    {
	      for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
		{
		  if (picobug_regnames[i]
		      && strcmp (picobug_regnames[i], name) == 0)
		    break;
		}

	      if (i <= gdbarch_num_regs (gdbarch))
		monitor_supply_register (regcache, i, p);
	    }
	}
      p = strtok (NULL, " \t\r\n");
    }

  return 0;
}
예제 #3
0
static void
w89k_load (struct serial *desc, char *file, int hashmark)
{
  bfd *abfd;
  asection *s;
  char *buffer;
  int i;

  buffer = alloca (XMODEM_PACKETSIZE);

  abfd = bfd_openr (file, 0);
  if (!abfd)
    {
      printf_filtered ("Unable to open file %s\n", file);
      return;
    }

  if (bfd_check_format (abfd, bfd_object) == 0)
    {
      printf_filtered ("File is not an object file\n");
      return;
    }

  for (s = abfd->sections; s; s = s->next)
    if (s->flags & SEC_LOAD)
      {
	bfd_size_type section_size;

	printf_filtered ("%s\t: 0x%4x .. 0x%4x  ", s->name, s->vma,
			 s->vma + s->_raw_size);
	gdb_flush (gdb_stdout);

	monitor_printf (w89k_cmds.load, s->vma);
	if (w89k_cmds.loadresp)
	  monitor_expect (w89k_cmds.loadresp, NULL, 0);

	xmodem_init_xfer (desc);

	section_size = bfd_section_size (abfd, s);

	for (i = 0; i < section_size; i += XMODEM_DATASIZE)
	  {
	    int numbytes;

	    numbytes = min (XMODEM_DATASIZE, section_size - i);

	    bfd_get_section_contents (abfd, s, buffer + XMODEM_DATAOFFSET, i,
				      numbytes);

	    xmodem_send_packet (desc, buffer, numbytes, hashmark);

	    if (hashmark)
	      {
		putchar_unfiltered ('#');
		gdb_flush (gdb_stdout);
	      }
	  }			/* Per-packet (or S-record) loop */

	xmodem_finish_xfer (desc);

	monitor_expect_prompt (NULL, 0);

	putchar_unfiltered ('\n');
      }				/* Loadable sections */

  if (hashmark)
    putchar_unfiltered ('\n');
}