Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / ser-ocd.c
CommitLineData
c906108c 1/* Remote serial interface for Macraigor Systems implementation of
c5aa993b 2 On-Chip Debugging using serial target box or serial wiggler
c906108c 3
b6ba6518
KB
4 Copyright 1994, 1997, 1998, 1999, 2000, 2001
5 Free Software Foundation, Inc.
c906108c
SS
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
c5aa993b
JM
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
c906108c
SS
23
24#include "defs.h"
25#include "serial.h"
26
27#ifdef _WIN32
28#include <windows.h>
29#endif
30
c906108c
SS
31#ifdef _WIN32
32/* On Windows, this function pointer is initialized to a function in
33 the wiggler DLL. */
507f3c78 34static int (*dll_do_command) (const char *, char *);
c906108c
SS
35#endif
36
37static int
fba45db2 38ocd_open (serial_t scb, const char *name)
c906108c
SS
39{
40#ifdef _WIN32
41 /* Find the wiggler DLL which talks to the board. */
42 if (dll_do_command == NULL)
43 {
44 HINSTANCE handle;
45
46 /* FIXME: Should the user be able to configure this? */
47 handle = LoadLibrary ("Wigglers.dll");
48 if (handle == NULL)
49 error ("Can't load Wigglers.dll");
50
b37bcaa8 51 dll_do_command = ((int (*) (const char *, char *))
c906108c
SS
52 GetProcAddress (handle, "do_command"));
53 if (dll_do_command == NULL)
54 error ("Can't find do_command function in Wigglers.dll");
55 }
56#else
57 /* No wiggler DLLs on Unix yet, fail. */
58 error ("Wiggler library not available for this type of host.");
59#endif /* _WIN32 */
60 return 0;
61}
62
63static int
fba45db2 64ocd_noop (serial_t scb)
c906108c
SS
65{
66 return 0;
67}
68
69static void
fba45db2 70ocd_raw (serial_t scb)
c906108c
SS
71{
72 /* Always in raw mode */
73}
74
c906108c
SS
75/* We need a buffer to store responses from the Wigglers.dll */
76#define WIGGLER_BUFF_SIZE 512
77unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
c5aa993b 78unsigned char *wiggler_buffer_ptr; /* curr spot in buffer */
c906108c
SS
79
80static int
fba45db2 81ocd_readchar (serial_t scb, int timeout)
c906108c
SS
82{
83 /* Catch attempts at reading past the end of the buffer */
84 if (wiggler_buffer_ptr >
c5aa993b
JM
85 (from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
86 error ("ocd_readchar asked to read past the end of the buffer!");
c906108c 87
c5aa993b 88 return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
c906108c
SS
89}
90
c5aa993b
JM
91struct ocd_ttystate
92{
c906108c
SS
93 int dummy;
94};
95
96/* ocd_{get set}_tty_state() are both dummys to fill out the function
97 vector. Someday, they may do something real... */
98
99static serial_ttystate
fba45db2 100ocd_get_tty_state (serial_t scb)
c906108c
SS
101{
102 struct ocd_ttystate *state;
103
104 state = (struct ocd_ttystate *) xmalloc (sizeof *state);
105
106 return (serial_ttystate) state;
107}
108
109static int
fba45db2 110ocd_set_tty_state (serial_t scb, serial_ttystate ttystate)
c906108c
SS
111{
112 return 0;
113}
114
115static int
fba45db2
KB
116ocd_noflush_set_tty_state (serial_t scb, serial_ttystate new_ttystate,
117 serial_ttystate old_ttystate)
c906108c
SS
118{
119 return 0;
120}
121
122static void
c2c6d25f
JM
123ocd_print_tty_state (serial_t scb,
124 serial_ttystate ttystate,
d9fcf2fb 125 struct ui_file *stream)
c906108c
SS
126{
127 /* Nothing to print. */
128 return;
129}
130
131static int
fba45db2 132ocd_setbaudrate (serial_t scb, int rate)
c906108c
SS
133{
134 return 0;
135}
136
58841d58
AC
137static int
138ocd_setstopbits (serial_t scb, int rate)
139{
140 return 0;
141}
142
c906108c 143static int
fba45db2 144ocd_write (serial_t scb, const char *str, int len)
c906108c 145{
c5aa993b 146#ifdef _WIN32
c906108c 147 /* send packet to Wigglers.dll and store response so we can give it to
c5aa993b 148 remote-wiggler.c when get_packet is run */
c906108c
SS
149 dll_do_command (str, from_wiggler_buffer);
150 wiggler_buffer_ptr = from_wiggler_buffer;
151#endif
152
153 return 0;
154}
155
156static void
fba45db2 157ocd_close (serial_t scb)
c906108c
SS
158{
159}
160
161static struct serial_ops ocd_ops =
162{
163 "ocd",
164 0,
165 ocd_open,
166 ocd_close,
167 ocd_readchar,
168 ocd_write,
c5aa993b
JM
169 ocd_noop, /* flush output */
170 ocd_noop, /* flush input */
171 ocd_noop, /* send break -- currently used only for nindy */
c906108c
SS
172 ocd_raw,
173 ocd_get_tty_state,
174 ocd_set_tty_state,
175 ocd_print_tty_state,
176 ocd_noflush_set_tty_state,
177 ocd_setbaudrate,
58841d58 178 ocd_setstopbits,
c5aa993b 179 ocd_noop, /* wait for output to drain */
c906108c
SS
180};
181
182void
fba45db2 183_initialize_ser_ocd_bdm (void)
c906108c
SS
184{
185 serial_add_interface (&ocd_ops);
186}
This page took 0.107274 seconds and 4 git commands to generate.