Wed Aug 6 16:15:31 1997 Geoffrey Noer <noer@cygnus.com>
authorGeoffrey Noer <noer@cygnus>
Thu, 7 Aug 1997 06:31:46 +0000 (06:31 +0000)
committerGeoffrey Noer <noer@cygnus>
Thu, 7 Aug 1997 06:31:46 +0000 (06:31 +0000)
        * Makefile.in: add DLLTOOL = @DLLTOOL@, pass on DLLTOOL to
        sub makes, change clean rule to also remove *.a to remove
        libwigglers.a, in dependencies: add ppc-bdm.o ocd.o ser-ocd.o and
        remove remote-wiggler.o
        * configure.in: add DLLTOOL support
        * configure: regenerate
        * wigglers.def: new file for imports for wigglers.dll
        * ser-ocd.c: new file which is layer between ocd.c and either the
        wigglers.dll or the target box, only stub so far
        * config/powerpc/ppc-eabi.mt: add ppc-bdm.o to TDEPFILES
        * config/powerpc/ppc-sim.mt: add ppc-bdm.o to TDEPFILES
        * config/i386/cygwin32.mh: add ocd.o ser-ocd.o libwigglers.a
        to XDEPFILES, add rules to build libwigglers.a

        checking in changes of Stu Grossman  <grossman@cygnus.com>:
        * remote-wiggler.c: delete
        * ocd.c: new, was remote-wiggler.c
        always include sys/types.h, include ocd.h, move WIGGLER
        commands and many wiggler prototypes to ocd.h, make wiggler_desc
        static, stop making local wiggler functions static,
        define write_mem_command for wiggler_write_bytes
        (wiggler_start_remote): stop hardcoding the target type,
        instead set and use a target_type variable.
        (wiggler_open): add new target_type and ops args
        (wiggler_wait): now no longer takes pid and target_status as args,
        stop trying to set target_status struct, remove BGND insn
        checks
        (read_bdm_registers): renamed to wiggler_read_bdm_registers
        (wiggler_read_bdm_registers): numregs arg changed to reglen arg,
        remove pktlen check, set reglen instead of numregs
        (dump_all_bdm_regs): delete
        (wiggler_fetch_registers): delete
        (wiggler_prepare_to_store): now just an empty function
        (wiggler_store_registers): delete
        (wiggler_read_bdm_register): new
        (wiggler_write_bdm_registers): new
        (wiggler_write_bdm_register): new
        (wiggler_write_bytes): use write_mem_command variable instead of
        WIGGLER_WRITE_MEM
        (get_packet): renamed to wiggler_get_packet, change refs throughout
        (put_packet): renamed to wiggler_put_packet, change refs throughout
        (wiggler_get_packet): add break to default case of switch,
        change length of WIGGLER_GET_VERSION len to 10 from 4 to match
        specs
        (wiggler_mourn): unpush_target with current_ops, not &wiggler_ops
        (flash_xfer_memory): delete
        (noop_store_registers): new placeholder replacement for
        target_store_registers() which prevents generic_load from trying to
        set up the PC.
        (bdm_update_flash_command): add store_registers_tmp variable,
        make handling of wiggler_ops more generic -- define wiggler_ops
        in a target-specific file instead (such as ppc-bdm.c in the case
        of the ppc), use current_target to deal with registers again
        making this file less target-specific.
        (bdm_read_register_command): new
        (_initialize_remote_wiggler): stop doing add_target (&wiggler_ops),
        comment out add_cmd ("read-register", ...)
        * ocd.h: new, contains common wiggler prototypes, command definitions
        * ppc-bdm.c: file for ppc-specific OCD code, including target_ops
        structure for ppc bdm
        (bdm_ppc_open): new
        (bdm_ppc_wait): new
        (bdm_ppc_fetch_registers): new
        (bdm_ppc_store_registers_: new
        (_initialize_bdm_ppc): new
* config/powerpc/tm-ppc-eabi.h: add necessary CPU32 BDM defines

13 files changed:
gdb/ChangeLog
gdb/Makefile.in
gdb/config/i386/cygwin32.mh
gdb/config/powerpc/ppc-eabi.mt
gdb/config/powerpc/ppc-sim.mt
gdb/configure
gdb/configure.in
gdb/ocd.c [new file with mode: 0644]
gdb/ocd.h [new file with mode: 0644]
gdb/ppc-bdm.c [new file with mode: 0644]
gdb/remote-wiggler.c [deleted file]
gdb/ser-ocd.c [new file with mode: 0644]
gdb/wigglers.def [new file with mode: 0644]

index 5deb3f283b235f06ff22bf4721a7b0d9ad5cbc76..fbc665002ed23da7c207ed46f67eed1ec96249cd 100644 (file)
@@ -1,3 +1,72 @@
+Wed Aug  6 16:15:31 1997  Geoffrey Noer  <noer@cygnus.com>
+
+       * Makefile.in: add DLLTOOL = @DLLTOOL@, pass on DLLTOOL to
+       sub makes, change clean rule to also remove *.a to remove
+       libwigglers.a, in dependencies: add ppc-bdm.o ocd.o ser-ocd.o and
+       remove remote-wiggler.o
+       * configure.in: add DLLTOOL support
+       * configure: regenerate
+       * wigglers.def: new file for imports for wigglers.dll
+       * ser-ocd.c: new file which is layer between ocd.c and either the
+       wigglers.dll or the target box, only stub so far
+       * config/powerpc/ppc-eabi.mt: add ppc-bdm.o to TDEPFILES
+       * config/powerpc/ppc-sim.mt: add ppc-bdm.o to TDEPFILES
+       * config/i386/cygwin32.mh: add ocd.o ser-ocd.o libwigglers.a
+       to XDEPFILES, add rules to build libwigglers.a
+
+       checking in changes of Stu Grossman  <grossman@cygnus.com>:
+       * remote-wiggler.c: delete
+       * ocd.c: new, was remote-wiggler.c
+       always include sys/types.h, include ocd.h, move WIGGLER
+       commands and many wiggler prototypes to ocd.h, make wiggler_desc
+       static, stop making local wiggler functions static,
+       define write_mem_command for wiggler_write_bytes
+       (wiggler_start_remote): stop hardcoding the target type,
+       instead set and use a target_type variable.
+       (wiggler_open): add new target_type and ops args
+       (wiggler_wait): now no longer takes pid and target_status as args,
+       stop trying to set target_status struct, remove BGND insn
+       checks
+       (read_bdm_registers): renamed to wiggler_read_bdm_registers     
+       (wiggler_read_bdm_registers): numregs arg changed to reglen arg,
+       remove pktlen check, set reglen instead of numregs 
+       (dump_all_bdm_regs): delete
+       (wiggler_fetch_registers): delete
+       (wiggler_prepare_to_store): now just an empty function
+       (wiggler_store_registers): delete
+       (wiggler_read_bdm_register): new
+       (wiggler_write_bdm_registers): new
+       (wiggler_write_bdm_register): new
+       (wiggler_write_bytes): use write_mem_command variable instead of
+       WIGGLER_WRITE_MEM
+       (get_packet): renamed to wiggler_get_packet, change refs throughout
+       (put_packet): renamed to wiggler_put_packet, change refs throughout
+       (wiggler_get_packet): add break to default case of switch,
+       change length of WIGGLER_GET_VERSION len to 10 from 4 to match
+       specs
+       (wiggler_mourn): unpush_target with current_ops, not &wiggler_ops
+       (flash_xfer_memory): delete
+       (noop_store_registers): new placeholder replacement for
+       target_store_registers() which prevents generic_load from trying to
+       set up the PC.
+       (bdm_update_flash_command): add store_registers_tmp variable,
+       make handling of wiggler_ops more generic -- define wiggler_ops
+       in a target-specific file instead (such as ppc-bdm.c in the case
+       of the ppc), use current_target to deal with registers again
+       making this file less target-specific.
+       (bdm_read_register_command): new
+       (_initialize_remote_wiggler): stop doing add_target (&wiggler_ops),
+       comment out add_cmd ("read-register", ...)
+       * ocd.h: new, contains common wiggler prototypes, command definitions
+       * ppc-bdm.c: file for ppc-specific OCD code, including target_ops
+       structure for ppc bdm
+       (bdm_ppc_open): new
+       (bdm_ppc_wait): new
+       (bdm_ppc_fetch_registers): new
+       (bdm_ppc_store_registers_: new
+       (_initialize_bdm_ppc): new
+       * config/powerpc/tm-ppc-eabi.h: add necessary CPU32 BDM defines
+
 start-sanitize-tic80
 Tue Aug  5 23:56:14 1997  Mark Alexander  <marka@cygnus.com>
 
index 0637f5bef7c5666d67258a2ab73f2aa6c4b249fb..99309c16108f6e5d5502f255d7bde6d9f8371fc1 100644 (file)
@@ -51,6 +51,7 @@ AR = @AR@
 AR_FLAGS = qv
 RANLIB = @RANLIB@
 AWK = @AWK@
+DLLTOOL = @DLLTOOL@
 
 # Flags that describe where you can find the termcap library.
 # This can be overridden in the host Makefile fragment file.
@@ -137,7 +138,7 @@ TCL_CFLAGS = @TCLHDIR@
 
 # Where is the TK library?  Typically in ../tk.
 TK = @TK_BUILD_LIB_SPEC@
-TK_CFLAGS = @TKHDIR@
+TK_CFLAGS = @TKHDIR@ @TK_BUILD_INCLUDES@
 
 # Where is Itcl?  Typically in ../itcl.
 ITCL_CFLAGS = @ITCLHDIR@
@@ -151,6 +152,9 @@ X11_CFLAGS = @TK_XINCLUDES@
 X11_LDFLAGS =
 X11_LIBS =
 
+WIN32LDAPP = @WIN32LDAPP@
+WIN32LIBS = @WIN32LIBS@
+
 ENABLE_GDBTK= @ENABLE_GDBTK@
 ENABLE_IDE= @ENABLE_IDE@
 
@@ -228,7 +232,7 @@ INSTALLED_LIBS=-lbfd -lreadline -lopcodes -liberty \
        -lmmalloc -liberty
 CLIBS = $(SIM) $(BFD) $(READLINE) $(OPCODES) $(LIBIBERTY) \
        $(TERMCAP) $(XM_CLIBS) $(TM_CLIBS) $(NAT_CLIBS) @LIBS@ \
-       $(MMALLOC) $(LIBIBERTY)
+       $(MMALLOC) $(LIBIBERTY) $(WIN32LIBS)
 CDEPS = $(XM_CDEPS) $(TM_CDEPS) $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE) \
        $(OPCODES) $(MMALLOC) $(LIBIBERTY)
 
@@ -282,6 +286,7 @@ FLAGS_TO_PASS = \
        "CHILL_LIB=$(CHILL_LIB)" \
        "CXX=$(CXX)" \
        "CXXFLAGS=$(CXXFLAGS)" \
+       "DLLTOOL=$(DLLTOOL)" \
        "RANLIB=$(RANLIB)" \
        "MAKEINFO=$(MAKEINFO)" \
        "INSTALL=$(INSTALL)" \
@@ -642,7 +647,7 @@ init.c: $(OBS) $(TSOBS)
 # Removing the old gdb first works better if it is running, at least on SunOS.
 gdb: $(OBS) $(TSOBS) $(ADD_DEPS) $(CDEPS) init.o
        rm -f gdb
-       $(HLDENV) $(CC_LD) $(INTERNAL_LDFLAGS) -o gdb \
+       $(HLDENV) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) -o gdb \
          init.o $(OBS) $(TSOBS) $(ADD_FILES) $(CLIBS) $(LOADLIBES)
 
 nlm:   force
@@ -753,7 +758,7 @@ tags: TAGS
 
 clean mostlyclean:
        @$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(SUBDIRS)" subdir_do 
-       rm -f *.o $(ADD_FILES) *~ init.c-tmp
+       rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp
        rm -f init.c version.c
        rm -f gdb core make.log libgdb-files
        rm -f gdb[0-9]
@@ -955,7 +960,7 @@ ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \
        remote-st.c remote-utils.c dcache.c \
        remote-udi.c remote-vx.c remote-vx29k.c \
        rs6000-nat.c rs6000-tdep.c \
-       ser-go32.c ser-tcp.c sh-tdep.c solib.c sparc-nat.c \
+       ser-go32.c ser-ocd.c ser-tcp.c sh-tdep.c solib.c sparc-nat.c \
        sparc-tdep.c sparcl-tdep.c sun3-nat.c sun386-nat.c \
        symm-tdep.c symm-nat.c \
        tahoe-tdep.c ultra3-nat.c ultra3-xdep.c umax-xdep.c \
@@ -1381,6 +1386,10 @@ parse.o: parse.c $(command_h) $(defs_h) $(expression_h) $(frame_h) \
        $(gdbtypes_h) language.h parser-defs.h $(symtab_h) $(value_h) \
        gdb_string.h
 
+ppc-bdm.o: ppc-bdm.c $(defs_h) $(gdbcore_h) gdb_string.h $(frame_h) \
+       $(inferior_h) $(bfd_h) symfile.h target.h $(wait_h) $(gdbcmd_h) \
+       objfiles.h gdb-stabs.h serial.h ocd.h
+
 ppcbug-rom.o: ppcbug-rom.c monitor.h $(bfd_h) $(wait_h) $(defs_h) $(gdbcmd_h) \
        $(inferior_h) target.h serial.h terminal.h
 
@@ -1459,8 +1468,9 @@ remote-vx29k.o: remote-vx29k.c $(wait_h) complaints.h $(defs_h) $(gdbcmd_h) \
         vx-share/ptrace.h vx-share/xdr_ld.h vx-share/xdr_ptrace.h \
         vx-share/xdr_rdb.h gdb_string.h
 
-remote-wiggler.o: remote-wiggler.c $(wait_h) complaints.h $(defs_h) \
-       $(gdbcmd_h) $(gdbcore_h) $(inferior_h) target.h
+ocd.o: ocd.c ocd.h $(gdbcore_h) gdb_string.h $(frame_h) $(inferior_h) \
+       $(bfd_h) symfile.h target.h $(wait_h) $(gdbcmd_h) objfiles.h \
+       gdb-stabs.h $(dcache_h) serial.h
 
 remote-utils.o: remote-utils.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) \
        $(inferior_h) $(remote_utils_h) gdb_string.h
@@ -1493,6 +1503,8 @@ ser-go32.o: ser-go32.c $(defs_h) serial.h
 
 ser-mac.o: ser-mac.c $(defs_h) serial.h signals.h
 
+ser-ocd.o: ser-ocd.c $(defs_h) serial.h signals.h gdb_string.h
+
 ser-tcp.o: ser-tcp.c $(defs_h) serial.h signals.h gdb_string.h
 
 ser-unix.o: ser-unix.c $(defs_h) serial.h 
index e3686d1212acfc7eed4cb83f2ad7388065d659c4..0655e1eba8420ee1d8eda22d1c85cc921dc07e30 100644 (file)
@@ -1,8 +1,19 @@
 MH_CFLAGS=
 XM_FILE=xm-cygwin32.h
-XDEPFILES=ser-tcp.o
+XDEPFILES=ser-tcp.o ocd.o ser-ocd.o libwigglers.a
 TERMCAP= 
 NATDEPFILES= win32-nat.o
 NAT_FILE=../nm-empty.h
 XM_CLIBS=
 MMALLOC_CFLAGS = -I$(MMALLOC_SRC) -DMMCHECK_FORCE=1
+
+# BDM specific definitions for accessing the Wigglers.dll on Win32
+BDM_DLLNAME = Wigglers.dll
+BDM_LIBNAME = libwigglers.a
+BDM_DEFFILE = $(srcdir)/wigglers.def
+
+# Makefile target for making BDM_LIBNAME
+libwigglers.def:
+       $(DLLTOOL) --as=i386-cygwin32-as -k --dllname $(BDM_DLLNAME) --output-lib $(BDM_LIBNAME) --def $(BDM_DEFFILE)
+
+libwigglers.a: libwigglers.def
index b5da734f2355d52ee9ac55ee6cac174822cb4736..680ef1c4bfb2cfff6957103587a05d4da242fab2 100644 (file)
@@ -1,3 +1,3 @@
 # Target: PowerPC running eabi
-TDEPFILES= rs6000-tdep.o remote-ppcbug.o
+TDEPFILES= rs6000-tdep.o monitor.o dsrec.o ppcbug-rom.o ppc-bdm.o
 TM_FILE= tm-ppc-eabi.h
index 5a590ac08486f025f437aba1cff32e4d20f0ed6a..f48d4dbc9c148004c36c3ef347171aeabacfe937 100644 (file)
@@ -1,5 +1,5 @@
 # Target: PowerPC running eabi under the simulator
-TDEPFILES= rs6000-tdep.o remote-ppcbug.o
+TDEPFILES= rs6000-tdep.o monitor.o dsrec.o ppcbug-rom.o ppc-bdm.o
 TM_FILE= tm-ppc-eabi.h
 
 SIM_OBS = remote-sim.o
index 0e08faf5082ef21ce0b8a8ffdec282be90725eac..5d35b54df77bc59c688b5f1a3248394d12404886 100755 (executable)
@@ -864,6 +864,9 @@ else
 fi
 
 
+DLLTOOL=${DLLTOOL-dlltool}
+
+
 ac_aux_dir=
 for ac_dir in `cd $srcdir;pwd`/.. $srcdir/`cd $srcdir;pwd`/..; do
   if test -f $ac_dir/install-sh; then
