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
) (const char *, char *);
37 ocd_open (serial_t scb
, const char *name
)
40 /* Find the wiggler DLL which talks to the board. */
41 if (dll_do_command
== NULL
)
45 /* FIXME: Should the user be able to configure this? */
46 handle
= LoadLibrary ("Wigglers.dll");
48 error ("Can't load Wigglers.dll");
50 dll_do_command
= ((int (*) (const char *, char *))
51 GetProcAddress (handle
, "do_command"));
52 if (dll_do_command
== NULL
)
53 error ("Can't find do_command function in Wigglers.dll");
56 /* No wiggler DLLs on Unix yet, fail. */
57 error ("Wiggler library not available for this type of host.");
63 ocd_noop (serial_t scb
)
69 ocd_raw (serial_t scb
)
71 /* Always in raw mode */
74 /* We need a buffer to store responses from the Wigglers.dll */
75 #define WIGGLER_BUFF_SIZE 512
76 unsigned char from_wiggler_buffer
[WIGGLER_BUFF_SIZE
];
77 unsigned char *wiggler_buffer_ptr
; /* curr spot in buffer */
80 ocd_readchar (serial_t scb
, int timeout
)
82 /* Catch attempts at reading past the end of the buffer */
83 if (wiggler_buffer_ptr
>
84 (from_wiggler_buffer
+ (sizeof (char *) * WIGGLER_BUFF_SIZE
)))
85 error ("ocd_readchar asked to read past the end of the buffer!");
87 return (int) *wiggler_buffer_ptr
++; /* return curr char and increment ptr */
95 /* ocd_{get set}_tty_state() are both dummys to fill out the function
96 vector. Someday, they may do something real... */
98 static serial_ttystate
99 ocd_get_tty_state (serial_t scb
)
101 struct ocd_ttystate
*state
;
103 state
= (struct ocd_ttystate
*) xmalloc (sizeof *state
);
105 return (serial_ttystate
) state
;
109 ocd_set_tty_state (serial_t scb
, serial_ttystate ttystate
)
115 ocd_noflush_set_tty_state (serial_t scb
, serial_ttystate new_ttystate
,
116 serial_ttystate old_ttystate
)
122 ocd_print_tty_state (serial_t scb
,
123 serial_ttystate ttystate
,
124 struct ui_file
*stream
)
126 /* Nothing to print. */
131 ocd_setbaudrate (serial_t scb
, int rate
)
137 ocd_write (serial_t scb
, const char *str
, int len
)
140 /* send packet to Wigglers.dll and store response so we can give it to
141 remote-wiggler.c when get_packet is run */
142 dll_do_command (str
, from_wiggler_buffer
);
143 wiggler_buffer_ptr
= from_wiggler_buffer
;
150 ocd_close (serial_t scb
)
154 static struct serial_ops ocd_ops
=
162 ocd_noop
, /* flush output */
163 ocd_noop
, /* flush input */
164 ocd_noop
, /* send break -- currently used only for nindy */
169 ocd_noflush_set_tty_state
,
171 ocd_noop
, /* wait for output to drain */
175 _initialize_ser_ocd_bdm (void)
177 serial_add_interface (&ocd_ops
);