1 /* Remote serial interface for Macraigor Systems implementation of
2 On-Chip Debugging using serial target box or serial wiggler
4 Copyright 1994, 1997 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. */
30 static int ser_ocd_open
PARAMS ((serial_t scb
, const char *name
));
31 static void ser_ocd_raw
PARAMS ((serial_t scb
));
32 static int ser_ocd_readchar
PARAMS ((serial_t scb
, int timeout
));
33 static int ser_ocd_setbaudrate
PARAMS ((serial_t scb
, int rate
));
34 static int ser_ocd_write
PARAMS ((serial_t scb
, const char *str
, int len
));
35 static void ser_ocd_close
PARAMS ((serial_t scb
));
36 static serial_ttystate ser_ocd_get_tty_state
PARAMS ((serial_t scb
));
37 static int ser_ocd_set_tty_state
PARAMS ((serial_t scb
, serial_ttystate state
));
40 /* On Windows, this function pointer is initialized to a function in
42 static int (*dll_do_command
) PARAMS ((const char *, char *));
51 /* Find the wiggler DLL which talks to the board. */
52 if (dll_do_command
== NULL
)
56 /* FIXME: Should the user be able to configure this? */
57 handle
= LoadLibrary ("Wigglers.dll");
59 error ("Can't load Wigglers.dll");
61 dll_do_command
= ((int (*)PARAMS ((const char *, char *)))
62 GetProcAddress (handle
, "do_command"));
63 if (dll_do_command
== NULL
)
64 error ("Can't find do_command function in Wigglers.dll");
67 /* No wiggler DLLs on Unix yet, fail. */
68 error ("Wiggler library not available for this type of host.");
84 /* Always in raw mode */
92 /* We need a buffer to store responses from the Wigglers.dll */
93 #define WIGGLER_BUFF_SIZE 512
94 unsigned char from_wiggler_buffer
[WIGGLER_BUFF_SIZE
];
95 unsigned char *wiggler_buffer_ptr
; /* curr spot in buffer */
98 ocd_readchar (scb
, timeout
)
102 /* Catch attempts at reading past the end of the buffer */
103 if (wiggler_buffer_ptr
>
104 (from_wiggler_buffer
+ (sizeof (char *) * WIGGLER_BUFF_SIZE
)))
105 error ("ocd_readchar asked to read past the end of the buffer!");
107 return (int) *wiggler_buffer_ptr
++; /* return curr char and increment ptr */
115 /* ocd_{get set}_tty_state() are both dummys to fill out the function
116 vector. Someday, they may do something real... */
118 static serial_ttystate
119 ocd_get_tty_state (scb
)
122 struct ocd_ttystate
*state
;
124 state
= (struct ocd_ttystate
*) xmalloc (sizeof *state
);
126 return (serial_ttystate
) state
;
130 ocd_set_tty_state (scb
, ttystate
)
132 serial_ttystate ttystate
;
138 ocd_noflush_set_tty_state (scb
, new_ttystate
, old_ttystate
)
140 serial_ttystate new_ttystate
;
141 serial_ttystate old_ttystate
;
147 ocd_print_tty_state (scb
, ttystate
)
149 serial_ttystate ttystate
;
151 /* Nothing to print. */
156 ocd_setbaudrate (scb
, rate
)
164 ocd_write (scb
, str
, len
)
172 /* send packet to Wigglers.dll and store response so we can give it to
173 remote-wiggler.c when get_packet is run */
174 dll_do_command (str
, from_wiggler_buffer
);
175 wiggler_buffer_ptr
= from_wiggler_buffer
;
187 static struct serial_ops ocd_ops
=
195 ocd_noop
, /* flush output */
196 ocd_noop
, /* flush input */
197 ocd_noop
, /* send break -- currently used only for nindy */
202 ocd_noflush_set_tty_state
,
204 ocd_noop
, /* wait for output to drain */
208 _initialize_ser_ocd_bdm ()
210 serial_add_interface (&ocd_ops
);