Rename gdbarch_update() to gdbarch_update_p()
[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
d9fcf2fb 4 Copyright 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
c906108c
SS
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
c5aa993b
JM
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
c906108c
SS
22
23#include "defs.h"
24#include "serial.h"
25
26#ifdef _WIN32
27#include <windows.h>
28#endif
29
c906108c
SS
30#ifdef _WIN32
31/* On Windows, this function pointer is initialized to a function in
32 the wiggler DLL. */
507f3c78 33static int (*dll_do_command) (const char *, char *);
c906108c
SS
34#endif
35
36static int
fba45db2 37ocd_open (serial_t scb, const char *name)
c906108c
SS
38{
39#ifdef _WIN32
40 /* Find the wiggler DLL which talks to the board. */
41 if (dll_do_command == NULL)
42 {
43 HINSTANCE handle;
44
45 /* FIXME: Should the user be able to configure this? */
46 handle = LoadLibrary ("Wigglers.dll");
47 if (handle == NULL)
48 error ("Can't load Wigglers.dll");
49
b37bcaa8 50 dll_do_command = ((int (*) (const char *, char *))
c906108c
SS
51 GetProcAddress (handle, "do_command"));
52 if (dll_do_command == NULL)
53 error ("Can't find do_command function in Wigglers.dll");
54 }
55#else
56 /* No wiggler DLLs on Unix yet, fail. */
57 error ("Wiggler library not available for this type of host.");
58#endif /* _WIN32 */
59 return 0;
60}
61
62static int
fba45db2 63ocd_noop (serial_t scb)
c906108c
SS
64{
65 return 0;
66}
67
68static void
fba45db2 69ocd_raw (serial_t scb)
c906108c
SS
70{
71 /* Always in raw mode */
72}
73
c906108c
SS
74/* We need a buffer to store responses from the Wigglers.dll */
75#define WIGGLER_BUFF_SIZE 512
76unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
c5aa993b 77unsigned char *wiggler_buffer_ptr; /* curr spot in buffer */
c906108c
SS
78
79static int
fba45db2 80ocd_readchar (serial_t scb, int timeout)
c906108c
SS
81{
82 /* Catch attempts at reading past the end of the buffer */
83 if (wiggler_buffer_ptr >
c5aa993b
JM
84 (from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
85 error ("ocd_readchar asked to read past the end of the buffer!");
c906108c 86
c5aa993b 87 return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
c906108c
SS
88}
89
c5aa993b
JM
90struct ocd_ttystate
91{
c906108c
SS
92 int dummy;
93};
94
95/* ocd_{get set}_tty_state() are both dummys to fill out the function
96 vector. Someday, they may do something real... */
97
98static serial_ttystate
fba45db2 99ocd_get_tty_state (serial_t scb)
c906108c
SS
100{
101 struct ocd_ttystate *state;
102
103 state = (struct ocd_ttystate *) xmalloc (sizeof *state);
104
105 return (serial_ttystate) state;
106}
107
108static int
fba45db2 109ocd_set_tty_state (serial_t scb, serial_ttystate ttystate)
c906108c
SS
110{
111 return 0;
112}
113
114static int
fba45db2
KB
115ocd_noflush_set_tty_state (serial_t scb, serial_ttystate new_ttystate,
116 serial_ttystate old_ttystate)
c906108c
SS
117{
118 return 0;
119}
120
121static void
c2c6d25f
JM
122ocd_print_tty_state (serial_t scb,
123 serial_ttystate ttystate,
d9fcf2fb 124 struct ui_file *stream)
c906108c
SS
125{
126 /* Nothing to print. */
127 return;
128}
129
130static int
fba45db2 131ocd_setbaudrate (serial_t scb, int rate)
c906108c
SS
132{
133 return 0;
134}
135
136static int
fba45db2 137ocd_write (serial_t scb, const char *str, int len)
c906108c 138{
c5aa993b 139#ifdef _WIN32
c906108c 140 /* send packet to Wigglers.dll and store response so we can give it to
c5aa993b 141 remote-wiggler.c when get_packet is run */
c906108c
SS
142 dll_do_command (str, from_wiggler_buffer);
143 wiggler_buffer_ptr = from_wiggler_buffer;
144#endif
145
146 return 0;
147}
148
149static void
fba45db2 150ocd_close (serial_t scb)
c906108c
SS
151{
152}
153
154static struct serial_ops ocd_ops =
155{
156 "ocd",
157 0,
158 ocd_open,
159 ocd_close,
160 ocd_readchar,
161 ocd_write,
c5aa993b
JM
162 ocd_noop, /* flush output */
163 ocd_noop, /* flush input */
164 ocd_noop, /* send break -- currently used only for nindy */
c906108c
SS
165 ocd_raw,
166 ocd_get_tty_state,
167 ocd_set_tty_state,
168 ocd_print_tty_state,
169 ocd_noflush_set_tty_state,
170 ocd_setbaudrate,
c5aa993b 171 ocd_noop, /* wait for output to drain */
c906108c
SS
172};
173
174void
fba45db2 175_initialize_ser_ocd_bdm (void)
c906108c
SS
176{
177 serial_add_interface (&ocd_ops);
178}
This page took 0.074887 seconds and 4 git commands to generate.