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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [remote-or1k.c] - Diff between revs 373 and 374

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

Rev 373 Rev 374
Line 158... Line 158...
/* Number of interrupts while waiting for process.  */
/* Number of interrupts while waiting for process.  */
static int interrupt_count = 0;
static int interrupt_count = 0;
 
 
/* Reason of last stop.  */
/* Reason of last stop.  */
static int hit_watchpoint = 0;
static int hit_watchpoint = 0;
 
static int hit_breakpoint = 0;
 
static int next_breakpoint = 0;
 
static int prev_step_insn_has_delay_slot = 0;
 
 
/* Current register values.  */
/* Current register values.  */
unsigned int dmr1 = 0;
unsigned int dmr1 = 0;
unsigned int dmr2 = 0;
unsigned int dmr2 = 0;
unsigned int dsr = 0;
unsigned int dsr = 0;
unsigned int drr = 0;
unsigned int drr = 0;
//unsigned int npc = 0;
 
//unsigned int ppc = 0;
 
 
 
/* Current matchpoints.  */
/* Current matchpoints.  */
unsigned int dvr[MAX_MATCHPOINTS];
unsigned int dvr[MAX_MATCHPOINTS];
struct dcr_struct dcr[MAX_MATCHPOINTS];
struct dcr_struct dcr[MAX_MATCHPOINTS];
 
 
Line 295... Line 296...
     unsigned int regno;
     unsigned int regno;
     unsigned int data;
     unsigned int data;
{
{
  or1k_set_chain (SC_RISC_DEBUG);
  or1k_set_chain (SC_RISC_DEBUG);
  or1k_write_reg (regno, (ULONGEST)data);
  or1k_write_reg (regno, (ULONGEST)data);
 
  if (regno == PC_SPRNUM) {
 
    hit_breakpoint = 0;
 
    prev_step_insn_has_delay_slot = 0;
 
  }
}
}
 
 
/* Reads register SPR from regno.  */
/* Reads register SPR from regno.  */
 
 
unsigned int
unsigned int
Line 736... Line 741...
{
{
  unsigned int pc;
  unsigned int pc;
  unsigned int ppc;
  unsigned int ppc;
  unsigned int npc;
  unsigned int npc;
  unsigned int val;
  unsigned int val;
  int two_steps = 0;
 
 
 
  pc = read_pc();
  pc = read_pc();
  npc = or1k_read_spr_reg (PC_SPRNUM);
  npc = or1k_read_spr_reg (PC_SPRNUM);
  ppc = or1k_read_spr_reg (PPC_SPRNUM);
  ppc = or1k_read_spr_reg (PPC_SPRNUM);
  debug ("pc = %08x BP = %x npc = %08x ppc = %08x\n", pc, breakpoint_here_p (pc), npc, ppc);
  debug ("pc = %08x BP = %x npc = %08x ppc = %08x\n", pc, breakpoint_here_p (pc), npc, ppc);
Line 755... Line 759...
  /* Clear reason register for later.  */
  /* Clear reason register for later.  */
  or1k_write_spr_reg (DRR_SPRNUM, 0);
  or1k_write_spr_reg (DRR_SPRNUM, 0);
 
 
  or1k_commit_debug_registers ();
  or1k_commit_debug_registers ();
 
 
  if (step) {
  /* Else clause added by CZ 26/06/01 */
    /* Always set program counter to branch instruction and reexecute it */
  if (step)
    if (insn_has_delay_slot (or1k_fetch_instruction (ppc)))
 
      {
      {
        or1k_write_spr_reg (PC_SPRNUM, ppc);
      /* HW STEP.  Set DMR1_ST.  */
        two_steps = 1;
      dmr1 |= DMR1_ST;
      }
      or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
    else if (breakpoint_here_p (pc) && ((ppc + 4) != npc))
      dmr1 &= ~DMR1_ST;
 
 
 
      prev_step_insn_has_delay_slot = insn_has_delay_slot (or1k_fetch_instruction (ppc));
 
 
 
      if (hit_breakpoint && ((ppc + 4) != npc))
      {
      {
        /* Trapped on delay slot instruction. */
        /* Trapped on delay slot instruction. */
        /* Set PC to branch insn preceding delay slot. */
        /* Set PC to branch insn preceding delay slot. */
        or1k_write_spr_reg (PC_SPRNUM, ppc - 4);
        or1k_write_spr_reg (PC_SPRNUM, ppc - 4);
        two_steps = 1;
 
      } else if (breakpoint_here_p (pc))
 
        or1k_write_spr_reg (PC_SPRNUM, pc);
 
 
 
      /* HW STEP.  Set DMR1_ST.  */
          or1k_unstall ();
      dmr1 |= DMR1_ST;
 
      or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
 
      dmr1 &= ~DMR1_ST;
 
 
 
      if (two_steps)
          or1k_set_chain (SC_REGISTER);
 
          val = or1k_read_reg (JTAG_RISCOP);
 
          do {
 
            val = or1k_read_reg (JTAG_RISCOP);
 
          } while ((val & 1) == 0);
 
        }
 
      else if (next_breakpoint  && insn_has_delay_slot (or1k_fetch_instruction (ppc)))
        {
        {
 
          /* Steping to the trap insn in delay slot - we need to execute branch insn again */
 
          debug ("resume: steping to the trap insn in delay slot\n");
 
          or1k_write_spr_reg (PC_SPRNUM, ppc);
 
 
          or1k_unstall ();
          or1k_unstall ();
 
 
          or1k_set_chain (SC_REGISTER);
          or1k_set_chain (SC_REGISTER);
          val = or1k_read_reg (JTAG_RISCOP);
          val = or1k_read_reg (JTAG_RISCOP);
          do
          do {
            val = or1k_read_reg (JTAG_RISCOP);
            val = or1k_read_reg (JTAG_RISCOP);
          while ((val & 1) == 0);
          } while ((val & 1) == 0);
        }
        }
 
      else if (hit_breakpoint)
 
        or1k_write_spr_reg (PC_SPRNUM, pc);
    }
    }
  else
  else
    {
    {
      dmr1 &= ~DMR1_ST;
      dmr1 &= ~DMR1_ST;
      or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
      or1k_write_spr_reg (DMR1_SPRNUM, dmr1);
      if (breakpoint_here_p (pc))
      if (prev_step_insn_has_delay_slot)
        or1k_write_spr_reg (PC_SPRNUM, pc);
        or1k_write_spr_reg (PC_SPRNUM, ppc);
 
      else
 
        or1k_write_spr_reg (PC_SPRNUM, npc);
    }
    }
 
 
  /* We can now continue normally, independent of step */
  /* We can now continue normally, independent of step */
  or1k_unstall ();
  or1k_unstall ();
  or1k_status = TARGET_RUNNING;
  or1k_status = TARGET_RUNNING;
Line 955... Line 970...
/*  write_pc (pc);
/*  write_pc (pc);
*/
*/
  store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), pc);
  store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), pc);
  supply_register (PC_REGNUM, buf);
  supply_register (PC_REGNUM, buf);
 
 
 
  hit_breakpoint = breakpoint_here_p (pc);
 
  next_breakpoint = breakpoint_here_p (npc);
 
 
  /*or1k_write_spr_reg (PC_SPRNUM, pc);
  /*or1k_write_spr_reg (PC_SPRNUM, pc);
  store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), pc);
  store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), pc);
  supply_register (PC_REGNUM, buf);*/
  supply_register (PC_REGNUM, buf);*/
 
 
  /* Log remote stop.  */
  /* Log remote stop.  */

powered by: WebSVN 2.1.0

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