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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [remote-es.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
/* Memory-access and commands for remote es1800 processes, for GDB.
/* Memory-access and commands for remote es1800 processes, for GDB.
   Copyright (C) 1988, 1992 Free Software Foundation, Inc.
   Copyright (C) 1988, 1992 Free Software Foundation, Inc.
 
 
   This file is added to GDB to make it possible to do debugging via an
   This file is added to GDB to make it possible to do debugging via an
   ES-1800 emulator. The code was originally written by Johan Holmberg
   ES-1800 emulator. The code was originally written by Johan Holmberg
   TT/SJ Ericsson Telecom AB and later modified by Johan Henriksson
   TT/SJ Ericsson Telecom AB and later modified by Johan Henriksson
   TT/SJ. It was modified for gdb 4.0 by TX/DK Jan Nordenand by TX/DKG
   TT/SJ. It was modified for gdb 4.0 by TX/DK Jan Nordenand by TX/DKG
   Harald Johansen.
   Harald Johansen.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   GDB is free software; you can redistribute it and/or modify
   GDB 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 1, or (at your option)
   the Free Software Foundation; either version 1, or (at your option)
   any later version.
   any later version.
 
 
   GDB is distributed in the hope that it will be useful,
   GDB 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.  */
 
 
 
 
/* Emulator communication protocol.
/* Emulator communication protocol.
   All values are encoded in ascii hex digits.
   All values are encoded in ascii hex digits.
 
 
   Request
   Request
   Command
   Command
   Reply
   Reply
   read registers:
   read registers:
   DR<cr>
   DR<cr>
   - 0 -    - 1 -    - 2 -    - 3 -      - 4 -    - 5 -    -- 6 -   - 7 -
   - 0 -    - 1 -    - 2 -    - 3 -      - 4 -    - 5 -    -- 6 -   - 7 -
   D = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
   D = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
   A = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX
   A = XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX   XXXXXXXX XXXXXXXX XXXXXXXX
   PC = XXXXXX       SSP = XXXXXX    USP = XXXXXX     SR = XXXXXXXX
   PC = XXXXXX       SSP = XXXXXX    USP = XXXXXX     SR = XXXXXXXX
   >
   >
   Each byte of register data is described by two hex digits.
   Each byte of register data is described by two hex digits.
 
 
   write regs
   write regs
   D0=XXXXXXXX<cr>
   D0=XXXXXXXX<cr>
   >D1=XXXXXXXX<cr>
   >D1=XXXXXXXX<cr>
   >D2=XXXXXXXX<cr>
   >D2=XXXXXXXX<cr>
   >D3=XXXXXXXX<cr>
   >D3=XXXXXXXX<cr>
   >D4=XXXXXXXX<cr>
   >D4=XXXXXXXX<cr>
   >D5=XXXXXXXX<cr>
   >D5=XXXXXXXX<cr>
   >D6=XXXXXXXX<cr>
   >D6=XXXXXXXX<cr>
   >D7=XXXXXXXX<cr>
   >D7=XXXXXXXX<cr>
   >A0=XXXXXXXX<cr>
   >A0=XXXXXXXX<cr>
   >A1=XXXXXXXX<cr>
   >A1=XXXXXXXX<cr>
   >A2=XXXXXXXX<cr>
   >A2=XXXXXXXX<cr>
   >A3=XXXXXXXX<cr>
   >A3=XXXXXXXX<cr>
   >A4=XXXXXXXX<cr>
   >A4=XXXXXXXX<cr>
   >A5=XXXXXXXX<cr>
   >A5=XXXXXXXX<cr>
   >A6=XXXXXXXX<cr>
   >A6=XXXXXXXX<cr>
   >A7=XXXXXXXX<cr>
   >A7=XXXXXXXX<cr>
   >SR=XXXXXXXX<cr>
   >SR=XXXXXXXX<cr>
   >PC=XXXXXX<cr>
   >PC=XXXXXX<cr>
   >
   >
   Each byte of register data is described by two hex digits.
   Each byte of register data is described by two hex digits.
 
 
   read mem
   read mem
   @.BAA..AA
   @.BAA..AA
   $FFFFFFXX
   $FFFFFFXX
   >
   >
   AA..AA is address, XXXXXXX is the contents
   AA..AA is address, XXXXXXX is the contents
 
 
   write mem
   write mem
   @.BAA..AA=$XXXXXXXX
   @.BAA..AA=$XXXXXXXX
   >
   >
   AA..AA is address, XXXXXXXX is data
   AA..AA is address, XXXXXXXX is data
 
 
   cont
   cont
   PC=$AA..AA
   PC=$AA..AA
   >RBK
   >RBK
   R>
   R>
   AA..AA is address to resume. If AA..AA is omitted, resume at same address.
   AA..AA is address to resume. If AA..AA is omitted, resume at same address.
 
 
   step
   step
   PC=$AA..AA
   PC=$AA..AA
   >STP
   >STP
   R>
   R>
   AA..AA is address to resume. If AA..AA is omitted, resume at same address.
   AA..AA is address to resume. If AA..AA is omitted, resume at same address.
 
 
   kill req
   kill req
   STP
   STP
   >
   >
 */
 */
 
 
 
 
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/file.h>
#include <errno.h>
#include <errno.h>
#include <ctype.h>
#include <ctype.h>
#include <setjmp.h>
#include <setjmp.h>
#include <fcntl.h>
#include <fcntl.h>
#include "defs.h"
#include "defs.h"
#include "gdb_string.h"
#include "gdb_string.h"
#include "frame.h"
#include "frame.h"
#include "inferior.h"
#include "inferior.h"
#include "target.h"
#include "target.h"
#include "gdb_wait.h"
#include "gdb_wait.h"
#include "command.h"
#include "command.h"
#include "remote-utils.h"
#include "remote-utils.h"
#include "gdbcore.h"
#include "gdbcore.h"
#include "serial.h"
#include "serial.h"
 
 
/* Prototypes for local functions */
/* Prototypes for local functions */
 
 
static void
static void
es1800_child_detach PARAMS ((char *, int));
es1800_child_detach PARAMS ((char *, int));
 
 
static void
static void
es1800_child_open PARAMS ((char *, int));
es1800_child_open PARAMS ((char *, int));
 
 
static void
static void
es1800_transparent PARAMS ((char *, int));
es1800_transparent PARAMS ((char *, int));
 
 
static void
static void
es1800_create_inferior PARAMS ((char *, char *, char **));
es1800_create_inferior PARAMS ((char *, char *, char **));
 
 
static void
static void
es1800_load PARAMS ((char *, int));
es1800_load PARAMS ((char *, int));
 
 
static void
static void
es1800_kill PARAMS ((void));
es1800_kill PARAMS ((void));
 
 
static int
static int
verify_break PARAMS ((int));
verify_break PARAMS ((int));
 
 
static int
static int
es1800_remove_breakpoint PARAMS ((CORE_ADDR, char *));
es1800_remove_breakpoint PARAMS ((CORE_ADDR, char *));
 
 
static int
static int
es1800_insert_breakpoint PARAMS ((CORE_ADDR, char *));
es1800_insert_breakpoint PARAMS ((CORE_ADDR, char *));
 
 
static void
static void
es1800_files_info PARAMS ((struct target_ops *));
es1800_files_info PARAMS ((struct target_ops *));
 
 
static int
static int
es1800_xfer_inferior_memory PARAMS ((CORE_ADDR, char *, int, int,
es1800_xfer_inferior_memory PARAMS ((CORE_ADDR, char *, int, int,
                                     struct target_ops *));
                                     struct target_ops *));
 
 
static void
static void
es1800_prepare_to_store PARAMS ((void));
es1800_prepare_to_store PARAMS ((void));
 
 
static int es1800_wait PARAMS ((int, struct target_waitstatus *));
static int es1800_wait PARAMS ((int, struct target_waitstatus *));
 
 
static void es1800_resume PARAMS ((int, int, enum target_signal));
static void es1800_resume PARAMS ((int, int, enum target_signal));
 
 
static void
static void
es1800_detach PARAMS ((char *, int));
es1800_detach PARAMS ((char *, int));
 
 
static void
static void
es1800_attach PARAMS ((char *, int));
es1800_attach PARAMS ((char *, int));
 
 
static int
static int
damn_b PARAMS ((char *));
damn_b PARAMS ((char *));
 
 
static void
static void
es1800_open PARAMS ((char *, int));
es1800_open PARAMS ((char *, int));
 
 
static void
static void
es1800_timer PARAMS ((void));
es1800_timer PARAMS ((void));
 
 
static void
static void
es1800_reset PARAMS ((char *));
es1800_reset PARAMS ((char *));
 
 
static void
static void
es1800_request_quit PARAMS ((void));
es1800_request_quit PARAMS ((void));
 
 
static int
static int
readchar PARAMS ((void));
readchar PARAMS ((void));
 
 
static void
static void
expect PARAMS ((char *, int));
expect PARAMS ((char *, int));
 
 
static void
static void
expect_prompt PARAMS ((void));
expect_prompt PARAMS ((void));
 
 
static void
static void
download PARAMS ((FILE *, int, int));
download PARAMS ((FILE *, int, int));
 
 
#if 0
#if 0
static void
static void
bfd_copy PARAMS ((bfd *, bfd *));
bfd_copy PARAMS ((bfd *, bfd *));
#endif
#endif
 
 
static void
static void
get_break_addr PARAMS ((int, CORE_ADDR *));
get_break_addr PARAMS ((int, CORE_ADDR *));
 
 
static int
static int
fromhex PARAMS ((int));
fromhex PARAMS ((int));
 
 
static int
static int
tohex PARAMS ((int));
tohex PARAMS ((int));
 
 
static void
static void
es1800_close PARAMS ((int));
es1800_close PARAMS ((int));
 
 
static void
static void
es1800_fetch_registers PARAMS ((void));
es1800_fetch_registers PARAMS ((void));
 
 
static void
static void
es1800_fetch_register PARAMS ((int));
es1800_fetch_register PARAMS ((int));
 
 
static void
static void
es1800_store_register PARAMS ((int));
es1800_store_register PARAMS ((int));
 
 
static void
static void
es1800_read_bytes PARAMS ((CORE_ADDR, char *, int));
es1800_read_bytes PARAMS ((CORE_ADDR, char *, int));
 
 
static void
static void
es1800_write_bytes PARAMS ((CORE_ADDR, char *, int));
es1800_write_bytes PARAMS ((CORE_ADDR, char *, int));
 
 
static void
static void
send_with_reply PARAMS ((char *, char *, int));
send_with_reply PARAMS ((char *, char *, int));
 
 
static void
static void
send_command PARAMS ((char *));
send_command PARAMS ((char *));
 
 
static void
static void
send PARAMS ((char *));
send PARAMS ((char *));
 
 
static void
static void
getmessage PARAMS ((char *, int));
getmessage PARAMS ((char *, int));
 
 
static void
static void
es1800_mourn_inferior PARAMS ((void));
es1800_mourn_inferior PARAMS ((void));
 
 
static void
static void
es1800_create_break_insn PARAMS ((char *, int));
es1800_create_break_insn PARAMS ((char *, int));
 
 
static void
static void
es1800_init_break PARAMS ((char *, int));
es1800_init_break PARAMS ((char *, int));
 
 
/* Local variables */
/* Local variables */
 
 
/* FIXME: Convert this to use "set remotedebug" instead.  */
/* FIXME: Convert this to use "set remotedebug" instead.  */
#define LOG_FILE "es1800.log"
#define LOG_FILE "es1800.log"
#if defined (LOG_FILE)
#if defined (LOG_FILE)
static FILE *log_file;
static FILE *log_file;
#endif
#endif
 
 
extern struct target_ops es1800_ops;    /* Forward decl */
extern struct target_ops es1800_ops;    /* Forward decl */
extern struct target_ops es1800_child_ops;      /* Forward decl */
extern struct target_ops es1800_child_ops;      /* Forward decl */
 
 
static int kiodebug;
static int kiodebug;
static int timeout = 100;
static int timeout = 100;
static char *savename;          /* Name of i/o device used */
static char *savename;          /* Name of i/o device used */
static serial_ttystate es1800_saved_ttystate;
static serial_ttystate es1800_saved_ttystate;
static int es1800_fc_save;      /* Save fcntl state */
static int es1800_fc_save;      /* Save fcntl state */
 
 
/* indicates that the emulator uses 32-bit data-adress (68020-mode)
/* indicates that the emulator uses 32-bit data-adress (68020-mode)
   instead of 24-bit (68000 -mode) */
   instead of 24-bit (68000 -mode) */
 
 
static int m68020;
static int m68020;
 
 
#define MODE (m68020 ? "M68020" : "M68000" )
#define MODE (m68020 ? "M68020" : "M68000" )
#define ES1800_BREAK_VEC (0xf)
#define ES1800_BREAK_VEC (0xf)
 
 
/* Descriptor for I/O to remote machine.  Initialize it to NULL so that
/* Descriptor for I/O to remote machine.  Initialize it to NULL so that
   es1800_open knows that we don't have a file open when the program
   es1800_open knows that we don't have a file open when the program
   starts.  */
   starts.  */
 
 
static serial_t es1800_desc = NULL;
static serial_t es1800_desc = NULL;
 
 
#define PBUFSIZ 1000
#define PBUFSIZ 1000
#define HDRLEN sizeof("@.BAAAAAAAA=$VV\r")
#define HDRLEN sizeof("@.BAAAAAAAA=$VV\r")
 
 
/* Maximum number of bytes to read/write at once.  The value here
/* Maximum number of bytes to read/write at once.  The value here
   is chosen to fill up a packet.  */
   is chosen to fill up a packet.  */
 
 
#define MAXBUFBYTES ((PBUFSIZ-150)*16/75 )
#define MAXBUFBYTES ((PBUFSIZ-150)*16/75 )
 
 
static int es1800_break_vec = 0;
static int es1800_break_vec = 0;
static char es1800_break_insn[2];
static char es1800_break_insn[2];
static long es1800_break_address;
static long es1800_break_address;
static void (*old_sigint) ();   /* Old signal-handler for sigint */
static void (*old_sigint) ();   /* Old signal-handler for sigint */
static jmp_buf interrupt;
static jmp_buf interrupt;
 
 
/* Local signalhandler to allow breaking tranfers or program run.
/* Local signalhandler to allow breaking tranfers or program run.
   Rely on global variables: old_sigint(), interrupt */
   Rely on global variables: old_sigint(), interrupt */
 
 
static void
static void
es1800_request_quit ()
es1800_request_quit ()
{
{
  /* restore original signalhandler */
  /* restore original signalhandler */
  signal (SIGINT, old_sigint);
  signal (SIGINT, old_sigint);
  longjmp (interrupt, 1);
  longjmp (interrupt, 1);
}
}
 
 
 
 
/* Reset emulator.
/* Reset emulator.
   Sending reset character(octal 32) to emulator.
   Sending reset character(octal 32) to emulator.
   quit - return to '(esgdb)' prompt or continue        */
   quit - return to '(esgdb)' prompt or continue        */
 
 
static void
static void
es1800_reset (quit)
es1800_reset (quit)
     char *quit;
     char *quit;
{
{
  char buf[80];
  char buf[80];
 
 
  if (quit)
  if (quit)
    {
    {
      printf ("\nResetting emulator...  ");
      printf ("\nResetting emulator...  ");
    }
    }
  strcpy (buf, "\032");
  strcpy (buf, "\032");
  send (buf);
  send (buf);
  expect_prompt ();
  expect_prompt ();
  if (quit)
  if (quit)
    {
    {
      error ("done\n");
      error ("done\n");
    }
    }
}
}
 
 
 
 
/* Open a connection to a remote debugger and push the new target
/* Open a connection to a remote debugger and push the new target
   onto the stack. Check if the emulator is responding and find out
   onto the stack. Check if the emulator is responding and find out
   what kind of processor the emulator is connected to.
   what kind of processor the emulator is connected to.
   Initiate the breakpoint handling in the emulator.
   Initiate the breakpoint handling in the emulator.
 
 
   name     - the filename used for communication (ex. '/dev/tta')
   name     - the filename used for communication (ex. '/dev/tta')
   from_tty - says whether to be verbose or not */
   from_tty - says whether to be verbose or not */
 
 
static void
static void
es1800_open (name, from_tty)
es1800_open (name, from_tty)
     char *name;
     char *name;
     int from_tty;
     int from_tty;
{
{
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  char *p;
  char *p;
  int i, fcflag;
  int i, fcflag;
 
 
  m68020 = 0;
  m68020 = 0;
 
 
  if (!name)                    /* no device name given in target command */
  if (!name)                    /* no device name given in target command */
    {
    {
      error_no_arg ("serial port device name");
      error_no_arg ("serial port device name");
    }
    }
 
 
  target_preopen (from_tty);
  target_preopen (from_tty);
  es1800_close (0);
  es1800_close (0);
 
 
  /* open the device and configure it for communication */
  /* open the device and configure it for communication */
 
 
#ifndef DEBUG_STDIN
#ifndef DEBUG_STDIN
 
 
  es1800_desc = SERIAL_OPEN (name);
  es1800_desc = SERIAL_OPEN (name);
  if (es1800_desc == NULL)
  if (es1800_desc == NULL)
    {
    {
      perror_with_name (name);
      perror_with_name (name);
    }
    }
  savename = savestring (name, strlen (name));
  savename = savestring (name, strlen (name));
 
 
  es1800_saved_ttystate = SERIAL_GET_TTY_STATE (es1800_desc);
  es1800_saved_ttystate = SERIAL_GET_TTY_STATE (es1800_desc);
 
 
  if ((fcflag = fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_GETFL, 0)) == -1)
  if ((fcflag = fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_GETFL, 0)) == -1)
    {
    {
      perror_with_name ("fcntl serial");
      perror_with_name ("fcntl serial");
    }
    }
  es1800_fc_save = fcflag;
  es1800_fc_save = fcflag;
 
 
  fcflag = (fcflag & (FREAD | FWRITE));         /* mask out any funny stuff */
  fcflag = (fcflag & (FREAD | FWRITE));         /* mask out any funny stuff */
  if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, fcflag) == -1)
  if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, fcflag) == -1)
    {
    {
      perror_with_name ("fcntl serial");
      perror_with_name ("fcntl serial");
    }
    }
 
 
  if (baud_rate != -1)
  if (baud_rate != -1)
    {
    {
      if (SERIAL_SETBAUDRATE (es1800_desc, baud_rate))
      if (SERIAL_SETBAUDRATE (es1800_desc, baud_rate))
        {
        {
          SERIAL_CLOSE (es1800_desc);
          SERIAL_CLOSE (es1800_desc);
          perror_with_name (name);
          perror_with_name (name);
        }
        }
    }
    }
 
 
  SERIAL_RAW (es1800_desc);
  SERIAL_RAW (es1800_desc);
 
 
  /* If there is something sitting in the buffer we might take it as a
  /* If there is something sitting in the buffer we might take it as a
     response to a command, which would be bad.  */
     response to a command, which would be bad.  */
  SERIAL_FLUSH_INPUT (es1800_desc);
  SERIAL_FLUSH_INPUT (es1800_desc);
 
 
