1 /* Remote serial interface for Macraigor Systems implementation of
2 On-Chip Debugging using serial target box or serial wiggler
4 Copyright 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
6 This file is part of GDB.
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.
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.
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,
21 Boston, MA 02111-1307, USA. */
31 /* On Windows, this function pointer is initialized to a function in
33 static int (*dll_do_command) PARAMS ((const char *, char *));
42 /* Find the wiggler DLL which talks to the board. */
43 if (dll_do_command == NULL)
47 /* FIXME: Should the user be able to configure this? */
48 handle = LoadLibrary ("Wigglers.dll");
50 error ("Can't load Wigglers.dll");
52 dll_do_command = ((int (*)PARAMS ((const char *, char *)))
53 GetProcAddress (handle, "do_command"));
54 if (dll_do_command == NULL)
55 error ("Can't find do_command function in Wigglers.dll");
58 /* No wiggler DLLs on Unix yet, fail. */
59 error ("Wiggler library not available for this type of host.");
75 /* Always in raw mode */
78 /* We need a buffer to store responses from the Wigglers.dll */
79 #define WIGGLER_BUFF_SIZE 512
80 unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
81 unsigned char *wiggler_buffer_ptr; /* curr spot in buffer */
84 ocd_readchar (scb, timeout)
88 /* Catch attempts at reading past the end of the buffer */
89 if (wiggler_buffer_ptr >
90 (from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
91 error ("ocd_readchar asked to read past the end of the buffer!");
93 return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
101 /* ocd_{get set}_tty_state() are both dummys to fill out the function
102 vector. Someday, they may do something real... */
104 static serial_ttystate
105 ocd_get_tty_state (scb)
108 struct ocd_ttystate *state;
110 state = (struct ocd_ttystate *) xmalloc (sizeof *state);
112 return (serial_ttystate) state;
116 ocd_set_tty_state (scb, ttystate)
118 serial_ttystate ttystate;
124 ocd_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
126 serial_ttystate new_ttystate;
127 serial_ttystate old_ttystate;
133 ocd_print_tty_state (serial_t scb,
134 serial_ttystate ttystate,
135 struct ui_file *stream)
137 /* Nothing to print. */
142 ocd_setbaudrate (scb, rate)
150 ocd_write (scb, str, len)
156 /* send packet to Wigglers.dll and store response so we can give it to
157 remote-wiggler.c when get_packet is run */
158 dll_do_command (str, from_wiggler_buffer);
159 wiggler_buffer_ptr = from_wiggler_buffer;
171 static struct serial_ops ocd_ops =
179 ocd_noop, /* flush output */
180 ocd_noop, /* flush input */
181 ocd_noop, /* send break -- currently used only for nindy */
186 ocd_noflush_set_tty_state,
188 ocd_noop, /* wait for output to drain */
192 _initialize_ser_ocd_bdm ()
194 serial_add_interface (&ocd_ops);