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

Subversion Repositories adv_debug_sys

[/] [adv_debug_sys/] [trunk/] [Software/] [adv_jtag_bridge/] [rsp-server.c] - Diff between revs 42 and 50

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 42 Rev 50
Line 376... Line 376...
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int handle_rsp (void)
int handle_rsp (void)
{
{
  struct pollfd  fds[2];        /* The FD to poll for */
  struct pollfd  fds[2];        /* The FD to poll for */
  char monitor_status;
  char monitor_status;
  unsigned long drrval;
  uint32_t drrval;
 
  uint32_t ppcval;
 
 
  /* Give up if no RSP server port (this should not occur) */
  /* Give up if no RSP server port (this should not occur) */
  if (-1 == rsp.server_fd)
  if (-1 == rsp.server_fd)
    {
    {
      fprintf (stderr, "Warning: No RSP server port open\n");
      fprintf (stderr, "Warning: No RSP server port open\n");
Line 494... Line 495...
                     GDB. If this exception was a trap due to a memory breakpoint, then
                     GDB. If this exception was a trap due to a memory breakpoint, then
                     adjust the NPC. */
                     adjust the NPC. */
                  if (rsp.client_waiting)
                  if (rsp.client_waiting)
                    {
                    {
                      // Read the PPC
                      // Read the PPC
                      unsigned long ppcval;
 
                      dbg_cpu0_read(SPR_PPC, &ppcval);
                      dbg_cpu0_read(SPR_PPC, &ppcval);
 
 
                      if ((TARGET_SIGNAL_TRAP == rsp.sigval) &&
                      if ((TARGET_SIGNAL_TRAP == rsp.sigval) &&
                          (NULL != mp_hash_lookup (BP_MEMORY, ppcval)))  // We also get TRAP from a single-step, don't change npc unless it's really a BP
                          (NULL != mp_hash_lookup (BP_MEMORY, ppcval)))  // We also get TRAP from a single-step, don't change npc unless it's really a BP
                        {
                        {
Line 600... Line 600...
  struct sockaddr_in  sock_addr;        /* The socket address */
  struct sockaddr_in  sock_addr;        /* The socket address */
  socklen_t           len;              /* Size of the socket address */
  socklen_t           len;              /* Size of the socket address */
  int                 fd;               /* The client FD */
  int                 fd;               /* The client FD */
  int                 flags;            /* fcntl () flags */
  int                 flags;            /* fcntl () flags */
  int                 optval;           /* Option value for setsockopt () */
  int                 optval;           /* Option value for setsockopt () */
  unsigned long       tmp;
  uint32_t            tmp;
 
 
  /* Get the client FD */
  /* Get the client FD */
  len = sizeof (sock_addr);
  len = sizeof (sock_addr);
  fd  = accept (rsp.server_fd, (struct sockaddr *)&sock_addr, &len);
  fd  = accept (rsp.server_fd, (struct sockaddr *)&sock_addr, &len);
  if (fd < 0)
  if (fd < 0)
Line 1728... Line 1728...
   @param[in] except  The exception to use (if any)                          */
   @param[in] except  The exception to use (if any)                          */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
rsp_continue_generic (unsigned long int  except)
rsp_continue_generic (unsigned long int  except)
{
{
  unsigned long tmp;
  uint32_t tmp;
 
 
  /* Clear Debug Reason Register and watchpoint break generation in Debug Mode
  /* Clear Debug Reason Register and watchpoint break generation in Debug Mode
     Register 2 */
     Register 2 */
  dbg_cpu0_write(SPR_DRR, 0);
  dbg_cpu0_write(SPR_DRR, 0);
  dbg_cpu0_read(SPR_DMR2, &tmp);
  dbg_cpu0_read(SPR_DMR2, &tmp);
Line 1769... Line 1769...
static void
static void
rsp_read_all_regs ()
rsp_read_all_regs ()
{
{
  struct rsp_buf  buf;                  /* Buffer for the reply */
  struct rsp_buf  buf;                  /* Buffer for the reply */
  int             r;                    /* Register index */
  int             r;                    /* Register index */
  unsigned long regbuf[MAX_GPRS];
  uint32_t        regbuf[MAX_GPRS];
  unsigned int errcode = APP_ERR_NONE;
  unsigned int errcode = APP_ERR_NONE;
 
 
  // Read all the GPRs in a single burst, for efficiency
  // Read all the GPRs in a single burst, for efficiency
  errcode = dbg_cpu0_read_block(SPR_GPR_BASE, regbuf, MAX_GPRS);
  errcode = dbg_cpu0_read_block(SPR_GPR_BASE, regbuf, MAX_GPRS);
 
 
Line 1799... Line 1799...
 
 
  reg2hex(regbuf[1], &(buf.data[SR_REGNUM  * 8]));
  reg2hex(regbuf[1], &(buf.data[SR_REGNUM  * 8]));
 
 
  //fprintf(stderr, "Read SPRs:  0x%08X, 0x%08X, 0x%08X\n", regbuf[0], regbuf[1], regbuf[2]);
  //fprintf(stderr, "Read SPRs:  0x%08X, 0x%08X, 0x%08X\n", regbuf[0], regbuf[1], regbuf[2]);
 
 
  /*
 
  dbg_cpu0_read(SPR_PPC, &tmp);
 
  reg2hex(tmp, &(buf.data[PPC_REGNUM * 8]));
 
 
 
  if(use_cached_npc == 1) {  // Hackery to work around CPU hardware quirk
 
    tmp = cached_npc;
 
  }
 
  else {
 
    dbg_cpu0_read(SPR_NPC, &tmp);
 
  }
 
  reg2hex(tmp, &(buf.data[NPC_REGNUM * 8]));
 
 
 
  dbg_cpu0_read(SPR_SR, &tmp);
 
  reg2hex(tmp, &(buf.data[SR_REGNUM  * 8]));
 
  */
 
 
 
  if(errcode == APP_ERR_NONE) {
  if(errcode == APP_ERR_NONE) {
    /* Finalize the packet and send it */
    /* Finalize the packet and send it */
    buf.data[NUM_REGS * 8] = 0;
    buf.data[NUM_REGS * 8] = 0;
    buf.len                = NUM_REGS * 8;
    buf.len                = NUM_REGS * 8;
    put_packet (&buf);
    put_packet (&buf);
Line 1848... Line 1832...
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
rsp_write_all_regs (struct rsp_buf *buf)
rsp_write_all_regs (struct rsp_buf *buf)
{
{
  int             r;                    /* Register index */
  int             r;                    /* Register index */
  unsigned long regbuf[MAX_GPRS];
  uint32_t        regbuf[MAX_GPRS];
  unsigned int errcode;
  unsigned int errcode;
 
 
  /* The GPRs */
  /* The GPRs */
  for (r = 0; r < MAX_GPRS; r++)
  for (r = 0; r < MAX_GPRS; r++)
    {
    {
Line 2049... Line 2033...
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
rsp_read_reg (struct rsp_buf *buf)
rsp_read_reg (struct rsp_buf *buf)
{
{
  unsigned int  regnum;
  unsigned int  regnum;
  unsigned long tmp;
  uint32_t tmp;
  unsigned int errcode = APP_ERR_NONE;
  unsigned int errcode = APP_ERR_NONE;
 
 
  /* Break out the fields from the data */
  /* Break out the fields from the data */
  if (1 != sscanf (buf->data, "p%x", &regnum))
  if (1 != sscanf (buf->data, "p%x", &regnum))
    {
    {
Line 2282... Line 2266...
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
rsp_command (struct rsp_buf *buf)
rsp_command (struct rsp_buf *buf)
{
{
  char  cmd[GDB_BUF_MAX];
  char  cmd[GDB_BUF_MAX];
  unsigned long tmp;
  uint32_t tmp;
 
 
  hex2ascii (cmd, &(buf->data[strlen ("qRcmd,")]));
  hex2ascii (cmd, &(buf->data[strlen ("qRcmd,")]));
 
 
  /* Work out which command it is */
  /* Work out which command it is */
  if (0 == strncmp ("readspr ", cmd, strlen ("readspr")))
  if (0 == strncmp ("readspr ", cmd, strlen ("readspr")))
Line 2311... Line 2295...
          return;
          return;
        }
        }
 
 
      /* Construct the reply */
      /* Construct the reply */
      dbg_cpu0_read(regno, &tmp);  // TODO Check return value of all hardware accesses
      dbg_cpu0_read(regno, &tmp);  // TODO Check return value of all hardware accesses
      sprintf (cmd, "%8lx", tmp);
      sprintf (cmd, "%8x", tmp);
      ascii2hex (buf->data, cmd);
      ascii2hex (buf->data, cmd);
      buf->len = strlen (buf->data);
      buf->len = strlen (buf->data);
      put_packet (buf);
      put_packet (buf);
    }
    }
  else if (0 == strncmp ("writespr ", cmd, strlen ("writespr")))
  else if (0 == strncmp ("writespr ", cmd, strlen ("writespr")))
Line 2459... Line 2443...
   @param[in] except  The exception to use (if any)                          */
   @param[in] except  The exception to use (if any)                          */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
rsp_step_generic (unsigned long int  except)
rsp_step_generic (unsigned long int  except)
{
{
  unsigned long tmp;
  uint32_t tmp;
 
 
  /* Clear Debug Reason Register and watchpoint break generation in Debug Mode
  /* Clear Debug Reason Register and watchpoint break generation in Debug Mode
     Register 2 */
     Register 2 */
  tmp = 0;
  tmp = 0;
  dbg_cpu0_write(SPR_DRR, tmp);  // *** TODO Check return value of all hardware accesses
  dbg_cpu0_write(SPR_DRR, tmp);  // *** TODO Check return value of all hardware accesses
Line 2659... Line 2643...
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
rsp_remove_matchpoint (struct rsp_buf *buf)
rsp_remove_matchpoint (struct rsp_buf *buf)
{
{
  enum mp_type       type;              /* What sort of matchpoint */
  enum mp_type       type;              /* What sort of matchpoint */
  unsigned long int  addr;              /* Address specified */
  uint32_t           addr;              /* Address specified */
  int                len;               /* Matchpoint length (not used) */
  int                len;               /* Matchpoint length (not used) */
  struct mp_entry   *mpe;               /* Info about the replaced instr */
  struct mp_entry   *mpe;               /* Info about the replaced instr */
  unsigned long instbuf[1];
  uint32_t           instbuf[1];
 
 
  /* Break out the instruction */
  /* Break out the instruction */
  if (3 != sscanf (buf->data, "z%1d,%lx,%1d", (int *)&type, &addr, &len))
  if (3 != sscanf (buf->data, "z%1d,%x,%1d", (int *)&type, &addr, &len))
    {
    {
      fprintf (stderr, "Warning: RSP matchpoint deletion request not "
      fprintf (stderr, "Warning: RSP matchpoint deletion request not "
               "recognized: ignored\n");
               "recognized: ignored\n");
      put_str_packet ("E01");
      put_str_packet ("E01");
      return;
      return;
Line 2742... Line 2726...
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
static void
rsp_insert_matchpoint (struct rsp_buf *buf)
rsp_insert_matchpoint (struct rsp_buf *buf)
{
{
  enum mp_type       type;              /* What sort of matchpoint */
  enum mp_type       type;              /* What sort of matchpoint */
  unsigned long int  addr;              /* Address specified */
  uint32_t           addr;              /* Address specified */
  int                len;               /* Matchpoint length (not used) */
  int                len;               /* Matchpoint length (not used) */
  unsigned long instbuf[1];
  uint32_t           instbuf[1];
 
 
  /* Break out the instruction */
  /* Break out the instruction */
  if (3 != sscanf (buf->data, "Z%1d,%lx,%1d", (int *)&type, &addr, &len))
  if (3 != sscanf (buf->data, "Z%1d,%x,%1d", (int *)&type, &addr, &len))
    {
    {
      fprintf (stderr, "Warning: RSP matchpoint insertion request not "
      fprintf (stderr, "Warning: RSP matchpoint insertion request not "
               "recognized: ignored\n");
               "recognized: ignored\n");
      put_str_packet ("E01");
      put_str_packet ("E01");
      return;
      return;

powered by: WebSVN 2.1.0

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