#endif /* DEBUG_STDIN */
#endif /* DEBUG_STDIN */
 
 
  push_target (&es1800_ops);    /* Switch to using remote target now */
  push_target (&es1800_ops);    /* Switch to using remote target now */
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("Remote ES1800 debugging using %s\n", name);
      printf ("Remote ES1800 debugging using %s\n", name);
    }
    }
 
 
#if defined (LOG_FILE)
#if defined (LOG_FILE)
 
 
  log_file = fopen (LOG_FILE, "w");
  log_file = fopen (LOG_FILE, "w");
  if (log_file == NULL)
  if (log_file == NULL)
    {
    {
      perror_with_name (LOG_FILE);
      perror_with_name (LOG_FILE);
    }
    }
 
 
#endif /* LOG_FILE */
#endif /* LOG_FILE */
 
 
  /* Hello?  Are you there?, also check mode  */
  /* Hello?  Are you there?, also check mode  */
 
 
  /*  send_with_reply( "DB 0 TO 1", buf, sizeof(buf)); */
  /*  send_with_reply( "DB 0 TO 1", buf, sizeof(buf)); */
  /*  for (p = buf, i = 0; *p++ =='0';)  *//* count the number of zeros */
  /*  for (p = buf, i = 0; *p++ =='0';)  *//* count the number of zeros */
  /*      i++; */
  /*      i++; */
 
 
  send ("\032");
  send ("\032");
  getmessage (buf, sizeof (buf));       /* send reset character */
  getmessage (buf, sizeof (buf));       /* send reset character */
 
 
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("Checking mode.... ");
      printf ("Checking mode.... ");
    }
    }
  /*  m68020 = (i==8); *//* if eight zeros then we are in m68020 mode */
  /*  m68020 = (i==8); *//* if eight zeros then we are in m68020 mode */
 
 
  /* What kind of processor am i talking to ? */
  /* What kind of processor am i talking to ? */
  p = buf;
  p = buf;
  while (*p++ != '\n')
  while (*p++ != '\n')
    {;
    {;
    }
    }
  while (*p++ != '\n')
  while (*p++ != '\n')
    {;
    {;
    }
    }
  while (*p++ != '\n')
  while (*p++ != '\n')
    {;
    {;
    }
    }
  for (i = 0; i < 20; i++, p++)
  for (i = 0; i < 20; i++, p++)
    {;
    {;
    }
    }
  m68020 = !strncmp (p, "68020", 5);
  m68020 = !strncmp (p, "68020", 5);
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("You are in %s(%c%c%c%c%c)-mode\n", MODE, p[0], p[1], p[2],
      printf ("You are in %s(%c%c%c%c%c)-mode\n", MODE, p[0], p[1], p[2],
              p[3], p[4]);
              p[3], p[4]);
    }
    }
 
 
  /* if no init_break statement is present in .gdb file we have to check
  /* if no init_break statement is present in .gdb file we have to check
     whether to download a breakpoint routine or not */
     whether to download a breakpoint routine or not */
 
 
#if 0
#if 0
  if ((es1800_break_vec == 0) || (verify_break (es1800_break_vec) != 0)
  if ((es1800_break_vec == 0) || (verify_break (es1800_break_vec) != 0)
      && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
      && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
    {
    {
      CORE_ADDR memaddress;
      CORE_ADDR memaddress;
      printf ("Give the start address of the breakpoint routine: ");
      printf ("Give the start address of the breakpoint routine: ");
      scanf ("%li", &memaddress);
      scanf ("%li", &memaddress);
      es1800_init_break ((es1800_break_vec ? es1800_break_vec :
      es1800_init_break ((es1800_break_vec ? es1800_break_vec :
                          ES1800_BREAK_VEC), memaddress);
                          ES1800_BREAK_VEC), memaddress);
    }
    }
#endif
#endif
 
 
}
}
 
 
/*  Close out all files and local state before this target loses control.
/*  Close out all files and local state before this target loses control.
   quitting - are we quitting gdb now? */
   quitting - are we quitting gdb now? */
 
 
static void
static void
es1800_close (quitting)
es1800_close (quitting)
     int quitting;
     int quitting;
{
{
  if (es1800_desc != NULL)
  if (es1800_desc != NULL)
    {
    {
      printf ("\nClosing connection to emulator...\n");
      printf ("\nClosing connection to emulator...\n");
      if (SERIAL_SET_TTY_STATE (es1800_desc, es1800_saved_ttystate) < 0)
      if (SERIAL_SET_TTY_STATE (es1800_desc, es1800_saved_ttystate) < 0)
        print_sys_errmsg ("warning: unable to restore tty state", errno);
        print_sys_errmsg ("warning: unable to restore tty state", errno);
      fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, es1800_fc_save);
      fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, es1800_fc_save);
      SERIAL_CLOSE (es1800_desc);
      SERIAL_CLOSE (es1800_desc);
      es1800_desc = NULL;
      es1800_desc = NULL;
    }
    }
  if (savename != NULL)
  if (savename != NULL)
    {
    {
      free (savename);
      free (savename);
    }
    }
  savename = NULL;
  savename = NULL;
 
 
#if defined (LOG_FILE)
#if defined (LOG_FILE)
 
 
  if (log_file != NULL)
  if (log_file != NULL)
    {
    {
      if (ferror (log_file))
      if (ferror (log_file))
        {
        {
          printf ("Error writing log file.\n");
          printf ("Error writing log file.\n");
        }
        }
      if (fclose (log_file) != 0)
      if (fclose (log_file) != 0)
        {
        {
          printf ("Error closing log file.\n");
          printf ("Error closing log file.\n");
        }
        }
      log_file = NULL;
      log_file = NULL;
    }
    }
 
 
#endif /* LOG_FILE */
#endif /* LOG_FILE */
 
 
}
}
 
 
/*  Attaches to a process on the target side
/*  Attaches to a process on the target side
   proc_id  - the id of the process to be attached.
   proc_id  - the id of the process to be attached.
   from_tty - says whether to be verbose or not */
   from_tty - says whether to be verbose or not */
 
 
static void
static void
es1800_attach (args, from_tty)
es1800_attach (args, from_tty)
     char *args;
     char *args;
     int from_tty;
     int from_tty;
{
{
  error ("Cannot attach to pid %s, this feature is not implemented yet.",
  error ("Cannot attach to pid %s, this feature is not implemented yet.",
         args);
         args);
}
}
 
 
 
 
/* Takes a program previously attached to and detaches it.
/* Takes a program previously attached to and detaches it.
   We better not have left any breakpoints
   We better not have left any breakpoints
   in the program or it'll die when it hits one.
   in the program or it'll die when it hits one.
   Close the open connection to the remote debugger.
   Close the open connection to the remote debugger.
   Use this when you want to detach and do something else
   Use this when you want to detach and do something else
   with your gdb.
   with your gdb.
 
 
   args     - arguments given to the 'detach' command
   args     - arguments given to the 'detach' command
   from_tty - says whether to be verbose or not */
   from_tty - says whether to be verbose or not */
 
 
static void
static void
es1800_detach (args, from_tty)
es1800_detach (args, from_tty)
     char *args;
     char *args;
     int from_tty;
     int from_tty;
{
{
  if (args)
  if (args)
    {
    {
      error ("Argument given to \"detach\" when remotely debugging.");
      error ("Argument given to \"detach\" when remotely debugging.");
    }
    }
  pop_target ();
  pop_target ();
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("Ending es1800 remote debugging.\n");
      printf ("Ending es1800 remote debugging.\n");
    }
    }
}
}
 
 
 
 
/* Tell the remote machine to resume.
/* Tell the remote machine to resume.
   step    - single-step or run free
   step    - single-step or run free
   siggnal - the signal value to be given to the target (0 = no signal) */
   siggnal - the signal value to be given to the target (0 = no signal) */
 
 
static void
static void
es1800_resume (pid, step, siggnal)
es1800_resume (pid, step, siggnal)
     int pid;
     int pid;
     int step;
     int step;
     enum target_signal siggnal;
     enum target_signal siggnal;
{
{
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
 
 
  if (siggnal)
  if (siggnal)
    {
    {
      error ("Can't send signals to a remote system.");
      error ("Can't send signals to a remote system.");
    }
    }
  if (step)
  if (step)
    {
    {
      strcpy (buf, "STP\r");
      strcpy (buf, "STP\r");
      send (buf);
      send (buf);
    }
    }
  else
  else
    {
    {
      send_command ("RBK");
      send_command ("RBK");
    }
    }
}
}
 
 
/* Wait until the remote machine stops, then return,
/* Wait until the remote machine stops, then return,
   storing status in STATUS just as `wait' would.
   storing status in STATUS just as `wait' would.
   status -  */
   status -  */
 
 
