]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/ser-ocd.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gdb / ser-ocd.c
CommitLineData
35ce4f08
GN
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
5dcd8e70
ILT
25#ifdef _WIN32
26#include <windows.h>
27#endif
28
35ce4f08
GN
29static int ser_ocd_open PARAMS ((serial_t scb, const char *name));
30static void ser_ocd_raw PARAMS ((serial_t scb));
31static int ser_ocd_readchar PARAMS ((serial_t scb, int timeout));
32static int ser_ocd_setbaudrate PARAMS ((serial_t scb, int rate));
33static int ser_ocd_write PARAMS ((serial_t scb, const char *str, int len));
34static void ser_ocd_close PARAMS ((serial_t scb));
35static serial_ttystate ser_ocd_get_tty_state PARAMS ((serial_t scb));
36static int ser_ocd_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
37
5dcd8e70
ILT
38#ifdef _WIN32
39/* On Windows, this function pointer is initialized to a function in
40 the wiggler DLL. */
41static int (*dll_do_command) PARAMS ((const char *, char *));
42#endif
43
35ce4f08
GN
44static int
45ocd_open (scb, name)
46 serial_t scb;
47 const char *name;
48{
5dcd8e70
ILT
49#ifdef _WIN32
50 /* Find the wiggler DLL which talks to the board. */
51 if (dll_do_command == NULL)
52 {
53 HINSTANCE handle;
54
55 /* FIXME: Should the user be able to configure this? */
56 handle = LoadLibrary ("Wigglers.dll");
57 if (handle == NULL)
58 error ("Can't load Wigglers.dll");
59
60 dll_do_command = ((int (*) PARAMS ((const char *, char *)))
61 GetProcAddress (handle, "do_command"));
62 if (dll_do_command == NULL)
63 error ("Can't find do_command function in Wigglers.dll");
64 }
ab0e2218
SS
65#else
66 /* No wiggler DLLs on Unix yet, fail. */
67 error ("Wiggler library not available for this type of host.");
68#endif /* _WIN32 */
35ce4f08
GN
69 return 0;
70}
71
72static int
73ocd_noop (scb)
74 serial_t scb;
75{
76 return 0;
77}
78
79static void
80ocd_raw (scb)
81 serial_t scb;
82{
83 /* Always in raw mode */
84}
85
35ce4f08
GN
86static void
87ocd_readremote ()
88{
89}
90
61a0d022
GN
91/* We need a buffer to store responses from the Wigglers.dll */
92#define WIGGLER_BUFF_SIZE 512
93unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
94unsigned char * wiggler_buffer_ptr; /* curr spot in buffer */
95
35ce4f08
GN
96static int
97ocd_readchar (scb, timeout)
98 serial_t scb;
99 int timeout;
100{
61a0d022
GN
101 /* Catch attempts at reading past the end of the buffer */
102 if (wiggler_buffer_ptr >
103 (from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
104 error ("ocd_readchar asked to read past the end of the buffer!");
105
9cf7f520 106 return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
35ce4f08
GN
107}
108
109struct ocd_ttystate {
110 int dummy;
111};
112
113/* ocd_{get set}_tty_state() are both dummys to fill out the function
114 vector. Someday, they may do something real... */
115
116static serial_ttystate
117ocd_get_tty_state (scb)
118 serial_t scb;
119{
120 struct ocd_ttystate *state;
121
122 state = (struct ocd_ttystate *) xmalloc (sizeof *state);
123
124 return (serial_ttystate) state;
125}
126
127static int
128ocd_set_tty_state (scb, ttystate)
129 serial_t scb;
130 serial_ttystate ttystate;
131{
132 return 0;
133}
134
135static int
136ocd_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
137 serial_t scb;
138 serial_ttystate new_ttystate;
139 serial_ttystate old_ttystate;
140{
141 return 0;
142}
143
144static void
145ocd_print_tty_state (scb, ttystate)
146 serial_t scb;
147 serial_ttystate ttystate;
148{
149 /* Nothing to print. */
150 return;
151}
152
153static int
154ocd_setbaudrate (scb, rate)
155 serial_t scb;
156 int rate;
157{
158 return 0;
159}
160
161static int
162ocd_write (scb, str, len)
163 serial_t scb;
164 const char *str;
165 int len;
166{
167 char c;
168
2549d2b3 169#ifdef _WIN32
35ce4f08
GN
170 /* send packet to Wigglers.dll and store response so we can give it to
171 remote-wiggler.c when get_packet is run */
5dcd8e70 172 dll_do_command (str, from_wiggler_buffer);
9cf7f520 173 wiggler_buffer_ptr = from_wiggler_buffer;
35ce4f08
GN
174#endif
175
176 return 0;
177}
178
179static void
180ocd_close (scb)
181 serial_t scb;
182{
35ce4f08
GN
183}
184
185static struct serial_ops ocd_ops =
186{
187 "ocd",
188 0,
189 ocd_open,
190 ocd_close,
191 ocd_readchar,
192 ocd_write,
193 ocd_noop, /* flush output */
194 ocd_noop, /* flush input */
195 ocd_noop, /* send break -- currently used only for nindy */
196 ocd_raw,
197 ocd_get_tty_state,
198 ocd_set_tty_state,
199 ocd_print_tty_state,
200 ocd_noflush_set_tty_state,
201 ocd_setbaudrate,
3ffbdf15 202 ocd_noop, /* wait for output to drain */
35ce4f08
GN
203};
204
205void
206_initialize_ser_ocd_bdm ()
207{
208 serial_add_interface (&ocd_ops);
209}