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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [microblaze-rom.c] - Blame information for rev 231

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* Remote debugging interface to Xilinx MicroBlaze.
2
 
3
   Copyright 2009, 2010 Free Software Foundation, Inc.
4
 
5
   This file is part of GDB.
6
 
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3 of the License, or
10
   (at your option) any later version.
11
 
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
 
17
   You should have received a copy of the GNU General Public License
18
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
 
20
#include "defs.h"
21
#include "gdbcore.h"
22
#include "target.h"
23
#include "monitor.h"
24
#include "gdb_string.h"
25
#include "serial.h"
26
#include "regcache.h"
27
 
28
static char *picobug_inits[] =
29
{"\r", NULL};
30
 
31
static struct target_ops picobug_ops;
32
static struct monitor_ops picobug_cmds;
33
 
34
/* Picobug only supports a subset of registers from MCore. In reality,
35
   it doesn't support ss1, either.  */
36
static char *picobug_regnames[] = {
37
  "r0",   "r1",   "r2",   "r3",   "r4",   "r5",   "r6",   "r7",
38
  "r8",   "r9",   "r10",  "r11",  "r12",  "r13",  "r14",  "r15",
39
  0,      0,      0,      0,      0,      0,      0,      0,
40
  0,      0,      0,      0,      0,      0,      0,      0,
41
  "psr",  "vbr",  "epsr", "fpsr", "epc",  "fpc",  0,      "ss1",
42
  "ss2",  "ss3",  "ss4",  0,      0,      0,      0,      0,
43
  0,      0,      0,      0,      0,      0,      0,      0,
44
  0,      0,      0,      0,      0,      0,      0,      0,
45
  "pc" };
46
 
47
 
48
 
49
static void
50
picobug_open (char *args, int from_tty)
51
{
52
  monitor_open (args, &picobug_cmds, from_tty);
53
}
54
/* We choose to write our own dumpregs routine, since the output of
55
   the register dumping is rather difficult to encapsulate in a
56
   regexp:
57
 
58
picobug> rd
59
     pc 2f00031e      epc 2f00031e      fpc 00000000
60
    psr 80000101     epsr 80000101     fpsr 00000000
61
ss0-ss4 bad0beef 00000000 00000000 00000000 00000000      vbr 30005c00
62
  r0-r7 2f0fff4c 00000090 00000001 00000002 00000003 00000004 00000005 00000006
63
 r8-r15 2f0fff64 00000000 00000000 00000000 00000000 00000000 00000000 2f00031e
64
*/
65
 
66
static int
67
picobug_dumpregs (struct regcache *regcache)
68
{
69
  struct gdbarch *gdbarch = get_regcache_arch (regcache);
70
  char buf[1024];
71
  int resp_len;
72
  char *p;
73
 
74
  /* Send the dump register command to the monitor and
75
     get the reply.  */
76
  monitor_printf (picobug_cmds.dump_registers);
77
  resp_len = monitor_expect_prompt (buf, sizeof (buf));
78
 
79
  p = strtok (buf, " \t\r\n");
80
  while (p)
81
    {
82
      if (strchr (p, '-'))
83
        {
84
          /* got a range. either r0-r7, r8-r15 or ss0-ss4.  */
85
          if (strncmp (p, "r0", 2) == 0 || strncmp (p, "r8", 2) == 0)
86
            {
87
              int rn = (p[1] == '0' ? 0 : 8);
88
              int i = 0;
89
 
90
              /* Get the next 8 values and record them.  */
91
              while (i < 8)
92
                {
93
                  p = strtok (NULL, " \t\r\n");
94
                  if (p)
95
                    monitor_supply_register (regcache, rn + i, p);
96
                  i++;
97
                }
98
            }
99
          else if (strncmp (p, "ss", 2) == 0)
100
            {
101
              /* get the next five values, ignoring the first.  */
102
              int rn;
103
              p = strtok (NULL, " \t\r\n");
104
              for (rn = 39; rn < 43; rn++)
105
                {
106
                  p = strtok (NULL, " \t\r\n");
107
                  if (p)
108
                    monitor_supply_register (regcache, rn, p);
109
                }
110
            }
111
          else
112
            {
113
              break;
114
            }
115
        }
116
      else
117
        {
118
          /* Simple register type, paired.  */
119
          char *name = p;
120
          int i;
121
 
122
          /* Get and record value.  */
123
          p = strtok (NULL, " \t\r\n");
124
          if (p)
125
            {
126
              for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
127
                {
128
                  if (picobug_regnames[i]
129
                      && strcmp (picobug_regnames[i], name) == 0)
130
                    break;
131
                }
132
 
133
              if (i <= gdbarch_num_regs (gdbarch))
134
                monitor_supply_register (regcache, i, p);
135
            }
136
        }
137
      p = strtok (NULL, " \t\r\n");
138
    }
139
 
140
  return 0;
141
}
142
 