static int
static int
es1800_wait (pid, status)
es1800_wait (pid, status)
     int pid;
     int pid;
     struct target_waitstatus *status;
     struct target_waitstatus *status;
{
{
  unsigned char buf[PBUFSIZ];
  unsigned char buf[PBUFSIZ];
  int old_timeout = timeout;
  int old_timeout = timeout;
 
 
  status->kind = TARGET_WAITKIND_EXITED;
  status->kind = TARGET_WAITKIND_EXITED;
  status->value.integer = 0;
  status->value.integer = 0;
 
 
  timeout = 0;                   /* Don't time out -- user program is running. */
  timeout = 0;                   /* Don't time out -- user program is running. */
  if (!setjmp (interrupt))
  if (!setjmp (interrupt))
    {
    {
      old_sigint = signal (SIGINT, es1800_request_quit);
      old_sigint = signal (SIGINT, es1800_request_quit);
      while (1)
      while (1)
        {
        {
          getmessage (buf, sizeof (buf));
          getmessage (buf, sizeof (buf));
          if (strncmp (buf, "\r\n* BREAK *", 11) == 0)
          if (strncmp (buf, "\r\n* BREAK *", 11) == 0)
            {
            {
              status->kind = TARGET_WAITKIND_STOPPED;
              status->kind = TARGET_WAITKIND_STOPPED;
              status->value.sig = TARGET_SIGNAL_TRAP;
              status->value.sig = TARGET_SIGNAL_TRAP;
              send_command ("STP");     /* Restore stack and PC and such */
              send_command ("STP");     /* Restore stack and PC and such */
              if (m68020)
              if (m68020)
                {
                {
                  send_command ("STP");
                  send_command ("STP");
                }
                }
              break;
              break;
            }
            }
          if (strncmp (buf, "STP\r\n ", 6) == 0)
          if (strncmp (buf, "STP\r\n ", 6) == 0)
            {
            {
              status->kind = TARGET_WAITKIND_STOPPED;
              status->kind = TARGET_WAITKIND_STOPPED;
              status->value.sig = TARGET_SIGNAL_TRAP;
              status->value.sig = TARGET_SIGNAL_TRAP;
              break;
              break;
            }
            }
          if (buf[strlen (buf) - 2] == 'R')
          if (buf[strlen (buf) - 2] == 'R')
            {
            {
              printf ("Unexpected emulator reply: \n%s\n", buf);
              printf ("Unexpected emulator reply: \n%s\n", buf);
            }
            }
          else
          else
            {
            {
              printf ("Unexpected stop: \n%s\n", buf);
              printf ("Unexpected stop: \n%s\n", buf);
              status->kind = TARGET_WAITKIND_STOPPED;
              status->kind = TARGET_WAITKIND_STOPPED;
              status->value.sig = TARGET_SIGNAL_QUIT;
              status->value.sig = TARGET_SIGNAL_QUIT;
              break;
              break;
            }
            }
        }
        }
    }
    }
  else
  else
    {
    {
      fflush (stdin);
      fflush (stdin);
      printf ("\nStopping emulator...");
      printf ("\nStopping emulator...");
      if (!setjmp (interrupt))
      if (!setjmp (interrupt))
        {
        {
          old_sigint = signal (SIGINT, es1800_request_quit);
          old_sigint = signal (SIGINT, es1800_request_quit);
          send_command ("STP");
          send_command ("STP");
          printf (" emulator stopped\n");
          printf (" emulator stopped\n");
          status->kind = TARGET_WAITKIND_STOPPED;
          status->kind = TARGET_WAITKIND_STOPPED;
          status->value.sig = TARGET_SIGNAL_INT;
          status->value.sig = TARGET_SIGNAL_INT;
        }
        }
      else
      else
        {
        {
          fflush (stdin);
          fflush (stdin);
          es1800_reset ((char *) 1);
          es1800_reset ((char *) 1);
        }
        }
    }
    }
  signal (SIGINT, old_sigint);
  signal (SIGINT, old_sigint);
  timeout = old_timeout;
  timeout = old_timeout;
  return (0);
  return (0);
}
}
 
 
 
 
/* Fetch register values from remote machine.
/* Fetch register values from remote machine.
   regno - the register to be fetched (fetch all registers if -1) */
   regno - the register to be fetched (fetch all registers if -1) */
 
 
static void
static void
es1800_fetch_register (regno)
es1800_fetch_register (regno)
     int regno;
     int regno;
{
{
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  int k;
  int k;
  int r;
  int r;
  char *p;
  char *p;
  static char regtab[18][4] =
  static char regtab[18][4] =
  {
  {
    "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
    "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
    "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
    "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
    "SR ", "PC "
    "SR ", "PC "
  };
  };
 
 
  if ((regno < 15) || (regno == 16) || (regno == 17))
  if ((regno < 15) || (regno == 16) || (regno == 17))
    {
    {
      r = regno * 4;
      r = regno * 4;
      send_with_reply (regtab[regno], buf, sizeof (buf));
      send_with_reply (regtab[regno], buf, sizeof (buf));
      p = buf;
      p = buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
          if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
          registers[r++] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
        }
        }
    }
    }
  else
  else
    {
    {
      es1800_fetch_registers ();
      es1800_fetch_registers ();
    }
    }
}
}
 
 
/* Read the remote registers into REGISTERS.
/* Read the remote registers into REGISTERS.
   Always fetches all registers. */
   Always fetches all registers. */
 
 
static void
static void
es1800_fetch_registers ()
es1800_fetch_registers ()
{
{
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  char SR_buf[PBUFSIZ];
  char SR_buf[PBUFSIZ];
  int i;
  int i;
  int k;
  int k;
  int r;
  int r;
  char *p;
  char *p;
 
 
  send_with_reply ("DR", buf, sizeof (buf));
  send_with_reply ("DR", buf, sizeof (buf));
 
 
  /* Reply is edited to a string that describes registers byte by byte,
  /* Reply is edited to a string that describes registers byte by byte,
     each byte encoded as two hex characters.  */
     each byte encoded as two hex characters.  */
 
 
  p = buf;
  p = buf;
  r = 0;
  r = 0;
 
 
  /*  parsing row one - D0-D7-registers  */
  /*  parsing row one - D0-D7-registers  */
 
 
  while (*p++ != '\n')
  while (*p++ != '\n')
    {;
    {;
    }
    }
  for (i = 4; i < 70; i += (i == 39 ? 3 : 1))
  for (i = 4; i < 70; i += (i == 39 ? 3 : 1))
    {
    {
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[i + 0] == 0 || p[i + 1] == 0)
          if (p[i + 0] == 0 || p[i + 1] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] = (fromhex (p[i + 0]) * 16) + fromhex (p[i + 1]);
          registers[r++] = (fromhex (p[i + 0]) * 16) + fromhex (p[i + 1]);
          i += 2;
          i += 2;
        }
        }
    }
    }
  p += i;
  p += i;
 
 
  /*  parsing row two - A0-A6-registers  */
  /*  parsing row two - A0-A6-registers  */
 
 
  while (*p++ != '\n')
  while (*p++ != '\n')
    {;
    {;
    }
    }
  for (i = 4; i < 61; i += (i == 39 ? 3 : 1))
  for (i = 4; i < 61; i += (i == 39 ? 3 : 1))
    {
    {
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[i + 0] == 0 || p[i + 1] == 0)
          if (p[i + 0] == 0 || p[i + 1] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] = (fromhex (p[i + 0])) * 16 + fromhex (p[i + 1]);
          registers[r++] = (fromhex (p[i + 0])) * 16 + fromhex (p[i + 1]);
          i += 2;
          i += 2;
        }
        }
    }
    }
  p += i;
  p += i;
 
 
  while (*p++ != '\n')
  while (*p++ != '\n')
    {;
    {;
    }
    }
 
 
  /* fetch SSP-, SR- and PC-registers  */
  /* fetch SSP-, SR- and PC-registers  */
 
 
  /* first - check STATUS-word and decide which stackpointer to use */
  /* first - check STATUS-word and decide which stackpointer to use */
 
 
  send_with_reply ("SR", SR_buf, sizeof (SR_buf));
  send_with_reply ("SR", SR_buf, sizeof (SR_buf));
  p = SR_buf;
  p = SR_buf;
  p += 5;
  p += 5;
 
 
  if (m68020)
  if (m68020)
    {
    {
      if (*p == '3')            /* use masterstackpointer MSP */
      if (*p == '3')            /* use masterstackpointer MSP */
        {
        {
          send_with_reply ("MSP", buf, sizeof (buf));
          send_with_reply ("MSP", buf, sizeof (buf));
        }
        }
      else if (*p == '2')       /* use interruptstackpointer ISP  */
      else if (*p == '2')       /* use interruptstackpointer ISP  */
        {
        {
          send_with_reply ("ISP", buf, sizeof (buf));
          send_with_reply ("ISP", buf, sizeof (buf));
        }
        }
      else
      else
        /* use userstackpointer USP  */
        /* use userstackpointer USP  */
        {
        {
          send_with_reply ("USP", buf, sizeof (buf));
          send_with_reply ("USP", buf, sizeof (buf));
        }
        }
      p = buf;
      p = buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
        }
        }
 
 
      p = SR_buf;
      p = SR_buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] =
          registers[r++] =
            fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
            fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
        }
        }
      send_with_reply ("PC", buf, sizeof (buf));
      send_with_reply ("PC", buf, sizeof (buf));
      p = buf;
      p = buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
        }
        }
    }
    }
  else
  else
    /* 68000-mode */
    /* 68000-mode */
    {
    {
      if (*p == '2')            /* use supervisorstackpointer SSP  */
      if (*p == '2')            /* use supervisorstackpointer SSP  */
        {
        {
          send_with_reply ("SSP", buf, sizeof (buf));
          send_with_reply ("SSP", buf, sizeof (buf));
        }
        }
      else
      else
        /* use userstackpointer USP  */
        /* use userstackpointer USP  */
        {
        {
          send_with_reply ("USP", buf, sizeof (buf));
          send_with_reply ("USP", buf, sizeof (buf));
        }
        }
 
 
      /* fetch STACKPOINTER */
      /* fetch STACKPOINTER */
 
 
      p = buf;
      p = buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
        }
        }
 
 
      /* fetch STATUS */
      /* fetch STATUS */
 
 
      p = SR_buf;
      p = SR_buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] =
          registers[r++] =
            fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
            fromhex (SR_buf[k * 2 + 1]) * 16 + fromhex (SR_buf[k * 2 + 2]);
        }
        }
 
 
      /* fetch PC */
      /* fetch PC */
 
 
      send_with_reply ("PC", buf, sizeof (buf));
      send_with_reply ("PC", buf, sizeof (buf));
      p = buf;
      p = buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
          if (p[k * 2 + 1] == 0 || p[k * 2 + 2] == 0)
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
          registers[r++] = fromhex (buf[k * 2 + 1]) * 16 + fromhex (buf[k * 2 + 2]);
        }
        }
    }
    }
}
}
 
 
/* Store register value, located in REGISTER, on the target processor.
/* Store register value, located in REGISTER, on the target processor.
   regno - the register-number of the register to store
   regno - the register-number of the register to store
   (-1 means store them all)
   (-1 means store them all)
   FIXME: Return errno value.  */
   FIXME: Return errno value.  */
 
 
static void
static void
es1800_store_register (regno)
es1800_store_register (regno)
     int regno;
     int regno;
{
{
 
 
  static char regtab[18][4] =
  static char regtab[18][4] =
  {
  {
    "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
    "D0 ", "D1 ", "D2 ", "D3 ", "D4 ", "D5 ", "D6 ", "D7 ",
    "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
    "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ", "A6 ", "SSP",
    "SR ", "PC "
    "SR ", "PC "
  };
  };
 
 
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  char SR_buf[PBUFSIZ];
  char SR_buf[PBUFSIZ];
  char stack_pointer[4];
  char stack_pointer[4];
  char *p;
  char *p;
  int i;
  int i;
  int j;
  int j;
  int k;
  int k;
  unsigned char *r;
  unsigned char *r;
 
 
  r = (unsigned char *) registers;
  r = (unsigned char *) registers;
 
 
  if (regno == -1)              /* write all registers */
  if (regno == -1)              /* write all registers */
    {
    {
      j = 0;
      j = 0;
      k = 18;
      k = 18;
    }
    }
  else
  else
    /* write one register */
    /* write one register */
    {
    {
      j = regno;
      j = regno;
      k = regno + 1;
      k = regno + 1;
      r += regno * 4;
      r += regno * 4;
    }
    }
 
 
  if ((regno == -1) || (regno == 15))
  if ((regno == -1) || (regno == 15))
    {
    {
      /* fetch current status */
      /* fetch current status */
      send_with_reply ("SR", SR_buf, sizeof (SR_buf));
      send_with_reply ("SR", SR_buf, sizeof (SR_buf));
      p = SR_buf;
      p = SR_buf;
      p += 5;
      p += 5;
      if (m68020)
      if (m68020)
        {
        {
          if (*p == '3')        /* use masterstackpointer MSP */
          if (*p == '3')        /* use masterstackpointer MSP */
            {
            {
              strcpy (stack_pointer, "MSP");
              strcpy (stack_pointer, "MSP");
            }
            }
          else
          else
            {
            {
              if (*p == '2')    /* use interruptstackpointer ISP  */
              if (*p == '2')    /* use interruptstackpointer ISP  */
                {
                {
                  strcpy (stack_pointer, "ISP");
                  strcpy (stack_pointer, "ISP");
                }
                }
              else
              else
                {
                {
                  strcpy (stack_pointer, "USP");        /* use userstackpointer USP  */
                  strcpy (stack_pointer, "USP");        /* use userstackpointer USP  */
                }
                }
            }
            }
        }
        }
      else
      else
        /* 68000-mode */
        /* 68000-mode */
        {
        {
          if (*p == '2')        /* use supervisorstackpointer SSP  */
          if (*p == '2')        /* use supervisorstackpointer SSP  */
            {
            {
              strcpy (stack_pointer, "SSP");
              strcpy (stack_pointer, "SSP");
            }
            }
          else
          else
            {
            {
              strcpy (stack_pointer, "USP");    /* use userstackpointer USP  */
              strcpy (stack_pointer, "USP");    /* use userstackpointer USP  */
            }
            }
        }
        }
      strcpy (regtab[15], stack_pointer);
      strcpy (regtab[15], stack_pointer);
    }
    }
 
 
  for (i = j; i < k; i++)
  for (i = j; i < k; i++)
    {
    {
      buf[0] = regtab[i][0];
      buf[0] = regtab[i][0];
      buf[1] = regtab[i][1];
      buf[1] = regtab[i][1];
      buf[2] = regtab[i][2];
      buf[2] = regtab[i][2];
      buf[3] = '=';
      buf[3] = '=';
      buf[4] = '$';
      buf[4] = '$';
      buf[5] = tohex ((*r >> 4) & 0x0f);
      buf[5] = tohex ((*r >> 4) & 0x0f);
      buf[6] = tohex (*r++ & 0x0f);
      buf[6] = tohex (*r++ & 0x0f);
      buf[7] = tohex ((*r >> 4) & 0x0f);
      buf[7] = tohex ((*r >> 4) & 0x0f);
      buf[8] = tohex (*r++ & 0x0f);
      buf[8] = tohex (*r++ & 0x0f);
      buf[9] = tohex ((*r >> 4) & 0x0f);
      buf[9] = tohex ((*r >> 4) & 0x0f);
      buf[10] = tohex (*r++ & 0x0f);
      buf[10] = tohex (*r++ & 0x0f);
      buf[11] = tohex ((*r >> 4) & 0x0f);
      buf[11] = tohex ((*r >> 4) & 0x0f);
      buf[12] = tohex (*r++ & 0x0f);
      buf[12] = tohex (*r++ & 0x0f);
      buf[13] = 0;
      buf[13] = 0;
 
 
      send_with_reply (buf, buf, sizeof (buf));         /* FIXME, reply not used? */
      send_with_reply (buf, buf, sizeof (buf));         /* FIXME, reply not used? */
    }
    }
}
}
 
 
 
 
/* Prepare to store registers.  */
/* Prepare to store registers.  */
 
 
static void
static void
es1800_prepare_to_store ()
es1800_prepare_to_store ()
{
{
  /* Do nothing, since we can store individual regs */
  /* Do nothing, since we can store individual regs */
}
}
 
 
/* Convert hex digit A to a number.  */
/* Convert hex digit A to a number.  */
 
 
static int
static int
fromhex (a)
fromhex (a)
     int a;
     int a;
{
{
  if (a >= '0' && a <= '9')
  if (a >= '0' && a <= '9')
    {
    {
      return a - '0';
      return a - '0';
    }
    }
  else if (a >= 'a' && a <= 'f')
  else if (a >= 'a' && a <= 'f')
    {
    {
      return a - 'a' + 10;
      return a - 'a' + 10;
    }
    }
  else if (a >= 'A' && a <= 'F')
  else if (a >= 'A' && a <= 'F')
    {
    {
      return a - 'A' + 10;
      return a - 'A' + 10;
    }
    }
  else
  else
    {
    {
      error ("Reply contains invalid hex digit");
      error ("Reply contains invalid hex digit");
    }
    }
  return (-1);
  return (-1);
}
}
 
 
 
 
/* Convert number NIB to a hex digit.  */
/* Convert number NIB to a hex digit.  */
 
 
static int
static int
tohex (nib)
tohex (nib)
     int nib;
     int nib;
{
{
  if (nib < 10)
  if (nib < 10)
    {
    {
      return ('0' + nib);
      return ('0' + nib);
    }
    }
  else
  else
    {
    {
      return ('A' + nib - 10);
      return ('A' + nib - 10);
    }
    }
}
}
 
 
/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
   to or from debugger address MYADDR.  Write to inferior if WRITE is
   to or from debugger address MYADDR.  Write to inferior if WRITE is
   nonzero.  Returns length of data written or read; 0 for error.
   nonzero.  Returns length of data written or read; 0 for error.
 
 
   memaddr - the target's address
   memaddr - the target's address
   myaddr  - gdb's address
   myaddr  - gdb's address
   len     - number of bytes
   len     - number of bytes
   write   - write if != 0 otherwise read       */
   write   - write if != 0 otherwise read       */
 
 