@@ -911,7 +914,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:915: checking host system type" >&5
+echo "configure:918: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -932,7 +935,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:936: checking target system type" >&5
+echo "configure:939: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -950,7 +953,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:954: checking build system type" >&5
+echo "configure:957: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -995,7 +998,7 @@ configdirs="doc testsuite"
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:999: checking for a BSD compatible install" >&5
+echo "configure:1002: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1053,7 +1056,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1057: checking for $ac_word" >&5
+echo "configure:1060: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1084,7 +1087,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1088: checking for $ac_word" >&5
+echo "configure:1091: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1115,7 +1118,7 @@ if test -n "$ac_tool_prefix"; then
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1119: checking for $ac_word" >&5
+echo "configure:1122: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1151,7 +1154,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1155: checking for $ac_word" >&5
+echo "configure:1158: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1185,7 +1188,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1189: checking for $ac_word" >&5
+echo "configure:1192: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1235,12 +1238,12 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x,"
 
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1239: checking return type of signal handlers" >&5
+echo "configure:1242: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1244 "configure"
+#line 1247 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -1257,7 +1260,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:1261: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1264: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -1277,12 +1280,12 @@ EOF
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1281: checking for ANSI C header files" >&5
+echo "configure:1284: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1286 "configure"
+#line 1289 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1290,7 +1293,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1294: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1307,7 +1310,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1311 "configure"
+#line 1314 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1325,7 +1328,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1329 "configure"
+#line 1332 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1346,7 +1349,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1350 "configure"
+#line 1353 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1357,7 +1360,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:1361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1384,17 +1387,17 @@ for ac_hdr in limits.h memory.h string.h strings.h unistd.h termios.h termio.h s
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1388: checking for $ac_hdr" >&5
+echo "configure:1391: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1393 "configure"
+#line 1396 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1398: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1401: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1421,12 +1424,12 @@ fi
 done
 
 echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:1425: checking whether stat file-mode macros are broken" >&5
+echo "configure:1428: checking whether stat file-mode macros are broken" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1430 "configure"
+#line 1433 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -1478,12 +1481,12 @@ fi
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1482: checking for working const" >&5
+echo "configure:1485: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1487 "configure"
+#line 1490 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1532,7 +1535,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:1536: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1539: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1556,12 +1559,12 @@ fi
 for ac_func in setpgid sbrk select poll
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1560: checking for $ac_func" >&5
+echo "configure:1563: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1565 "configure"
+#line 1568 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1584,7 +1587,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:1588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1626,19 +1629,19 @@ EOF
 fi
 
 echo $ac_n "checking for gregset_t type""... $ac_c" 1>&6
-echo "configure:1630: checking for gregset_t type" >&5
+echo "configure:1633: checking for gregset_t type" >&5
 if eval "test \"`echo '$''{'gdb_cv_have_gregset_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1635 "configure"
+#line 1638 "configure"
 #include "confdefs.h"
 #include <sys/procfs.h>
 int main() {
 gregset_t *gregsetp = 0
 ; return 0; }
 EOF
