Thu Aug 7 13:09:17 1997 Geoffrey Noer <noer@cygnus.com>
[platform/upstream/binutils.git] / gdb / ser-ocd.c
1 /* Remote serial interface for Macraigor Systems implementation of
2         On-Chip Debugging using serial target box or serial wiggler
3
4    Copyright 1994, 1997 Free Software Foundation, Inc.
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, Boston, MA 02111-1307, USA.  */
21
22 #include "defs.h"
23 #include "serial.h"
24
25 static int ser_ocd_open PARAMS ((serial_t scb, const char *name));
26 static void ser_ocd_raw PARAMS ((serial_t scb));
27 static int ser_ocd_readchar PARAMS ((serial_t scb, int timeout));
28 static int ser_ocd_setbaudrate PARAMS ((serial_t scb, int rate));
29 static int ser_ocd_write PARAMS ((serial_t scb, const char *str, int len));
30 static void ser_ocd_close PARAMS ((serial_t scb));
31 static serial_ttystate ser_ocd_get_tty_state PARAMS ((serial_t scb));
32 static int ser_ocd_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
33
34 static int
35 ocd_open (scb, name)
36      serial_t scb;
37      const char *name;
38 {
39   return 0;
40 }
41
42 static int
43 ocd_noop (scb)
44      serial_t scb;
45 {
46   return 0;
47 }
48
49 static void
50 ocd_raw (scb)
51      serial_t scb;
52 {
53   /* Always in raw mode */
54 }
55
56 /* We need a buffer to store responses from the Wigglers.dll */
57 char * from_wigglers_buffer;
58 char * bptr;                    /* curr spot in buffer */
59
60 static void
61 ocd_readremote ()
62 {
63 }
64
65 static int
66 ocd_readchar (scb, timeout)
67      serial_t scb;
68      int timeout;
69 {
70
71 }
72
73 struct ocd_ttystate {
74   int dummy;
75 };
76
77 /* ocd_{get set}_tty_state() are both dummys to fill out the function
78    vector.  Someday, they may do something real... */
79
80 static serial_ttystate
81 ocd_get_tty_state (scb)
82      serial_t scb;
83 {
84   struct ocd_ttystate *state;
85
86   state = (struct ocd_ttystate *) xmalloc (sizeof *state);
87
88   return (serial_ttystate) state;
89 }
90
91 static int
92 ocd_set_tty_state (scb, ttystate)
93      serial_t scb;
94      serial_ttystate ttystate;
95 {
96   return 0;
97 }
98
99 static int
100 ocd_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
101      serial_t scb;
102      serial_ttystate new_ttystate;
103      serial_ttystate old_ttystate;
104 {
105   return 0;
106 }
107
108 static void
109 ocd_print_tty_state (scb, ttystate)
110      serial_t scb;
111      serial_ttystate ttystate;
112 {
113   /* Nothing to print.  */
114   return;
115 }
116
117 static int
118 ocd_setbaudrate (scb, rate)
119      serial_t scb;
120      int rate;
121 {
122   return 0;
123 }
124
125 static int
126 ocd_write (scb, str, len)
127      serial_t scb;
128      const char *str;
129      int len;
130 {
131   char c;
132
133   ocd_readremote();
134
135 #ifdef __CYGWIN32__ 
136   /* send packet to Wigglers.dll and store response so we can give it to
137         remote-wiggler.c when get_packet is run */
138   do_command (str, from_wigglers_buffer);
139 #endif
140
141   return 0;
142 }
143
144 static void
145 ocd_close (scb)
146      serial_t scb;
147 {
148   ocd_close (0);
149 }
150
151 static struct serial_ops ocd_ops =
152 {
153   "ocd",
154   0,
155   ocd_open,
156   ocd_close,
157   ocd_readchar,
158   ocd_write,
159   ocd_noop,             /* flush output */
160   ocd_noop,             /* flush input */
161   ocd_noop,             /* send break -- currently used only for nindy */
162   ocd_raw,
163   ocd_get_tty_state,
164   ocd_set_tty_state,
165   ocd_print_tty_state,
166   ocd_noflush_set_tty_state,
167   ocd_setbaudrate,
168 };
169
170 void
171 _initialize_ser_ocd_bdm ()
172 {
173   serial_add_interface (&ocd_ops);
174 }