static int
static int
es1800_xfer_inferior_memory (memaddr, myaddr, len, write, tops)
es1800_xfer_inferior_memory (memaddr, myaddr, len, write, tops)
     CORE_ADDR memaddr;
     CORE_ADDR memaddr;
     char *myaddr;
     char *myaddr;
     int len;
     int len;
     int write;
     int write;
     struct target_ops *tops;   /* Unused */
     struct target_ops *tops;   /* Unused */
{
{
  int origlen = len;
  int origlen = len;
  int xfersize;
  int xfersize;
 
 
  while (len > 0)
  while (len > 0)
    {
    {
      xfersize = len > MAXBUFBYTES ? MAXBUFBYTES : len;
      xfersize = len > MAXBUFBYTES ? MAXBUFBYTES : len;
      if (write)
      if (write)
        {
        {
          es1800_write_bytes (memaddr, myaddr, xfersize);
          es1800_write_bytes (memaddr, myaddr, xfersize);
        }
        }
      else
      else
        {
        {
          es1800_read_bytes (memaddr, myaddr, xfersize);
          es1800_read_bytes (memaddr, myaddr, xfersize);
        }
        }
      memaddr += xfersize;
      memaddr += xfersize;
      myaddr += xfersize;
      myaddr += xfersize;
      len -= xfersize;
      len -= xfersize;
    }
    }
  return (origlen);             /* no error possible */
  return (origlen);             /* no error possible */
}
}
 
 
 
 
/* Write memory data directly to the emulator.
/* Write memory data directly to the emulator.
   This does not inform the data cache; the data cache uses this.
   This does not inform the data cache; the data cache uses this.
   MEMADDR is the address in the remote memory space.
   MEMADDR is the address in the remote memory space.
   MYADDR is the address of the buffer in our space.
   MYADDR is the address of the buffer in our space.
   LEN is the number of bytes.
   LEN is the number of bytes.
 
 
   memaddr - the target's address
   memaddr - the target's address
   myaddr  - gdb's address
   myaddr  - gdb's address
   len     - number of bytes   */
   len     - number of bytes   */
 
 
static void
static void
es1800_write_bytes (memaddr, myaddr, len)
es1800_write_bytes (memaddr, myaddr, len)
     CORE_ADDR memaddr;
     CORE_ADDR memaddr;
     char *myaddr;
     char *myaddr;
     int len;
     int len;
{
{
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  int i;
  int i;
  char *p;
  char *p;
 
 
  p = myaddr;
  p = myaddr;
  for (i = 0; i < len; i++)
  for (i = 0; i < len; i++)
    {
    {
      sprintf (buf, "@.B$%x=$%x", memaddr + i, (*p++) & 0xff);
      sprintf (buf, "@.B$%x=$%x", memaddr + i, (*p++) & 0xff);
      send_with_reply (buf, buf, sizeof (buf));         /* FIXME send_command? */
      send_with_reply (buf, buf, sizeof (buf));         /* FIXME send_command? */
    }
    }
}
}
 
 
 
 
/* Read memory data directly from the emulator.
/* Read memory data directly from the emulator.
   This does not use the data cache; the data cache uses this.
   This does not use the data cache; the data cache uses this.
 
 
   memaddr - the target's address
   memaddr - the target's address
   myaddr  - gdb's address
   myaddr  - gdb's address
   len     - number of bytes   */
   len     - number of bytes   */
 
 
static void
static void
es1800_read_bytes (memaddr, myaddr, len)
es1800_read_bytes (memaddr, myaddr, len)
     CORE_ADDR memaddr;
     CORE_ADDR memaddr;
     char *myaddr;
     char *myaddr;
     int len;
     int len;
{
{
  static int DB_tab[16] =
  static int DB_tab[16] =
  {8, 11, 14, 17, 20, 23, 26, 29, 34, 37, 40, 43, 46, 49, 52, 55};
  {8, 11, 14, 17, 20, 23, 26, 29, 34, 37, 40, 43, 46, 49, 52, 55};
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  int i;
  int i;
  int low_addr;
  int low_addr;
  char *p;
  char *p;
  char *b;
  char *b;
 
 
  if (len > PBUFSIZ / 2 - 1)
  if (len > PBUFSIZ / 2 - 1)
    {
    {
      abort ();
      abort ();
    }
    }
 
 
  if (len == 1)                 /* The emulator does not like expressions like:  */
  if (len == 1)                 /* The emulator does not like expressions like:  */
    {
    {
      len = 2;                  /* DB.B $20018 TO $20018                       */
      len = 2;                  /* DB.B $20018 TO $20018                       */
    }
    }
 
 
  /* Reply describes registers byte by byte, each byte encoded as two hex
  /* Reply describes registers byte by byte, each byte encoded as two hex
     characters.  */
     characters.  */
 
 
  sprintf (buf, "DB.B $%x TO $%x", memaddr, memaddr + len - 1);
  sprintf (buf, "DB.B $%x TO $%x", memaddr, memaddr + len - 1);
  send_with_reply (buf, buf, sizeof (buf));
  send_with_reply (buf, buf, sizeof (buf));
  b = buf;
  b = buf;
  low_addr = memaddr & 0x0f;
  low_addr = memaddr & 0x0f;
  for (i = low_addr; i < low_addr + len; i++)
  for (i = low_addr; i < low_addr + len; i++)
    {
    {
      if ((!(i % 16)) && i)
      if ((!(i % 16)) && i)
        {                       /* if (i = 16,32,48)  */
        {                       /* if (i = 16,32,48)  */
          while (*p++ != '\n')
          while (*p++ != '\n')
            {;
            {;
            }
            }
          b = p;
          b = p;
        }
        }
      p = b + DB_tab[i % 16] + (m68020 ? 2 : 0);
      p = b + DB_tab[i % 16] + (m68020 ? 2 : 0);
      if (p[0] == 32 || p[1] == 32)
      if (p[0] == 32 || p[1] == 32)
        {
        {
          error ("Emulator reply is too short: %s", buf);
          error ("Emulator reply is too short: %s", buf);
        }
        }
      myaddr[i - low_addr] = fromhex (p[0]) * 16 + fromhex (p[1]);
      myaddr[i - low_addr] = fromhex (p[0]) * 16 + fromhex (p[1]);
    }
    }
}
}
 
 
/* Information about the current target  */
/* Information about the current target  */
 
 
static void
static void
es1800_files_info (tops)
es1800_files_info (tops)
     struct target_ops *tops;   /* Unused */
     struct target_ops *tops;   /* Unused */
{
{
  printf ("ES1800 Attached to %s at %d baud in %s mode\n", savename, 19200,
  printf ("ES1800 Attached to %s at %d baud in %s mode\n", savename, 19200,
          MODE);
          MODE);
}
}
 
 
 
 
/* We read the contents of the target location and stash it,
/* We read the contents of the target location and stash it,
   then overwrite it with a breakpoint instruction.
   then overwrite it with a breakpoint instruction.
 
 
   addr           - is the target location in the target machine.
   addr           - is the target location in the target machine.
   contents_cache - is a pointer to memory allocated for saving the target contents.
   contents_cache - is a pointer to memory allocated for saving the target contents.
   It is guaranteed by the caller to be long enough to save sizeof
   It is guaranteed by the caller to be long enough to save sizeof
   BREAKPOINT bytes.
   BREAKPOINT bytes.
 
 
   FIXME: This size is target_arch dependent and should be available in
   FIXME: This size is target_arch dependent and should be available in
   the target_arch transfer vector, if we ever have one...  */
   the target_arch transfer vector, if we ever have one...  */
 
 
static int
static int
es1800_insert_breakpoint (addr, contents_cache)
es1800_insert_breakpoint (addr, contents_cache)
     CORE_ADDR addr;
     CORE_ADDR addr;
     char *contents_cache;
     char *contents_cache;
{
{
  int val;
  int val;
 
 
  val = target_read_memory (addr, contents_cache, sizeof (es1800_break_insn));
  val = target_read_memory (addr, contents_cache, sizeof (es1800_break_insn));
 
 
  if (val == 0)
  if (val == 0)
    {
    {
      val = target_write_memory (addr, es1800_break_insn,
      val = target_write_memory (addr, es1800_break_insn,
                                 sizeof (es1800_break_insn));
                                 sizeof (es1800_break_insn));
    }
    }
 
 
  return (val);
  return (val);
}
}
 
 
 
 
/* Write back the stashed instruction
/* Write back the stashed instruction
 
 
   addr           - is the target location in the target machine.
   addr           - is the target location in the target machine.
   contents_cache - is a pointer to memory allocated for saving the target contents.
   contents_cache - is a pointer to memory allocated for saving the target contents.
   It is guaranteed by the caller to be long enough to save sizeof
   It is guaranteed by the caller to be long enough to save sizeof
   BREAKPOINT bytes.    */
   BREAKPOINT bytes.    */
 
 
static int
static int
es1800_remove_breakpoint (addr, contents_cache)
es1800_remove_breakpoint (addr, contents_cache)
     CORE_ADDR addr;
     CORE_ADDR addr;
     char *contents_cache;
     char *contents_cache;
{
{
 
 
  return (target_write_memory (addr, contents_cache,
  return (target_write_memory (addr, contents_cache,
                               sizeof (es1800_break_insn)));
                               sizeof (es1800_break_insn)));
}
}
 
 
/* create_break_insn ()
/* create_break_insn ()
   Primitive datastructures containing the es1800 breakpoint instruction  */
   Primitive datastructures containing the es1800 breakpoint instruction  */
 
 
static void
static void
es1800_create_break_insn (ins, vec)
es1800_create_break_insn (ins, vec)
     char *ins;
     char *ins;
     int vec;
     int vec;
{
{
  if (vec == 15)
  if (vec == 15)
    {
    {
      ins[0] = 0x4e;
      ins[0] = 0x4e;
      ins[1] = 0x4f;
      ins[1] = 0x4f;
    }
    }
}
}
 
 
 
 
/* verify_break ()
/* verify_break ()
   Seach for breakpoint routine in emulator memory.
   Seach for breakpoint routine in emulator memory.
   returns non-zero on failure
   returns non-zero on failure
   vec - trap vector used for breakpoints  */
   vec - trap vector used for breakpoints  */
 
 
static int
static int
verify_break (vec)
verify_break (vec)
     int vec;
     int vec;
{
{
  CORE_ADDR memaddress;
  CORE_ADDR memaddress;
  char buf[8];
  char buf[8];
  char *instr = "NqNqNqNs";     /* breakpoint routine */
  char *instr = "NqNqNqNs";     /* breakpoint routine */
  int status;
  int status;
 
 
  get_break_addr (vec, &memaddress);
  get_break_addr (vec, &memaddress);
 
 
  if (memaddress)
  if (memaddress)
    {
    {
      status = target_read_memory (memaddress, buf, 8);
      status = target_read_memory (memaddress, buf, 8);
      if (status != 0)
      if (status != 0)
        {
        {
          memory_error (status, memaddress);
          memory_error (status, memaddress);
        }
        }
      return (STRCMP (instr, buf));
      return (STRCMP (instr, buf));
    }
    }
  return (-1);
  return (-1);
}
}
 
 
 
 
/* get_break_addr ()
/* get_break_addr ()
   find address of breakpint routine
   find address of breakpint routine
   vec - trap vector used for breakpoints
   vec - trap vector used for breakpoints
   addrp - store the address here       */
   addrp - store the address here       */
 
 
