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

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [gdb-5.0/] [gdb/] [dbug-rom.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* Remote debugging interface to dBUG ROM monitor for GDB, the GNU debugger.
2
   Copyright 1996, 1999 Free Software Foundation, Inc.
3
 
4
   Written by Stan Shebs of Cygnus Support.
5
 
6
   This file is part of GDB.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 2 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 59 Temple Place - Suite 330,
21
   Boston, MA 02111-1307, USA.  */
22
 
23
/* dBUG is a monitor supplied on various Motorola boards, including
24
   m68k, ColdFire, and PowerPC-based designs.  The code here assumes
25
   the ColdFire, and (as of 9/25/96) has only been tested with a
26
   ColdFire IDP board.  */
27
 
28
#include "defs.h"
29
#include "gdbcore.h"
30
#include "target.h"
31
#include "monitor.h"
32
#include "serial.h"
33
 
34
static void dbug_open PARAMS ((char *args, int from_tty));
35
 
36
static void
37
dbug_supply_register (regname, regnamelen, val, vallen)
38
     char *regname;
39
     int regnamelen;
40
     char *val;
41
     int vallen;
42
{
43
  int regno;
44
 
45
  if (regnamelen != 2)
46
    return;
47
 
48
  switch (regname[0])
49
    {
50
    case 'S':
51
      if (regname[1] != 'R')
52
        return;
53
      regno = PS_REGNUM;
54
      break;
55
    case 'P':
56
      if (regname[1] != 'C')
57
        return;
58
      regno = PC_REGNUM;
59
      break;
60
    case 'D':
61
      if (regname[1] < '0' || regname[1] > '7')
62
        return;
63
      regno = regname[1] - '0' + D0_REGNUM;
64
      break;
65
    case 'A':
66
      if (regname[1] < '0' || regname[1] > '7')
67
        return;
68
      regno = regname[1] - '0' + A0_REGNUM;
69
      break;
70
    default:
71
      return;
72
    }
73
 
74
  monitor_supply_register (regno, val);
75
}
76
 
77
/* This array of registers needs to match the indexes used by GDB. The
78
   whole reason this exists is because the various ROM monitors use
79
   different names than GDB does, and don't support all the registers
80
   either. So, typing "info reg sp" becomes an "A7". */
81
 
82
static char *dbug_regnames[NUM_REGS] =
83
{
84
  "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
85
  "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
86
  "SR", "PC"
87
  /* no float registers */
88
};
89
static struct target_ops dbug_ops;
90
static struct monitor_ops dbug_cmds;
91
 
92
static char *dbug_inits[] =
93
{"\r", NULL};
94
 
95
 
96
static void
97
init_dbug_cmds (void)
98
{
99
  dbug_cmds.flags = MO_CLR_BREAK_USES_ADDR | MO_GETMEM_NEEDS_RANGE | MO_FILL_USES_ADDR;
100
  dbug_cmds.init = dbug_inits;  /* Init strings */
101
  dbug_cmds.cont = "go\r";      /* continue command */
102
  dbug_cmds.step = "trace\r";   /* single step */
103
  dbug_cmds.stop = NULL;        /* interrupt command */
104
  dbug_cmds.set_break = "br %x\r";      /* set a breakpoint */
105
  dbug_cmds.clr_break = "br -r %x\r";   /* clear a breakpoint */
106
  dbug_cmds.clr_all_break = "br -r\r";  /* clear all breakpoints */
107
  dbug_cmds.fill = "bf.b %x %x %x\r";   /* fill (start end val) */
108
  dbug_cmds.setmem.cmdb = "mm.b %x %x\r";       /* setmem.cmdb (addr, value) */
109
  dbug_cmds.setmem.cmdw = "mm.w %x %x\r";       /* setmem.cmdw (addr, value) */
110
  dbug_cmds.setmem.cmdl = "mm.l %x %x\r";       /* setmem.cmdl (addr, value) */
111
  dbug_cmds.setmem.cmdll = NULL;        /* setmem.cmdll (addr, value) */
112
  dbug_cmds.setmem.resp_delim = NULL;   /* setmem.resp_delim */
113
  dbug_cmds.setmem.term = NULL; /* setmem.term */
114
  dbug_cmds.setmem.term_cmd = NULL;     /* setmem.term_cmd */
115
  dbug_cmds.getmem.cmdb = "md.b %x %x\r";       /* getmem.cmdb (addr, addr2) */
116
  dbug_cmds.getmem.cmdw = "md.w %x %x\r";       /* getmem.cmdw (addr, addr2) */
117
  dbug_cmds.getmem.cmdl = "md.l %x %x\r";       /* getmem.cmdl (addr, addr2) */
118
  dbug_cmds.getmem.cmdll = NULL;        /* getmem.cmdll (addr, addr2) */
119
  dbug_cmds.getmem.resp_delim = ":";    /* getmem.resp_delim */
120
  dbug_cmds.getmem.term = NULL; /* getmem.term */
121
  dbug_cmds.getmem.term_cmd = NULL;     /* getmem.term_cmd */
122
  dbug_cmds.setreg.cmd = "rm %s %x\r";  /* setreg.cmd (name, value) */
123
  dbug_cmds.setreg.resp_delim = NULL;   /* setreg.resp_delim */
124
  dbug_cmds.setreg.term = NULL; /* setreg.term */
125
  dbug_cmds.setreg.term_cmd = NULL;     /* setreg.term_cmd */
126
  dbug_cmds.getreg.cmd = "rd %s\r";     /* getreg.cmd (name) */
127
  dbug_cmds.getreg.resp_delim = ":";    /* getreg.resp_delim */
128
  dbug_cmds.getreg.term = NULL; /* getreg.term */
129
  dbug_cmds.getreg.term_cmd = NULL;     /* getreg.term_cmd */
130
  dbug_cmds.dump_registers = "rd\r";    /* dump_registers */
131
  dbug_cmds.register_pattern = "\\(\\w+\\) +:\\([0-9a-fA-F]+\\b\\)";    /* register_pattern */
132
  dbug_cmds.supply_register = dbug_supply_register;     /* supply_register */
133
  dbug_cmds.load_routine = NULL;        /* load_routine (defaults to SRECs) */
134
  dbug_cmds.load = "dl\r";      /* download command */
135
  dbug_cmds.loadresp = "\n";    /* load response */
136
  dbug_cmds.prompt = "dBUG>";   /* monitor command prompt */
137
  dbug_cmds.line_term = "\r";   /* end-of-line terminator */
138
  dbug_cmds.cmd_end = NULL;     /* optional command terminator */
139
  dbug_cmds.target = &dbug_ops; /* target operations */
140
  dbug_cmds.stopbits = SERIAL_1_STOPBITS;       /* number of stop bits */
141
  dbug_cmds.regnames = dbug_regnames;   /* registers names */
142
  dbug_cmds.magic = MONITOR_OPS_MAGIC;  /* magic */
143
}                               /* init_debug_ops */
144
 
145
static void
146
dbug_open (args, from_tty)
147
     char *args;
148
     int from_tty;
149
{
150
  monitor_open (args, &dbug_cmds, from_tty);
151
}
152
 
153
void
154
_initialize_dbug_rom ()
155
{
156
  init_dbug_cmds ();
157
  init_monitor_ops (&dbug_ops);
158
 
159
  dbug_ops.to_shortname = "dbug";
160
  dbug_ops.to_longname = "dBUG monitor";
161
  dbug_ops.to_doc = "Debug via the dBUG monitor.\n\
162
Specify the serial device it is connected to (e.g. /dev/ttya).";
163
  dbug_ops.to_open = dbug_open;
164
 
165
  add_target (&dbug_ops);
166
}

powered by: WebSVN 2.1.0

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