-if { (eval echo configure:1642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   gdb_cv_have_gregset_t=yes
 else
@@ -1659,19 +1662,19 @@ EOF
 fi
 
 echo $ac_n "checking for fpregset_t type""... $ac_c" 1>&6
-echo "configure:1663: checking for fpregset_t type" >&5
+echo "configure:1666: checking for fpregset_t type" >&5
 if eval "test \"`echo '$''{'gdb_cv_have_fpregset_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1668 "configure"
+#line 1671 "configure"
 #include "confdefs.h"
 #include <sys/procfs.h>
 int main() {
 fpregset_t *fpregsetp = 0
 ; return 0; }
 EOF
-if { (eval echo configure:1675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   gdb_cv_have_fpregset_t=yes
 else
@@ -1692,7 +1695,7 @@ EOF
 fi
 
 echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
-echo "configure:1696: checking for main in -lm" >&5
+echo "configure:1699: checking for main in -lm" >&5
 ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1700,14 +1703,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1704 "configure"
+#line 1707 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1737,12 +1740,12 @@ fi
 
 
 echo $ac_n "checking for long long support in compiler""... $ac_c" 1>&6
-echo "configure:1741: checking for long long support in compiler" >&5
+echo "configure:1744: checking for long long support in compiler" >&5
 if eval "test \"`echo '$''{'gdb_cv_c_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1746 "configure"
+#line 1749 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1752,7 +1755,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1756: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1759: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   gdb_cv_c_long_long=yes
 else
@@ -1774,7 +1777,7 @@ fi
 
 
 echo $ac_n "checking for long long support in printf""... $ac_c" 1>&6
-echo "configure:1778: checking for long long support in printf" >&5
+echo "configure:1781: checking for long long support in printf" >&5
 if eval "test \"`echo '$''{'gdb_cv_printf_has_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1782,7 +1785,7 @@ else
   gdb_cv_printf_has_long_long=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 1786 "configure"
+#line 1789 "configure"
 #include "confdefs.h"
 
 int main () {
@@ -1792,7 +1795,7 @@ int main () {
   return (strcmp ("12345", buf));
 }
 EOF
-if { (eval echo configure:1796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   gdb_cv_printf_has_long_long=yes
 else
@@ -1816,19 +1819,19 @@ echo "$ac_t""$gdb_cv_printf_has_long_long" 1>&6
 
 
 echo $ac_n "checking for long double support in compiler""... $ac_c" 1>&6
-echo "configure:1820: checking for long double support in compiler" >&5
+echo "configure:1823: checking for long double support in compiler" >&5
 if eval "test \"`echo '$''{'ac_cv_c_long_double'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1825 "configure"
+#line 1828 "configure"
 #include "confdefs.h"
 
 int main() {
 long double foo;
 ; return 0; }
 EOF
-if { (eval echo configure:1832: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1835: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_long_double=yes
 else
@@ -1850,7 +1853,7 @@ fi
 
 
 echo $ac_n "checking for long double support in printf""... $ac_c" 1>&6
-echo "configure:1854: checking for long double support in printf" >&5
+echo "configure:1857: checking for long double support in printf" >&5
 if eval "test \"`echo '$''{'gdb_cv_printf_has_long_double'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1858,7 +1861,7 @@ else
   gdb_cv_printf_has_long_double=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 1862 "configure"
+#line 1865 "configure"
 #include "confdefs.h"
 
 int main () {
@@ -1868,7 +1871,7 @@ int main () {
   return (strncmp ("3.14159", buf, 7));
 }
 EOF
-if { (eval echo configure:1872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   gdb_cv_printf_has_long_double=yes
 else
@@ -1894,17 +1897,17 @@ for ac_hdr in unistd.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1898: checking for $ac_hdr" >&5
+echo "configure:1901: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1903 "configure"
+#line 1906 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1911: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1933,12 +1936,12 @@ done
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1937: checking for $ac_func" >&5
+echo "configure:1940: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1942 "configure"
+#line 1945 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1961,7 +1964,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:1965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1986,7 +1989,7 @@ fi
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:1990: checking for working mmap" >&5
+echo "configure:1993: checking for working mmap" >&5
 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1994,7 +1997,7 @@ else
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 1998 "configure"
+#line 2001 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -2134,7 +2137,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:2138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -2158,12 +2161,12 @@ fi
 
 
 echo $ac_n "checking whether malloc must be declared""... $ac_c" 1>&6
-echo "configure:2162: checking whether malloc must be declared" >&5
+echo "configure:2165: checking whether malloc must be declared" >&5
 if eval "test \"`echo '$''{'bfd_cv_decl_needed_malloc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2167 "configure"
+#line 2170 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2184,7 +2187,7 @@ int main() {
 char *(*pfn) = (char *(*)) malloc
 ; return 0; }
 EOF
-if { (eval echo configure:2188: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2191: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_malloc=no
 else
@@ -2206,12 +2209,12 @@ EOF
 fi
 
 echo $ac_n "checking whether realloc must be declared""... $ac_c" 1>&6
-echo "configure:2210: checking whether realloc must be declared" >&5
+echo "configure:2213: checking whether realloc must be declared" >&5
 if eval "test \"`echo '$''{'bfd_cv_decl_needed_realloc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2215 "configure"
+#line 2218 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2232,7 +2235,7 @@ int main() {
 char *(*pfn) = (char *(*)) realloc
 ; return 0; }
 EOF
-if { (eval echo configure:2236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2239: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_realloc=no
 else
@@ -2254,12 +2257,12 @@ EOF
 fi
 
 echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6
-echo "configure:2258: checking whether free must be declared" >&5
+echo "configure:2261: checking whether free must be declared" >&5
 if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2263 "configure"
+#line 2266 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2280,7 +2283,7 @@ int main() {
 char *(*pfn) = (char *(*)) free
 ; return 0; }
 EOF
-if { (eval echo configure:2284: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2287: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   bfd_cv_decl_needed_free=no
 else
@@ -2308,7 +2311,7 @@ if test ${build} = ${host} -a ${host} = ${target} ; then
        case ${host_os} in
        hpux*)
                echo $ac_n "checking for HPUX/OSF thread support""... $ac_c" 1>&6
-echo "configure:2312: checking for HPUX/OSF thread support" >&5
+echo "configure:2315: checking for HPUX/OSF thread support" >&5
                if test -f /usr/include/dce/cma_config.h ; then
                        if test "$GCC" = "yes" ; then
                                echo "$ac_t""yes" 1>&6
@@ -2326,7 +2329,7 @@ EOF
                ;;
        solaris*)
                echo $ac_n "checking for Solaris thread debugging library""... $ac_c" 1>&6
-echo "configure:2330: checking for Solaris thread debugging library" >&5
+echo "configure:2333: checking for Solaris thread debugging library" >&5
                if test -f /usr/lib/libthread_db.so.1 ; then
                        echo "$ac_t""yes" 1>&6
                        cat >> confdefs.h <<\EOF
@@ -2335,7 +2338,7 @@ EOF
 
                        CONFIG_OBS="${CONFIG_OBS} sol-thread.o"
                        echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:2339: checking for dlopen in -ldl" >&5
+echo "configure:2342: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2343,7 +2346,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2347 "configure"
+#line 2350 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2354,7 +2357,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:2358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2480,12 +2483,12 @@ fi
 
 # In the cygwin32 environment, we need some additional flags.
 echo $ac_n "checking for cygwin32""... $ac_c" 1>&6
-echo "configure:2484: checking for cygwin32" >&5
+echo "configure:2487: checking for cygwin32" >&5
 if eval "test \"`echo '$''{'gdb_cv_os_cygwin32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2489 "configure"
+#line 2492 "configure"
 #include "confdefs.h"
 
 #ifdef __CYGWIN32__
@@ -2538,7 +2541,7 @@ if test "${with_tclconfig+set}" = set; then
 fi
 
   echo $ac_n "checking for Tcl configuration""... $ac_c" 1>&6
-echo "configure:2542: checking for Tcl configuration" >&5
+echo "configure:2545: checking for Tcl configuration" >&5
   if eval "test \"`echo '$''{'ac_cv_c_tclconfig'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2646,7 +2649,7 @@ if test "${with_tkconfig+set}" = set; then
 fi
 
   echo $ac_n "checking for Tk configuration""... $ac_c" 1>&6
-echo "configure:2650: checking for Tk configuration" >&5
+echo "configure:2653: checking for Tk configuration" >&5
   if eval "test \"`echo '$''{'ac_cv_c_tkconfig'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2742,7 +2745,7 @@ fi
 
 no_tcl=true
 echo $ac_n "checking for Tcl private headers. dir=${configdir}""... $ac_c" 1>&6
-echo "configure:2746: checking for Tcl private headers. dir=${configdir}" >&5
+echo "configure:2749: checking for Tcl private headers. dir=${configdir}" >&5
 # Check whether --with-tclinclude or --without-tclinclude was given.
 if test "${with_tclinclude+set}" = set; then
   withval="$with_tclinclude"
@@ -2808,17 +2811,17 @@ fi
 if test x"${ac_cv_c_tclh}" = x ; then
    ac_safe=`echo "tclInt.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for tclInt.h""... $ac_c" 1>&6
-echo "configure:2812: checking for tclInt.h" >&5
+echo "configure:2815: checking for tclInt.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2817 "configure"
+#line 2820 "configure"
 #include "confdefs.h"
 #include <tclInt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2822: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2878,7 +2881,7 @@ fi
 #
 no_tk=true
 echo $ac_n "checking for Tk private headers""... $ac_c" 1>&6
-echo "configure:2882: checking for Tk private headers" >&5
+echo "configure:2885: checking for Tk private headers" >&5
 # Check whether --with-tkinclude or --without-tkinclude was given.
 if test "${with_tkinclude+set}" = set; then
   withval="$with_tkinclude"
@@ -2944,17 +2947,17 @@ fi
 if test x"${ac_cv_c_tkh}" = x ; then
    ac_safe=`echo "tk.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for tk.h""... $ac_c" 1>&6
-echo "configure:2948: checking for tk.h" >&5
+echo "configure:2951: checking for tk.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2953 "configure"
+#line 2956 "configure"
 #include "confdefs.h"
 #include <tk.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2958: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2961: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3000,7 +3003,7 @@ fi
 
           
 echo $ac_n "checking for Itcl private headers. srcdir=${srcdir}""... $ac_c" 1>&6
-echo "configure:3004: checking for Itcl private headers. srcdir=${srcdir}" >&5
+echo "configure:3007: checking for Itcl private headers. srcdir=${srcdir}" >&5
 if test x"${ac_cv_c_itclh}" = x ; then
   for i in ${srcdir}/../itcl ${srcdir}/../../itcl ${srcdir}/../../../itcl ; do
     if test -f $i/src/itcl.h ; then
@@ -3023,7 +3026,7 @@ fi
 
           
 echo $ac_n "checking for Tix private headers. srcdir=${srcdir}""... $ac_c" 1>&6
-echo "configure:3027: checking for Tix private headers. srcdir=${srcdir}" >&5
+echo "configure:3030: checking for Tix private headers. srcdir=${srcdir}" >&5
 if test x"${ac_cv_c_tixh}" = x ; then
   for i in ${srcdir}/../tix ${srcdir}/../../tix ${srcdir}/../../../tix ; do
     if test -f $i/generic/tix.h ; then
@@ -3229,7 +3232,7 @@ links="${links} nm.h"
 fi
 # start-sanitize-gdbtk
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:3233: checking whether ln -s works" >&5
+echo "configure:3236: checking whether ln -s works" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3398,6 +3401,7 @@ s%@infodir@%$infodir%g
 s%@mandir@%$mandir%g
 s%@CC@%$CC%g
 s%@CPP@%$CPP%g
+s%@DLLTOOL@%$DLLTOOL%g
 s%@host@%$host%g
 s%@host_alias@%$host_alias%g
 s%@host_cpu@%$host_cpu%g
index d9fe00a7554fec36238f1614152697acee7bc530..cb72af8464dfcf0c9932dccc686acb33079424e9 100644 (file)
@@ -28,6 +28,9 @@ AC_AIX
 AC_MINIX
 AC_ISC_POSIX
 
+DLLTOOL=${DLLTOOL-dlltool}
+AC_SUBST(DLLTOOL)
+
 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
 AC_CANONICAL_SYSTEM
 
diff --git a/gdb/ocd.c b/gdb/ocd.c
new file mode 100644 (file)
index 0000000..b20bd9c
--- /dev/null
+++ b/gdb/ocd.c
@@ -0,0 +1,1371 @@
+/* Remote target communications for the Macraigor Systems BDM Wiggler
+   Copyright 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "defs.h"
+#include "gdbcore.h"
+#include "gdb_string.h"
+#include <fcntl.h>
+#include "frame.h"
+#include "inferior.h"
+#include "bfd.h"
+#include "symfile.h"
+#include "target.h"
+#include "wait.h"
+#include "gdbcmd.h"
+#include "objfiles.h"
+#include "gdb-stabs.h"
+#include "dcache.h"
+#include <sys/types.h>
+#include <signal.h>
+#include "serial.h"
+#include "ocd.h"
+
+/* Prototypes for local functions */
+
+static int wiggler_write_bytes PARAMS ((CORE_ADDR memaddr,
+                                      char *myaddr, int len));
+
+static int wiggler_read_bytes PARAMS ((CORE_ADDR memaddr,
+                                     char *myaddr, int len));
+
+static int wiggler_start_remote PARAMS ((char *dummy));
+
+static int readchar PARAMS ((int timeout));
+
+static void reset_packet PARAMS ((void));
+
+static void output_packet PARAMS ((void));
+
+static int get_quoted_char PARAMS ((int timeout));
+
+static void put_quoted_char PARAMS ((int c));
+
+static void wiggler_interrupt PARAMS ((int signo));
+
+static void wiggler_interrupt_twice PARAMS ((int signo));
+
+static void interrupt_query PARAMS ((void));
+
+static unsigned char * do_command PARAMS ((int cmd, int *statusp, int *lenp));
+
+static void wiggler_put_packet PARAMS ((unsigned char *packet, int pktlen));
+
+static unsigned char * wiggler_get_packet PARAMS ((int cmd, int *pktlen, int timeout));
+
+static struct target_ops *current_ops = NULL;
+
+static int last_run_status;
+
+/* This was 5 seconds, which is a long time to sit and wait.
+   Unless this is going though some terminal server or multiplexer or
+   other form of hairy serial connection, I would think 2 seconds would
+   be plenty.  */
+
+/* Changed to allow option to set timeout value.
+   was static int remote_timeout = 2; */
+extern int remote_timeout;
+
+/* Descriptor for I/O to remote machine.  Initialize it to NULL so that
+   wiggler_open knows that we don't have a file open when the program
+   starts.  */
+static serial_t wiggler_desc = NULL;
+\f
+void
+wiggler_error (s, error_code)
+     char *s;
+     int error_code;
+{
+  char buf[100];
+
+  fputs_filtered (s, gdb_stderr);
+  fputs_filtered (" ", gdb_stderr);
+
+  switch (error_code)
+    {
+    case 0x1: s = "Unknown fault"; break;
+    case 0x2: s = "Power failed"; break;
+    case 0x3: s = "Cable disconnected"; break;
+    case 0x4: s = "Couldn't enter BDM"; break;
+    case 0x5: s = "Target stuck in reset"; break;
+    case 0x6: s = "Port not configured"; break;
+    case 0x7: s = "Write verify failed"; break;
+    case 0x11: s = "Bus error"; break;
+    case 0x12: s = "Checksum error"; break;
+    case 0x13: s = "Illegal command"; break;
+    case 0x14: s = "Parameter error"; break;
+    case 0x15: s = "Internal error"; break;
+    case 0x16: s = "Register buffer error"; break;
+    case 0x80: s = "Flash erase error"; break;
+    default:
+      sprintf (buf, "Unknown error code %d", error_code);
+      s = buf;
+    }
+
+  error (s);
+}
+
+/*  Return nonzero if the thread TH is still alive on the remote system.  */
+
+int
+wiggler_thread_alive (th)
+     int th;
+{
+  return 1;
+}
+\f
+/* Clean up connection to a remote debugger.  */
+
+/* ARGSUSED */
+void
+wiggler_close (quitting)
+     int quitting;
+{
+  if (wiggler_desc)
+    SERIAL_CLOSE (wiggler_desc);
+  wiggler_desc = NULL;
+}
+
+/* Stub for catch_errors.  */
+
+static int
+wiggler_start_remote (dummy)
+     char *dummy;
+{
+  unsigned char buf[10], *p;
+  int pktlen;
+  int status;
+  int error_code;
+  int speed;
+  enum wiggler_target_type target_type;
+
+  target_type = (enum wiggler_target_type)dummy;
+
+  immediate_quit = 1;          /* Allow user to interrupt it */
+
+  SERIAL_SEND_BREAK (wiggler_desc); /* Wake up the wiggler */
+
+  do_command (WIGGLER_AYT, &status, &pktlen);
+
+  p = do_command (WIGGLER_GET_VERSION, &status, &pktlen);
+
+  printf_unfiltered ("[Wiggler version %x.%x, capability 0x%x]\n",
+                    p[0], p[1], (p[2] << 16) | p[3]);
+
+#if 1
+  speed = 80;                  /* Divide clock by 4000 */
+
+  buf[0] = WIGGLER_INIT;
+  buf[1] = speed >> 8;
+  buf[2] = speed & 0xff;
+  buf[3] = target_type;
+  wiggler_put_packet (buf, 4); /* Init Wiggler params */
+  p = wiggler_get_packet (buf[0], &pktlen, remote_timeout);
+
+  if (pktlen < 2)
+    error ("Truncated response packet from Wiggler");
+
+  status = p[1];
+  error_code = p[2];
+
+  if (error_code != 0)
+    wiggler_error ("WIGGLER_INIT:", error_code);
+#endif
+
+#if 0
+  /* Reset the target */
+
+  do_command (WIGGLER_RESET_RUN, &status, &pktlen);
+/*  do_command (WIGGLER_RESET, &status, &pktlen);*/
+#endif
+
+  /* If processor is still running, stop it.  */
+
+  if (!(status & WIGGLER_FLAG_BDM))
+    wiggler_stop ();
+
+#if 1
+  buf[0] = WIGGLER_SET_CTL_FLAGS;
+  buf[1] = 0;
+  buf[2] = 1;          /* Asynchronously return status when target stops */
+  wiggler_put_packet (buf, 3);
+
+  p = wiggler_get_packet (buf[0], &pktlen, remote_timeout);
+
+  if (pktlen < 2)
+    error ("Truncated response packet from Wiggler");
+
+  status = p[1];
+  error_code = p[2];
+
+  if (error_code != 0)
+    wiggler_error ("WIGGLER_SET_CTL_FLAGS:", error_code);
+#endif
+
+  immediate_quit = 0;
+
+/* This is really the job of start_remote however, that makes an assumption
+   that the target is about to print out a status message of some sort.  That
+   doesn't happen here (in fact, it may not be possible to get the monitor to
+   send the appropriate packet).  */
+
+  flush_cached_frames ();
+  registers_changed ();
+  stop_pc = read_pc ();
+  set_current_frame (create_new_frame (read_fp (), stop_pc));
+  select_frame (get_current_frame (), 0);
+  print_stack_frame (selected_frame, -1, 1);
+
+  return 1;
+}
+
+/* Open a connection to a remote debugger.
+   NAME is the filename used for communication.  */
+
+static DCACHE *wiggler_dcache;
+
+void
+wiggler_open (name, from_tty, target_type, ops)
+     char *name;
+     int from_tty;
+     enum wiggler_target_type target_type;
+     struct target_ops *ops;
+{
+  if (name == 0)
+    error ("To open a Wiggler connection, you need to specify what serial\n\
+device the Wiggler is attached to (e.g. /dev/ttya).");
+
+  target_preopen (from_tty);
+
+  current_ops = ops;
+
+  unpush_target (current_ops);
+
+  wiggler_dcache = dcache_init (wiggler_read_bytes, wiggler_write_bytes);
+
+  wiggler_desc = SERIAL_OPEN (name);
+  if (!wiggler_desc)
+    perror_with_name (name);
+
+  if (baud_rate != -1)
+    {
+      if (SERIAL_SETBAUDRATE (wiggler_desc, baud_rate))
+       {
+         SERIAL_CLOSE (wiggler_desc);
+         perror_with_name (name);
+       }
+    }
+
+  SERIAL_RAW (wiggler_desc);
+
+  /* If there is something sitting in the buffer we might take it as a
+     response to a command, which would be bad.  */
+  SERIAL_FLUSH_INPUT (wiggler_desc);
+
+  if (from_tty)
+    {
+      puts_filtered ("Remote target wiggler connected to ");
+      puts_filtered (name);
+      puts_filtered ("\n");
+    }
+  push_target (current_ops);   /* Switch to using remote target now */
+
+  /* Without this, some commands which require an active target (such as kill)
+     won't work.  This variable serves (at least) double duty as both the pid
+     of the target process (if it has such), and as a flag indicating that a
+     target is active.  These functions should be split out into seperate
+     variables, especially since GDB will someday have a notion of debugging
+     several processes.  */
+
+  inferior_pid = 42000;
+  /* Start the remote connection; if error (0), discard this target.
+     In particular, if the user quits, be sure to discard it
+     (we'd be in an inconsistent state otherwise).  */
+  if (!catch_errors (wiggler_start_remote, (char *)target_type,
+                    "Couldn't establish connection to remote target\n", RETURN_MASK_ALL))
+    pop_target();
+}
+
+/* This takes a program previously attached to and detaches it.  After
+   this is done, GDB can be used to debug some other program.  We
+   better not have left any breakpoints in the target program or it'll
+   die when it hits one.  */
+
+void
+wiggler_detach (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  if (args)
+    error ("Argument given to \"detach\" when remotely debugging.");
+
+  pop_target ();
+  if (from_tty)
+    puts_filtered ("Ending remote debugging.\n");
+}
+\f
+/* Tell the remote machine to resume.  */
+
+void
+wiggler_resume (pid, step, siggnal)
+     int pid, step;
+     enum target_signal siggnal;
+{
+  int pktlen;
+
+  dcache_flush (wiggler_dcache);
+
+  if (step)
+    do_command (WIGGLER_STEP, &last_run_status, &pktlen);
+  else
+    do_command (WIGGLER_RUN, &last_run_status, &pktlen);
+}
+\f
+void
+wiggler_stop ()
+{
+  int status;
+  int pktlen;
+
+  do_command (WIGGLER_STOP, &status, &pktlen);
+
+  if (!(status & WIGGLER_FLAG_BDM))
+    error ("Can't stop target via BDM");
+}
+
+static volatile int wiggler_interrupt_flag;
+
+/* Send ^C to target to halt it.  Target will respond, and send us a
+   packet.  */
+
+static void
+wiggler_interrupt (signo)
+     int signo;
+{
+  /* If this doesn't work, try more severe steps.  */
+  signal (signo, wiggler_interrupt_twice);
+  
+  if (remote_debug)
+    printf_unfiltered ("wiggler_interrupt called\n");
+
+  {
+    char buf[1];
+
+    wiggler_stop ();
+    buf[0] = WIGGLER_AYT;
+    wiggler_put_packet (buf, 1);
+    wiggler_interrupt_flag = 1;
+  }
+}
+
+static void (*ofunc)();
+
+/* The user typed ^C twice.  */
+static void
+wiggler_interrupt_twice (signo)
+     int signo;
+{
+  signal (signo, ofunc);
+  
+  interrupt_query ();
+
+  signal (signo, wiggler_interrupt);
+}
+
+/* Ask the user what to do when an interrupt is received.  */
+
+static void
+interrupt_query ()
+{
+  target_terminal_ours ();
+
+  if (query ("Interrupted while waiting for the program.\n\
+Give up (and stop debugging it)? "))
+    {
+      target_mourn_inferior ();
+      return_to_top_level (RETURN_QUIT);
+    }
+
+  target_terminal_inferior ();
+}
+
+/* If nonzero, ignore the next kill.  */
+static int kill_kludge;
+
+/* Wait until the remote machine stops, then return,
+   storing status in STATUS just as `wait' would.
+   Returns "pid" (though it's not clear what, if anything, that
+   means in the case of this target).  */
+
+int
+wiggler_wait ()
+{
+  unsigned char *p;
+  int error_code, status;
+  int pktlen;
+
+  wiggler_interrupt_flag = 0;
+
+  /* Target may already be stopped by the time we get here. */
+
+  if (!(last_run_status & WIGGLER_FLAG_BDM))
+    {
+      ofunc = (void (*)()) signal (SIGINT, wiggler_interrupt);
+
+      p = wiggler_get_packet (WIGGLER_AYT, &pktlen, -1);
+
+      signal (SIGINT, ofunc);
+
+      if (pktlen < 2)
+       error ("Truncated response packet from Wiggler");
+
+      status = p[1];
+      error_code = p[2];
+
+      if (error_code != 0)
+       wiggler_error ("target_wait:", error_code);
+
+      if (status & WIGGLER_FLAG_PWF)
+       error ("Wiggler lost VCC at BDM interface.");
+      else if (status & WIGGLER_FLAG_CABLE_DISC)
+       error ("BDM cable appears to have been disconnected.");
+
+      if (!(status & WIGGLER_FLAG_BDM))
+       error ("Wiggler woke up, but wasn't stopped: 0x%x", status);
+    }
+
+  if (wiggler_interrupt_flag)
+    return 1;
+  else
+    return 0;
+}
+
+/* Read registers from the Wiggler.  Specify the starting and ending register
+   number.  Return the number of regs actually read in *NUMREGS.  Returns a
+   pointer to a static array containing the register contents.  */
+
+unsigned char *
+wiggler_read_bdm_registers (first_bdm_regno, last_bdm_regno, reglen)
+     int first_bdm_regno;
+     int last_bdm_regno;
+     int *reglen;
+{
+  unsigned char buf[10];
+  int i;
+  unsigned char *p;
+  unsigned char *regs;
+  int error_code, status;
+  int pktlen;
+
+  buf[0] = WIGGLER_READ_REGS;
+  buf[1] = first_bdm_regno >> 8;
+  buf[2] = first_bdm_regno & 0xff;
+  buf[3] = last_bdm_regno >> 8;
+  buf[4] = last_bdm_regno & 0xff;
+
+  wiggler_put_packet (buf, 5);
+  p = wiggler_get_packet (WIGGLER_READ_REGS, &pktlen, remote_timeout);
+
+  status = p[1];
+  error_code = p[2];
+
+  if (error_code != 0)
+    wiggler_error ("read_bdm_registers:", error_code);
+
+  i = p[3];
+  if (i == 0)
+    i = 256;
+
+  if (i > pktlen - 4
+      || ((i & 3) != 0))
+    error ("Register block size bad:  %d", i);
+
+  *reglen = i;
+
+  regs = p + 4;
+
+  return regs;
+}
+
+/* Read register BDM_REGNO and returns its value ala read_register() */
+
+CORE_ADDR
+wiggler_read_bdm_register (bdm_regno)
+     int bdm_regno;
+{
+  int reglen;
+  unsigned char *p;
+  CORE_ADDR regval;
+
+  p = wiggler_read_bdm_registers (bdm_regno, bdm_regno, &reglen);
+  regval = extract_unsigned_integer (p, reglen);
+
+  return regval;
+}
+
+void
+wiggler_write_bdm_registers (first_bdm_regno, regptr, reglen)
+     int first_bdm_regno;
+     unsigned char *regptr;
+     int reglen;
+{
+  unsigned char *buf;
+  unsigned char *p;
+  int error_code, status;
+  int pktlen;
+
+  buf = alloca (4 + reglen);
+
+  buf[0] = WIGGLER_WRITE_REGS;
+  buf[1] = first_bdm_regno >> 8;
+  buf[2] = first_bdm_regno & 0xff;
+  buf[3] = reglen;
+  memcpy (buf + 4, regptr, reglen);
+
+  wiggler_put_packet (buf, 4 + reglen);
+  p = wiggler_get_packet (WIGGLER_WRITE_REGS, &pktlen, remote_timeout);
+
+  if (pktlen < 3)
+    error ("Truncated response packet from Wiggler");
+
+  status = p[1];
+  error_code = p[2];
+
+  if (error_code != 0)
+    wiggler_error ("wiggler_write_bdm_registers:", error_code);
+}
+
+void
+wiggler_write_bdm_register (bdm_regno, reg)
+     int bdm_regno;
+     CORE_ADDR reg;
+{
+  unsigned char buf[4];
+
+  store_unsigned_integer (buf, 4, reg);
+
+  wiggler_write_bdm_registers (bdm_regno, buf, 4);
+}
+\f
+void 
+wiggler_prepare_to_store ()
+{
+}
+\f
+/* Write memory data directly to the remote machine.
+   This does not inform the data cache; the data cache uses this.
+   MEMADDR is the address in the remote memory space.
+   MYADDR is the address of the buffer in our space.
+   LEN is the number of bytes.
+
+   Returns number of bytes transferred, or 0 for error.  */
+
+static int write_mem_command = WIGGLER_WRITE_MEM;
+
+static int
+wiggler_write_bytes (memaddr, myaddr, len)
+     CORE_ADDR memaddr;
+     char *myaddr;
+     int len;
+{
+  char buf[256 + 10];
+  unsigned char *p;
+  int origlen;
+
+  origlen = len;
+
+  buf[0] = write_mem_command;
+  buf[5] = 1;                  /* Write as bytes */
+  buf[6] = 0;                  /* Don't verify */
+
+  while (len > 0)
+    {
+      int numbytes;
+      int pktlen;
+      int status, error_code;
+
+      numbytes = min (len, 256 - 8);
+
+      buf[1] = memaddr >> 24;
+      buf[2] = memaddr >> 16;
+      buf[3] = memaddr >> 8;
+      buf[4] = memaddr;
+
+      buf[7] = numbytes;
+
+      memcpy (&buf[8], myaddr, numbytes);
+      wiggler_put_packet (buf, 8 + numbytes);
+      p = wiggler_get_packet (WIGGLER_WRITE_MEM, &pktlen, remote_timeout);
+      if (pktlen < 3)
+       error ("Truncated response packet from Wiggler");
+
+      status = p[1];
+      error_code = p[2];
+
+      if (error_code == 0x11)  /* Got a bus error? */
+       {
+         CORE_ADDR error_address;
+
+         error_address = p[3] << 24;
+         error_address |= p[4] << 16;
+         error_address |= p[5] << 8;
+         error_address |= p[6];
+         numbytes = error_address - memaddr;
+
+         len -= numbytes;
+
+         errno = EIO;
+
+         break;
+       }
+      else if (error_code != 0)
+       wiggler_error ("wiggler_write_bytes:", error_code);
+
+      len -= numbytes;
+      memaddr += numbytes;
+      myaddr += numbytes;
+    }
+
+  return origlen - len;
+}
+
+/* Read memory data directly from the remote machine.
+   This does not use the data cache; the data cache uses this.
+   MEMADDR is the address in the remote memory space.
+   MYADDR is the address of the buffer in our space.
+   LEN is the number of bytes.
+
+   Returns number of bytes transferred, or 0 for error.  */
+
+static int
+wiggler_read_bytes (memaddr, myaddr, len)
+     CORE_ADDR memaddr;
+     char *myaddr;
+     int len;
+{
+  char buf[256 + 10];
+  unsigned char *p;
+  int origlen;
+
+  origlen = len;
+
+  buf[0] = WIGGLER_READ_MEM;
+  buf[5] = 1;                  /* Read as bytes */
+
+  while (len > 0)
+    {
+      int numbytes;
+      int pktlen;
+      int status, error_code;
+
+      numbytes = min (len, 256 - 7);
+
+      buf[1] = memaddr >> 24;
+      buf[2] = memaddr >> 16;
+      buf[3] = memaddr >> 8;
+      buf[4] = memaddr;
+
+      buf[6] = numbytes;
+
+      wiggler_put_packet (buf, 7);
+      p = wiggler_get_packet (WIGGLER_READ_MEM, &pktlen, remote_timeout);
+      if (pktlen < 4)
+       error ("Truncated response packet from Wiggler");
+
+      status = p[1];
+      error_code = p[2];
+
+      if (error_code == 0x11)  /* Got a bus error? */
+       {
+         CORE_ADDR error_address;
+
+         error_address = p[3] << 24;
+         error_address |= p[4] << 16;
+         error_address |= p[5] << 8;
+         error_address |= p[6];
+         numbytes = error_address - memaddr;
+
+         len -= numbytes;
+
+         errno = EIO;
+
+         break;
+       }
+      else if (error_code != 0)
+       wiggler_error ("wiggler_read_bytes:", error_code);
+
+      memcpy (myaddr, &p[4], numbytes);
+
+      len -= numbytes;
+      memaddr += numbytes;
+      myaddr += numbytes;
+    }
+
+  return origlen - len;
+}
+\f
+/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
+   to or from debugger address MYADDR.  Write to inferior if SHOULD_WRITE is
+   nonzero.  Returns length of data written or read; 0 for error.  */
+
+/* ARGSUSED */
+int
+wiggler_xfer_memory (memaddr, myaddr, len, should_write, target)
+     CORE_ADDR memaddr;
+     char *myaddr;
+     int len;
+     int should_write;
+     struct target_ops *target;                        /* ignored */
+{
+  return dcache_xfer_memory (wiggler_dcache, memaddr, myaddr, len, should_write);
+}
+\f
+void
+wiggler_files_info (ignore)
+     struct target_ops *ignore;
+{
+  puts_filtered ("Debugging a target over a serial line.\n");
+}
+\f
+/* Stuff for dealing with the packets which are part of this protocol.
+   See comment at top of file for details.  */
+
+/* Read a single character from the remote side, handling wierd errors. */
+
+static int
+readchar (timeout)
+     int timeout;
+{
+  int ch;
+
+  ch = SERIAL_READCHAR (wiggler_desc, timeout);
+
+  switch (ch)
+    {
+    case SERIAL_EOF:
+      error ("Remote connection closed");
+    case SERIAL_ERROR:
+      perror_with_name ("Remote communication error");
+    case SERIAL_TIMEOUT:
+    default:
+      return ch;
+    }
+}
+
+#if 0
+/* Read a character from the data stream, dequoting as necessary.  SYN is
+   treated special.  Any SYNs appearing in the data stream are returned as the
+   distinct value RAW_SYN (which has a value > 8 bits and therefore cannot be
+   mistaken for real data).  */
+
+static int
+get_quoted_char (timeout)
+     int timeout;
+{
+  int ch;
+
+  ch = readchar (timeout);
+
+  switch (ch)
+    {
+    case SERIAL_TIMEOUT:
+      error ("Timeout in mid-packet, aborting");
+    case SYN:
+      return RAW_SYN;
+    case DLE:
+      ch = readchar (timeout);
+      if (ch == SYN)
+       return RAW_SYN;
+      return ch & ~0100;
+    default:
+      return ch;
+    }
+}
+
+static unsigned char pkt[256 * 2 + 10], *pktp; /* Worst case */
+
+static void
+reset_packet ()
+{
+  pktp = pkt;
+}
+
+static void
+output_packet ()
+{
+  if (SERIAL_WRITE (wiggler_desc, pkt, pktp - pkt))
+    perror_with_name ("output_packet: write failed");
+
+  reset_packet ();
+}
+
+/* Output a quoted character.  SYNs and DLEs are quoted.  Everything else goes
+   through untouched.  */
+
+static void
+put_quoted_char (c)
+     int c;
+{
+  switch (c)
+    {
+    case SYN:
+    case DLE:
+      *pktp++ = DLE;
+      c |= 0100;
+    }
+
+  *pktp++ = c;
+}
+
+/* Send a packet to the Wiggler.  The packet framed by a SYN character, a byte
+   count and a checksum.  The byte count only counts the number of bytes
+   between the count and the checksum.  A count of zero actually means 256.
+   Any SYNs within the packet (including the checksum and count) must be
+   quoted.  The quote character must be quoted as well.  Quoting is done by
+   replacing the character with the two-character sequence DLE, {char} | 0100.
+   Note that the quoting mechanism has no effect on the byte count.
+ */
+
+static void
+stu_put_packet (buf, len)
+     unsigned char *buf;
+     int len;
+{
+  unsigned char checksum;
+  unsigned char c;
+
+  if (len == 0 || len > 256)
+    abort ();                  /* Can't represent 0 length packet */
+
+  reset_packet ();
+
+  checksum = 0;
+
+  put_quoted_char (RAW_SYN);
+
+  c = len;
+
+  do
+    {
+      checksum += c;
+
+      put_quoted_char (c);
+
+      c = *buf++;
+    }
+  while (len-- > 0);
+
+  put_quoted_char (-checksum & 0xff);
+
+  output_packet ();
+}
+
+#else
+
+/* Send a packet to the Wiggler.  The packet framed by a SYN character, a byte
+   count and a checksum.  The byte count only counts the number of bytes
+   between the count and the checksum.  A count of zero actually means 256.
+   Any SYNs within the packet (including the checksum and count) must be
+   quoted.  The quote character must be quoted as well.  Quoting is done by
+   replacing the character with the two-character sequence DLE, {char} | 0100.
+   Note that the quoting mechanism has no effect on the byte count.
+ */
+
+static void
+wiggler_put_packet (buf, len)
+     unsigned char *buf;
+     int len;
+{
+  unsigned char checksum;
+  unsigned char c;
+  unsigned char *packet, *packet_ptr;
+
+  packet = alloca (len + 1 + 1); /* packet + SYN + checksum */
+  packet_ptr = packet;
+
+  checksum = 0;
+
+  *packet_ptr++ = 0x55;
+
+  while (len-- > 0)
+    {
+      c = *buf++;
+
+      checksum += c;
+      *packet_ptr++ = c;
+    }
+
+  *packet_ptr++ = -checksum;
+  if (SERIAL_WRITE (wiggler_desc, packet, packet_ptr - packet))
+    perror_with_name ("output_packet: write failed");
+}
+#endif
+
+#if 0
+/* Get a packet from the Wiggler.  Timeout is only enforced for the first byte
+   of the packet.  Subsequent bytes are expected to arrive in time <= 
+   remote_timeout.  Returns a pointer to a static buffer containing the payload
+   of the packet.  *LENP contains the length of the packet.
+*/
+
+static unsigned char *
+stu_get_packet (cmd, lenp, timeout)
+     unsigned char cmd;
+     int *lenp;
+{
+  int ch;
+  int len;
+  static unsigned char buf[256 + 10], *p;
+  unsigned char checksum;
+
+ find_packet:
+
+  ch = get_quoted_char (timeout);
+
+  if (ch < 0)
+    error ("get_packet (readchar): %d", ch);
+
+  if (ch != RAW_SYN)
+    goto find_packet;
+
+ found_syn:                    /* Found the start of a packet */
+
+  p = buf;
+  checksum = 0;
+
+  len = get_quoted_char (remote_timeout);
+
+  if (len == RAW_SYN)
+    goto found_syn;
+
+  checksum += len;
+
+  if (len == 0)
+    len = 256;
+
+  len++;                       /* Include checksum */
+
+  while (len-- > 0)
+    {
+      ch = get_quoted_char (remote_timeout);
+      if (ch == RAW_SYN)
+       goto found_syn;
+
+      *p++ = ch;
+      checksum += ch;
+    }
+
+  if (checksum != 0)
+    goto find_packet;
+
+  if (cmd != buf[0])
+    error ("Response phase error.  Got 0x%x, expected 0x%x", buf[0], cmd);
+
+  *lenp = p - buf - 1;
+  return buf;
+}
+
+#else
+
+/* Get a packet from the Wiggler.  Timeout is only enforced for the first byte
+   of the packet.  Subsequent bytes are expected to arrive in time <= 
+   remote_timeout.  Returns a pointer to a static buffer containing the payload
+   of the packet.  *LENP contains the length of the packet.
+*/
+
+static unsigned char *
+wiggler_get_packet (cmd, lenp, timeout)
+     int cmd;
+     int *lenp;
+{
+  int ch;
+  int len;
+  int i;
+  static unsigned char packet[512];
+  unsigned char *packet_ptr;
+  unsigned char checksum;
+
+ find_packet:
+
+  ch = readchar (timeout);
+
+  if (ch < 0)
+    error ("wiggler_get_packet (readchar): %d", ch);
+
+  if (ch != 0x55)
+    goto find_packet;
+
+/* Found the start of a packet */
+
+  packet_ptr = packet;
+  checksum = 0;
+
+/* Read command char.  That sort of tells us how long the packet is. */
+
+  ch = readchar (timeout);
+
+  if (ch < 0)
+    error ("wiggler_get_packet (readchar): %d", ch);
+
+  *packet_ptr++ = ch;
+  checksum += ch;
+
+/* Get status. */
+
+  ch = readchar (timeout);
+
+  if (ch < 0)
+    error ("wiggler_get_packet (readchar): %d", ch);
+  *packet_ptr++ = ch;
+  checksum += ch;
+
+/* Get error code. */
+
+  ch = readchar (timeout);
+
+  if (ch < 0)
+    error ("wiggler_get_packet (readchar): %d", ch);
+  *packet_ptr++ = ch;
+  checksum += ch;
+
+  switch (ch)                  /* Figure out length of packet */
+    {
+    case 0x7:                  /* Write verify error? */
+      len = 8;                 /* write address, value read back */
+      break;
+    case 0x11:                 /* Bus error? */
+                               /* write address, read flag */
+    case 0x15:                 /* Internal error */
+      len = 5;                 /* error code, vector */
+      break;
+    default:                   /* Error w/no params */
+      len = 0;
+      break;
+    case 0x0:                  /* Normal result */
+      switch (packet[0])
+       {
+       case WIGGLER_AYT:       /* Are You There? */
+       case WIGGLER_SET_BAUD_RATE: /* Set Baud Rate */
+       case WIGGLER_INIT:      /* Initialize wiggler */
+       case WIGGLER_SET_SPEED: /* Set Speed */
+       case WIGGLER_SET_FUNC_CODE: /* Set Function Code */
+       case WIGGLER_SET_CTL_FLAGS: /* Set Control Flags */
+       case WIGGLER_SET_BUF_ADDR: /* Set Register Buffer Address */
+       case WIGGLER_RUN:       /* Run Target from PC  */
+       case WIGGLER_RUN_ADDR:  /* Run Target from Specified Address  */
+       case WIGGLER_STOP:      /* Stop Target */
+       case WIGGLER_RESET_RUN: /* Reset Target and Run */
+       case WIGGLER_RESET:     /* Reset Target and Halt */
+       case WIGGLER_STEP:      /* Single Step */
+       case WIGGLER_WRITE_REGS: /* Write Register */
+       case WIGGLER_WRITE_MEM: /* Write Memory */
+       case WIGGLER_FILL_MEM:  /* Fill Memory */
+       case WIGGLER_MOVE_MEM:  /* Move Memory */
+       case WIGGLER_WRITE_INT_MEM: /* Write Internal Memory */
+       case WIGGLER_JUMP:      /* Jump to Subroutine */
+       case WIGGLER_ERASE_FLASH: /* Erase flash memory */
+       case WIGGLER_PROGRAM_FLASH: /* Write flash memory */
+       case WIGGLER_EXIT_MON:  /* Exit the flash programming monitor  */
+       case WIGGLER_ENTER_MON: /* Enter the flash programming monitor  */
+         len = 0;
+         break;
+       case WIGGLER_GET_VERSION: /* Get Version */
+         len = 10;
+         break;
+       case WIGGLER_GET_STATUS_MASK: /* Get Status Mask */
+         len = 1;
+         break;
+       case WIGGLER_GET_CTRS:  /* Get Error Counters */
+       case WIGGLER_READ_REGS: /* Read Register */
+       case WIGGLER_READ_MEM:  /* Read Memory */
+       case WIGGLER_READ_INT_MEM: /* Read Internal Memory */
+         len = 257;
+         break;
+       default:
+         fprintf_filtered (gdb_stderr, "Unknown packet type 0x%x\n", ch);
+         goto find_packet;
+       }
+    }
+
+  if (len == 257)              /* Byte stream? */
+    {                          /* Yes, byte streams contain the length */
+      ch = readchar (timeout);
+
+      if (ch < 0)
+       error ("wiggler_get_packet (readchar): %d", ch);
+      *packet_ptr++ = ch;
+      checksum += ch;
+      len = ch;
+      if (len == 0)
+       len = 256;
+    }
+
+  while (len-- >= 0)           /* Do rest of packet and checksum */
+    {
+      ch = readchar (timeout);
+
+      if (ch < 0)
+       error ("wiggler_get_packet (readchar): %d", ch);
+      *packet_ptr++ = ch;
+      checksum += ch;
+    }
+
+  if (checksum != 0)
+    goto find_packet;
+
+  if (cmd != -1 && cmd != packet[0])
+    error ("Response phase error.  Got 0x%x, expected 0x%x", packet[0], cmd);
+
+  *lenp = packet_ptr - packet - 1; /* Subtract checksum byte */
+  return packet;
+}
+#endif
+
+/* Execute a simple (one-byte) command.  Returns a pointer to the data
+   following the error code.  */
+
+static unsigned char *
+do_command (cmd, statusp, lenp)
+     int cmd;
+     int *statusp;
+     int *lenp;
+{
+  unsigned char buf[100], *p;
+  int status, error_code;
+  char errbuf[100];
+
+  buf[0] = cmd;
+  wiggler_put_packet (buf, 1);         /* Send command */
+  p = wiggler_get_packet (*buf, lenp, remote_timeout);
+
+  if (*lenp < 3)
+    error ("Truncated response packet from Wiggler");
+
+  status = p[1];
+  error_code = p[2];
+
+  if (error_code != 0)
+    {
+      sprintf (errbuf, "do_command (0x%x):", cmd);
+      wiggler_error (errbuf, error_code);
+    }
+
+  if (status & WIGGLER_FLAG_PWF)
+    error ("Wiggler can't detect VCC at BDM interface.");
+  else if (status & WIGGLER_FLAG_CABLE_DISC)
+    error ("BDM cable appears to be disconnected.");
+
+  *statusp = status;
+
+  return p + 3;
+}
+\f
+void
+wiggler_kill ()
+{
+  /* For some mysterious reason, wait_for_inferior calls kill instead of
+     mourn after it gets TARGET_WAITKIND_SIGNALLED.  Work around it.  */
+  if (kill_kludge)
+    {
+      kill_kludge = 0;
+      target_mourn_inferior ();
+      return;
+    }
+
+  /* Don't wait for it to die.  I'm not really sure it matters whether
+     we do or not.  */
+  target_mourn_inferior ();
+}
+
+void
+wiggler_mourn ()
+{
+  unpush_target (current_ops);
+  generic_mourn_inferior ();
+}
+
+/* All we actually do is set the PC to the start address of exec_bfd, and start
+   the program at that point.  */
+
+void
+wiggler_create_inferior (exec_file, args, env)
+     char *exec_file;
+     char *args;
+     char **env;
+{
+  if (args && (*args != '\000'))
+    error ("Args are not supported by BDM.");
+
+  clear_proceed_status ();
+  proceed (bfd_get_start_address (exec_bfd), TARGET_SIGNAL_0, 0);
+}
+
+void
+wiggler_load (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  generic_load (args, from_tty);
+
+  inferior_pid = 0;
+
+/* This is necessary because many things were based on the PC at the time that
+   we attached to the monitor, which is no longer valid now that we have loaded
+   new code (and just changed the PC).  Another way to do this might be to call
+   normal_stop, except that the stack may not be valid, and things would get
+   horribly confused... */
+
+  clear_symtab_users ();
+}
+
+/* BDM (at least on CPU32) uses a different breakpoint */
+
+static int
+wiggler_insert_breakpoint (addr, contents_cache)
+     CORE_ADDR addr;
+     char *contents_cache;
+{
+  static char break_insn[] = {BDM_BREAKPOINT};
+  int val;
+
+  val = target_read_memory (addr, contents_cache, sizeof break_insn);
+
+  if (val == 0)
+    val = target_write_memory (addr, break_insn, sizeof break_insn);
+
+  return val;
+}
+
+static void
+bdm_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  error ("bdm command must be followed by `reset'");
+}
+
+static void
+bdm_reset_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  int status, pktlen;
+
+  if (!wiggler_desc)
+    error ("Not connected to wiggler.");
+
+  do_command (WIGGLER_RESET, &status, &pktlen);
+  dcache_flush (wiggler_dcache);
+  registers_changed ();
+}
+
+static void
+bdm_restart_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  int status, pktlen;
+
+  if (!wiggler_desc)
+    error ("Not connected to wiggler.");
+
+  do_command (WIGGLER_RESET_RUN, &status, &pktlen);
+  last_run_status = status;
+  clear_proceed_status ();
+  wait_for_inferior ();
+  normal_stop ();
+}
+
+/* Temporary replacement for target_store_registers().  This prevents
+   generic_load from trying to set the PC.  */
+
+static void
+noop_store_registers (regno)
+     int regno;
+{
+}
+
+static void
+bdm_update_flash_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  int status, pktlen;
+  struct cleanup *old_chain;
+  void (*store_registers_tmp) PARAMS ((int));
+
+  if (!wiggler_desc)
+    error ("Not connected to wiggler.");
+
+  if (!args)
+    error ("Must specify file containing new Wiggler code.");
+
+/*  old_chain = make_cleanup (flash_cleanup, 0);*/
+
+  do_command (WIGGLER_ENTER_MON, &status, &pktlen);
+
+  do_command (WIGGLER_ERASE_FLASH, &status, &pktlen);
+
+  write_mem_command = WIGGLER_PROGRAM_FLASH;
+  store_registers_tmp = current_target.to_store_registers;
+  current_target.to_store_registers = noop_store_registers;
+
+  generic_load (args, from_tty);
+
+  current_target.to_store_registers = store_registers_tmp;
+  write_mem_command = WIGGLER_WRITE_MEM;
+
+  do_command (WIGGLER_EXIT_MON, &status, &pktlen);
+
+/*  discard_cleanups (old_chain);*/
+}
+
+static void
+bdm_read_register_command (args, from_tty)
+     char *args;
+     int from_tty;
+{
+  /* XXX repeat should go on to the next register */
+
+  if (!wiggler_desc)
+    error ("Not connected to wiggler.");
+
+  if (!args)
+    error ("Must specify BDM register number.");
+
+}
+\f
+void
+_initialize_remote_wiggler ()
+{
+  extern struct cmd_list_element *cmdlist;
+  static struct cmd_list_element *bdm_cmd_list = NULL;
+
+  add_show_from_set (add_set_cmd ("remotetimeout", no_class,
+                                 var_integer, (char *)&remote_timeout,
+                                 "Set timeout value for remote read.\n", &setlist),
+                    &showlist);
+
+  add_prefix_cmd ("bdm", class_obscure, bdm_command, "", &bdm_cmd_list, "bdm ",
+                 0, &cmdlist);
+
+  add_cmd ("reset", class_obscure, bdm_reset_command, "", &bdm_cmd_list);
+  add_cmd ("restart", class_obscure, bdm_restart_command, "", &bdm_cmd_list);
+  add_cmd ("update-flash", class_obscure, bdm_update_flash_command, "", &bdm_cmd_list);
+  /*  add_cmd ("read-register", class_obscure, bdm_read_register_command, "", &bdm_cmd_list);*/
+}
diff --git a/gdb/ocd.h b/gdb/ocd.h
new file mode 100644 (file)
index 0000000..a8e0494
--- /dev/null
+++ b/gdb/ocd.h
@@ -0,0 +1,132 @@
+/* Definitions for the Macraigor Systems BDM Wiggler
+   Copyright 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef WIGGLER_H
+#define WIGGLER_H
+
+/* Wiggler serial protocol definitions */
+
+#define DLE 020                        /* Quote char */
+#define SYN 026                        /* Start of packet */
+#define RAW_SYN ((026 << 8) | 026) /* get_quoted_char found a naked SYN */
+
+/* Status flags */
+
+#define WIGGLER_FLAG_RESET 0x01 /* Target is being reset */
+#define WIGGLER_FLAG_STOPPED 0x02 /* Target is halted */
+#define WIGGLER_FLAG_BDM 0x04  /* Target is in BDM */
+#define WIGGLER_FLAG_PWF 0x08  /* Power failed */
+#define WIGGLER_FLAG_CABLE_DISC 0x10 /* BDM cable disconnected */
+
+/* Commands */
+
+#define WIGGLER_AYT 0x0                /* Are you there? */
+#define WIGGLER_GET_VERSION 0x1        /* Get Version */
+#define WIGGLER_SET_BAUD_RATE 0x2 /* Set Baud Rate */
+#define WIGGLER_INIT 0x10      /* Initialize Wiggler */
+#define WIGGLER_SET_SPEED 0x11 /* Set Speed */
+#define WIGGLER_GET_STATUS_MASK 0x12 /* Get Status Mask */
+#define WIGGLER_GET_CTRS 0x13  /* Get Error Counters */
+#define WIGGLER_SET_FUNC_CODE 0x14 /* Set Function Code */
+#define WIGGLER_SET_CTL_FLAGS 0x15 /* Set Control Flags */
+#define WIGGLER_SET_BUF_ADDR 0x16 /* Set Register Buffer Address */
+#define WIGGLER_RUN 0x20       /* Run Target from PC */
+#define WIGGLER_RUN_ADDR 0x21  /* Run Target from Specified Address */
+#define WIGGLER_STOP 0x22      /* Stop Target */
+#define WIGGLER_RESET_RUN 0x23 /* Reset Target and Run */
+#define WIGGLER_RESET 0x24     /* Reset Target and Halt */
+#define WIGGLER_STEP 0x25      /* Single step */
+#define WIGGLER_READ_REGS 0x30 /* Read Registers */
+#define WIGGLER_WRITE_REGS 0x31        /* Write Registers */
+#define WIGGLER_READ_MEM 0x32  /* Read Memory */
+#define WIGGLER_WRITE_MEM 0x33 /* Write Memory */
+#define WIGGLER_FILL_MEM 0x34  /* Fill Memory */
+#define WIGGLER_MOVE_MEM 0x35  /* Move Memory */
+
+#define WIGGLER_READ_INT_MEM 0x80 /* Read Internal Memory */
+#define WIGGLER_WRITE_INT_MEM 0x81 /* Write Internal Memory */
+#define WIGGLER_JUMP 0x82      /* Jump to Subroutine */
+
+#define WIGGLER_ERASE_FLASH 0x90 /* Erase flash memory */
+#define WIGGLER_PROGRAM_FLASH 0x91 /* Write flash memory */
+#define WIGGLER_EXIT_MON 0x93  /* Exit the flash programming monitor  */
+#define WIGGLER_ENTER_MON 0x94 /* Enter the flash programming monitor  */
+
+#define WIGGLER_SET_STATUS 0x0a        /* Set status */
+#define   WIGGLER_FLAG_STOP 0x0 /* Stop the target, enter BDM */
+#define   WIGGLER_FLAG_START 0x01 /* Start the target at PC */
+#define   WIGGLER_FLAG_RETURN_STATUS 0x04 /* Return async status */
+
+/* Target type (for WIGGLER_INIT command) */
+
+enum wiggler_target_type {
+  WIGGLER_TARGET_CPU32=0x0,    /* Moto cpu32 family */
+  WIGGLER_TARGET_CPU16=0x1,
+  WIGGLER_TARGET_MOTO_PPC=0x2, /* Motorola PPC 5xx/8xx */
+  WIGGLER_TARGET_IBM_PPC=0x3}; /* IBM PPC 4xx */
+
+void wiggler_open PARAMS ((char *name, int from_tty, enum wiggler_target_type,
+                          struct target_ops *ops));
+
+void wiggler_close PARAMS ((int quitting));
+
+void wiggler_detach PARAMS ((char *args, int from_tty));
+
+void wiggler_resume PARAMS ((int pid, int step, enum target_signal siggnal));
+
+void wiggler_prepare_to_store PARAMS ((void));
+
+void wiggler_stop PARAMS ((void));
+
+void wiggler_files_info PARAMS ((struct target_ops *ignore));
+
+
+int wiggler_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
+                                int len, int should_write,
+                                struct target_ops *target));
+
+void wiggler_mourn PARAMS ((void));
+
+void wiggler_create_inferior PARAMS ((char *exec_file,
+                                     char *args,
+                                     char **env));
+
+int wiggler_thread_alive PARAMS ((int th));
+
+void wiggler_error PARAMS ((char *s, int error_code));
+
+void wiggler_kill PARAMS ((void));
+
+void wiggler_load PARAMS((char *args, int from_tty));
+
+unsigned char * wiggler_read_bdm_registers PARAMS ((int first_bdm_regno,
+                                                   int last_bdm_regno,
+                                                   int *reglen));
+
+CORE_ADDR wiggler_read_bdm_register PARAMS ((int bdm_regno));
+
+void wiggler_write_bdm_registers PARAMS ((int first_bdm_regno,
+                                         unsigned char *regptr,
+                                         int reglen));
+
+void wiggler_write_bdm_register PARAMS ((int bdm_regno, CORE_ADDR reg));
+
+int wiggler_wait PARAMS ((void));
+
+#endif /* WIGGLER_H */
diff --git a/gdb/ppc-bdm.c b/gdb/ppc-bdm.c
new file mode 100644 (file)
index 0000000..6181298
--- /dev/null
@@ -0,0 +1,260 @@
+/* Remote target communications for the Macraigor Systems BDM Wiggler
+   talking to a Motorola PPC 505.
+   Copyright 1996, 1997 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "defs.h"
+#include "gdbcore.h"
+#include "gdb_string.h"
+#include <fcntl.h>
+#include "frame.h"
+#include "inferior.h"
+#include "bfd.h"
+#include "symfile.h"
+#include "target.h"
+#include "wait.h"
+#include "gdbcmd.h"
+#include "objfiles.h"
+#include "gdb-stabs.h"
+#include <sys/types.h>
+#include <signal.h>
+#include "serial.h"
+#include "ocd.h"
+
+static void bdm_ppc_open PARAMS ((char *name, int from_tty));
+
+static int bdm_ppc_wait PARAMS ((int pid,
+                                struct target_waitstatus *target_status));
+
+static void bdm_ppc_fetch_registers PARAMS ((int regno));
+
+static void bdm_ppc_store_registers PARAMS ((int regno));
+
+extern struct target_ops bdm_ppc_ops;  /* Forward decl */
+\f
+/* Open a connection to a remote debugger.
+   NAME is the filename used for communication.  */
+
+static void
+bdm_ppc_open (name, from_tty)
+     char *name;
+     int from_tty;
+{
+  wiggler_open (name, from_tty, WIGGLER_TARGET_MOTO_PPC, &bdm_ppc_ops);
+}
+
+/* Wait until the remote machine stops, then return,
+   storing status in STATUS just as `wait' would.
+   Returns "pid" (though it's not clear what, if anything, that
+   means in the case of this target).  */
+
+static int
+bdm_ppc_wait (pid, target_status)
+     int pid;
+     struct target_waitstatus *target_status;
+{
+  int stop_reason;
+
+  target_status->kind = TARGET_WAITKIND_STOPPED;
+
+  stop_reason = wiggler_wait ();
+
+  if (stop_reason)
+    {
+      target_status->value.sig = TARGET_SIGNAL_INT;
+      return inferior_pid;
+    }
+
+  target_status->value.sig = TARGET_SIGNAL_TRAP; /* XXX for now */
+
+  {
+    unsigned long ecr, der;
+
+    ecr = wiggler_read_bdm_register (148); /* Read the exception cause register */
+    der = wiggler_read_bdm_register (149); /* Read the debug enables register */
+    fprintf_unfiltered (gdb_stdout, "ecr = 0x%x, der = 0x%x\n", ecr, der);
+  }
+
+  return inferior_pid;
+}
+\f
+static int bdm_regmap[] = {BDM_REGMAP};
+
+/* Read the remote registers into regs.
+
+   The Wiggler uses the following codes to access the registers:
+
+   0 -> 1023           SPR 0 -> 1023
+       0 - SPR 0 - MQ
+       1 - SPR 1 - XER
+       8 - SPR 8 - LR
+       9 - SPR 9 - CTR (known as cnt in GDB)
+       26 - SPR 26 - SRR0 - pc
+   1024 -> 2047                DCR 0 -> DCR 1023 (IBM PPC 4xx only)
+   2048 -> 2079                R0 -> R31
+   2080 -> 2143                FP0 -> FP31 (64 bit regs)
+   2144                        CR (known as cnd in GDB)
+   2145                        FPCSR
+   2146                        MSR (known as ps in GDB)
+ */
+
+static void
+bdm_ppc_fetch_registers (regno)
+     int regno;
+{
+  int i;
+  unsigned char *regs;
+  int first_regno, last_regno;
+  int first_bdm_regno, last_bdm_regno;
+  int reglen;
+
+  if (regno == -1)
+    {
+      first_regno = 0;
+      last_regno = NUM_REGS - 1;
+
+      first_bdm_regno = 0;
+      last_bdm_regno = BDM_NUM_REGS - 1;
+    }
+  else
+    {
+      first_regno = regno;
+      last_regno = regno;
+
+      first_bdm_regno = bdm_regmap [regno];
+      last_bdm_regno = bdm_regmap [regno];
+    }
+
+  if (first_bdm_regno == -1)
+    {
+      supply_register (first_regno, NULL);
+      return;                  /* Unsupported register */
+    }
+
+  regs = wiggler_read_bdm_registers (first_bdm_regno, last_bdm_regno, &reglen);
+
+  for (i = first_regno; i <= last_regno; i++)
+    {
+      int bdm_regno, regoffset;
+
+      bdm_regno = bdm_regmap [i];
+      if (bdm_regno != -1)
+       {
+         regoffset = bdm_regno - first_bdm_regno;
+
+         if (regoffset >= reglen / 4)
+           continue;
+
+         supply_register (i, regs + 4 * regoffset);
+       }
+      else
+       supply_register (i, NULL); /* Unsupported register */
+    }
+}
+
+/* Store register REGNO, or all registers if REGNO == -1, from the contents
+   of REGISTERS.  FIXME: ignores errors.  */
+
+static void
+bdm_ppc_store_registers (regno)
+     int regno;
+{
+  int i;
+  int first_regno, last_regno;
+  int first_bdm_regno, last_bdm_regno;
+
+  if (regno == -1)
+    {
+      first_regno = 0;
+      last_regno = NUM_REGS - 1;
+
+      first_bdm_regno = 0;
+      last_bdm_regno = BDM_NUM_REGS - 1;
+    }
+  else
+    {
+      first_regno = regno;
+      last_regno = regno;
+
+      first_bdm_regno = bdm_regmap [regno];
+      last_bdm_regno = bdm_regmap [regno];
+    }
+
+  if (first_bdm_regno == -1)
+    return;                    /* Unsupported register */
+
+  for (i = first_regno; i <= last_regno; i++)
+    {
+      int bdm_regno;
+
+      bdm_regno = bdm_regmap [i];
+
+      wiggler_write_bdm_registers (bdm_regno, registers + REGISTER_BYTE (i), 4);
+    }
+}
+\f
+/* Define the target subroutine names */
+
+struct target_ops bdm_ppc_ops = {
+  "wiggler",                   /* to_shortname */
+  "",                          /* to_longname */
+  "",                          /* to_doc */
+  bdm_ppc_open,                        /* to_open */
+  wiggler_close,               /* to_close */
+  NULL,                                /* to_attach */
+  wiggler_detach,              /* to_detach */
+  wiggler_resume,              /* to_resume */
+  bdm_ppc_wait,                        /* to_wait */
+  bdm_ppc_fetch_registers,     /* to_fetch_registers */
+  bdm_ppc_store_registers,     /* to_store_registers */
+  wiggler_prepare_to_store,    /* to_prepare_to_store */
+  wiggler_xfer_memory,         /* to_xfer_memory */
+  wiggler_files_info,          /* to_files_info */
+  memory_insert_breakpoint,    /* to_insert_breakpoint */
+  memory_remove_breakpoint,    /* to_remove_breakpoint */
+  NULL,                                /* to_terminal_init */
+  NULL,                                /* to_terminal_inferior */
+  NULL,                                /* to_terminal_ours_for_output */
+  NULL,                                /* to_terminal_ours */
+  NULL,                                /* to_terminal_info */
+  wiggler_kill,                        /* to_kill */
+  wiggler_load,                        /* to_load */
+  NULL,                                /* to_lookup_symbol */
+  wiggler_create_inferior,     /* to_create_inferior */
+  wiggler_mourn,               /* to_mourn_inferior */
+  0,                           /* to_can_run */
+  0,                           /* to_notice_signals */
+  wiggler_thread_alive,                /* to_thread_alive */
+  wiggler_stop,                        /* to_stop */
+  process_stratum,             /* to_stratum */
+  NULL,                                /* to_next */
+  1,                           /* to_has_all_memory */
+  1,                           /* to_has_memory */
+  1,                           /* to_has_stack */
+  1,                           /* to_has_registers */
+  1,                           /* to_has_execution */
+  NULL,                                /* sections */
+  NULL,                                /* sections_end */
+  OPS_MAGIC                    /* to_magic */
+};
+
+void
+_initialize_bdm_ppc ()
+{
+  add_target (&bdm_ppc_ops);
+}
diff --git a/gdb/remote-wiggler.c b/gdb/remote-wiggler.c
deleted file mode 100644 (file)
index c767641..0000000
+++ /dev/null
@@ -1,1678 +0,0 @@
-/* Remote target communications for the Macraigor Systems BDM Wiggler
-   Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "gdb_string.h"
-#include <fcntl.h>
-#include "frame.h"
-#include "inferior.h"
-#include "bfd.h"
-#include "symfile.h"
-#include "target.h"
-#include "wait.h"
-#include "gdbcmd.h"
-#include "objfiles.h"
-#include "gdb-stabs.h"
-
-#include "dcache.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <signal.h>
-#include "serial.h"
-
-/* Wiggler serial protocol definitions */
-
-#define DLE 020                        /* Quote char */
-#define SYN 026                        /* Start of packet */
-#define RAW_SYN ((026 << 8) | 026) /* get_quoted_char found a naked SYN */
-
-/* Status flags */
-
-#define WIGGLER_FLAG_RESET 0x01 /* Target is being reset */
-#define WIGGLER_FLAG_STOPPED 0x02 /* Target is halted */
-#define WIGGLER_FLAG_BDM 0x04  /* Target is in BDM */
-#define WIGGLER_FLAG_PWF 0x08  /* Power failed */
-#define WIGGLER_FLAG_CABLE_DISC 0x10 /* BDM cable disconnected */
-
-#define WIGGLER_AYT 0x0                /* Are you there? */
-#define WIGGLER_GET_VERSION 0x1        /* Get Version */
-#define WIGGLER_SET_BAUD_RATE 0x2 /* Set Baud Rate */
-#define WIGGLER_INIT 0x10      /* Initialize Wiggler */
-#define WIGGLER_SET_SPEED 0x11 /* Set Speed */
-#define WIGGLER_GET_STATUS_MASK 0x12 /* Get Status Mask */
-#define WIGGLER_GET_CTRS 0x13  /* Get Error Counters */
-#define WIGGLER_SET_FUNC_CODE 0x14 /* Set Function Code */
-#define WIGGLER_SET_CTL_FLAGS 0x15 /* Set Control Flags */
-#define WIGGLER_SET_BUF_ADDR 0x16 /* Set Register Buffer Address */
-#define WIGGLER_RUN 0x20       /* Run Target from PC */
-#define WIGGLER_RUN_ADDR 0x21  /* Run Target from Specified Address */
-#define WIGGLER_STOP 0x22      /* Stop Target */
-#define WIGGLER_RESET_RUN 0x23 /* Reset Target and Run */
-#define WIGGLER_RESET 0x24     /* Reset Target and Halt */
-#define WIGGLER_STEP 0x25      /* Single step */
-#define WIGGLER_READ_REGS 0x30 /* Read Registers */
-#define WIGGLER_WRITE_REGS 0x31        /* Write Registers */
-#define WIGGLER_READ_MEM 0x32  /* Read Memory */
-#define WIGGLER_WRITE_MEM 0x33 /* Write Memory */
-#define WIGGLER_FILL_MEM 0x34  /* Fill Memory */
-#define WIGGLER_MOVE_MEM 0x35  /* Move Memory */
-
-#define WIGGLER_READ_INT_MEM 0x80 /* Read Internal Memory */
-#define WIGGLER_WRITE_INT_MEM 0x81 /* Write Internal Memory */
-#define WIGGLER_JUMP 0x82      /* Jump to Subroutine */
-
-#define WIGGLER_ERASE_FLASH 0x90 /* Erase flash memory */
-#define WIGGLER_PROGRAM_FLASH 0x91 /* Write flash memory */
-#define WIGGLER_EXIT_MON 0x93  /* Exit the flash programming monitor  */
-#define WIGGLER_ENTER_MON 0x94 /* Enter the flash programming monitor  */
-
-#define WIGGLER_SET_STATUS 0x0a        /* Set status */
-#define   WIGGLER_FLAG_STOP 0x0 /* Stop the target, enter BDM */
-#define   WIGGLER_FLAG_START 0x01 /* Start the target at PC */
-#define   WIGGLER_FLAG_RETURN_STATUS 0x04 /* Return async status */
-
-/* Stuff that should be in tm-xxx files. */
-#if 1
-#define BDM_NUM_REGS 24
-#define BDM_REGMAP   0,  1,  2,  3,  4,  5,  6,  7, /* d0 -> d7 */ \
-                    8,  9, 10, 11, 12, 13, 14, 15, /* a0 -> a7 */ \
-                   18, 16,                         /* ps, pc */ \
-                   -1, -1, -1, -1, -1, -1, -1, -1, /* fp0 -> fp7 */ \
-                   -1, -1, -1, -1, -1 /* fpcontrol, fpstatus, fpiaddr, fpcode, fpflags */
-#define BDM_BREAKPOINT 0x4a, 0xfa /* BGND insn */
-#else
-#define BDM_NUM_REGS 24
-#define BDM_REGMAP   8,  9, 10, 11, 12, 13, 14, 15, /* d0 -> d7 */ \
-                   16, 17, 18, 19, 20, 21, 22, 23, /* a0 -> a7 */ \
-                    4,  0,                         /* ps, pc */ \
-                   -1, -1, -1, -1, -1, -1, -1, -1, /* fp0 -> fp7 */ \
-                   -1, -1, -1, -1, -1 /* fpcontrol, fpstatus, fpiaddr, fpcode, fpflags */
-#define WIGGLER_POLL
-#endif
-
-/* Prototypes for local functions */
-
-static void wiggler_stop PARAMS ((void));
-
-static void put_packet PARAMS ((unsigned char *packet, int pktlen));
-static unsigned char * get_packet PARAMS ((int cmd, int *pktlen, int timeout));
-
-static int wiggler_write_bytes PARAMS ((CORE_ADDR memaddr,
-                                      char *myaddr, int len));
-
-static int wiggler_read_bytes PARAMS ((CORE_ADDR memaddr,
-                                     char *myaddr, int len));
-
-static void wiggler_files_info PARAMS ((struct target_ops *ignore));
-
-static int wiggler_xfer_memory PARAMS ((CORE_ADDR memaddr, char *myaddr,
-                                      int len, int should_write,
-                                      struct target_ops *target));
-
-static void wiggler_prepare_to_store PARAMS ((void));
-
-static void wiggler_fetch_registers PARAMS ((int regno));
-
-static void wiggler_resume PARAMS ((int pid, int step,
-                                  enum target_signal siggnal));
-
-static int wiggler_start_remote PARAMS ((char *dummy));
-
-static void wiggler_open PARAMS ((char *name, int from_tty));
-
-static void wiggler_close PARAMS ((int quitting));
-
-static void wiggler_store_registers PARAMS ((int regno));
-
-static void wiggler_mourn PARAMS ((void));
-
-static int readchar PARAMS ((int timeout));
-
-static void reset_packet PARAMS ((void));
-
-static void output_packet PARAMS ((void));
-
-static int get_quoted_char PARAMS ((int timeout));
-
-static void put_quoted_char PARAMS ((int c));
-
-static int wiggler_wait PARAMS ((int pid, struct target_waitstatus *status));
-
-static void wiggler_kill PARAMS ((void));
-
-static void wiggler_detach PARAMS ((char *args, int from_tty));
-
-static void wiggler_interrupt PARAMS ((int signo));
-
-static void wiggler_interrupt_twice PARAMS ((int signo));
-
-static void interrupt_query PARAMS ((void));
-
-static unsigned char * do_command PARAMS ((int cmd, int *statusp, int *lenp));
-
-static unsigned char * read_bdm_registers PARAMS ((int first_bdm_regno,
-                                                  int last_bdm_regno,
-                                                  int *numregs));
-
-extern struct target_ops wiggler_ops;  /* Forward decl */
-
-static int last_run_status;
-
-/* This was 5 seconds, which is a long time to sit and wait.
-   Unless this is going though some terminal server or multiplexer or
-   other form of hairy serial connection, I would think 2 seconds would
-   be plenty.  */
-
-/* Changed to allow option to set timeout value.
-   was static int remote_timeout = 2; */
-extern int remote_timeout;
-
-/* Descriptor for I/O to remote machine.  Initialize it to NULL so that
-   wiggler_open knows that we don't have a file open when the program
-   starts.  */
-serial_t wiggler_desc = NULL;
-\f
-static void
-wiggler_error (s, error_code)
-     char *s;
-     int error_code;
-{
-  char buf[100];
-
-  fputs_filtered (s, gdb_stderr);
-  fputs_filtered (" ", gdb_stderr);
-
-  switch (error_code)
-    {
-    case 0x1: s = "Unknown fault"; break;
-    case 0x2: s = "Power failed"; break;
-    case 0x3: s = "Cable disconnected"; break;
-    case 0x4: s = "Couldn't enter BDM"; break;
-    case 0x5: s = "Target stuck in reset"; break;
-    case 0x6: s = "Port not configured"; break;
-    case 0x7: s = "Write verify failed"; break;
-    case 0x11: s = "Bus error"; break;
-    case 0x12: s = "Checksum error"; break;
-    case 0x13: s = "Illegal command"; break;
-    case 0x14: s = "Parameter error"; break;
-    case 0x15: s = "Internal error"; break;
-    case 0x16: s = "Register buffer error"; break;
-    case 0x80: s = "Flash erase error"; break;
-    default:
-      sprintf (buf, "Unknown error code %d", error_code);
-      s = buf;
-    }
-
-  error (s);
-}
-
-/*  Return nonzero if the thread TH is still alive on the remote system.  */
-
-static int
-wiggler_thread_alive (th)
-     int th;
-{
-  return 1;
-}
-\f
-/* Clean up connection to a remote debugger.  */
-
-/* ARGSUSED */
-static void
-wiggler_close (quitting)
-     int quitting;
-{
-  if (wiggler_desc)
-    SERIAL_CLOSE (wiggler_desc);
-  wiggler_desc = NULL;
-}
-
-/* Stub for catch_errors.  */
-
-static int
-wiggler_start_remote (dummy)
-     char *dummy;
-{
-  unsigned char buf[10], *p;
-  int pktlen;
-  int status;
-  int error_code;
-  int speed;
-
-  immediate_quit = 1;          /* Allow user to interrupt it */
-
-  SERIAL_SEND_BREAK (wiggler_desc); /* Wake up the wiggler */
-
-  do_command (WIGGLER_AYT, &status, &pktlen);
-
-  p = do_command (WIGGLER_GET_VERSION, &status, &pktlen);
-
-  printf_unfiltered ("[Wiggler version %x.%x, capability 0x%x]\n",
-                    p[0], p[1], (p[2] << 16) | p[3]);
-
-#if 1
-  speed = 80;                  /* Divide clock by 4000 */
-
-  buf[0] = WIGGLER_INIT;
-  buf[1] = speed >> 8;
-  buf[2] = speed & 0xff;
-  buf[3] = 0;                  /* CPU32 for now */
-  put_packet (buf, 4);         /* Init Wiggler params */
-  p = get_packet (buf[0], &pktlen, remote_timeout);
-
-  if (pktlen < 2)
-    error ("Truncated response packet from Wiggler");
-
-  status = p[1];
-  error_code = p[2];
-
-  if (error_code != 0)
-    wiggler_error ("WIGGLER_INIT:", error_code);
-#endif
-
-#if 0
-  /* Reset the target */
-
-  do_command (WIGGLER_RESET_RUN, &status, &pktlen);
-/*  do_command (WIGGLER_RESET, &status, &pktlen);*/
-#endif
-
-  /* If processor is still running, stop it.  */
-
-  if (!(status & WIGGLER_FLAG_BDM))
-    wiggler_stop ();
-
-#if 1
-  buf[0] = WIGGLER_SET_CTL_FLAGS;
-  buf[1] = 0;
-  buf[2] = 1;          /* Asynchronously return status when target stops */
-  put_packet (buf, 3);
-
-  p = get_packet (buf[0], &pktlen, remote_timeout);
-
-  if (pktlen < 2)
-    error ("Truncated response packet from Wiggler");
-
-  status = p[1];
-  error_code = p[2];
-
-  if (error_code != 0)
-    wiggler_error ("WIGGLER_SET_CTL_FLAGS:", error_code);
-#endif
-
-  immediate_quit = 0;
-
-/* This is really the job of start_remote however, that makes an assumption
-   that the target is about to print out a status message of some sort.  That
-   doesn't happen here (in fact, it may not be possible to get the monitor to
-   send the appropriate packet).  */
-
-  flush_cached_frames ();
-  registers_changed ();
-  stop_pc = read_pc ();
-  set_current_frame (create_new_frame (read_fp (), stop_pc));
-  select_frame (get_current_frame (), 0);
-  print_stack_frame (selected_frame, -1, 1);
-
-  return 1;
-}
-
-/* Open a connection to a remote debugger.
-   NAME is the filename used for communication.  */
-
-static DCACHE *wiggler_dcache;
-
-static void
-wiggler_open (name, from_tty)
-     char *name;
-     int from_tty;
-{
-  if (name == 0)
-    error ("To open a Wiggler connection, you need to specify what serial\n\
-device the Wiggler is attached to (e.g. /dev/ttya).");
-
-  target_preopen (from_tty);
-
-  unpush_target (&wiggler_ops);
-
-  wiggler_dcache = dcache_init (wiggler_read_bytes, wiggler_write_bytes);
-
-  wiggler_desc = SERIAL_OPEN (name);
-  if (!wiggler_desc)
-    perror_with_name (name);
-
-  if (baud_rate != -1)
-    {
-      if (SERIAL_SETBAUDRATE (wiggler_desc, baud_rate))
-       {
-         SERIAL_CLOSE (wiggler_desc);
-         perror_with_name (name);
-       }
-    }
-
-  SERIAL_RAW (wiggler_desc);
-
-  /* If there is something sitting in the buffer we might take it as a
-     response to a command, which would be bad.  */
-  SERIAL_FLUSH_INPUT (wiggler_desc);
-
-  if (from_tty)
-    {
-      puts_filtered ("Remote target wiggler connected to ");
-      puts_filtered (name);
-      puts_filtered ("\n");
-    }
-  push_target (&wiggler_ops);  /* Switch to using remote target now */
-
-  /* Without this, some commands which require an active target (such as kill)
-     won't work.  This variable serves (at least) double duty as both the pid
-     of the target process (if it has such), and as a flag indicating that a
-     target is active.  These functions should be split out into seperate
-     variables, especially since GDB will someday have a notion of debugging
-     several processes.  */
-
-  inferior_pid = 42000;
-  /* Start the remote connection; if error (0), discard this target.
-     In particular, if the user quits, be sure to discard it
-     (we'd be in an inconsistent state otherwise).  */
-  if (!catch_errors (wiggler_start_remote, (char *)0, 
-                    "Couldn't establish connection to remote target\n", RETURN_MASK_ALL))
-    pop_target();
-}
-
-/* This takes a program previously attached to and detaches it.  After
-   this is done, GDB can be used to debug some other program.  We
-   better not have left any breakpoints in the target program or it'll
-   die when it hits one.  */
-
-static void
-wiggler_detach (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  if (args)
-    error ("Argument given to \"detach\" when remotely debugging.");
-
-  pop_target ();
-  if (from_tty)
-    puts_filtered ("Ending remote debugging.\n");
-}
-\f
-/* Tell the remote machine to resume.  */
-
-static void
-wiggler_resume (pid, step, siggnal)
-     int pid, step;
-     enum target_signal siggnal;
-{
-  int pktlen;
-
-  dcache_flush (wiggler_dcache);
-
-  if (step)
-    do_command (WIGGLER_STEP, &last_run_status, &pktlen);
-  else
-    do_command (WIGGLER_RUN, &last_run_status, &pktlen);
-}
-\f
-static void
-wiggler_stop ()
-{
-  int status;
-  int pktlen;
-
-  do_command (WIGGLER_STOP, &status, &pktlen);
-
-  if (!(status & WIGGLER_FLAG_BDM))
-    error ("Can't stop target via BDM");
-}
-
-static volatile int wiggler_interrupt_flag;
-
-/* Send ^C to target to halt it.  Target will respond, and send us a
-   packet.  */
-
-static void
-wiggler_interrupt (signo)
-     int signo;
-{
-  /* If this doesn't work, try more severe steps.  */
-  signal (signo, wiggler_interrupt_twice);
-  
-  if (remote_debug)
-    printf_unfiltered ("wiggler_interrupt called\n");
-
-  {
-    char buf[1];
-
-    wiggler_stop ();
-    buf[0] = WIGGLER_AYT;
-    put_packet (buf, 1);
-    wiggler_interrupt_flag = 1;
-  }
-}
-
-static void (*ofunc)();
-
-/* The user typed ^C twice.  */
-static void
-wiggler_interrupt_twice (signo)
-     int signo;
-{
-  signal (signo, ofunc);
-  
-  interrupt_query ();
-
-  signal (signo, wiggler_interrupt);
-}
-
-/* Ask the user what to do when an interrupt is received.  */
-
-static void
-interrupt_query ()
-{
-  target_terminal_ours ();
-
-  if (query ("Interrupted while waiting for the program.\n\
-Give up (and stop debugging it)? "))
-    {
-      target_mourn_inferior ();
-      return_to_top_level (RETURN_QUIT);
-    }
-
-  target_terminal_inferior ();
-}
-
-/* If nonzero, ignore the next kill.  */
-static int kill_kludge;
-
-/* Wait until the remote machine stops, then return,
-   storing status in STATUS just as `wait' would.
-   Returns "pid" (though it's not clear what, if anything, that
-   means in the case of this target).  */
-
-static int
-wiggler_wait (pid, target_status)
-     int pid;
-     struct target_waitstatus *target_status;
-{
-  unsigned char *p;
-  int error_code, status;
-  int pktlen;
-
-  wiggler_interrupt_flag = 0;
-
-  target_status->kind = TARGET_WAITKIND_STOPPED;
-  target_status->value.sig = TARGET_SIGNAL_TRAP;
-
-  /* Target may already be stopped by the time we get here. */
-
-  if (!(last_run_status & WIGGLER_FLAG_BDM))
-    {
-      ofunc = (void (*)()) signal (SIGINT, wiggler_interrupt);
-
-      p = get_packet (WIGGLER_AYT, &pktlen, -1);
-
-      signal (SIGINT, ofunc);
-
-      if (pktlen < 2)
-       error ("Truncated response packet from Wiggler");
-
-      status = p[1];
-      error_code = p[2];
-
-      if (error_code != 0)
-       wiggler_error ("target_wait:", error_code);
-
-      if (status & WIGGLER_FLAG_PWF)
-       error ("Wiggler lost VCC at BDM interface.");
-      else if (status & WIGGLER_FLAG_CABLE_DISC)
-       error ("BDM cable appears to have been disconnected.");
-
-      if (!(status & WIGGLER_FLAG_BDM))
-       error ("Wiggler woke up, but wasn't stopped: 0x%x", status);
-
-      if (wiggler_interrupt_flag)
-       target_status->value.sig = TARGET_SIGNAL_INT;
-    }
-
-  /* This test figures out if we just executed a BGND insn, and if it's one of
-     our breakpoints.  If so, then we back up PC.  N.B. When a BGND insn is
-     executed, the PC points at the loc just after the insn (ie: it's always
-     two bytes *after* the BGND).  So, it's not sufficient to just see if PC-2
-     is a BGND insn because we could have gotten there via a jump.  We dis-
-     ambiguate this case by examining the ATEMP register (which is only
-     accessible from BDM).  This will tell us if we entered BDM because we
-     executed a BGND insn.  */
-
-  if (breakpoint_inserted_here_p (read_pc () - 2)) /* One of our breakpoints? */
-    {                          /* Yes, see if we actually executed it */
-#if 0  /* Temporarily disabled until atemp reading is fixed. */
-      int atemp;
-      int numregs;
-
-      p = read_bdm_registers (23, 23, &numregs);
-      atemp = extract_unsigned_integer (p, 4);
-
-      if (atemp == 1)          /* And, did we hit a breakpoint insn? */
-#endif
-       write_pc (read_pc () - 2); /* Yes, then back up PC */
-    }
-
-  return inferior_pid;
-}
-
-/* Read the remote registers into the block REGS.  */
-/* Currently we just read all the registers, so we don't use regno.  */
-/* ARGSUSED */
-
-static unsigned char *
-read_bdm_registers (first_bdm_regno, last_bdm_regno, numregs)
-     int first_bdm_regno;
-     int last_bdm_regno;
-     int *numregs;
-{
-  unsigned char buf[10];
-  int i;
-  unsigned char *p;
-  unsigned char *regs;
-  int error_code, status;
-  int pktlen;
-
-  buf[0] = WIGGLER_READ_REGS;
-  buf[1] = first_bdm_regno >> 8;
-  buf[2] = first_bdm_regno & 0xff;
-  buf[3] = last_bdm_regno >> 8;
-  buf[4] = last_bdm_regno & 0xff;
-
-  put_packet (buf, 5);
-  p = get_packet (WIGGLER_READ_REGS, &pktlen, remote_timeout);
-
-  if (pktlen < 5)
-    error ("Truncated response packet from Wiggler");
-
-  status = p[1];
-  error_code = p[2];
-
-  if (error_code != 0)
-    wiggler_error ("read_bdm_registers:", error_code);
-
-  i = p[3];
-  if (i == 0)
-    i = 256;
-
-  if (i > pktlen - 4
-      || ((i & 3) != 0))
-    error ("Register block size bad:  %d", i);
-
-  *numregs = i / 4;
-
-  regs = p + 4;
-
-  return regs;
-}
-
-static void
-dump_all_bdm_regs ()
-{
-  unsigned char *regs;
-  int numregs;
-  int i;
-
-  regs = read_bdm_registers (0, BDM_NUM_REGS - 1, &numregs);
-
-  printf_unfiltered ("rpc = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("usp = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("ssp = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("vbr = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("sr = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("sfc = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("dfc = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("atemp = 0x%x ",
-                    (int)extract_unsigned_integer (regs, 4));
-  regs += 4;
-  printf_unfiltered ("\n");
-
-  for (i = 0; i <= 7; i++)
-    printf_unfiltered ("d%i = 0x%x ", i,
-                      (int)extract_unsigned_integer (regs + i * 4, 4));
-  regs += 8 * 4;
-  printf_unfiltered ("\n");
-
-  for (i = 0; i <= 7; i++)
-    printf_unfiltered ("a%i = 0x%x ", i,
-                      (int)extract_unsigned_integer (regs + i * 4, 4));
-  printf_unfiltered ("\n");
-}
-
-static int bdm_regmap[] = {BDM_REGMAP};
-
-/* Read the remote registers into the block REGS.  */
-/* Currently we just read all the registers, so we don't use regno.  */
-/* ARGSUSED */
-static void
-wiggler_fetch_registers (regno)
-     int regno;
-{
-  int i;
-  unsigned char *regs;
-  int first_regno, last_regno;
-  int first_bdm_regno, last_bdm_regno;
-  int numregs;
-
-  if (regno == -1)
-    {
-      first_regno = 0;
-      last_regno = NUM_REGS - 1;
-
-      first_bdm_regno = 0;
-      last_bdm_regno = BDM_NUM_REGS - 1;
-    }
-  else
-    {
-      first_regno = regno;
-      last_regno = regno;
-
-      first_bdm_regno = bdm_regmap [regno];
-      last_bdm_regno = bdm_regmap [regno];
-    }
-
-  if (first_bdm_regno == -1)
-    {
-      supply_register (first_regno, NULL);
-      return;                  /* Unsupported register */
-    }
-
-  regs = read_bdm_registers (first_bdm_regno, last_bdm_regno, &numregs);
-
-  for (i = first_regno; i <= last_regno; i++)
-    {
-      int bdm_regno, regoffset;
-
-      bdm_regno = bdm_regmap [i];
-      if (bdm_regno != -1)
-       {
-         regoffset = bdm_regno - first_bdm_regno;
-
-         if (regoffset >= numregs)
-           continue;
-
-         supply_register (i, regs + 4 * regoffset);
-       }
-      else
-       supply_register (i, NULL); /* Unsupported register */
-    }
-}
-
-static void 
-wiggler_prepare_to_store ()
-{
-}
-
-/* Store register REGNO, or all registers if REGNO == -1, from the contents
-   of REGISTERS.  FIXME: ignores errors.  */
-
-static void
-wiggler_store_registers (regno)
-     int regno;
-{
-  unsigned char buf[10 + 256];
-  int i;
-  unsigned char *p;
-  int error_code, status;
-  int pktlen;
-  int first_regno, last_regno;
-  int first_bdm_regno, last_bdm_regno;
-
-  if (regno == -1)
-    {
-      first_regno = 0;
-      last_regno = NUM_REGS - 1;
-
-      first_bdm_regno = 0;
-      last_bdm_regno = BDM_NUM_REGS - 1;
-    }
-  else
-    {
-      first_regno = regno;
-      last_regno = regno;
-
-      first_bdm_regno = bdm_regmap [regno];
-      last_bdm_regno = bdm_regmap [regno];
-    }
-
-  if (first_bdm_regno == -1)
-    return;                    /* Unsupported register */
-
-  buf[0] = WIGGLER_WRITE_REGS;
-  buf[3] = 4;
-
-  for (i = first_regno; i <= last_regno; i++)
-    {
-      int bdm_regno;
-
-      bdm_regno = bdm_regmap [i];
-
-      buf[1] = bdm_regno >> 8;
-      buf[2] = bdm_regno & 0xff;
-
-      memcpy (&buf[4], &registers[REGISTER_BYTE (i)], 4);
-      put_packet (buf, 4 + 4);
-      p = get_packet (WIGGLER_WRITE_REGS, &pktlen, remote_timeout);
-
-      if (pktlen < 3)
-       error ("Truncated response packet from Wiggler");
-
-      status = p[1];
-      error_code = p[2];
-
-      if (error_code != 0)
-       wiggler_error ("wiggler_store_registers:", error_code);
-    }
-}
-\f
-/* Write memory data directly to the remote machine.
-   This does not inform the data cache; the data cache uses this.
-   MEMADDR is the address in the remote memory space.
-   MYADDR is the address of the buffer in our space.
-   LEN is the number of bytes.
-
-   Returns number of bytes transferred, or 0 for error.  */
-
-static int
-wiggler_write_bytes (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-{
-  char buf[256 + 10];
-  unsigned char *p;
-  int origlen;
-
-  origlen = len;
-
-  buf[0] = WIGGLER_WRITE_MEM;
-  buf[5] = 1;                  /* Write as bytes */
-  buf[6] = 0;                  /* Don't verify */
-
-  while (len > 0)
-    {
-      int numbytes;
-      int pktlen;
-      int status, error_code;
-
-      numbytes = min (len, 256 - 8);
-
-      buf[1] = memaddr >> 24;
-      buf[2] = memaddr >> 16;
-      buf[3] = memaddr >> 8;
-      buf[4] = memaddr;
-
-      buf[7] = numbytes;
-
-      memcpy (&buf[8], myaddr, numbytes);
-      put_packet (buf, 8 + numbytes);
-      p = get_packet (WIGGLER_WRITE_MEM, &pktlen, remote_timeout);
-      if (pktlen < 3)
-       error ("Truncated response packet from Wiggler");
-
-      status = p[1];
-      error_code = p[2];
-
-      if (error_code == 0x11)  /* Got a bus error? */
-       {
-         CORE_ADDR error_address;
-
-         error_address = p[3] << 24;
-         error_address |= p[4] << 16;
-         error_address |= p[5] << 8;
-         error_address |= p[6];
-         numbytes = error_address - memaddr;
-
-         len -= numbytes;
-
-         errno = EIO;
-
-         break;
-       }
-      else if (error_code != 0)
-       wiggler_error ("wiggler_write_bytes:", error_code);
-
-      len -= numbytes;
-      memaddr += numbytes;
-      myaddr += numbytes;
-    }
-
-  return origlen - len;
-}
-
-/* Read memory data directly from the remote machine.
-   This does not use the data cache; the data cache uses this.
-   MEMADDR is the address in the remote memory space.
-   MYADDR is the address of the buffer in our space.
-   LEN is the number of bytes.
-
-   Returns number of bytes transferred, or 0 for error.  */
-
-static int
-wiggler_read_bytes (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-{
-  char buf[256 + 10];
-  unsigned char *p;
-  int origlen;
-
-  origlen = len;
-
-  buf[0] = WIGGLER_READ_MEM;
-  buf[5] = 1;                  /* Read as bytes */
-
-  while (len > 0)
-    {
-      int numbytes;
-      int pktlen;
-      int status, error_code;
-
-      numbytes = min (len, 256 - 7);
-
-      buf[1] = memaddr >> 24;
-      buf[2] = memaddr >> 16;
-      buf[3] = memaddr >> 8;
-      buf[4] = memaddr;
-
-      buf[6] = numbytes;
-
-      put_packet (buf, 7);
-      p = get_packet (WIGGLER_READ_MEM, &pktlen, remote_timeout);
-      if (pktlen < 4)
-       error ("Truncated response packet from Wiggler");
-
-      status = p[1];
-      error_code = p[2];
-
-      if (error_code == 0x11)  /* Got a bus error? */
-       {
-         CORE_ADDR error_address;
-
-         error_address = p[3] << 24;
-         error_address |= p[4] << 16;
-         error_address |= p[5] << 8;
-         error_address |= p[6];
-         numbytes = error_address - memaddr;
-
-         len -= numbytes;
-
-         errno = EIO;
-
-         break;
-       }
-      else if (error_code != 0)
-       wiggler_error ("wiggler_read_bytes:", error_code);
-
-      memcpy (myaddr, &p[4], numbytes);
-
-      len -= numbytes;
-      memaddr += numbytes;
-      myaddr += numbytes;
-    }
-
-  return origlen - len;
-}
-\f
-/* Read or write LEN bytes from inferior memory at MEMADDR, transferring
-   to or from debugger address MYADDR.  Write to inferior if SHOULD_WRITE is
-   nonzero.  Returns length of data written or read; 0 for error.  */
-
-/* ARGSUSED */
-static int
-wiggler_xfer_memory (memaddr, myaddr, len, should_write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int should_write;
-     struct target_ops *target;                        /* ignored */
-{
-  return dcache_xfer_memory (wiggler_dcache, memaddr, myaddr, len, should_write);
-}
-\f
-static void
-wiggler_files_info (ignore)
-     struct target_ops *ignore;
-{
-  puts_filtered ("Debugging a target over a serial line.\n");
-}
-\f
-/* Stuff for dealing with the packets which are part of this protocol.
-   See comment at top of file for details.  */
-
-/* Read a single character from the remote side, handling wierd errors. */
-
-static int
-readchar (timeout)
-     int timeout;
-{
-  int ch;
-
-  ch = SERIAL_READCHAR (wiggler_desc, timeout);
-
-  switch (ch)
-    {
-    case SERIAL_EOF:
-      error ("Remote connection closed");
-    case SERIAL_ERROR:
-      perror_with_name ("Remote communication error");
-    case SERIAL_TIMEOUT:
-    default:
-      return ch;
-    }
-}
-
-#if 0
-/* Read a character from the data stream, dequoting as necessary.  SYN is
-   treated special.  Any SYNs appearing in the data stream are returned as the
-   distinct value RAW_SYN (which has a value > 8 bits and therefore cannot be
-   mistaken for real data).  */
-
-static int
-get_quoted_char (timeout)
-     int timeout;
-{
-  int ch;
-
-  ch = readchar (timeout);
-
-  switch (ch)
-    {
-    case SERIAL_TIMEOUT:
-      error ("Timeout in mid-packet, aborting");
-    case SYN:
-      return RAW_SYN;
-    case DLE:
-      ch = readchar (timeout);
-      if (ch == SYN)
-       return RAW_SYN;
-      return ch & ~0100;
-    default:
-      return ch;
-    }
-}
-
-static unsigned char pkt[256 * 2 + 10], *pktp; /* Worst case */
-
-static void
-reset_packet ()
-{
-  pktp = pkt;
-}
-
-static void
-output_packet ()
-{
-  if (SERIAL_WRITE (wiggler_desc, pkt, pktp - pkt))
-    perror_with_name ("output_packet: write failed");
-
-  reset_packet ();
-}
-
-/* Output a quoted character.  SYNs and DLEs are quoted.  Everything else goes
-   through untouched.  */
-
-static void
-put_quoted_char (c)
-     int c;
-{
-  switch (c)
-    {
-    case SYN:
-    case DLE:
-      *pktp++ = DLE;
-      c |= 0100;
-    }
-
-  *pktp++ = c;
-}
-
-/* Send a packet to the Wiggler.  The packet framed by a SYN character, a byte
-   count and a checksum.  The byte count only counts the number of bytes
-   between the count and the checksum.  A count of zero actually means 256.
-   Any SYNs within the packet (including the checksum and count) must be
-   quoted.  The quote character must be quoted as well.  Quoting is done by
-   replacing the character with the two-character sequence DLE, {char} | 0100.
-   Note that the quoting mechanism has no effect on the byte count.
- */
-
-static void
-stu_put_packet (buf, len)
-     unsigned char *buf;
-     int len;
-{
-  unsigned char checksum;
-  unsigned char c;
-
-  if (len == 0 || len > 256)
-    abort ();                  /* Can't represent 0 length packet */
-
-  reset_packet ();
-
-  checksum = 0;
-
-  put_quoted_char (RAW_SYN);
-
-  c = len;
-
-  do
-    {
-      checksum += c;
-
-      put_quoted_char (c);
-
-      c = *buf++;
-    }
-  while (len-- > 0);
-
-  put_quoted_char (-checksum & 0xff);
-
-  output_packet ();
-}
-
-#else
-
-/* Send a packet to the Wiggler.  The packet framed by a SYN character, a byte
-   count and a checksum.  The byte count only counts the number of bytes
-   between the count and the checksum.  A count of zero actually means 256.
-   Any SYNs within the packet (including the checksum and count) must be
-   quoted.  The quote character must be quoted as well.  Quoting is done by
-   replacing the character with the two-character sequence DLE, {char} | 0100.
-   Note that the quoting mechanism has no effect on the byte count.
- */
-
-static void
-put_packet (buf, len)
-     unsigned char *buf;
-     int len;
-{
-  unsigned char checksum;
-  unsigned char c;
-  unsigned char *packet, *packet_ptr;
-
-  packet = alloca (len + 1 + 1); /* packet + SYN + checksum */
-  packet_ptr = packet;
-
-  checksum = 0;
-
-  *packet_ptr++ = 0x55;
-
-  while (len-- > 0)
-    {
-      c = *buf++;
-
-      checksum += c;
-      *packet_ptr++ = c;
-    }
-
-  *packet_ptr++ = -checksum;
-  if (SERIAL_WRITE (wiggler_desc, packet, packet_ptr - packet))
-    perror_with_name ("output_packet: write failed");
-}
-#endif
-
-#if 0
-/* Get a packet from the Wiggler.  Timeout is only enforced for the first byte
-   of the packet.  Subsequent bytes are expected to arrive in time <= 
-   remote_timeout.  Returns a pointer to a static buffer containing the payload
-   of the packet.  *LENP contains the length of the packet.
-*/
-
-static unsigned char *
-stu_get_packet (cmd, lenp, timeout)
-     unsigned char cmd;
-     int *lenp;
-{
-  int ch;
-  int len;
-  static unsigned char buf[256 + 10], *p;
-  unsigned char checksum;
-
- find_packet:
-
-  ch = get_quoted_char (timeout);
-
-  if (ch < 0)
-    error ("get_packet (readchar): %d", ch);
-
-  if (ch != RAW_SYN)
-    goto find_packet;
-
- found_syn:                    /* Found the start of a packet */
-
-  p = buf;
-  checksum = 0;
-
-  len = get_quoted_char (remote_timeout);
-
-  if (len == RAW_SYN)
-    goto found_syn;
-
-  checksum += len;
-
-  if (len == 0)
-    len = 256;
-
-  len++;                       /* Include checksum */
-
-  while (len-- > 0)
-    {
-      ch = get_quoted_char (remote_timeout);
-      if (ch == RAW_SYN)
-       goto found_syn;
-
-      *p++ = ch;
-      checksum += ch;
-    }
-
-  if (checksum != 0)
-    goto find_packet;
-
-  if (cmd != buf[0])
-    error ("Response phase error.  Got 0x%x, expected 0x%x", buf[0], cmd);
-
-  *lenp = p - buf - 1;
-  return buf;
-}
-
-#else
-
-/* Get a packet from the Wiggler.  Timeout is only enforced for the first byte
-   of the packet.  Subsequent bytes are expected to arrive in time <= 
-   remote_timeout.  Returns a pointer to a static buffer containing the payload
-   of the packet.  *LENP contains the length of the packet.
-*/
-
-static unsigned char *
-get_packet (cmd, lenp, timeout)
-     int cmd;
-     int *lenp;
-{
-  int ch;
-  int len;
-  int i;
-  static unsigned char packet[512];
-  unsigned char *packet_ptr;
-  unsigned char checksum;
-
- find_packet:
-
-  ch = readchar (timeout);
-
-  if (ch < 0)
-    error ("get_packet (readchar): %d", ch);
-
-  if (ch != 0x55)
-    goto find_packet;
-
-/* Found the start of a packet */
-
-  packet_ptr = packet;
-  checksum = 0;
-
-/* Read command char.  That sort of tells us how long the packet is. */
-
-  ch = readchar (timeout);
-
-  if (ch < 0)
-    error ("get_packet (readchar): %d", ch);
-
-  *packet_ptr++ = ch;
-  checksum += ch;
-
-/* Get status. */
-
-  ch = readchar (timeout);
-
-  if (ch < 0)
-    error ("get_packet (readchar): %d", ch);
-  *packet_ptr++ = ch;
-  checksum += ch;
-
-/* Get error code. */
-
-  ch = readchar (timeout);
-
-  if (ch < 0)
-    error ("get_packet (readchar): %d", ch);
-  *packet_ptr++ = ch;
-  checksum += ch;
-
-  switch (ch)                  /* Figure out length of packet */
-    {
-    case 0x7:                  /* Write verify error? */
-      len = 8;                 /* write address, value read back */
-      break;
-    case 0x11:                 /* Bus error? */
-                               /* write address, read flag */
-    case 0x15:                 /* Internal error */
-      len = 5;                 /* error code, vector */
-      break;
-    default:                   /* Error w/no params */
-      len = 0;
-    case 0x0:                  /* Normal result */
-      switch (packet[0])
-       {
-       case WIGGLER_AYT:       /* Are You There? */
-       case WIGGLER_SET_BAUD_RATE: /* Set Baud Rate */
-       case WIGGLER_INIT:      /* Initialize wiggler */
-       case WIGGLER_SET_SPEED: /* Set Speed */
-       case WIGGLER_SET_FUNC_CODE: /* Set Function Code */
-       case WIGGLER_SET_CTL_FLAGS: /* Set Control Flags */
-       case WIGGLER_SET_BUF_ADDR: /* Set Register Buffer Address */
-       case WIGGLER_RUN:       /* Run Target from PC  */
-       case WIGGLER_RUN_ADDR:  /* Run Target from Specified Address  */
-       case WIGGLER_STOP:      /* Stop Target */
-       case WIGGLER_RESET_RUN: /* Reset Target and Run */
-       case WIGGLER_RESET:     /* Reset Target and Halt */
-       case WIGGLER_STEP:      /* Single Step */
-       case WIGGLER_WRITE_REGS: /* Write Register */
-       case WIGGLER_WRITE_MEM: /* Write Memory */
-       case WIGGLER_FILL_MEM:  /* Fill Memory */
-       case WIGGLER_MOVE_MEM:  /* Move Memory */
-       case WIGGLER_WRITE_INT_MEM: /* Write Internal Memory */
-       case WIGGLER_JUMP:      /* Jump to Subroutine */
-       case WIGGLER_ERASE_FLASH: /* Erase flash memory */
-       case WIGGLER_PROGRAM_FLASH: /* Write flash memory */
-       case WIGGLER_EXIT_MON:  /* Exit the flash programming monitor  */
-       case WIGGLER_ENTER_MON: /* Enter the flash programming monitor  */
-         len = 0;
-         break;
-       case WIGGLER_GET_VERSION: /* Get Version */
-         len = 4;
-         break;
-       case WIGGLER_GET_STATUS_MASK: /* Get Status Mask */
-         len = 1;
-         break;
-       case WIGGLER_GET_CTRS:  /* Get Error Counters */
-       case WIGGLER_READ_REGS: /* Read Register */
-       case WIGGLER_READ_MEM:  /* Read Memory */
-       case WIGGLER_READ_INT_MEM: /* Read Internal Memory */
-         len = 257;
-         break;
-       default:
-         fprintf_filtered (gdb_stderr, "Unknown packet type 0x%x\n", ch);
-         goto find_packet;
-       }
-    }
-
-  if (len == 257)              /* Byte stream? */
-    {                          /* Yes, byte streams contain the length */
-      ch = readchar (timeout);
-
-      if (ch < 0)
-       error ("get_packet (readchar): %d", ch);
-      *packet_ptr++ = ch;
-      checksum += ch;
-      len = ch;
-      if (len == 0)
-       len = 256;
-    }
-
-  while (len-- >= 0)           /* Do rest of packet and checksum */
-    {
-      ch = readchar (timeout);
-
-      if (ch < 0)
-       error ("get_packet (readchar): %d", ch);
-      *packet_ptr++ = ch;
-      checksum += ch;
-    }
-
-  if (checksum != 0)
-    goto find_packet;
-
-  if (cmd != -1 && cmd != packet[0])
-    error ("Response phase error.  Got 0x%x, expected 0x%x", packet[0], cmd);
-
-  *lenp = packet_ptr - packet - 1; /* Subtract checksum byte */
-  return packet;
-}
-#endif
-
-/* Execute a simple (one-byte) command.  Returns a pointer to the data
-   following the error code.  */
-
-static unsigned char *
-do_command (cmd, statusp, lenp)
-     int cmd;
-     int *statusp;
-     int *lenp;
-{
-  unsigned char buf[100], *p;
-  int status, error_code;
-  char errbuf[100];
-
-  buf[0] = cmd;
-  put_packet (buf, 1);         /* Send command */
-  p = get_packet (*buf, lenp, remote_timeout);
-
-  if (*lenp < 3)
-    error ("Truncated response packet from Wiggler");
-
-  status = p[1];
-  error_code = p[2];
-
-  if (error_code != 0)
-    {
-      sprintf (errbuf, "do_command (0x%x):", cmd);
-      wiggler_error (errbuf, error_code);
-    }
-
-  if (status & WIGGLER_FLAG_PWF)
-    error ("Wiggler can't detect VCC at BDM interface.");
-  else if (status & WIGGLER_FLAG_CABLE_DISC)
-    error ("BDM cable appears to be disconnected.");
-
-  *statusp = status;
-
-  return p + 3;
-}
-\f
-static void
-wiggler_kill ()
-{
-  /* For some mysterious reason, wait_for_inferior calls kill instead of
-     mourn after it gets TARGET_WAITKIND_SIGNALLED.  Work around it.  */
-  if (kill_kludge)
-    {
-      kill_kludge = 0;
-      target_mourn_inferior ();
-      return;
-    }
-
-  /* Don't wait for it to die.  I'm not really sure it matters whether
-     we do or not.  */
-  target_mourn_inferior ();
-}
-
-static void
-wiggler_mourn ()
-{
-  unpush_target (&wiggler_ops);
-  generic_mourn_inferior ();
-}
-
-/* All we actually do is set the PC to the start address of exec_bfd, and start
-   the program at that point.  */
-
-static void
-wiggler_create_inferior (exec_file, args, env)
-     char *exec_file;
-     char *args;
-     char **env;
-{
-  if (args && (*args != '\000'))
-    error ("Args are not supported by BDM.");
-
-  clear_proceed_status ();
-  proceed (bfd_get_start_address (exec_bfd), TARGET_SIGNAL_0, 0);
-}
-
-static void
-wiggler_load (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  generic_load (args, from_tty);
-
-  inferior_pid = 0;
-
-/* This is necessary because many things were based on the PC at the time that
-   we attached to the monitor, which is no longer valid now that we have loaded
-   new code (and just changed the PC).  Another way to do this might be to call
-   normal_stop, except that the stack may not be valid, and things would get
-   horribly confused... */
-
-  clear_symtab_users ();
-}
-
-/* BDM (at least on CPU32) uses a different breakpoint */
-
-static int
-wiggler_insert_breakpoint (addr, contents_cache)
-     CORE_ADDR addr;
-     char *contents_cache;
-{
-  static char break_insn[] = {BDM_BREAKPOINT};
-  int val;
-
-  val = target_read_memory (addr, contents_cache, sizeof break_insn);
-
-  if (val == 0)
-    val = target_write_memory (addr, break_insn, sizeof break_insn);
-
-  return val;
-}
-
-static void
-bdm_command (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  error ("bdm command must be followed by `reset'");
-}
-
-static void
-bdm_reset_command (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  int status, pktlen;
-
-  if (!wiggler_desc)
-    error ("Not connected to wiggler.");
-
-  do_command (WIGGLER_RESET, &status, &pktlen);
-  dcache_flush (wiggler_dcache);
-  registers_changed ();
-}
-
-static void
-bdm_restart_command (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  int status, pktlen;
-
-  if (!wiggler_desc)
-    error ("Not connected to wiggler.");
-
-  do_command (WIGGLER_RESET_RUN, &status, &pktlen);
-  last_run_status = status;
-  clear_proceed_status ();
-  wait_for_inferior ();
-  normal_stop ();
-}
-
-static int
-flash_xfer_memory (memaddr, myaddr, len, should_write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int should_write;
-     struct target_ops *target;                        /* ignored */
-{
-  char buf[256 + 10];
-  unsigned char *p;
-  int origlen;
-
-  if (!should_write)
-    abort ();
-
-  origlen = len;
-
-  buf[0] = WIGGLER_PROGRAM_FLASH;
-
-  while (len > 0)
-    {
-      int numbytes;
-      int pktlen;
-      int status, error_code;
-
-      numbytes = min (len, 256 - 6);
-
-      buf[1] = memaddr >> 24;
-      buf[2] = memaddr >> 16;
-      buf[3] = memaddr >> 8;
-      buf[4] = memaddr;
-
-      buf[5] = numbytes;
-
-      memcpy (&buf[6], myaddr, numbytes);
-      put_packet (buf, 6 + numbytes);
-      p = get_packet (WIGGLER_PROGRAM_FLASH, &pktlen, remote_timeout);
-      if (pktlen < 3)
-       error ("Truncated response packet from Wiggler");
-
-      status = p[1];
-      error_code = p[2];
-
-      if (error_code != 0)     
-       wiggler_error ("flash_xfer_memory:", error_code);
-
-      len -= numbytes;
-      memaddr += numbytes;
-      myaddr += numbytes;
-    }
-
-  return origlen - len;
-}
-
-static void
-bdm_update_flash_command (args, from_tty)
-     char *args;
-     int from_tty;
-{
-  int status, pktlen;
-  struct cleanup *old_chain;
-
-  if (!wiggler_desc)
-    error ("Not connected to wiggler.");
-
-  if (!args)
-    error ("Must specify file containing new Wiggler code.");
-
-/*  old_chain = make_cleanup (flash_cleanup, 0);*/
-
-  do_command (WIGGLER_ENTER_MON, &status, &pktlen);
-
-  do_command (WIGGLER_ERASE_FLASH, &status, &pktlen);
-
-  wiggler_ops.to_xfer_memory = flash_xfer_memory;
-
-  generic_load (args, from_tty);
-
-  wiggler_ops.to_xfer_memory = wiggler_xfer_memory;
-
-  do_command (WIGGLER_EXIT_MON, &status, &pktlen);
-
-/*  discard_cleanups (old_chain);*/
-}
-\f
-/* Define the target subroutine names */
-
-struct target_ops wiggler_ops = {
-  "wiggler",                   /* to_shortname */
-  "",                          /* to_longname */
-  "",                          /* to_doc */
-  wiggler_open,                        /* to_open */
-  wiggler_close,               /* to_close */
-  NULL,                                /* to_attach */
-  wiggler_detach,              /* to_detach */
-  wiggler_resume,              /* to_resume */
-  wiggler_wait,                        /* to_wait */
-  wiggler_fetch_registers,     /* to_fetch_registers */
-  wiggler_store_registers,     /* to_store_registers */
-  wiggler_prepare_to_store,    /* to_prepare_to_store */
-  wiggler_xfer_memory,         /* to_xfer_memory */
-  wiggler_files_info,          /* to_files_info */
-  wiggler_insert_breakpoint,   /* to_insert_breakpoint */
-  memory_remove_breakpoint,    /* to_remove_breakpoint */
-  NULL,                                /* to_terminal_init */
-  NULL,                                /* to_terminal_inferior */
-  NULL,                                /* to_terminal_ours_for_output */
-  NULL,                                /* to_terminal_ours */
-  NULL,                                /* to_terminal_info */
-  wiggler_kill,                        /* to_kill */
-  wiggler_load,                        /* to_load */
-  NULL,                                /* to_lookup_symbol */
-  wiggler_create_inferior,     /* to_create_inferior */
-  wiggler_mourn,               /* to_mourn_inferior */
-  0,                           /* to_can_run */
-  0,                           /* to_notice_signals */
-  wiggler_thread_alive,                /* to_thread_alive */
-  0,                           /* to_stop */
-  process_stratum,             /* to_stratum */
-  NULL,                                /* to_next */
-  1,                           /* to_has_all_memory */
-  1,                           /* to_has_memory */
-  1,                           /* to_has_stack */
-  1,                           /* to_has_registers */
-  1,                           /* to_has_execution */
-  NULL,                                /* sections */
-  NULL,                                /* sections_end */
-  OPS_MAGIC                    /* to_magic */
-};
-
-void
-_initialize_remote_wiggler ()
-{
-  extern struct cmd_list_element *cmdlist;
-  static struct cmd_list_element *bdm_cmd_list = NULL;
-
-  add_target (&wiggler_ops);
-
-  add_show_from_set (add_set_cmd ("remotetimeout", no_class,
-                                 var_integer, (char *)&remote_timeout,
-                                 "Set timeout value for remote read.\n", &setlist),
-                    &showlist);
-
-  add_prefix_cmd ("bdm", class_obscure, bdm_command, "", &bdm_cmd_list, "bdm ",
-                 0, &cmdlist);
-
-  add_cmd ("reset", class_obscure, bdm_reset_command, "", &bdm_cmd_list);
-  add_cmd ("restart", class_obscure, bdm_restart_command, "", &bdm_cmd_list);
-  add_cmd ("update-flash", class_obscure, bdm_update_flash_command, "", &bdm_cmd_list);
-}
diff --git a/gdb/ser-ocd.c b/gdb/ser-ocd.c
new file mode 100644 (file)
index 0000000..d3f1c8e
--- /dev/null
@@ -0,0 +1,174 @@
+/* Remote serial interface for Macraigor Systems implementation of
+       On-Chip Debugging using serial target box or serial wiggler
+
+   Copyright 1994, 1997 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "defs.h"
+#include "serial.h"
+
+static int ser_ocd_open PARAMS ((serial_t scb, const char *name));
+static void ser_ocd_raw PARAMS ((serial_t scb));
+static int ser_ocd_readchar PARAMS ((serial_t scb, int timeout));
+static int ser_ocd_setbaudrate PARAMS ((serial_t scb, int rate));
+static int ser_ocd_write PARAMS ((serial_t scb, const char *str, int len));
+static void ser_ocd_close PARAMS ((serial_t scb));
+static serial_ttystate ser_ocd_get_tty_state PARAMS ((serial_t scb));
+static int ser_ocd_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
+
+static int
+ocd_open (scb, name)
+     serial_t scb;
+     const char *name;
+{
+  return 0;
+}
+
+static int
+ocd_noop (scb)
+     serial_t scb;
+{
+  return 0;
+}
+
+static void
+ocd_raw (scb)
+     serial_t scb;
+{
+  /* Always in raw mode */
+}
+
+/* We need a buffer to store responses from the Wigglers.dll */
+char * from_wigglers_buffer;
+char * bptr;                   /* curr spot in buffer */
+
+static void
+ocd_readremote ()
+{
+}
+
+static int
+ocd_readchar (scb, timeout)
+     serial_t scb;
+     int timeout;
+{
+
+}
+
+struct ocd_ttystate {
+  int dummy;
+};
+
+/* ocd_{get set}_tty_state() are both dummys to fill out the function
+   vector.  Someday, they may do something real... */
+
+static serial_ttystate
+ocd_get_tty_state (scb)
+     serial_t scb;
+{
+  struct ocd_ttystate *state;
+
+  state = (struct ocd_ttystate *) xmalloc (sizeof *state);
+
+  return (serial_ttystate) state;
+}
+
+static int
+ocd_set_tty_state (scb, ttystate)
+     serial_t scb;
+     serial_ttystate ttystate;
+{
+  return 0;
+}
+
+static int
+ocd_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
+     serial_t scb;
+     serial_ttystate new_ttystate;
+     serial_ttystate old_ttystate;
+{
+  return 0;
+}
+
+static void
+ocd_print_tty_state (scb, ttystate)
+     serial_t scb;
+     serial_ttystate ttystate;
+{
+  /* Nothing to print.  */
+  return;
+}
+
+static int
+ocd_setbaudrate (scb, rate)
+     serial_t scb;
+     int rate;
+{
+  return 0;
+}
+
+static int
+ocd_write (scb, str, len)
+     serial_t scb;
+     const char *str;
+     int len;
+{
+  char c;
+
+  ocd_readremote();
+
+#ifdef __CYGWIN32__ 
+  /* send packet to Wigglers.dll and store response so we can give it to
+       remote-wiggler.c when get_packet is run */
+  do_command (str, from_wigglers_buffer);
+#endif
+
+  return 0;
+}
+
+static void
+ocd_close (scb)
+     serial_t scb;
+{
+  wiggler_close (0);
+}
+
+static struct serial_ops ocd_ops =
+{
+  "ocd",
+  0,
+  ocd_open,
+  ocd_close,
+  ocd_readchar,
+  ocd_write,
+  ocd_noop,            /* flush output */
+  ocd_noop,            /* flush input */
+  ocd_noop,            /* send break -- currently used only for nindy */
+  ocd_raw,
+  ocd_get_tty_state,
+  ocd_set_tty_state,
+  ocd_print_tty_state,
+  ocd_noflush_set_tty_state,
+  ocd_setbaudrate,
+};
+
+void
+_initialize_ser_ocd_bdm ()
+{
+  serial_add_interface (&ocd_ops);
+}
diff --git a/gdb/wigglers.def b/gdb/wigglers.def
new file mode 100644 (file)
index 0000000..f29a100
--- /dev/null
@@ -0,0 +1,3 @@
+EXPORTS
+do_command
+test_command