static void
static void
get_break_addr (vec, addrp)
get_break_addr (vec, addrp)
     int vec;
     int vec;
     CORE_ADDR *addrp;
     CORE_ADDR *addrp;
{
{
  CORE_ADDR memaddress = 0;
  CORE_ADDR memaddress = 0;
  int status;
  int status;
  int k;
  int k;
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  char base_addr[4];
  char base_addr[4];
  char *p;
  char *p;
 
 
  if (m68020)
  if (m68020)
    {
    {
      send_with_reply ("VBR ", buf, sizeof (buf));
      send_with_reply ("VBR ", buf, sizeof (buf));
      p = buf;
      p = buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
          if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
          base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
        }
        }
      /* base addr of exception vector table */
      /* base addr of exception vector table */
      memaddress = *((CORE_ADDR *) base_addr);
      memaddress = *((CORE_ADDR *) base_addr);
    }
    }
 
 
  memaddress += (vec + 32) * 4; /* address of trap vector */
  memaddress += (vec + 32) * 4; /* address of trap vector */
  status = target_read_memory (memaddress, (char *) addrp, 4);
  status = target_read_memory (memaddress, (char *) addrp, 4);
  if (status != 0)
  if (status != 0)
    {
    {
      memory_error (status, memaddress);
      memory_error (status, memaddress);
    }
    }
}
}
 
 
 
 
/* Kill an inferior process */
/* Kill an inferior process */
 
 
static void
static void
es1800_kill ()
es1800_kill ()
{
{
  if (inferior_pid != 0)
  if (inferior_pid != 0)
    {
    {
      inferior_pid = 0;
      inferior_pid = 0;
      es1800_mourn_inferior ();
      es1800_mourn_inferior ();
    }
    }
}
}
 
 
 
 
/* Load a file to the ES1800 emulator.
/* Load a file to the ES1800 emulator.
   Converts the file from a.out format into Extended Tekhex format
   Converts the file from a.out format into Extended Tekhex format
   before the file is loaded.
   before the file is loaded.
   Also loads the trap routine, and sets the ES1800 breakpoint on it
   Also loads the trap routine, and sets the ES1800 breakpoint on it
   filename - the a.out to be loaded
   filename - the a.out to be loaded
   from_tty - says whether to be verbose or not
   from_tty - says whether to be verbose or not
   FIXME Uses emulator overlay memory for trap routine  */
   FIXME Uses emulator overlay memory for trap routine  */
 
 
static void
static void
es1800_load (filename, from_tty)
es1800_load (filename, from_tty)
     char *filename;
     char *filename;
     int from_tty;
     int from_tty;
{
{
 
 
  FILE *instream;
  FILE *instream;
  char loadname[15];
  char loadname[15];
  char buf[160];
  char buf[160];
  struct cleanup *old_chain;
  struct cleanup *old_chain;
  int es1800_load_format = 5;
  int es1800_load_format = 5;
 
 
  if (es1800_desc == NULL)
  if (es1800_desc == NULL)
    {
    {
      printf ("No emulator attached, type emulator-command first\n");
      printf ("No emulator attached, type emulator-command first\n");
      return;
      return;
    }
    }
 
 
  filename = tilde_expand (filename);
  filename = tilde_expand (filename);
  make_cleanup (free, filename);
  make_cleanup (free, filename);
 
 
  switch (es1800_load_format)
  switch (es1800_load_format)
    {
    {
    case 2:                     /* Extended Tekhex  */
    case 2:                     /* Extended Tekhex  */
      if (from_tty)
      if (from_tty)
        {
        {
          printf ("Converting \"%s\" to Extended Tekhex Format\n", filename);
          printf ("Converting \"%s\" to Extended Tekhex Format\n", filename);
        }
        }
      sprintf (buf, "tekhex %s", filename);
      sprintf (buf, "tekhex %s", filename);
      system (buf);
      system (buf);
      sprintf (loadname, "out.hex");
      sprintf (loadname, "out.hex");
      break;
      break;
 
 
    case 5:                     /* Motorola S-rec  */
    case 5:                     /* Motorola S-rec  */
      if (from_tty)
      if (from_tty)
        {
        {
          printf ("Converting \"%s\" to Motorola S-record format\n",
          printf ("Converting \"%s\" to Motorola S-record format\n",
                  filename);
                  filename);
        }
        }
      /* in the future the source code in copy (part of binutils-1.93) will
      /* in the future the source code in copy (part of binutils-1.93) will
         be included in this file */
         be included in this file */
      sprintf (buf,
      sprintf (buf,
               "copy -s \"a.out-sunos-big\" -d \"srec\" %s /tmp/out.hex",
               "copy -s \"a.out-sunos-big\" -d \"srec\" %s /tmp/out.hex",
               filename);
               filename);
      system (buf);
      system (buf);
      sprintf (loadname, "/tmp/out.hex");
      sprintf (loadname, "/tmp/out.hex");
      break;
      break;
 
 
    default:
    default:
      error ("Downloading format not defined\n");
      error ("Downloading format not defined\n");
    }
    }
 
 
  breakpoint_init_inferior ();
  breakpoint_init_inferior ();
  inferior_pid = 0;
  inferior_pid = 0;
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("Downloading \"%s\" to the ES 1800\n", filename);
      printf ("Downloading \"%s\" to the ES 1800\n", filename);
    }
    }
  if ((instream = fopen (loadname, "r")) == NULL)
  if ((instream = fopen (loadname, "r")) == NULL)
    {
    {
      perror_with_name ("fopen:");
      perror_with_name ("fopen:");
    }
    }
 
 
  old_chain = make_cleanup (fclose, instream);
  old_chain = make_cleanup (fclose, instream);
  immediate_quit++;
  immediate_quit++;
 
 
  es1800_reset (0);
  es1800_reset (0);
 
 
  download (instream, from_tty, es1800_load_format);
  download (instream, from_tty, es1800_load_format);
 
 
  /* if breakpoint routine is not present anymore we have to check
  /* if breakpoint routine is not present anymore we have to check
     whether to download a new breakpoint routine or not */
     whether to download a new breakpoint routine or not */
 
 
  if ((verify_break (es1800_break_vec) != 0)
  if ((verify_break (es1800_break_vec) != 0)
      && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
      && query ("No breakpoint routine in ES 1800 emulator!\nDownload a breakpoint routine to the emulator? "))
    {
    {
      char buf[128];
      char buf[128];
      printf ("Using break vector 0x%x\n", es1800_break_vec);
      printf ("Using break vector 0x%x\n", es1800_break_vec);
      sprintf (buf, "0x%x ", es1800_break_vec);
      sprintf (buf, "0x%x ", es1800_break_vec);
      printf ("Give the start address of the breakpoint routine: ");
      printf ("Give the start address of the breakpoint routine: ");
      fgets (buf + strlen (buf), sizeof (buf) - strlen (buf), stdin);
      fgets (buf + strlen (buf), sizeof (buf) - strlen (buf), stdin);
      es1800_init_break (buf, 0);
      es1800_init_break (buf, 0);
    }
    }
 
 
  do_cleanups (old_chain);
  do_cleanups (old_chain);
  expect_prompt ();
  expect_prompt ();
  readchar ();                  /* FIXME I am getting a ^G = 7 after the prompt  */
  readchar ();                  /* FIXME I am getting a ^G = 7 after the prompt  */
  printf ("\n");
  printf ("\n");
 
 
  if (fclose (instream) == EOF)
  if (fclose (instream) == EOF)
    {
    {
      ;
      ;
    }
    }
 
 
  if (es1800_load_format != 2)
  if (es1800_load_format != 2)
    {
    {
      sprintf (buf, "/usr/bin/rm %s", loadname);
      sprintf (buf, "/usr/bin/rm %s", loadname);
      system (buf);
      system (buf);
    }
    }
 
 
  symbol_file_command (filename, from_tty);     /* reading symbol table */
  symbol_file_command (filename, from_tty);     /* reading symbol table */
  immediate_quit--;
  immediate_quit--;
}
}
 
 
#if 0
#if 0
 
 
#define NUMCPYBYTES 20
#define NUMCPYBYTES 20
 
 
static void
static void
bfd_copy (from_bfd, to_bfd)
bfd_copy (from_bfd, to_bfd)
     bfd *from_bfd;
     bfd *from_bfd;
     bfd *to_bfd;
     bfd *to_bfd;
{
{
  asection *p, *new;
  asection *p, *new;
  int i;
  int i;
  char buf[NUMCPYBYTES];
  char buf[NUMCPYBYTES];
 
 
  for (p = from_bfd->sections; p != NULL; p = p->next)
  for (p = from_bfd->sections; p != NULL; p = p->next)
    {
    {
      printf ("  Copying section %s. Size = %x.\n", p->name, p->_cooked_size);
      printf ("  Copying section %s. Size = %x.\n", p->name, p->_cooked_size);
      printf ("    vma = %x,  offset = %x,  output_sec = %x\n",
      printf ("    vma = %x,  offset = %x,  output_sec = %x\n",
              p->vma, p->output_offset, p->output_section);
              p->vma, p->output_offset, p->output_section);
      new = bfd_make_section (to_bfd, p->name);
      new = bfd_make_section (to_bfd, p->name);
      if (p->_cooked_size &&
      if (p->_cooked_size &&
          !bfd_set_section_size (to_bfd, new, p->_cooked_size))
          !bfd_set_section_size (to_bfd, new, p->_cooked_size))
        {
        {
          error ("Wrong BFD size!\n");
          error ("Wrong BFD size!\n");
        }
        }
      if (!bfd_set_section_flags (to_bfd, new, p->flags))
      if (!bfd_set_section_flags (to_bfd, new, p->flags))
        {
        {
          error ("bfd_set_section_flags");
          error ("bfd_set_section_flags");
        }
        }
      new->vma = p->vma;
      new->vma = p->vma;
 
 
      for (i = 0; (i + NUMCPYBYTES) < p->_cooked_size; i += NUMCPYBYTES)
      for (i = 0; (i + NUMCPYBYTES) < p->_cooked_size; i += NUMCPYBYTES)
        {
        {
          if (!bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
          if (!bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
                                         (bfd_size_type) NUMCPYBYTES))
                                         (bfd_size_type) NUMCPYBYTES))
            {
            {
              error ("bfd_get_section_contents\n");
              error ("bfd_get_section_contents\n");
            }
            }
          if (!bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
          if (!bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
                                         (bfd_size_type) NUMCPYBYTES))
                                         (bfd_size_type) NUMCPYBYTES))
            {
            {
              error ("bfd_set_section_contents\n");
              error ("bfd_set_section_contents\n");
            }
            }
        }
        }
      bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
      bfd_get_section_contents (from_bfd, p, (PTR) buf, (file_ptr) i,
                                (bfd_size_type) (p->_cooked_size - i));
                                (bfd_size_type) (p->_cooked_size - i));
      bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
      bfd_set_section_contents (to_bfd, new, (PTR) buf, (file_ptr) i,
                                (bfd_size_type) (p->_cooked_size - i));
                                (bfd_size_type) (p->_cooked_size - i));
    }
    }
}
}
 
 
#endif
#endif
 
 
/* Start an process on the es1800 and set inferior_pid to the new
/* Start an process on the es1800 and set inferior_pid to the new
   process' pid.
   process' pid.
   execfile - the file to run
   execfile - the file to run
   args     - arguments passed to the program
   args     - arguments passed to the program
   env      - the environment vector to pass    */
   env      - the environment vector to pass    */
 
 
