1 /* Remote serial interface for Macraigor Systems implementation of
2 On-Chip Debugging using serial target box or serial wiggler
4 Copyright 1994, 1997, 1998, 1999, 2000, 2001
5 Free Software Foundation, Inc.
7 This file is part of GDB.
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.
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.
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
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
32 /* On Windows, this function pointer is initialized to a function in
34 static int (*dll_do_command
) (const char *, char *);
38 ocd_open (serial_t scb
, const char *name
)
41 /* Find the wiggler DLL which talks to the board. */
42 if (dll_do_command
== NULL
)
46 /* FIXME: Should the user be able to configure this? */
47 handle
= LoadLibrary ("Wigglers.dll");
49 error ("Can't load Wigglers.dll");
51 dll_do_command
= ((int (*) (const char *, char *))
52 GetProcAddress (handle
, "do_command"));
53 if (dll_do_command
== NULL
)
54 error ("Can't find do_command function in Wigglers.dll");
57 /* No wiggler DLLs on Unix yet, fail. */
58 error ("Wiggler library not available for this type of host.");
64 ocd_noop (serial_t scb
)
70 ocd_raw (serial_t scb
)
72 /* Always in raw mode */
75 /* We need a buffer to store responses from the Wigglers.dll */
76 #define WIGGLER_BUFF_SIZE 512
77 unsigned char from_wiggler_buffer
[WIGGLER_BUFF_SIZE
];
78 unsigned char *wiggler_buffer_ptr
; /* curr spot in buffer */
81 ocd_readchar (serial_t scb
, int timeout
)
83 /* Catch attempts at reading past the end of the buffer */
84 if (wiggler_buffer_ptr
>
85 (from_wiggler_buffer
+ (sizeof (char *) * WIGGLER_BUFF_SIZE
)))
86 error ("ocd_readchar asked to read past the end of the buffer!");
88 return (int) *wiggler_buffer_ptr
++; /* return curr char and increment ptr */
96 /* ocd_{get set}_tty_state() are both dummys to fill out the function
97 vector. Someday, they may do something real... */
99 static serial_ttystate
100 ocd_get_tty_state (serial_t scb
)
102 struct ocd_ttystate
*state
;
104 state
= (struct ocd_ttystate
*) xmalloc (sizeof *state
);
106 return (serial_ttystate
) state
;
110 ocd_set_tty_state (serial_t scb
, serial_ttystate ttystate
)
116 ocd_noflush_set_tty_state (serial_t scb
, serial_ttystate new_ttystate
,
117 serial_ttystate old_ttystate
)
123 ocd_print_tty_state (serial_t scb
,
124 serial_ttystate ttystate
,
125 struct ui_file
*stream
)
127 /* Nothing to print. */
132 ocd_setbaudrate (serial_t scb
, int rate
)
138 ocd_setstopbits (serial_t scb
, int rate
)
144 ocd_write (serial_t scb
, const char *str
, int len
)
147 /* send packet to Wigglers.dll and store response so we can give it to
148 remote-wiggler.c when get_packet is run */
149 dll_do_command (str
, from_wiggler_buffer
);
150 wiggler_buffer_ptr
= from_wiggler_buffer
;
157 ocd_close (serial_t scb
)
161 static struct serial_ops ocd_ops
=
169 ocd_noop
, /* flush output */
170 ocd_noop
, /* flush input */
171 ocd_noop
, /* send break -- currently used only for nindy */
176 ocd_noflush_set_tty_state
,
179 ocd_noop
, /* wait for output to drain */
183 _initialize_ser_ocd_bdm (void)
185 serial_add_interface (&ocd_ops
);