This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / remote-d10v.c
1 /* Remote target communications for d10v connected via a serial line.
2 Copyright 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997 Free
3 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 2 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, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21 #include "defs.h"
22 #include "gdb_string.h"
23 #include <fcntl.h>
24 #include "frame.h"
25 #include "inferior.h"
26 #include "bfd.h"
27 #include "symfile.h"
28 #include "target.h"
29 #include "wait.h"
30 /*#include "terminal.h"*/
31 #include "gdbcmd.h"
32 #include "objfiles.h"
33 #include "gdb-stabs.h"
34 #include "gdbthread.h"
35
36 #include "dcache.h"
37
38 #ifdef USG
39 #include <sys/types.h>
40 #endif
41
42 #include <signal.h>
43 #include "serial.h"
44
45 /* Prototypes for local functions */
46
47 static void remote_d10v_open PARAMS ((char *name, int from_tty));
48
49 /* Define the target subroutine names */
50 static struct target_ops remote_d10v_ops;
51
52 /* Open a connection to a remote debugger.
53 NAME is the filename used for communication. */
54
55 static void
56 remote_d10v_open (name, from_tty)
57 char *name;
58 int from_tty;
59 {
60 pop_target ();
61 push_remote_target (name, from_tty);
62 }
63
64
65 /* Translate a GDB virtual ADDR/LEN into a format the remote target
66 understands. Returns number of bytes that can be transfered
67 starting at taddr, ZERO if no bytes can be transfered. */
68 int
69 remote_d10v_translate_xfer_address (memaddr, nr_bytes, taddr)
70 CORE_ADDR memaddr;
71 int nr_bytes;
72 CORE_ADDR *taddr;
73 {
74 CORE_ADDR phys;
75 CORE_ADDR seg;
76 CORE_ADDR off;
77 char *from = "unknown";
78 char *to = "unknown";
79 unsigned short imap0 = read_register (IMAP0_REGNUM);
80 unsigned short imap1 = read_register (IMAP1_REGNUM);
81 unsigned short dmap = read_register (DMAP_REGNUM);
82
83 /* GDB interprets addresses as:
84
85 0x00xxxxxx: Logical data address segment (DMAP translated memory)
86 0x01xxxxxx: Logical instruction address segment (IMAP translated memory)
87 0x10xxxxxx: Physical data memory segment (On-chip data memory)
88 0x11xxxxxx: Physical instruction memory segment (On-chip insn memory)
89 0x12xxxxxx: Phisical unified memory segment (Unified memory)
90
91 The remote d10v board interprets addresses as:
92
93 0x00xxxxxx: Phisical unified memory segment (Unified memory)
94 0x01xxxxxx: Physical instruction memory segment (On-chip insn memory)
95 0x02xxxxxx: Physical data memory segment (On-chip data memory)
96
97 Translate according to current IMAP/dmap registers */
98
99 enum {
100 targ_unified = 0x00000000,
101 targ_insn = 0x01000000,
102 targ_data = 0x02000000,
103 };
104
105 seg = (memaddr >> 24);
106 off = (memaddr & 0xffffffL);
107
108 switch (seg)
109 {
110 case 0x00: /* in logical data address segment */
111 {
112 from = "logical-data";
113 if (off <= 0x7fffL)
114 {
115 /* On chip data */
116 phys = targ_data + off;
117 if (off + nr_bytes > 0x7fffL)
118 /* don't cross VM boundary */
119 nr_bytes = 0x7fffL - off + 1;
120 to = "chip-data";
121 }
122 else if (off <= 0xbfffL)
123 {
124 short map = dmap;
125 if (map & 0x1000)
126 {
127 /* Instruction memory */
128 phys = targ_insn | ((map & 0xf) << 14) | (off & 0x3fff);
129 to = "chip-insn";
130 }
131 else
132 {
133 /* Unified memory */
134 phys = targ_unified | ((map & 0x3ff) << 14) | (off & 0x3fff);
135 to = "unified";
136 }
137 if (off + nr_bytes > 0xbfffL)
138 /* don't cross VM boundary */
139 nr_bytes = (0xbfffL - off + 1);
140 }
141 else
142 {
143 /* Logical address out side of data segments, not supported */
144 return (0);
145 }
146 break;
147 }
148
149 case 0x01: /* in logical instruction address segment */
150 {
151 short map;
152 from = "logical-insn";
153 if (off <= 0x1ffffL)
154 {
155 map = imap0;
156 }
157 else if (off <= 0x3ffffL)
158 {
159 map = imap1;
160 }
161 else
162 {
163 /* Logical address outside of IMAP[01] segment, not
164 supported */
165 return (0);
166 }
167 if ((off & 0x1ffff) + nr_bytes > 0x1ffffL)
168 {
169 /* don't cross VM boundary */
170 nr_bytes = 0x1ffffL - (off & 0x1ffffL) + 1;
171 }
172 if (map & 0x1000)
173 /* Instruction memory */
174 {
175 phys = targ_insn | off;
176 to = "chip-insn";
177 }
178 else
179 {
180 phys = ((map & 0x7fL) << 17) + (off & 0x1ffffL);
181 if (phys > 0xffffffL)
182 /* Address outside of unified address segment */
183 return (0);
184 phys |= targ_unified;
185 to = "unified";
186 }
187 break;
188 }
189
190 case 0x10: /* Physical data memory segment */
191 from = "phys-data";
192 phys = targ_data | off;
193 to = "chip-data";
194 break;
195
196 case 0x11: /* Physical instruction memory */
197 from = "phys-insn";
198 phys = targ_insn | off;
199 to = "chip-insn";
200 break;
201
202 case 0x12: /* Physical unified memory */
203 from = "phys-unified";
204 phys = targ_unified | off;
205 to = "unified";
206 break;
207
208 default:
209 return (0);
210 }
211
212
213 *taddr = phys;
214 return nr_bytes;
215 }
216
217
218 void
219 _initialize_remote_d10v ()
220 {
221 remote_d10v_ops.to_shortname = "d10v";
222 remote_d10v_ops.to_longname = "Remote d10v serial target in gdb-specific protocol";
223 remote_d10v_ops.to_doc = "Use a remote d10v via a serial line, using a gdb-specific protocol.\n\
224 Specify the serial device it is connected to (e.g. /dev/ttya).";
225 remote_d10v_ops.to_open = remote_d10v_open;
226
227 add_target (&remote_d10v_ops);
228 }
This page took 0.035202 seconds and 4 git commands to generate.