static void
static void
es1800_create_inferior (execfile, args, env)
es1800_create_inferior (execfile, args, env)
     char *execfile;
     char *execfile;
     char *args;
     char *args;
     char **env;
     char **env;
{
{
  int entry_pt;
  int entry_pt;
  int pid;
  int pid;
#if 0
#if 0
  struct expression *expr;
  struct expression *expr;
  register struct cleanup *old_chain = 0;
  register struct cleanup *old_chain = 0;
  register value val;
  register value val;
#endif
#endif
 
 
  if (args && *args)
  if (args && *args)
    {
    {
      error ("Can't pass arguments to remote ES1800 process");
      error ("Can't pass arguments to remote ES1800 process");
    }
    }
 
 
#if 0
#if 0
  if (query ("Use 'start' as entry point? "))
  if (query ("Use 'start' as entry point? "))
    {
    {
      expr = parse_c_expression ("start");
      expr = parse_c_expression ("start");
      old_chain = make_cleanup (free_current_contents, &expr);
      old_chain = make_cleanup (free_current_contents, &expr);
      val = evaluate_expression (expr);
      val = evaluate_expression (expr);
      entry_pt = (val->location).address;
      entry_pt = (val->location).address;
    }
    }
  else
  else
    {
    {
      printf ("Enter the program's entry point (in hexadecimal): ");
      printf ("Enter the program's entry point (in hexadecimal): ");
      scanf ("%x", &entry_pt);
      scanf ("%x", &entry_pt);
    }
    }
#endif
#endif
 
 
  if (execfile == 0 || exec_bfd == 0)
  if (execfile == 0 || exec_bfd == 0)
    {
    {
      error ("No executable file specified");
      error ("No executable file specified");
    }
    }
 
 
  entry_pt = (int) bfd_get_start_address (exec_bfd);
  entry_pt = (int) bfd_get_start_address (exec_bfd);
 
 
  pid = 42;
  pid = 42;
 
 
  /* Now that we have a child process, make it our target.  */
  /* Now that we have a child process, make it our target.  */
 
 
  push_target (&es1800_child_ops);
  push_target (&es1800_child_ops);
 
 
  /* The "process" (board) is already stopped awaiting our commands, and
  /* The "process" (board) is already stopped awaiting our commands, and
     the program is already downloaded.  We just set its PC and go.  */
     the program is already downloaded.  We just set its PC and go.  */
 
 
  inferior_pid = pid;           /* Needed for wait_for_inferior below */
  inferior_pid = pid;           /* Needed for wait_for_inferior below */
 
 
  clear_proceed_status ();
  clear_proceed_status ();
 
 
  /* Tell wait_for_inferior that we've started a new process.  */
  /* Tell wait_for_inferior that we've started a new process.  */
 
 
  init_wait_for_inferior ();
  init_wait_for_inferior ();
 
 
  /* Set up the "saved terminal modes" of the inferior
  /* Set up the "saved terminal modes" of the inferior
     based on what modes we are starting it with.  */
     based on what modes we are starting it with.  */
 
 
  target_terminal_init ();
  target_terminal_init ();
 
 
  /* Install inferior's terminal modes.  */
  /* Install inferior's terminal modes.  */
 
 
  target_terminal_inferior ();
  target_terminal_inferior ();
 
 
  /* remote_start (args); */
  /* remote_start (args); */
  /* trap_expected = 0; */
  /* trap_expected = 0; */
  /* insert_step_breakpoint ();  FIXME, do we need this?  */
  /* insert_step_breakpoint ();  FIXME, do we need this?  */
 
 
  /* Let 'er rip... */
  /* Let 'er rip... */
  proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0);
  proceed ((CORE_ADDR) entry_pt, TARGET_SIGNAL_DEFAULT, 0);
 
 
}
}
 
 
 
 
/* The process has died, clean up.  */
/* The process has died, clean up.  */
 
 
static void
static void
es1800_mourn_inferior ()
es1800_mourn_inferior ()
{
{
  remove_breakpoints ();
  remove_breakpoints ();
  unpush_target (&es1800_child_ops);
  unpush_target (&es1800_child_ops);
  generic_mourn_inferior ();    /* Do all the proper things now */
  generic_mourn_inferior ();    /* Do all the proper things now */
}
}
 
 
/* ES1800-protocol specific routines */
/* ES1800-protocol specific routines */
 
 
/* Keep discarding input from the remote system, until STRING is found.
/* Keep discarding input from the remote system, until STRING is found.
   Let the user break out immediately.
   Let the user break out immediately.
   string - the string to expect
   string - the string to expect
   nowait - break out if string not the emulator's first respond otherwise
   nowait - break out if string not the emulator's first respond otherwise
   read until string is found (== 0)   */
   read until string is found (== 0)   */
 
 
static void
static void
expect (string, nowait)
expect (string, nowait)
     char *string;
     char *string;
     int nowait;
     int nowait;
{
{
  char c;
  char c;
  char *p = string;
  char *p = string;
 
 
  immediate_quit++;
  immediate_quit++;
  while (1)
  while (1)
    {
    {
      c = readchar ();
      c = readchar ();
      if (isalpha (c))
      if (isalpha (c))
        {
        {
          c = toupper (c);
          c = toupper (c);
        }
        }
      if (c == toupper (*p))
      if (c == toupper (*p))
        {
        {
          p++;
          p++;
          if (*p == '\0')
          if (*p == '\0')
            {
            {
              immediate_quit--;
              immediate_quit--;
              return;
              return;
            }
            }
        }
        }
      else if (!nowait)
      else if (!nowait)
        {
        {
          p = string;
          p = string;
        }
        }
      else
      else
        {
        {
          printf ("\'%s\' expected\n", string);
          printf ("\'%s\' expected\n", string);
          printf ("char %d is %d", p - string, c);
          printf ("char %d is %d", p - string, c);
          error ("\n");
          error ("\n");
        }
        }
    }
    }
}
}
 
 
/* Keep discarding input until we see the prompt.  */
/* Keep discarding input until we see the prompt.  */
 
 
static void
static void
expect_prompt ()
expect_prompt ()
{
{
  expect (">", 0);
  expect (">", 0);
}
}
 
 
 
 
/* Read one character */
/* Read one character */
 
 
#ifdef DEBUG_STDIN
#ifdef DEBUG_STDIN
 
 
/* read from stdin */
/* read from stdin */
 
 
static int
static int
readchar ()
readchar ()
{
{
  char buf[1];
  char buf[1];
 
 
  buf[0] = '\0';
  buf[0] = '\0';
  printf ("readchar, give one character\n");
  printf ("readchar, give one character\n");
  read (0, buf, 1);
  read (0, buf, 1);
 
 
#if defined (LOG_FILE)
#if defined (LOG_FILE)
  putc (buf[0] & 0x7f, log_file);
  putc (buf[0] & 0x7f, log_file);
#endif
#endif
 
 
  return (buf[0] & 0x7f);
  return (buf[0] & 0x7f);
}
}
 
 
#else /* !DEBUG_STDIN */
#else /* !DEBUG_STDIN */
 
 
/* Read a character from the remote system, doing all the fancy
/* Read a character from the remote system, doing all the fancy
   timeout stuff.  */
   timeout stuff.  */
 
 
static int
static int
readchar ()
readchar ()
{
{
  int ch;
  int ch;
 
 
  ch = SERIAL_READCHAR (es1800_desc, timeout);
  ch = SERIAL_READCHAR (es1800_desc, timeout);
 
 
  /* FIXME: doing an error() here will probably cause trouble, at least if from
  /* FIXME: doing an error() here will probably cause trouble, at least if from
     es1800_wait.  */
     es1800_wait.  */
  if (ch == SERIAL_TIMEOUT)
  if (ch == SERIAL_TIMEOUT)
    error ("Timeout reading from remote system.");
    error ("Timeout reading from remote system.");
  else if (ch == SERIAL_ERROR)
  else if (ch == SERIAL_ERROR)
    perror_with_name ("remote read");
    perror_with_name ("remote read");
 
 
#if defined (LOG_FILE)
#if defined (LOG_FILE)
  putc (ch & 0x7f, log_file);
  putc (ch & 0x7f, log_file);
  fflush (log_file);
  fflush (log_file);
#endif
#endif
 
 
  return (ch);
  return (ch);
}
}
 
 
#endif /* DEBUG_STDIN */
#endif /* DEBUG_STDIN */
 
 
 
 
/* Send a command to the emulator and save the reply.
/* Send a command to the emulator and save the reply.
   Report an error if we get an error reply.
   Report an error if we get an error reply.
   string - the es1800 command
   string - the es1800 command
   buf    - containing the emulator reply on return
   buf    - containing the emulator reply on return
   len    - size of buf  */
   len    - size of buf  */
 
 
static void
static void
send_with_reply (string, buf, len)
send_with_reply (string, buf, len)
     char *string, *buf;
     char *string, *buf;
     int len;
     int len;
{
{
  send (string);
  send (string);
  SERIAL_WRITE (es1800_desc, "\r", 1);
  SERIAL_WRITE (es1800_desc, "\r", 1);
 
 
#ifndef DEBUG_STDIN
#ifndef DEBUG_STDIN
  expect (string, 1);
  expect (string, 1);
  expect ("\r\n", 0);
  expect ("\r\n", 0);
#endif
#endif
 
 
  getmessage (buf, len);
  getmessage (buf, len);
}
}
 
 
 
 
/* Send the command in STR to the emulator adding \r. check
/* Send the command in STR to the emulator adding \r. check
   the echo for consistency.
   the echo for consistency.
   string - the es1800 command  */
   string - the es1800 command  */
 
 
static void
static void
send_command (string)
send_command (string)
     char *string;
     char *string;
{
{
  send (string);
  send (string);
  SERIAL_WRITE (es1800_desc, "\r", 1);
  SERIAL_WRITE (es1800_desc, "\r", 1);
 
 
#ifndef DEBUG_STDIN
#ifndef DEBUG_STDIN
  expect (string, 0);
  expect (string, 0);
  expect_prompt ();
  expect_prompt ();
#endif
#endif
 
 
}
}
 
 
/* Send a string
/* Send a string
   string - the es1800 command  */
   string - the es1800 command  */
 
 
static void
static void
send (string)
send (string)
     char *string;
     char *string;
{
{
  if (kiodebug)
  if (kiodebug)
    {
    {
      fprintf (stderr, "Sending: %s\n", string);
      fprintf (stderr, "Sending: %s\n", string);
    }
    }
  SERIAL_WRITE (es1800_desc, string, strlen (string));
  SERIAL_WRITE (es1800_desc, string, strlen (string));
}
}
 
 
 
 
/* Read a message from the emulator and store it in BUF.
/* Read a message from the emulator and store it in BUF.
   buf    - containing the emulator reply on return
   buf    - containing the emulator reply on return
   len    - size of buf  */
   len    - size of buf  */
 
 
static void
static void
getmessage (buf, len)
getmessage (buf, len)
     char *buf;
     char *buf;
     int len;
     int len;
{
{
  char *bp;
  char *bp;
  int c;
  int c;
  int prompt_found = 0;
  int prompt_found = 0;
  extern kiodebug;
  extern kiodebug;
 
 
#if defined (LOG_FILE)
#if defined (LOG_FILE)
  /* This is a convenient place to do this.  The idea is to do it often
  /* This is a convenient place to do this.  The idea is to do it often
     enough that we never lose much data if we terminate abnormally.  */
     enough that we never lose much data if we terminate abnormally.  */
  fflush (log_file);
  fflush (log_file);
#endif
#endif
 
 
  bp = buf;
  bp = buf;
  c = readchar ();
  c = readchar ();
  do
  do
    {
    {
      if (c)
      if (c)
        {
        {
          if (len-- < 2)        /* char and terminaling NULL */
          if (len-- < 2)        /* char and terminaling NULL */
            {
            {
              error ("input buffer overrun\n");
              error ("input buffer overrun\n");
            }
            }
          *bp++ = c;
          *bp++ = c;
        }
        }
      c = readchar ();
      c = readchar ();
      if ((c == '>') && (*(bp - 1) == ' '))
      if ((c == '>') && (*(bp - 1) == ' '))
        {
        {
          prompt_found = 1;
          prompt_found = 1;
        }
        }
    }
    }
  while (!prompt_found);
  while (!prompt_found);
  *bp = 0;
  *bp = 0;
 
 
  if (kiodebug)
  if (kiodebug)
    {
    {
      fprintf (stderr, "message received :%s\n", buf);
      fprintf (stderr, "message received :%s\n", buf);
    }
    }
}
}
 
 
static void
static void
download (instream, from_tty, format)
download (instream, from_tty, format)
     FILE *instream;
     FILE *instream;
     int from_tty;
     int from_tty;
     int format;
     int format;
{
{
  char c;
  char c;
  char buf[160];
  char buf[160];
  int i = 0;
  int i = 0;
 
 
  send_command ("SET #2,$1A");  /* reset char = ^Z */
  send_command ("SET #2,$1A");  /* reset char = ^Z */
  send_command ("SET #3,$11,$13");      /* XON  XOFF */
  send_command ("SET #3,$11,$13");      /* XON  XOFF */
  if (format == 2)
  if (format == 2)
    {
    {
      send_command ("SET #26,#2");
      send_command ("SET #26,#2");
    }
    }
  else
  else
    {
    {
      send_command ("SET #26,#5");      /* Format=Extended Tekhex */
      send_command ("SET #26,#5");      /* Format=Extended Tekhex */
    }
    }
  send_command ("DFB = $10");
  send_command ("DFB = $10");
  send_command ("PUR");
  send_command ("PUR");
  send_command ("CES");
  send_command ("CES");
  send ("DNL\r");
  send ("DNL\r");
  expect ("DNL", 1);
  expect ("DNL", 1);
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("    0 records loaded...\r");
      printf ("    0 records loaded...\r");
    }
    }
  while (fgets (buf, 160, instream))
  while (fgets (buf, 160, instream))
    {
    {
      send (buf);
      send (buf);
      if (from_tty)
      if (from_tty)
        {
        {
          printf ("%5d\b\b\b\b\b", ++i);
          printf ("%5d\b\b\b\b\b", ++i);
          fflush (stdout);
          fflush (stdout);
        }
        }
      if ((c = readchar ()) != 006)
      if ((c = readchar ()) != 006)
        {
        {
          error ("expected ACK");
          error ("expected ACK");
        }
        }
    }
    }
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("- All");
      printf ("- All");
    }
    }
}
}
 
 
/* Additional commands */
/* Additional commands */
 
 
#if defined (TIOCGETP) && defined (FNDELAY) && defined (EWOULDBLOCK)
#if defined (TIOCGETP) && defined (FNDELAY) && defined (EWOULDBLOCK)
#define PROVIDE_TRANSPARENT
#define PROVIDE_TRANSPARENT
#endif
#endif
 
 
#ifdef PROVIDE_TRANSPARENT
#ifdef PROVIDE_TRANSPARENT
/* Talk directly to the emulator
/* Talk directly to the emulator
   FIXME, uses busy wait, and is SUNOS (or at least BSD) specific  */
   FIXME, uses busy wait, and is SUNOS (or at least BSD) specific  */
 
 
