1999-04-16 09:35:26 +08:00
|
|
|
/* Remote serial interface for Macraigor Systems implementation of
|
1999-07-08 04:19:36 +08:00
|
|
|
On-Chip Debugging using serial target box or serial wiggler
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2000-02-02 08:21:19 +08:00
|
|
|
Copyright 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
1999-07-08 04:19:36 +08:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "serial.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
/* On Windows, this function pointer is initialized to a function in
|
|
|
|
the wiggler DLL. */
|
2000-06-04 08:41:10 +08:00
|
|
|
static int (*dll_do_command) (const char *, char *);
|
1999-04-16 09:35:26 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_open (serial_t scb, const char *name)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
/* Find the wiggler DLL which talks to the board. */
|
|
|
|
if (dll_do_command == NULL)
|
|
|
|
{
|
|
|
|
HINSTANCE handle;
|
|
|
|
|
|
|
|
/* FIXME: Should the user be able to configure this? */
|
|
|
|
handle = LoadLibrary ("Wigglers.dll");
|
|
|
|
if (handle == NULL)
|
|
|
|
error ("Can't load Wigglers.dll");
|
|
|
|
|
2000-06-14 08:59:07 +08:00
|
|
|
dll_do_command = ((int (*) (const char *, char *))
|
1999-04-16 09:35:26 +08:00
|
|
|
GetProcAddress (handle, "do_command"));
|
|
|
|
if (dll_do_command == NULL)
|
|
|
|
error ("Can't find do_command function in Wigglers.dll");
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* No wiggler DLLs on Unix yet, fail. */
|
|
|
|
error ("Wiggler library not available for this type of host.");
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_noop (serial_t scb)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_raw (serial_t scb)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
/* Always in raw mode */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We need a buffer to store responses from the Wigglers.dll */
|
|
|
|
#define WIGGLER_BUFF_SIZE 512
|
|
|
|
unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
|
1999-07-08 04:19:36 +08:00
|
|
|
unsigned char *wiggler_buffer_ptr; /* curr spot in buffer */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_readchar (serial_t scb, int timeout)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
/* Catch attempts at reading past the end of the buffer */
|
|
|
|
if (wiggler_buffer_ptr >
|
1999-07-08 04:19:36 +08:00
|
|
|
(from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
|
|
|
|
error ("ocd_readchar asked to read past the end of the buffer!");
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
struct ocd_ttystate
|
|
|
|
{
|
1999-04-16 09:35:26 +08:00
|
|
|
int dummy;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ocd_{get set}_tty_state() are both dummys to fill out the function
|
|
|
|
vector. Someday, they may do something real... */
|
|
|
|
|
|
|
|
static serial_ttystate
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_get_tty_state (serial_t scb)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
struct ocd_ttystate *state;
|
|
|
|
|
|
|
|
state = (struct ocd_ttystate *) xmalloc (sizeof *state);
|
|
|
|
|
|
|
|
return (serial_ttystate) state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_set_tty_state (serial_t scb, serial_ttystate ttystate)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_noflush_set_tty_state (serial_t scb, serial_ttystate new_ttystate,
|
|
|
|
serial_ttystate old_ttystate)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-09-22 11:28:34 +08:00
|
|
|
ocd_print_tty_state (serial_t scb,
|
|
|
|
serial_ttystate ttystate,
|
2000-02-02 08:21:19 +08:00
|
|
|
struct ui_file *stream)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
/* Nothing to print. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_setbaudrate (serial_t scb, int rate)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_write (serial_t scb, const char *str, int len)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
#ifdef _WIN32
|
1999-04-16 09:35:26 +08:00
|
|
|
/* send packet to Wigglers.dll and store response so we can give it to
|
1999-07-08 04:19:36 +08:00
|
|
|
remote-wiggler.c when get_packet is run */
|
1999-04-16 09:35:26 +08:00
|
|
|
dll_do_command (str, from_wiggler_buffer);
|
|
|
|
wiggler_buffer_ptr = from_wiggler_buffer;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-30 09:48:28 +08:00
|
|
|
ocd_close (serial_t scb)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct serial_ops ocd_ops =
|
|
|
|
{
|
|
|
|
"ocd",
|
|
|
|
0,
|
|
|
|
ocd_open,
|
|
|
|
ocd_close,
|
|
|
|
ocd_readchar,
|
|
|
|
ocd_write,
|
1999-07-08 04:19:36 +08:00
|
|
|
ocd_noop, /* flush output */
|
|
|
|
ocd_noop, /* flush input */
|
|
|
|
ocd_noop, /* send break -- currently used only for nindy */
|
1999-04-16 09:35:26 +08:00
|
|
|
ocd_raw,
|
|
|
|
ocd_get_tty_state,
|
|
|
|
ocd_set_tty_state,
|
|
|
|
ocd_print_tty_state,
|
|
|
|
ocd_noflush_set_tty_state,
|
|
|
|
ocd_setbaudrate,
|
1999-07-08 04:19:36 +08:00
|
|
|
ocd_noop, /* wait for output to drain */
|
1999-04-16 09:35:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2000-07-30 09:48:28 +08:00
|
|
|
_initialize_ser_ocd_bdm (void)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
serial_add_interface (&ocd_ops);
|
|
|
|
}
|