OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [ser-ocd.c] - Diff between revs 105 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.