/*ARGSUSED */
/*ARGSUSED */
static void
static void
es1800_transparent (args, from_tty)
es1800_transparent (args, from_tty)
     char *args;
     char *args;
     int from_tty;
     int from_tty;
{
{
  int console;
  int console;
  struct sgttyb modebl;
  struct sgttyb modebl;
  int fcflag;
  int fcflag;
  int cc;
  int cc;
  struct sgttyb console_mode_save;
  struct sgttyb console_mode_save;
  int console_fc_save;
  int console_fc_save;
  int es1800_fc_save;
  int es1800_fc_save;
  int inputcnt = 80;
  int inputcnt = 80;
  char inputbuf[80];
  char inputbuf[80];
  int consolecnt = 0;
  int consolecnt = 0;
  char consolebuf[80];
  char consolebuf[80];
  int es1800_cnt = 0;
  int es1800_cnt = 0;
  char es1800_buf[80];
  char es1800_buf[80];
  int i;
  int i;
 
 
  dont_repeat ();
  dont_repeat ();
  if (es1800_desc == NULL)
  if (es1800_desc == NULL)
    {
    {
      printf ("No emulator attached, type emulator-command first\n");
      printf ("No emulator attached, type emulator-command first\n");
      return;
      return;
    }
    }
 
 
  printf ("\n");
  printf ("\n");
  printf ("You are now communicating directly with the ES 1800 emulator.\n");
  printf ("You are now communicating directly with the ES 1800 emulator.\n");
  printf ("To leave this mode (transparent mode), press ^E.\n");
  printf ("To leave this mode (transparent mode), press ^E.\n");
  printf ("\n");
  printf ("\n");
  printf (" >");
  printf (" >");
  fflush (stdout);
  fflush (stdout);
 
 
  if ((console = open ("/dev/tty", O_RDWR)) == -1)
  if ((console = open ("/dev/tty", O_RDWR)) == -1)
    {
    {
      perror_with_name ("/dev/tty:");
      perror_with_name ("/dev/tty:");
    }
    }
 
 
  if ((fcflag = fcntl (console, F_GETFL, 0)) == -1)
  if ((fcflag = fcntl (console, F_GETFL, 0)) == -1)
    {
    {
      perror_with_name ("fcntl console");
      perror_with_name ("fcntl console");
    }
    }
 
 
  console_fc_save = fcflag;
  console_fc_save = fcflag;
  fcflag = fcflag | FNDELAY;
  fcflag = fcflag | FNDELAY;
 
 
  if (fcntl (console, F_SETFL, fcflag) == -1)
  if (fcntl (console, F_SETFL, fcflag) == -1)
    {
    {
      perror_with_name ("fcntl console");
      perror_with_name ("fcntl console");
    }
    }
 
 
  if (ioctl (console, TIOCGETP, &modebl))
  if (ioctl (console, TIOCGETP, &modebl))
    {
    {
      perror_with_name ("ioctl console");
      perror_with_name ("ioctl console");
    }
    }
 
 
  console_mode_save = modebl;
  console_mode_save = modebl;
  modebl.sg_flags = RAW;
  modebl.sg_flags = RAW;
 
 
  if (ioctl (console, TIOCSETP, &modebl))
  if (ioctl (console, TIOCSETP, &modebl))
    {
    {
      perror_with_name ("ioctl console");
      perror_with_name ("ioctl console");
    }
    }
 
 
  if ((fcflag = fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_GETFL, 0)) == -1)
  if ((fcflag = fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_GETFL, 0)) == -1)
    {
    {
      perror_with_name ("fcntl serial");
      perror_with_name ("fcntl serial");
    }
    }
 
 
  es1800_fc_save = fcflag;
  es1800_fc_save = fcflag;
  fcflag = fcflag | FNDELAY;
  fcflag = fcflag | FNDELAY;
 
 
  if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, fcflag) == -1)
  if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, fcflag) == -1)
    {
    {
      perror_with_name ("fcntl serial");
      perror_with_name ("fcntl serial");
    }
    }
 
 
  while (1)
  while (1)
    {
    {
      cc = read (console, inputbuf, inputcnt);
      cc = read (console, inputbuf, inputcnt);
      if (cc != -1)
      if (cc != -1)
        {
        {
          if ((*inputbuf & 0x7f) == 0x05)
          if ((*inputbuf & 0x7f) == 0x05)
            {
            {
              break;
              break;
            }
            }
          for (i = 0; i < cc;)
          for (i = 0; i < cc;)
            {
            {
              es1800_buf[es1800_cnt++] = inputbuf[i++];
              es1800_buf[es1800_cnt++] = inputbuf[i++];
            }
            }
          if ((cc = SERIAL_WRITE (es1800_desc, es1800_buf, es1800_cnt)) == -1)
          if ((cc = SERIAL_WRITE (es1800_desc, es1800_buf, es1800_cnt)) == -1)
            {
            {
              perror_with_name ("FEL! write:");
              perror_with_name ("FEL! write:");
            }
            }
          es1800_cnt -= cc;
          es1800_cnt -= cc;
          if (es1800_cnt && cc)
          if (es1800_cnt && cc)
            {
            {
              for (i = 0; i < es1800_cnt; i++)
              for (i = 0; i < es1800_cnt; i++)
                {
                {
                  es1800_buf[i] = es1800_buf[cc + i];
                  es1800_buf[i] = es1800_buf[cc + i];
                }
                }
            }
            }
        }
        }
      else if (errno != EWOULDBLOCK)
      else if (errno != EWOULDBLOCK)
        {
        {
          perror_with_name ("FEL! read:");
          perror_with_name ("FEL! read:");
        }
        }
 
 
      cc = read (DEPRECATED_SERIAL_FD (es1800_desc), inputbuf, inputcnt);
      cc = read (DEPRECATED_SERIAL_FD (es1800_desc), inputbuf, inputcnt);
      if (cc != -1)
      if (cc != -1)
        {
        {
          for (i = 0; i < cc;)
          for (i = 0; i < cc;)
            {
            {
              consolebuf[consolecnt++] = inputbuf[i++];
              consolebuf[consolecnt++] = inputbuf[i++];
            }
            }
          if ((cc = write (console, consolebuf, consolecnt)) == -1)
          if ((cc = write (console, consolebuf, consolecnt)) == -1)
            {
            {
              perror_with_name ("FEL! write:");
              perror_with_name ("FEL! write:");
            }
            }
          consolecnt -= cc;
          consolecnt -= cc;
          if (consolecnt && cc)
          if (consolecnt && cc)
            {
            {
              for (i = 0; i < consolecnt; i++)
              for (i = 0; i < consolecnt; i++)
                {
                {
                  consolebuf[i] = consolebuf[cc + i];
                  consolebuf[i] = consolebuf[cc + i];
                }
                }
            }
            }
        }
        }
      else if (errno != EWOULDBLOCK)
      else if (errno != EWOULDBLOCK)
        {
        {
          perror_with_name ("FEL! read:");
          perror_with_name ("FEL! read:");
        }
        }
    }
    }
 
 
  console_fc_save = console_fc_save & !FNDELAY;
  console_fc_save = console_fc_save & !FNDELAY;
  if (fcntl (console, F_SETFL, console_fc_save) == -1)
  if (fcntl (console, F_SETFL, console_fc_save) == -1)
    {
    {
      perror_with_name ("FEL! fcntl");
      perror_with_name ("FEL! fcntl");
    }
    }
 
 
  if (ioctl (console, TIOCSETP, &console_mode_save))
  if (ioctl (console, TIOCSETP, &console_mode_save))
    {
    {
      perror_with_name ("FEL! ioctl");
      perror_with_name ("FEL! ioctl");
    }
    }
 
 
  close (console);
  close (console);
 
 
  if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, es1800_fc_save) == -1)
  if (fcntl (DEPRECATED_SERIAL_FD (es1800_desc), F_SETFL, es1800_fc_save) == -1)
    {
    {
      perror_with_name ("FEL! fcntl");
      perror_with_name ("FEL! fcntl");
    }
    }
 
 
  printf ("\n");
  printf ("\n");
 
 
}
}
#endif /* PROVIDE_TRANSPARENT */
#endif /* PROVIDE_TRANSPARENT */
 
 
static void
static void
es1800_init_break (args, from_tty)
es1800_init_break (args, from_tty)
     char *args;
     char *args;
     int from_tty;
     int from_tty;
{
{
  CORE_ADDR memaddress = 0;
  CORE_ADDR memaddress = 0;
  char buf[PBUFSIZ];
  char buf[PBUFSIZ];
  char base_addr[4];
  char base_addr[4];
  char *space_index;
  char *space_index;
  char *p;
  char *p;
  int k;
  int k;
 
 
  if (args == NULL)
  if (args == NULL)
    {
    {
      error_no_arg ("a trap vector");
      error_no_arg ("a trap vector");
    }
    }
 
 
  if (!(space_index = strchr (args, ' ')))
  if (!(space_index = strchr (args, ' ')))
    {
    {
      error ("Two arguments needed (trap vector and address of break routine).\n");
      error ("Two arguments needed (trap vector and address of break routine).\n");
    }
    }
 
 
  *space_index = '\0';
  *space_index = '\0';
 
 
  es1800_break_vec = strtol (args, (char **) NULL, 0);
  es1800_break_vec = strtol (args, (char **) NULL, 0);
  es1800_break_address = parse_and_eval_address (space_index + 1);
  es1800_break_address = parse_and_eval_address (space_index + 1);
 
 
  es1800_create_break_insn (es1800_break_insn, es1800_break_vec);
  es1800_create_break_insn (es1800_break_insn, es1800_break_vec);
 
 
  if (m68020)
  if (m68020)
    {
    {
      send_with_reply ("VBR ", buf, sizeof (buf));
      send_with_reply ("VBR ", buf, sizeof (buf));
      p = buf;
      p = buf;
      for (k = 0; k < 4; k++)
      for (k = 0; k < 4; k++)
        {
        {
          if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
          if ((p[k * 2 + 1] == 0) || (p[k * 2 + 2] == 0))
            {
            {
              error ("Emulator reply is too short: %s", buf);
              error ("Emulator reply is too short: %s", buf);
            }
            }
          base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
          base_addr[k] = (fromhex (p[k * 2 + 1]) * 16) + fromhex (p[k * 2 + 2]);
        }
        }
      /* base addr of exception vector table */
      /* base addr of exception vector table */
      memaddress = *((CORE_ADDR *) base_addr);
      memaddress = *((CORE_ADDR *) base_addr);
    }
    }
 
 
  memaddress += (es1800_break_vec + 32) * 4;    /* address of trap vector */
  memaddress += (es1800_break_vec + 32) * 4;    /* address of trap vector */
 
 
  sprintf (buf, "@.L%lx=$%lx", memaddress, es1800_break_address);
  sprintf (buf, "@.L%lx=$%lx", memaddress, es1800_break_address);
  send_command (buf);           /* set the address of the break routine in the */
  send_command (buf);           /* set the address of the break routine in the */
  /* trap vector */
  /* trap vector */
 
 
  sprintf (buf, "@.L%lx=$4E714E71", es1800_break_address);      /* NOP; NOP */
  sprintf (buf, "@.L%lx=$4E714E71", es1800_break_address);      /* NOP; NOP */
  send_command (buf);
  send_command (buf);
  sprintf (buf, "@.L%lx=$4E714E73", es1800_break_address + 4);  /* NOP; RTE */
  sprintf (buf, "@.L%lx=$4E714E73", es1800_break_address + 4);  /* NOP; RTE */
  send_command (buf);
  send_command (buf);
 
 
  sprintf (buf, "AC2=$%lx", es1800_break_address + 4);
  sprintf (buf, "AC2=$%lx", es1800_break_address + 4);
  /* breakpoint at es1800-break_address */
  /* breakpoint at es1800-break_address */
  send_command (buf);
  send_command (buf);
  send_command ("WHEN AC2 THEN BRK");   /* ie in exception routine */
  send_command ("WHEN AC2 THEN BRK");   /* ie in exception routine */
 
 
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("Breakpoint (trap $%x) routine at address: %lx\n",
      printf ("Breakpoint (trap $%x) routine at address: %lx\n",
              es1800_break_vec, es1800_break_address);
              es1800_break_vec, es1800_break_address);
    }
    }
}
}
 
 
static void
static void
es1800_child_open (arg, from_tty)
es1800_child_open (arg, from_tty)
     char *arg;
     char *arg;
     int from_tty;
     int from_tty;
{
{
  error ("Use the \"run\" command to start a child process.");
  error ("Use the \"run\" command to start a child process.");
}
}
 
 
static void
static void
es1800_child_detach (args, from_tty)
es1800_child_detach (args, from_tty)
     char *args;
     char *args;
     int from_tty;
     int from_tty;
{
{
  if (args)
  if (args)
    {
    {
      error ("Argument given to \"detach\" when remotely debugging.");
      error ("Argument given to \"detach\" when remotely debugging.");
    }
    }
 
 
  pop_target ();
  pop_target ();
  if (from_tty)
  if (from_tty)
    {
    {
      printf ("Ending debugging the process %d.\n", inferior_pid);
      printf ("Ending debugging the process %d.\n", inferior_pid);
    }
    }
}
}
 
 
 
 
/* Define the target subroutine names  */
/* Define the target subroutine names  */
 
 
struct target_ops es1800_ops;
struct target_ops es1800_ops;
 
 
static void
static void
init_es1800_ops (void)
init_es1800_ops (void)
{
{
  es1800_ops.to_shortname = "es1800";
  es1800_ops.to_shortname = "es1800";
  es1800_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
  es1800_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
  es1800_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
  es1800_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
Specify the serial device it is connected to (e.g. /dev/ttya).";
Specify the serial device it is connected to (e.g. /dev/ttya).";
  es1800_ops.to_open = es1800_open;
  es1800_ops.to_open = es1800_open;
  es1800_ops.to_close = es1800_close;
  es1800_ops.to_close = es1800_close;
  es1800_ops.to_attach = es1800_attach;
  es1800_ops.to_attach = es1800_attach;
  es1800_ops.to_post_attach = NULL;
  es1800_ops.to_post_attach = NULL;
  es1800_ops.to_require_attach = NULL;
  es1800_ops.to_require_attach = NULL;
  es1800_ops.to_detach = es1800_detach;
  es1800_ops.to_detach = es1800_detach;
  es1800_ops.to_require_detach = NULL;
  es1800_ops.to_require_detach = NULL;
  es1800_ops.to_resume = es1800_resume;
  es1800_ops.to_resume = es1800_resume;
  es1800_ops.to_wait = NULL;
  es1800_ops.to_wait = NULL;
  es1800_ops.to_post_wait = NULL;
  es1800_ops.to_post_wait = NULL;
  es1800_ops.to_fetch_registers = NULL;
  es1800_ops.to_fetch_registers = NULL;
  es1800_ops.to_store_registers = NULL;
  es1800_ops.to_store_registers = NULL;
  es1800_ops.to_prepare_to_store = es1800_prepare_to_store;
  es1800_ops.to_prepare_to_store = es1800_prepare_to_store;
  es1800_ops.to_xfer_memory = es1800_xfer_inferior_memory;
  es1800_ops.to_xfer_memory = es1800_xfer_inferior_memory;
  es1800_ops.to_files_info = es1800_files_info;
  es1800_ops.to_files_info = es1800_files_info;
  es1800_ops.to_insert_breakpoint = es1800_insert_breakpoint;
  es1800_ops.to_insert_breakpoint = es1800_insert_breakpoint;
  es1800_ops.to_remove_breakpoint = es1800_remove_breakpoint;
  es1800_ops.to_remove_breakpoint = es1800_remove_breakpoint;
  es1800_ops.to_terminal_init = NULL;
  es1800_ops.to_terminal_init = NULL;
  es1800_ops.to_terminal_inferior = NULL;
  es1800_ops.to_terminal_inferior = NULL;
  es1800_ops.to_terminal_ours_for_output = NULL;
  es1800_ops.to_terminal_ours_for_output = NULL;
  es1800_ops.to_terminal_ours = NULL;
  es1800_ops.to_terminal_ours = NULL;
  es1800_ops.to_terminal_info = NULL;
  es1800_ops.to_terminal_info = NULL;
  es1800_ops.to_kill = NULL;
  es1800_ops.to_kill = NULL;
  es1800_ops.to_load = es1800_load;
  es1800_ops.to_load = es1800_load;
  es1800_ops.to_lookup_symbol = NULL;
  es1800_ops.to_lookup_symbol = NULL;
  es1800_ops.to_create_inferior = es1800_create_inferior;
  es1800_ops.to_create_inferior = es1800_create_inferior;
  es1800_ops.to_post_startup_inferior = NULL;
  es1800_ops.to_post_startup_inferior = NULL;
  es1800_ops.to_acknowledge_created_inferior = NULL;
  es1800_ops.to_acknowledge_created_inferior = NULL;
  es1800_ops.to_clone_and_follow_inferior = NULL;
  es1800_ops.to_clone_and_follow_inferior = NULL;
  es1800_ops.to_post_follow_inferior_by_clone = NULL;
  es1800_ops.to_post_follow_inferior_by_clone = NULL;
  es1800_ops.to_insert_fork_catchpoint = NULL;
  es1800_ops.to_insert_fork_catchpoint = NULL;
  es1800_ops.to_remove_fork_catchpoint = NULL;
  es1800_ops.to_remove_fork_catchpoint = NULL;
  es1800_ops.to_insert_vfork_catchpoint = NULL;
  es1800_ops.to_insert_vfork_catchpoint = NULL;
  es1800_ops.to_remove_vfork_catchpoint = NULL;
  es1800_ops.to_remove_vfork_catchpoint = NULL;
  es1800_ops.to_has_forked = NULL;
  es1800_ops.to_has_forked = NULL;
  es1800_ops.to_has_vforked = NULL;
  es1800_ops.to_has_vforked = NULL;
  es1800_ops.to_can_follow_vfork_prior_to_exec = NULL;
  es1800_ops.to_can_follow_vfork_prior_to_exec = NULL;
  es1800_ops.to_post_follow_vfork = NULL;
  es1800_ops.to_post_follow_vfork = NULL;
  es1800_ops.to_insert_exec_catchpoint = NULL;
  es1800_ops.to_insert_exec_catchpoint = NULL;
  es1800_ops.to_remove_exec_catchpoint = NULL;
  es1800_ops.to_remove_exec_catchpoint = NULL;
  es1800_ops.to_has_execd = NULL;
  es1800_ops.to_has_execd = NULL;
  es1800_ops.to_reported_exec_events_per_exec_call = NULL;
  es1800_ops.to_reported_exec_events_per_exec_call = NULL;
  es1800_ops.to_has_exited = NULL;
  es1800_ops.to_has_exited = NULL;
  es1800_ops.to_mourn_inferior = NULL;
  es1800_ops.to_mourn_inferior = NULL;
  es1800_ops.to_can_run = 0;
  es1800_ops.to_can_run = 0;
  es1800_ops.to_notice_signals = 0;
  es1800_ops.to_notice_signals = 0;
  es1800_ops.to_thread_alive = 0;
  es1800_ops.to_thread_alive = 0;
  es1800_ops.to_stop = 0;
  es1800_ops.to_stop = 0;
  es1800_ops.to_pid_to_exec_file = NULL;
  es1800_ops.to_pid_to_exec_file = NULL;
  es1800_ops.to_core_file_to_sym_file = NULL;
  es1800_ops.to_core_file_to_sym_file = NULL;
  es1800_ops.to_stratum = core_stratum;
  es1800_ops.to_stratum = core_stratum;
  es1800_ops.DONT_USE = 0;
  es1800_ops.DONT_USE = 0;
  es1800_ops.to_has_all_memory = 0;
  es1800_ops.to_has_all_memory = 0;
  es1800_ops.to_has_memory = 1;
  es1800_ops.to_has_memory = 1;
  es1800_ops.to_has_stack = 0;
  es1800_ops.to_has_stack = 0;
  es1800_ops.to_has_registers = 0;
  es1800_ops.to_has_registers = 0;
  es1800_ops.to_has_execution = 0;
  es1800_ops.to_has_execution = 0;
  es1800_ops.to_sections = NULL;
  es1800_ops.to_sections = NULL;
  es1800_ops.to_sections_end = NULL;
  es1800_ops.to_sections_end = NULL;
  es1800_ops.to_magic = OPS_MAGIC;
  es1800_ops.to_magic = OPS_MAGIC;
}
}
 
 
/* Define the target subroutine names  */
/* Define the target subroutine names  */
 
 
struct target_ops es1800_child_ops;
struct target_ops es1800_child_ops;
 
 
static void
static void
init_es1800_child_ops (void)
init_es1800_child_ops (void)
{
{
  es1800_child_ops.to_shortname = "es1800_process";
  es1800_child_ops.to_shortname = "es1800_process";
  es1800_child_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
  es1800_child_ops.to_longname = "Remote serial target in ES1800-emulator protocol";
  es1800_child_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
  es1800_child_ops.to_doc = "Remote debugging on the es1800 emulator via a serial line.\n\
Specify the serial device it is connected to (e.g. /dev/ttya).";
Specify the serial device it is connected to (e.g. /dev/ttya).";
  es1800_child_ops.to_open = es1800_child_open;
  es1800_child_ops.to_open = es1800_child_open;
  es1800_child_ops.to_close = NULL;
  es1800_child_ops.to_close = NULL;
  es1800_child_ops.to_attach = es1800_attach;
  es1800_child_ops.to_attach = es1800_attach;
  es1800_child_ops.to_post_attach = NULL;
  es1800_child_ops.to_post_attach = NULL;
  es1800_child_ops.to_require_attach = NULL;
  es1800_child_ops.to_require_attach = NULL;
  es1800_child_ops.to_detach = es1800_child_detach;
  es1800_child_ops.to_detach = es1800_child_detach;
  es1800_child_ops.to_require_detach = NULL;
  es1800_child_ops.to_require_detach = NULL;
  es1800_child_ops.to_resume = es1800_resume;
  es1800_child_ops.to_resume = es1800_resume;
  es1800_child_ops.to_wait = es1800_wait;
  es1800_child_ops.to_wait = es1800_wait;
  es1800_child_ops.to_post_wait = NULL;
  es1800_child_ops.to_post_wait = NULL;
  es1800_child_ops.to_fetch_registers = es1800_fetch_register;
  es1800_child_ops.to_fetch_registers = es1800_fetch_register;
  es1800_child_ops.to_store_registers = es1800_store_register;
  es1800_child_ops.to_store_registers = es1800_store_register;
  es1800_child_ops.to_prepare_to_store = es1800_prepare_to_store;
  es1800_child_ops.to_prepare_to_store = es1800_prepare_to_store;
  es1800_child_ops.to_xfer_memory = es1800_xfer_inferior_memory;
  es1800_child_ops.to_xfer_memory = es1800_xfer_inferior_memory;
  es1800_child_ops.to_files_info = es1800_files_info;
  es1800_child_ops.to_files_info = es1800_files_info;
  es1800_child_ops.to_insert_breakpoint = es1800_insert_breakpoint;
  es1800_child_ops.to_insert_breakpoint = es1800_insert_breakpoint;
  es1800_child_ops.to_remove_breakpoint = es1800_remove_breakpoint;
  es1800_child_ops.to_remove_breakpoint = es1800_remove_breakpoint;
  es1800_child_ops.to_terminal_init = NULL;
  es1800_child_ops.to_terminal_init = NULL;
  es1800_child_ops.to_terminal_inferior = NULL;
  es1800_child_ops.to_terminal_inferior = NULL;
  es1800_child_ops.to_terminal_ours_for_output = NULL;
  es1800_child_ops.to_terminal_ours_for_output = NULL;
  es1800_child_ops.to_terminal_ours = NULL;
  es1800_child_ops.to_terminal_ours = NULL;
  es1800_child_ops.to_terminal_info = NULL;
  es1800_child_ops.to_terminal_info = NULL;
  es1800_child_ops.to_kill = es1800_kill;
  es1800_child_ops.to_kill = es1800_kill;
  es1800_child_ops.to_load = es1800_load;
  es1800_child_ops.to_load = es1800_load;
  es1800_child_ops.to_lookup_symbol = NULL;
  es1800_child_ops.to_lookup_symbol = NULL;
  es1800_child_ops.to_create_inferior = es1800_create_inferior;
  es1800_child_ops.to_create_inferior = es1800_create_inferior;
  es1800_child_ops.to_post_startup_inferior = NULL;
  es1800_child_ops.to_post_startup_inferior = NULL;
  es1800_child_ops.to_acknowledge_created_inferior = NULL;
  es1800_child_ops.to_acknowledge_created_inferior = NULL;
  es1800_child_ops.to_clone_and_follow_inferior = NULL;
  es1800_child_ops.to_clone_and_follow_inferior = NULL;
  es1800_child_ops.to_post_follow_inferior_by_clone = NULL;
  es1800_child_ops.to_post_follow_inferior_by_clone = NULL;
  es1800_child_ops.to_insert_fork_catchpoint = NULL;
  es1800_child_ops.to_insert_fork_catchpoint = NULL;
  es1800_child_ops.to_remove_fork_catchpoint = NULL;
  es1800_child_ops.to_remove_fork_catchpoint = NULL;
  es1800_child_ops.to_insert_vfork_catchpoint = NULL;
  es1800_child_ops.to_insert_vfork_catchpoint = NULL;
  es1800_child_ops.to_remove_vfork_catchpoint = NULL;
  es1800_child_ops.to_remove_vfork_catchpoint = NULL;
  es1800_child_ops.to_has_forked = NULL;
  es1800_child_ops.to_has_forked = NULL;
  es1800_child_ops.to_has_vforked = NULL;
  es1800_child_ops.to_has_vforked = NULL;
  es1800_child_ops.to_can_follow_vfork_prior_to_exec = NULL;
  es1800_child_ops.to_can_follow_vfork_prior_to_exec = NULL;
  es1800_child_ops.to_post_follow_vfork = NULL;
  es1800_child_ops.to_post_follow_vfork = NULL;
  es1800_child_ops.to_insert_exec_catchpoint = NULL;
  es1800_child_ops.to_insert_exec_catchpoint = NULL;
  es1800_child_ops.to_remove_exec_catchpoint = NULL;
  es1800_child_ops.to_remove_exec_catchpoint = NULL;
  es1800_child_ops.to_has_execd = NULL;
  es1800_child_ops.to_has_execd = NULL;
  es1800_child_ops.to_reported_exec_events_per_exec_call = NULL;
  es1800_child_ops.to_reported_exec_events_per_exec_call = NULL;
  es1800_child_ops.to_has_exited = NULL;
  es1800_child_ops.to_has_exited = NULL;
  es1800_child_ops.to_mourn_inferior = es1800_mourn_inferior;
  es1800_child_ops.to_mourn_inferior = es1800_mourn_inferior;
  es1800_child_ops.to_can_run = 0;
  es1800_child_ops.to_can_run = 0;
  es1800_child_ops.to_notice_signals = 0;
  es1800_child_ops.to_notice_signals = 0;
  es1800_child_ops.to_thread_alive = 0;
  es1800_child_ops.to_thread_alive = 0;
  es1800_child_ops.to_stop = 0;
  es1800_child_ops.to_stop = 0;
  es1800_child_ops.to_pid_to_exec_file = NULL;
  es1800_child_ops.to_pid_to_exec_file = NULL;
  es1800_child_ops.to_core_file_to_sym_file = NULL;
  es1800_child_ops.to_core_file_to_sym_file = NULL;
  es1800_child_ops.to_stratum = process_stratum;
  es1800_child_ops.to_stratum = process_stratum;
  es1800_child_ops.DONT_USE = 0;
  es1800_child_ops.DONT_USE = 0;
  es1800_child_ops.to_has_all_memory = 1;
  es1800_child_ops.to_has_all_memory = 1;
  es1800_child_ops.to_has_memory = 1;
  es1800_child_ops.to_has_memory = 1;
  es1800_child_ops.to_has_stack = 1;
  es1800_child_ops.to_has_stack = 1;
  es1800_child_ops.to_has_registers = 1;
  es1800_child_ops.to_has_registers = 1;
  es1800_child_ops.to_has_execution = 1;
  es1800_child_ops.to_has_execution = 1;
  es1800_child_ops.to_sections = NULL;
  es1800_child_ops.to_sections = NULL;
  es1800_child_ops.to_sections_end = NULL;
  es1800_child_ops.to_sections_end = NULL;
  es1800_child_ops.to_magic = OPS_MAGIC;
  es1800_child_ops.to_magic = OPS_MAGIC;
}
}
 
 
void
void
_initialize_es1800 ()
_initialize_es1800 ()
{
{
  init_es1800_ops ();
  init_es1800_ops ();
  init_es1800_child_ops ();
  init_es1800_child_ops ();
  add_target (&es1800_ops);
  add_target (&es1800_ops);
  add_target (&es1800_child_ops);
  add_target (&es1800_child_ops);
#ifdef PROVIDE_TRANSPARENT
#ifdef PROVIDE_TRANSPARENT
  add_com ("transparent", class_support, es1800_transparent,
  add_com ("transparent", class_support, es1800_transparent,
           "Start transparent communication with the ES 1800 emulator.");
           "Start transparent communication with the ES 1800 emulator.");
#endif /* PROVIDE_TRANSPARENT */
#endif /* PROVIDE_TRANSPARENT */
  add_com ("init_break", class_support, es1800_init_break,
  add_com ("init_break", class_support, es1800_init_break,
         "Download break routine and initialize break facility on ES 1800");
         "Download break routine and initialize break facility on ES 1800");
}
}
 
 

powered by: WebSVN 2.1.0

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