143
static void
144
init_picobug_cmds (void)
145
{
146
  picobug_cmds.flags = MO_GETMEM_NEEDS_RANGE | MO_CLR_BREAK_USES_ADDR
147
                       | MO_PRINT_PROGRAM_OUTPUT;
148
 
149
  picobug_cmds.init = picobug_inits;            /* Init strings         */
150
  picobug_cmds.cont = "g\n";                    /* continue command     */
151
  picobug_cmds.step = "s\n";                    /* single step          */
152
  picobug_cmds.set_break = "br %x\n";           /* set a breakpoint     */
153
  picobug_cmds.clr_break = "nobr %x\n";         /* clear a breakpoint   */
154
  picobug_cmds.clr_all_break = "nobr\n";        /* clear all breakpoints */
155
  picobug_cmds.setmem.cmdb = "mm %x %x ;b\n";   /* setmem.cmdb (addr, value) */
156
  picobug_cmds.setmem.cmdw = "mm %x %x ;h\n";   /* setmem.cmdw (addr, value) */
157
  picobug_cmds.setmem.cmdl = "mm %x %x ;w\n";   /* setmem.cmdl (addr, value) */
158
  picobug_cmds.getmem.cmdb = "md %x %x\n";      /* getmem.cmdb (start addr,
159
                                                   end addr)            */
160
  picobug_cmds.getmem.resp_delim = ":";         /* getmem.resp_delim    */
161
  picobug_cmds.setreg.cmd = "rm %s %x\n";       /* setreg.cmd (name, value) */
162
  picobug_cmds.getreg.cmd = "rd %s\n";          /* getreg.cmd (name)    */
163
  picobug_cmds.getreg.resp_delim = ":";         /* getreg.resp_delim    */
164
  picobug_cmds.dump_registers = "rd\n";         /* dump_registers       */
165
  picobug_cmds.dumpregs = picobug_dumpregs;     /* dump registers parser */
166
  picobug_cmds.load = "lo\n";                   /* download command     */
167
  picobug_cmds.prompt = "picobug> ";            /* monitor command prompt */
168
  picobug_cmds.line_term = "\n";                /* end-of-line terminator */
169
  picobug_cmds.target = &picobug_ops;           /* target operations    */
170
  picobug_cmds.stopbits = SERIAL_1_STOPBITS;    /* number of stop bits  */
171
  picobug_cmds.regnames = picobug_regnames;     /* registers names      */
172
  picobug_cmds.num_breakpoints = 20;            /* number of breakpoints */
173
  picobug_cmds.magic = MONITOR_OPS_MAGIC;       /* magic                */
174
}
175
 
176
void
177
_initialize_picobug_rom ()
178
{
179
  int i;
180
 
181
  /* Initialize m32r RevC monitor target.  */
182
  init_picobug_cmds ();
183
  init_monitor_ops (&picobug_ops);
184
  picobug_ops.to_shortname = "picobug";
185
  picobug_ops.to_longname = "picobug monitor";
186
  picobug_ops.to_doc = "Debug via the picobug monitor.\n\
187
Specify the serial device it is connected to (e.g. /dev/ttya).";
188
  picobug_ops.to_open = picobug_open;
189
 
190
  add_target (&picobug_ops);
191
}

powered by: WebSVN 2.1.0

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