Browse Source

20000317 sourceware import

sh3port_dev
Ranjith Kumaran 22 years ago
parent
commit
03261851a1
  1. 3007
      libgloss/ChangeLog
  2. 185
      libgloss/Makefile.in
  3. 5
      libgloss/README
  4. 25
      libgloss/close.c
  5. 31
      libgloss/config/default.mh
  6. 33
      libgloss/config/default.mt
  7. 57
      libgloss/config/dos.mh
  8. 31
      libgloss/config/mips.mt
  9. 3
      libgloss/config/mn10200.mt
  10. 3
      libgloss/config/mn10300.mt
  11. 35
      libgloss/config/ppc.mh
  12. 1403
      libgloss/configure
  13. 168
      libgloss/configure.in
  14. 128
      libgloss/d30v/Makefile.in
  15. 1191
      libgloss/d30v/configure
  16. 90
      libgloss/d30v/configure.in
  17. 56
      libgloss/d30v/crt0.S
  18. 24
      libgloss/d30v/inbyte.c
  19. 21
      libgloss/d30v/outbyte.c
  20. 146
      libgloss/d30v/syscalls.c
  21. 848
      libgloss/debug.c
  22. 150
      libgloss/debug.h
  23. 147
      libgloss/doc/Makefile.in
  24. 887
      libgloss/doc/configure
  25. 15
      libgloss/doc/configure.in
  26. 2053
      libgloss/doc/porting.texi
  27. 143
      libgloss/fr30/Makefile.in
  28. 1219
      libgloss/fr30/configure
  29. 75
      libgloss/fr30/configure.in
  30. 46
      libgloss/fr30/crt0.s
  31. 162
      libgloss/fr30/syscalls.c
  32. 30
      libgloss/fstat.c
  33. 25
      libgloss/getpid.c
  34. 31
      libgloss/glue.h
  35. 215
      libgloss/hp74x/Makefile.in
  36. 156
      libgloss/hp74x/README
  37. 150
      libgloss/hp74x/checksum.c
  38. 991
      libgloss/hp74x/configure
  39. 34
      libgloss/hp74x/configure.in
  40. 177
      libgloss/hp74x/crt0.s
  41. 127
      libgloss/hp74x/debugger.h
  42. 585
      libgloss/hp74x/debugger.s
  43. 168
      libgloss/hp74x/diagnose.h
  44. 123
      libgloss/hp74x/hppa-defs.h
  45. 64
      libgloss/hp74x/hppa.ld
  46. 338
      libgloss/hp74x/io.c
  47. 164
      libgloss/hp74x/iva_table.h
  48. 996
      libgloss/hp74x/iva_table.s
  49. 698
      libgloss/hp74x/pa_stub.c
  50. 47
      libgloss/hp74x/test.c
  51. 126
      libgloss/i386/Makefile.in
  52. 1203
      libgloss/i386/configure
  53. 110
      libgloss/i386/configure.in
  54. 82
      libgloss/i386/cygmon-crt0.S
  55. 362
      libgloss/i386/cygmon-gmon.c
  56. 35
      libgloss/i386/cygmon-gmon.h
  57. 165
      libgloss/i386/cygmon-salib.c
  58. 96
      libgloss/i386/cygmon-syscall.h
  59. 88
      libgloss/i386/cygmon.ld
  60. 142
      libgloss/i960/Makefile.in
  61. 17
      libgloss/i960/asm.h
  62. 1219
      libgloss/i960/configure
  63. 75
      libgloss/i960/configure.in
  64. 66
      libgloss/i960/crt0.c
  65. 18
      libgloss/i960/mon-read.c
  66. 30
      libgloss/i960/mon-syscalls.S
  67. 14
      libgloss/i960/mon-write.c
  68. 83
      libgloss/i960/mon960.c
  69. 36
      libgloss/i960/mon960.ld
  70. 51
      libgloss/i960/syscall.h
  71. 27
      libgloss/isatty.c
  72. 28
      libgloss/kill.c
  73. 144
      libgloss/libnosys/Makefile.in
  74. 23
      libgloss/libnosys/acconfig.h
  75. 21
      libgloss/libnosys/close.c
  76. 19
      libgloss/libnosys/config.h.in
  77. 1439
      libgloss/libnosys/configure
  78. 206
      libgloss/libnosys/configure.in
  79. 6
      libgloss/libnosys/environ.c
  80. 23
      libgloss/libnosys/execve.c
  81. 21
      libgloss/libnosys/fork.c
  82. 24
      libgloss/libnosys/fstat.c
  83. 21
      libgloss/libnosys/getpid.c
  84. 27
      libgloss/libnosys/gettod.c
  85. 21
      libgloss/libnosys/isatty.c
  86. 22
      libgloss/libnosys/kill.c
  87. 22
      libgloss/libnosys/link.c
  88. 23
      libgloss/libnosys/lseek.c
  89. 23
      libgloss/libnosys/open.c
  90. 23
      libgloss/libnosys/read.c
  91. 27
      libgloss/libnosys/sbrk.c
  92. 24
      libgloss/libnosys/stat.c
  93. 22
      libgloss/libnosys/times.c
  94. 21
      libgloss/libnosys/unlink.c
  95. 21
      libgloss/libnosys/wait.c
  96. 39
      libgloss/libnosys/warning.h
  97. 24
      libgloss/libnosys/write.c
  98. 31
      libgloss/lseek.c
  99. 144
      libgloss/m32r/Makefile.in
  100. 10
      libgloss/m32r/chmod.c

3007
libgloss/ChangeLog

File diff suppressed because it is too large

185
libgloss/Makefile.in

@ -0,0 +1,185 @@
# Top level makefile for libgloss
#
# Copyright (c) 1995, 1996 Cygnus Support
#
# The authors hereby grant permission to use, copy, modify, distribute,
# and license this software and its documentation for any purpose, provided
# that existing copyright notices are retained in all copies and that this
# notice is included verbatim in any distributions. No written agreement,
# license, or royalty fee is required for any of the authorized uses.
# Modifications to this software may be copyrighted by their authors
# and need not follow the licensing terms described here, provided that
# the new terms are clearly indicated on the first page of each file where
# they apply.
#
VPATH = @srcdir@
srcdir = @srcdir@
objdir = .
srcroot = $(srcdir)/../..
objroot = $(objdir)/../..
prefix = @prefix@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
target_alias = @target_alias@
bindir = @bindir@
libdir = @libdir@
tooldir = $(exec_prefix)/$(target_alias)
TOP = .
SRCTOP = .
# Multilib support variables.
# TOP is used instead of MULTI{BUILD,SRC}TOP.
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
SHELL = /bin/sh
CC = @CC@
AS = @AS@
AR = @AR@
LD = @LD@
RANLIB = @RANLIB@
AR_FLAGS = qv
BISON = bison
MAKEINFO = makeinfo
SUBDIRS = @subdirs@
.NOEXPORT:
MAKEOVERRIDES=
# Host specific makefile fragment comes in here.
@host_makefile_frag@
# These are roughly topologically sorted in order to make porting more
# streamlined.
FLAGS_TO_PASS = \
"CC=$(CC)" \
"CFLAGS=$(CFLAGS)" \
"AR=$(AR)" \
"RANLIB=$(RANLIB)" \
"AR_FLAGS=$(AR_FLAGS)" \
"MAKEINFO=$(MAKEINFO)" \
"AS=$(AS)" \
"LD=$(LD)" \
"CROSS_CFLAGS=$(CROSS_CFLAGS)" \
"TARGET_CFLAGS=$(TARGET_CFLAGS)" \
"exec_prefix=$(exec_prefix)" \
"prefix=$(prefix)" \
"tooldir=$(tooldir)" \
"INSTALL=$(INSTALL)" \
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
"INSTALL_DATA=$(INSTALL_DATA)"
all: stmp-bsp force
@rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
stmp-bsp: force
@rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
for dir in .. ${SUBDIRS}; do \
if [ x$$dir != x.. ]; then \
if [ -d $$dir ]; then \
(cd $$dir; $(MAKE) $(FLAGS_TO_PASS)); \
else true; fi; \
else true; fi; \
done
install: force
@rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
for dir in .. ${SUBDIRS}; do \
if [ x$$dir != x.. ]; then \
if [ -d $$dir ]; then \
(cd $$dir; $(MAKE) $(FLAGS_TO_PASS) install); \
else true; fi; \
else true; fi; \
done
@rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
test: force
@rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
for dir in .. ${SUBDIRS}; do \
if [ x$$dir != x.. ]; then \
if [ -d $$dir ]; then \
(cd $$dir; $(MAKE) $(FLAGS_TO_PASS) test); \
else true; fi; \
else true; fi; \
done
@rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=test
clean-here:
-rm -f *~ core *.o a.out xgdb *.x
clean mostlyclean: clean-here
rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
$(MAKE) DO=$@ DODIRS="$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do; \
$(MULTICLEAN) multi-clean DO=$@
distclean maintainer-clean realclean: clean-here
-rm -f Makefile config.cache config.log config.status
-rm -f *-init.exp site.*
-rm -fr *.log summary detail *.sum
rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
$(MAKE) DO=$@ DODIRS="$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do; \
$(MULTICLEAN) multi-clean DO=$@
.PHONY: info install-info clean-info
subdir_do:
@rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
for i in .. $(DODIRS); do \
if [ x$$i != x.. ]; then \
if [ -f ./$$i/Makefile ]; then \
if (cd ./$$i; $(MAKE) $(FLAGS_TO_PASS) $(DO)); then \
true; \
else \
exit 1; \
fi; \
else true; fi; \
else true; fi; \
done
info dvi docs:
rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
$(MAKE) DO=$@ DODIRS=doc $(FLAGS_TO_PASS) subdir_do
install-info:
rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
$(MAKE) DO=$@ DODIRS=doc $(FLAGS_TO_PASS) subdir_do
clean-info:
force:
Makefile: Makefile.in config.status @host_makefile_frag_path@
$(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck

5
libgloss/README

@ -0,0 +1,5 @@
sparc - Fujitsu Sparclite board. Works on the ex930, ex931, ex933
hp74x - Hewlett Packard HP742 board. Also some support for the hp743.
m68k - Motorola MVME135 and IDP board. For CPU32 systems.
pa - WinBond and Oki boards with a PA.
mips - R3000 support. Array Tech LSI33k based RAID disk controller.

25
libgloss/close.c

@ -0,0 +1,25 @@
/* close.c -- close a file descriptor.
*
* Copyright (c) 1995 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "glue.h"
/*
* close -- We don't need to do anything, but pretend we did.
*/
int
_DEFUN (close ,(fd),
int fd)
{
return (0);
}

31
libgloss/config/default.mh

@ -0,0 +1,31 @@
NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
INCLUDES = -I. -I$(srcdir)/..
# Note that when building the library, ${MULTILIB} is not the way multilib
# options are passed; they're passed in $(CFLAGS).
CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
LDFLAGS_FOR_TARGET = ${MULTILIB} ${NEWLIB_LDFLAGS}
AR_FLAGS = qc
.c.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.C.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.s.o:
$(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $<
#
# GCC knows to run the preprocessor on .S files before it assembles them.
#
.S.o:
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $<
#
# this is a bogus target that'll produce an assembler from the
# C source with the right compiler options. this is so we can
# track down code generation or debug symbol bugs.
#
.c.s:
$(CC) $(CFLAGS_FOR_TARGET) -S $(INCLUDES) $(CFLAGS) $<

33
libgloss/config/default.mt

@ -0,0 +1,33 @@
#
# these are the minimum required stubs to support newlib
#
close.o: ${srcdir}/../close.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
fstat.o: ${srcdir}/../fstat.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
getpid.o: ${srcdir}/../getpid.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
isatty.o: ${srcdir}/../isatty.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
kill.o: ${srcdir}/../kill.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
lseek.o: ${srcdir}/../lseek.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
open.o: ${srcdir}/../open.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
print.o: ${srcdir}/../print.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
putnum.o: ${srcdir}/../putnum.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
read.o: ${srcdir}/../read.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
sbrk.o: ${srcdir}/../sbrk.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
stat.o: ${srcdir}/../stat.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
unlink.o: ${srcdir}/../unlink.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
write.o: ${srcdir}/../write.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
debug.o: ${srcdir}/../debug.c ${srcdir}/../debug.h
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) ${srcdir}/../debug.c

57
libgloss/config/dos.mh

@ -0,0 +1,57 @@
NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/; fi`
INCLUDES = -I.
# Note that when building the library, ${MULTILIB} is not the way multilib
# options are passed; they're passed in $(CFLAGS).
CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
LDFLAGS_FOR_TARGET = ${MULTILIB} ${NEWLIB_LDFLAGS}
ARFLAGS_FOR_TARGET = qc
# find the tools used to build libgloss. As this is a DOS build in a
# 3way cross, we have to specify the name as it lives prebuilt in Unix
# land. The freshly built tools are for the wrong architecture.
CC_FOR_TARGET = `t='$(program_transform_name)'; echo gcc | sed -e $$t`
AS_FOR_TARGET = `t='$(program_transform_name)'; echo as | sed -e $$t`
AR_FOR_TARGET = `t='$(program_transform_name)'; echo ar | sed -e $$t`
LD_FOR_TARGET = `t='$(program_transform_name)'; echo ld | sed -e $$t`
RANLIB_FOR_TARGET = `t='$(program_transform_name)'; echo ranlib | sed -e $$t`
OBJDUMP_FOR_TARGET = `t='$(program_transform_name)'; echo objdump | sed -e $$t`
OBJCOPY_FOR_TARGET = `t='$(program_transform_name)'; echo objcopy | sed -e $$t`
# Using CFLAGS here may be confusing if the user has given a special
# CFLAGS intended for use on the host, since we are passing it to the
# cross-compiler; I'm not sure what to do about this. INCLUDES is
# from the top level Makefile.
# FIXME: But isn't CFLAGS what is used to pass multilib options when
# building the library?
.c.o:
rootme=`pwd` ; \
echo CC_FOR_TARGET is ${CC_FOR_TARGET} ; \
$(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
.c.s:
rootme=`pwd` ; \
echo CC_FOR_TARGET is ${CC_FOR_TARGET} ; \
$(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) -S $(INCLUDES) $<
.S.o:
rootme=`pwd` ; \
echo CC_FOR_TARGET is ${CC_FOR_TARGET} ; \
$(CC_FOR_TARGET) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
.s.o:
rootme=`pwd` ; \
echo AS_FOR_TARGET is ${AS_FOR_TARGET} ; \
$(AS_FOR_TARGET) $(ASFLAGS_FOR_TARGET) $(INCLUDES) -o $*.o $<

31
libgloss/config/mips.mt

@ -0,0 +1,31 @@
#
# These are the minimum required stubs to support newlib
# for embedded MIPS targets. Note that although read.o and write.o
# are mentioned here, they are not used for all targets.
#
close.o: ${srcdir}/../close.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
fstat.o: ${srcdir}/../fstat.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
getpid.o: ${srcdir}/../getpid.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
isatty.o: ${srcdir}/../isatty.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
kill.o: ${srcdir}/../kill.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
lseek.o: ${srcdir}/../lseek.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
open.o: ${srcdir}/../open.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
print.o: ${srcdir}/../print.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
putnum.o: ${srcdir}/../putnum.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
read.o: ${srcdir}/../read.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
stat.o: ${srcdir}/../stat.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
unlink.o: ${srcdir}/../unlink.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
write.o: ${srcdir}/../write.c
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?

3
libgloss/config/mn10200.mt

@ -0,0 +1,3 @@
# Dummy target-specific Makefile fragment for MN10200. We can't
# use default.mt because it refers to generic source files whose
# names conflict with the MN10200-specific sources.

3
libgloss/config/mn10300.mt

@ -0,0 +1,3 @@
# Dummy target-specific Makefile fragment for MN10300. We can't
# use default.mt because it refers to generic source files whose
# names conflict with the MN10300-specific sources.

35
libgloss/config/ppc.mh

@ -0,0 +1,35 @@
NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
# For the PowerPC, always add -mrelocatable-lib -mno-eabi. These are set for the
# multilibs, but are ignored when building the toplevel directory.
CFLAGS_MRELOCATABLE = -mrelocatable-lib -mno-eabi
INCLUDES = -I. -I$(srcdir)/..
# Note that when building the library, ${MULTILIB} is not the way multilib
# options are passed; they're passed in $(CFLAGS).
CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
LDFLAGS_FOR_TARGET = ${MULTILIB} ${NEWLIB_LDFLAGS}
AR_FLAGS = qc
.c.o:
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS_MRELOCATABLE) -O2 $(INCLUDES) -c $(CFLAGS) $<
.C.o:
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS_MRELOCATABLE) -O2 $(INCLUDES) -c $(CFLAGS) $<
.s.o:
$(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $<
#
# GCC knows to run the preprocessor on .S files before it assembles them.
#
.S.o:
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS_MRELOCATABLE) $(INCLUDES) $(CFLAGS) -c $<
#
# this is a bogus target that'll produce an assembler from the
# C source with the right compiler options. this is so we can
# track down code generation or debug symbol bugs.
#
.c.s:
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS_MRELOCATABLE) -S $(INCLUDES) $(CFLAGS) $<

1403
libgloss/configure

File diff suppressed because it is too large

168
libgloss/configure.in

@ -0,0 +1,168 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.7)dnl
AC_INIT(README)
if test "${enable_shared}" = "yes" ; then
echo "Shared libraries not supported for cross compiling, ignored"
fi
if test "${srcdir}" = "." ; then
if test "${with_target_subdir}" != "." ; then
libgloss_topdir="${srcdir}/${with_multisrctop}../.."
else
libgloss_topdir="${srcdir}/${with_multisrctop}.."
fi
else
libgloss_topdir="${srcdir}/.."
fi
AC_CONFIG_AUX_DIR($libgloss_topdir)
AC_PROG_INSTALL
AC_CANONICAL_SYSTEM
if test -z "${with_multisubdir}" ; then
configdirs="doc libnosys"
else
configdirs="libnosys"
fi
case "${target}" in
i386-*-elf*)
configdirs="${configdirs} i386 testsuite";
;;
m32r-*-*)
configdirs="${configdirs} m32r testsuite"
;;
m68*-*-*)
configdirs="${configdirs} m68k testsuite"
;;
hppa*-*-pro*)
configdirs="${configdirs} pa testsuite"
;;
i960-*-coff)
configdirs="${configdirs} i960 testsuite"
;;
sparc-*-elf*)
configdirs="${configdirs} sparc testsuite"
;;
sparc64-*-elf*)
configdirs="${configdirs} sparc testsuite"
;;
sparc86x-*-*)
configdirs="${configdirs} sparc testsuite"
;;
sparclite-*-*)
configdirs="${configdirs} sparc testsuite"
;;
sparclet-*-aout*)
configdirs="${configdirs} sparc sparc/libsys testsuite"
;;
*arm-wince-pe)
configdirs="wince"
;;
sh*-*-pe)
configdirs="wince"
;;
mips*-*-pe)
configdirs="wince"
;;
mips*-*-*)
configdirs="${configdirs} mips testsuite"
;;
powerpc-*-*|powerpcle-*-*)
configdirs="${configdirs} rs6000 testsuite"
;;
mn10200-*-*)
configdirs="${configdirs} mn10200 testsuite"
;;
mn10300-*-*)
configdirs="${configdirs} mn10300 testsuite"
;;
d30v-*-*)
configdirs="${configdirs} d30v testsuite"
;;
fr30-*-*)
configdirs="${configdirs} fr30 testsuite"
;;
mcore-*-*)
configdirs="${configdirs} mcore testsuite"
;;
esac
# temporarily strip out testsuite
configdirs=`echo $configdirs | sed 's/testsuite//'`
AC_CONFIG_SUBDIRS($configdirs)
# FIXME: We temporarily define our own version of AC_PROG_CC. This is
# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
# are probably using a cross compiler, which will not be able to fully
# link an executable. This should really be fixed in autoconf
# itself.
AC_DEFUN(LIB_AC_PROG_CC,
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_PROG_CC_GNU
if test $ac_cv_prog_gcc = yes; then
GCC=yes
dnl Check whether -g works, even if CFLAGS is set, in case the package
dnl plays around with CFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
AC_PROG_CC_G
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-O2"
fi
else
GCC=
test "${CFLAGS+set}" = set || CFLAGS="-g"
fi
])
LIB_AC_PROG_CC
AS=${AS-as}
AC_SUBST(AS)
AC_CHECK_PROG(AR, ar, ar, :)
AR=${AR-ar}
AC_SUBST(AR)
LD=${LD-ld}
AC_SUBST(LD)
AC_PROG_RANLIB
host_makefile_frag=${srcdir}/config/default.mh
dnl We have to assign the same value to other variables because autoconf
dnl doesn't provide a mechanism to substitute a replacement keyword with
dnl arbitrary data or pathnames.
dnl
host_makefile_frag_path=$host_makefile_frag
AC_SUBST(host_makefile_frag_path)
AC_SUBST_FILE(host_makefile_frag)
# for now, only add multilibs for specific targets
AC_OUTPUT(Makefile,
. ${libgloss_topdir}/config-ml.in,
srcdir=${srcdir}
target=${target}
with_multisubdir=${with_multisubdir}
ac_configure_args="--enable-multilib ${ac_configure_args}"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
libgloss_topdir=${libgloss_topdir}
)

128
libgloss/d30v/Makefile.in

@ -0,0 +1,128 @@
# Copyright (c) 1997 Cygnus Support
#
# The authors hereby grant permission to use, copy, modify, distribute,
# and license this software and its documentation for any purpose, provided
# that existing copyright notices are retained in all copies and that this
# notice is included verbatim in any distributions. No written agreement,
# license, or royalty fee is required for any of the authorized uses.
# Modifications to this software may be copyrighted by their authors
# and need not follow the licensing terms described here, provided that
# the new terms are clearly indicated on the first page of each file where
# they apply.
#
#
# This currently works with the D30V simulator.
#
VPATH = @srcdir@ @srcdir@/..
srcdir = @srcdir@
objdir = .
srcroot = $(srcdir)/../..
objroot = $(objdir)/../..
prefix = @prefix@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
target_alias = @target_alias@
bindir = @bindir@
libdir = @libdir@
tooldir = $(exec_prefix)/$(target_alias)
# Multilib support variables.
# TOP is used instead of MULTI{BUILD,SRC}TOP.
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
SHELL = /bin/sh
CC = @CC@
AS = @AS@
AR = @AR@
LD = @LD@
RANLIB = @RANLIB@
OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \
then echo ${objroot}/../binutils/objdump ; \
else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi`
OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
then echo ${objroot}/../binutils/objcopy ; \
else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
OBJS = isatty.o print.o putnum.o sbrk.o
CFLAGS = -g
SCRIPTS = ${SIM_SCRIPTS}
# Here is all of the simulator stuff
SIM_SCRIPTS =
SIM_LDFLAGS =
SIM_BSP = libsim.a
SIM_CRT0 = crt0.o
SIM_OBJS = syscalls.o outbyte.o inbyte.o
SIM_TEST =
SIM_INSTALL = install-sim
# Host specific makefile fragment comes in here.
@host_makefile_frag@
#
# build a test program for each target board. Just trying to get
# it to link is a good test, so we ignore all the errors for now.
#
all: ${SIM_CRT0} ${SIM_BSP}
#
# here's where we build the board support packages for each target
#
${SIM_BSP}: ${OBJS} ${SIM_OBJS}
${AR} ${ARFLAGS} $@ ${SIM_OBJS} ${OBJS}
${RANLIB} $@
#
# here's where we build the test programs for each target
#
.PHONY: test
test: ${SIM_TEST}
crt0.o: crt0.S
syscalls.o: syscalls.c $(srcdir)/../syscall.h
outbyte.o: outbyte.c
inbyte.o: inbyte.c
isatty.o: $(srcdir)/../isatty.c
print.o: $(srcdir)/../print.c
putnum.o: $(srcdir)/../putnum.c
sbrk.o: $(srcdir)/../sbrk.c
clean mostlyclean:
rm -f a.out core *.[oais] *-test *.srec *.dis *.x syscall.h
distclean maintainer-clean realclean: clean
rm -f Makefile config.status *~
.PHONY: install info install-info clean-info
install: ${SIM_INSTALL}
install-sim:
set -e; for x in ${SIM_CRT0} ${SIM_BSP} ${SIM_SCRIPTS}; do ${INSTALL_DATA} $$x ${tooldir}/lib${MULTISUBDIR}/$$x; done
doc:
info:
install-info:
clean-info:
Makefile: Makefile.in config.status @host_makefile_frag_path@
$(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck

1191
libgloss/d30v/configure

File diff suppressed because it is too large

90
libgloss/d30v/configure.in

@ -0,0 +1,90 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.5)dnl
AC_INIT(crt0.S)
if test "${enable_shared}" = "yes" ; then
echo "Shared libraries not supported for cross compiling, ignored"
fi
if test "$srcdir" = "." ; then
if test "${with_target_subdir}" != "." ; then
libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
else
libgloss_topdir="${srcdir}/${with_multisrctop}../.."
fi
else
libgloss_topdir="${srcdir}/../.."
fi
AC_CONFIG_AUX_DIR($libgloss_topdir)
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
AC_PROG_INSTALL
# FIXME: We temporarily define our own version of AC_PROG_CC. This is
# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
# are probably using a cross compiler, which will not be able to fully
# link an executable. This should really be fixed in autoconf
# itself.
AC_DEFUN(LIB_AC_PROG_CC,
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_PROG_CC_GNU
if test $ac_cv_prog_gcc = yes; then
GCC=yes
dnl Check whether -g works, even if CFLAGS is set, in case the package
dnl plays around with CFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
AC_PROG_CC_G
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-O2"
fi
else
GCC=
test "${CFLAGS+set}" = set || CFLAGS="-g"
fi
])
LIB_AC_PROG_CC
AS=${AS-as}
AC_SUBST(AS)
AR=${AR-ar}
AC_SUBST(AR)
LD=${LD-ld}
AC_SUBST(LD)
AC_PROG_RANLIB
host_makefile_frag=${srcdir}/../config/default.mh
dnl We have to assign the same value to other variables because autoconf
dnl doesn't provide a mechanism to substitute a replacement keyword with
dnl arbitrary data or pathnames.
dnl
host_makefile_frag_path=$host_makefile_frag
AC_SUBST(host_makefile_frag_path)
AC_SUBST_FILE(host_makefile_frag)
AC_OUTPUT(Makefile,
. ${libgloss_topdir}/config-ml.in,
srcdir=${srcdir}
target=${target}
ac_configure_args="${ac_configure_args} --enable-multilib"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
libgloss_topdir=${libgloss_topdir}
)

56
libgloss/d30v/crt0.S

@ -0,0 +1,56 @@
/*
* crt0.S -- startup file for D30V systems.
*
* Copyright (c) 1997 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
.file "crt0.S"
.text
.globl _start
.extern main
.extern exit
.extern __stack
.extern __sbss_start
.extern __sbss_end
.extern __ebss_start
.extern __ebss_end
.extern __bss_start
.extern __bss_end
.extern memset
.type _start,@function
_start: or.l sp,r0,__stack
/* Zero the .sbss area */
or.l r2,r0,__sbss_start
or.l r4,r0,__sbss_end
sub r4,r4,r2 || or.s r3,r0,0
bsrtnz.l r4,(memset)
/* Zero the .ebss area */
or.l r2,r0,__ebss_start
or.l r4,r0,__ebss_end
sub r4,r4,r2 || or.s r3,r0,0
bsrtnz.l r4,(memset)
/* Zero the .bss area */
or.l r2,r0,__bss_start
or.l r4,r0,__bss_end
sub r4,r4,r2 || or.s r3,r0,0
bsrtnz.l r4,(memset)
or.s r2,r0,0 || or.s r3,r0,0
or r4,r0,0 || nop
jsr.l (main)
jsr.l (exit)
.size _start,.-_start

24
libgloss/d30v/inbyte.c

@ -0,0 +1,24 @@
/* inbyte -- read a single byte.
*
* Copyright (c) 1997 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
int
inbyte (void)
{
char ch;
if (read (0, &ch, 1) == 1)
return ch;
return -1;
}

21
libgloss/d30v/outbyte.c

@ -0,0 +1,21 @@
/* outbyte -- write a single byte.
*
* Copyright (c) 1997 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
void
outbyte (int byte)
{
char ch = byte;
write (1, &ch, 1);
}

146
libgloss/d30v/syscalls.c

@ -0,0 +1,146 @@
/*
* syscalls.c -- provide system call support via trap 31
*
* Copyright (c) 1997 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*
* Read bytes, using simulator trap 31.
*/
#include <stdlib.h>
#include "syscall.h"
extern int *__errno(), errno;
__asm__ (
" .globl __syscall
.type __syscall,@function
__syscall:
trap 31 || nop
cmpge f0,r2,0 -> jmp/tx link
bra __set_errno
.size __syscall,.-__syscall
");
int
__set_errno (int new_errno)
{
errno = new_errno;
*(__errno)() = errno;
return -1;
}
void
_exit (int status)
{
__syscall (status, 0, 0, 0, SYS_exit);
}
int
open (const char *filename, int flags, int mode)
{
return __syscall (filename, flags, mode, 0, SYS_open);
}
int
close (int filedes)
{
return __syscall (filedes, 0, 0, 0, SYS_close);
}
int
read (int filedes, void *buffer, size_t length)
{
return __syscall (filedes, buffer, length, 0, SYS_read);
}
int
write (int filedes, void *buffer, size_t length)
{
return __syscall (filedes, buffer, length, 0, SYS_write);
}
long
lseek (int filedes, long offset, int whence)
{
return __syscall (filedes, offset, whence, 0, SYS_lseek);
}
int
unlink (const char *filename)
{
return __syscall (filename, 0, 0, 0, SYS_unlink);
}
int
getpid (void)
{
return __syscall (0, 0, 0, 0, SYS_getpid);
}
int
kill (int signal, int pid)
{
return __syscall (signal, pid, 0, 0, SYS_kill);
}
int
fstat (int filedes, void *info)
{
return __syscall (filedes, info, 0, 0, SYS_fstat);
}
int
__argvlen (void)
{
return __syscall (0, 0, 0, 0, SYS_argvlen);
}
int
__argv (void)
{
return __syscall (0, 0, 0, 0, SYS_argv);
}
int
chdir (char *dir)
{
return __syscall (dir, 0, 0, 0, SYS_chdir);
}
int
stat (const char *filename, void *info)
{
return __syscall (filename, info, 0, 0, SYS_stat);
}
int
chmod (const char *filename, int mode)
{
return __syscall (filename, mode, 0, 0, SYS_chmod);
}
int
utime (const char *filename, void *packet)
{
return __syscall (filename, packet, 0, 0, SYS_utime);
}
time_t
time (time_t *time_ptr)
{
time_t result;
result = (time_t) __syscall (time_ptr, 0, 0, 0, SYS_time);
if (time_ptr != NULL)
*time_ptr = result;
return result;
}

848
libgloss/debug.c

@ -0,0 +1,848 @@
/*
* Copyright (c) 1995, 1996 Cygnus Support
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
/*
* A debug packet whose contents are <data> looks like:
*
* $ <data> # CSUM1 CSUM2
*
* <data> must be ASCII alphanumeric and cannot include characters
* '$' or '#'. If <data> starts with two characters followed by
* ':', then the existing stubs interpret this as a sequence number.
*
* CSUM1 and CSUM2 are ascii hex representation of an 8-bit
* checksum of <data>, the most significant nibble is sent first.
* the hex digits 0-9,a-f are used.
*
* We respond with:
*
* + - if CSUM is correct and ready for next packet
* - - if CSUM is incorrect
*
* <data> is as follows:
* Most values are encoded in ascii hex digits.
*/
#include "debug.h"
#include <signal.h>
/*
* buffers that hold the packets while they're being constructed.
*/
char packet_in_buf[BUFMAX];
char packet_out_buf[BUFMAX];
int packet_index;
/*
* indicate to caller of mem2hex or hex2mem that there has been an error.
* 0 means ok, 1 means error
*/
volatile int mem_err = 0;
/*
* 1 means print debugging messages from the target, 0 means be quiet. This is
* changed by gdb_debug().
*/
int remote_debug = 0;
/*
* indicate whether the debug vectors ahave been initialized
* 0 means not yet, 1 means yep, it's ready.
*/
int initialized = 0;
/*
* These variables are instantialted in the GDB stub code.
*/
/* this is a list of signal to exception mappings. */
extern struct trap_info hard_trap_info[];
/* this is a memory fault exception handler, used by mem2hex & hex2mem */
extern void set_mem_fault_trap();
/*
* print debugging messages. This uses print, rather than one of the
* stdio routines, cause if there are stack or memory problems, the
* stdio routines don't work.
* params are the debug level, and the string to print
* it doesn't return anything.
*/
void
debuglog(int level, char *msg)
{
char *p;
unsigned char buf[BUFMAX];
char newmsg[BUFMAX];
int i;
if (level > remote_debug)
return;
if ((level <0) || (level > 100)) {
print ("ERROR: debug print level out of range");
return;
}
/* convert some characters so it'll look right in the log */
p = newmsg;
for (i = 0 ; msg[i] != '\0'; i++) {
if (i > BUFMAX)
print ("\r\nERROR: Debug message too long\r\n");
switch (msg[i]) {
case '\n': /* newlines */
*p++ = '\\';
*p++ = 'n';
continue;
case '\r': /* carriage returns */
*p++ = '\\';
*p++ = 'r';
continue;
case '\033': /* escape */
*p++ = '\\';
*p++ = 'e';
continue;
case '\t': /* tab */
*p++ = '\\';
*p++ = 't';
continue;
case '\b': /* backspace */
*p++ = '\\';
*p++ = 'b';
continue;
default: /* no change */
*p++ = msg[i];
}
if (msg[i] < 26) { /* modify control characters */
*p++ = '^';
*p++ = msg[i] + 'A';
continue;
}
if (msg[i] >= 127) { /* modify control characters */
*p++ = '!';
*p++ = msg[i] + 'A';
continue;
}
}
*p = '\0'; /* terminate the string */
print (newmsg);
print ("\r\n");
}
/*
* convert an ascii hex digit to a number.
* param is hex digit.
* returns a decimal digit.
*/
int
hex2digit (int digit)
{
if (digit == 0)
return 0;
if (digit >= '0' && digit <= '9')
return digit - '0';
if (digit >= 'a' && digit <= 'f')
return digit - 'a' + 10;
if (digit >= 'A' && digit <= 'F')
return digit - 'A' + 10;
/* shouldn't ever get this far */
return ERROR;
}
/*
* convert number NIB to a hex digit.
* param is a decimal digit.
* returns a hex digit.
*/
char
digit2hex(int digit)
{
if (digit < 10)
return '0' + digit;
else
return 'a' + digit - 10;
}
/*
* Convert the memory pointed to by mem into hex, placing result in buf.
* Return a pointer to the last char put in buf (null), in case of mem fault,
* return 0.
* If MAY_FAULT is non-zero, then we will handle memory faults by returning
* a 0, else treat a fault like any other fault in the stub.
*/
unsigned char *
mem2hex(unsigned char *mem, unsigned char *buf, int count, int may_fault)
{
unsigned char ch;
DEBUG (1, "In mem2hex");
set_mem_fault_trap(MAY_FAULT);
while (count-- > 0) {
ch = *mem++;
if (mem_err) {
DEBUG (1, "memory fault in mem2hex");
return 0;
}
*buf++ = digit2hex(ch >> 4);
*buf++ = digit2hex(ch & 0xf);
}
*buf = 0;
set_mem_fault_trap(OK);
return buf;
}
/*
* Convert the hex array pointed to by buf into binary to be placed in mem
* return a pointer to the character AFTER the last byte written
*/
unsigned char *
hex2mem(unsigned char *buf, unsigned char *mem, int count, int may_fault)
{
int i;
unsigned char ch;
DEBUG (1, "In hex2mem");
set_mem_fault_trap(may_fault);
for (i=0; i<count; i++) {
ch = hex2digit(*buf++) << 4;
ch |= hex2digit(*buf++);
*mem++ = ch;
if (mem_err)
return 0;
}
set_mem_fault_trap(0);
return mem;
}
/*
* while we find nice hex chars, build an int.
* param is a pointer to the string.
* returns the int in the param field, and the number of chars processed.
*/
int
hex2int (char **ptr, int *intValue)
{
int numChars = 0;
int hexValue;
*intValue = 0;
while (**ptr)
{
hexValue = hex2digit(**ptr);
if (hexValue < 0)
break;
*intValue = (*intValue << 4) | hexValue;
numChars ++;
(*ptr)++;
}
return (numChars);
}
/*
* Scan for the sequence $<data>#<checksum>
*/
void
getpacket(unsigned char *buffer)
{
unsigned char checksum;
unsigned char xmitcsum;
int i;
int count;
unsigned char ch;
do {
/* wait around for the start character, ignore all other characters */
while ((ch = (inbyte() & 0x7f)) != '$') ;
checksum = 0;
xmitcsum = -1;
count = 0;
/* now, read until a # or end of buffer is found */
while (count < BUFMAX) {
ch = inbyte() & 0x7f;
if (ch == '#')
break;
checksum = checksum + ch;
buffer[count] = ch;
count = count + 1;
}
if (count >= BUFMAX)
continue;
buffer[count] = 0;
if (ch == '#') {
xmitcsum = hex2digit(inbyte() & 0x7f) << 4;
xmitcsum |= hex2digit(inbyte() & 0x7f);
#if 1
/* Humans shouldn't have to figure out checksums to type to it. */
outbyte ('+');
return;
#endif
if (checksum != xmitcsum)
outbyte('-'); /* failed checksum */
else {
outbyte('+'); /* successful transfer */
/* if a sequence char is present, reply the sequence ID */
if (buffer[2] == ':') {
outbyte(buffer[0]);
outbyte(buffer[1]);
/* remove sequence chars from buffer */
count = strlen(buffer);
for (i=3; i <= count; i++)
buffer[i-3] = buffer[i];
}
}
}
}
while (checksum != xmitcsum);
}
/*
* Send the packet in buffer.
*/
void
putpacket(unsigned char *buffer)
{
unsigned char checksum;
int count;
unsigned char ch;
/* $<packet info>#<checksum>. */
do {
outbyte('$');
checksum = 0;
count = 0;
while (ch = buffer[count]) {
if (! outbyte(ch))
return;
checksum += ch;
count += 1;
}
outbyte('#');
outbyte(digit2hex(checksum >> 4));
outbyte(digit2hex(checksum & 0xf));
}
while ((inbyte() & 0x7f) != '+');
}
/*
*
*/
void
gdb_event_loop(int sigval, unsigned long *registers)
{
int addr;
int length;
unsigned char *ptr;
ptr = packet_out_buf;
DEBUG (1, "In gdb_event_loop");
while (1) {
packet_out_buf[0] = 0;
getpacket(packet_in_buf);
ptr = &packet_in_buf[1];
switch (packet_in_buf[0]) {
case '?': /* get the last known signal */
gdb_last_signal(sigval);
break;
case 'd': /* toggle debug messages from the stub */
gdb_toggle();
break;
case 'g': /* return the value of the CPU registers */
target_read_registers(registers);
break;
case 'G': /* set the value of the CPU registers - return OK */
target_write_registers(registers);
break;
case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
/* Try to read %x,%x. */
if (hex2int((char **)&ptr, &addr)
&& *ptr++ == ','
&& hex2int((char **)&ptr, &length)) {
gdb_read_memory(addr, length);
} else {
make_return_packet(1);
}
break;
case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
/* Try to read '%x,%x:'. */
if (hex2int((char **)&ptr, &addr)
&& *ptr++ == ','
&& hex2int((char **)&ptr, &length)
&& *ptr++ == ':') {
gdb_write_memory (addr, length, ptr);
} else {
make_return_packet(2);
}
break;
case 'c': /* cAA..AA Continue at address AA..AA(optional) */
/* try to read optional parameter, pc unchanged if no parm */
if (hex2int((char **)&ptr, &addr)) {
write_pc(registers, addr);
}
/*
* we need to flush the instruction cache here, as we may have
* deposited a breakpoint, and the icache probably has no way of
* knowing that a data ref to some location may have changed
* something that is in the instruction cache.
*/
flush_i_cache();
/* by returning, we pick up execution where we left off */
return;
/* kill the program */
case 'k' :
gdb_kill();
break;
case 'r': /* Reset */
target_reset();
break;
} /* switch */
/* reply to the request */
putpacket(packet_out_buf);
}
DEBUG (1, "Leaving handle_exception()");
}
/* Convert the hardware trap type code to a unix signal number. */
int
computeSignal(int tt)
{
struct trap_info *ht;
for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
if (ht->tt == tt)
return ht->signo;
return SIGHUP; /* default for things we don't know about */
}
/*
* Set up exception handlers for tracing and breakpoints
*/
void
set_debug_traps()
{
struct trap_info *ht;
DEBUG (1, "Entering set_debug_traps()");
if (hard_trap_info->tt == 0) {
print ("ERROR: ARG#$@%^&*!! no hard trap info!!\r\n");
}
for (ht = hard_trap_info; ht->tt && ht->signo; ht++) {
exception_handler(ht->tt, (unsigned long)default_trap_hook);
}
/* In case GDB is started before us, ack any packets (presumably
"$?#xx") sitting there. */
outbyte ('+');
initialized = 1;
DEBUG (1, "Leaving set_debug_traps()");
}
/*
* make a return packet.
* param is the value to return.
* 0 = OK, any other value is converted to a two digit hex number.
* returns a string or "OK" or "ENN", where NN is the error number. Each N
* is an ASCII encoded hex digit.
*/
char *
make_return_packet(int val)
{
if (val == 0) {
packet_out_buf[0] = 'O';
packet_out_buf[1] = 'K';
packet_out_buf[2] = 0;
} else {
packet_out_buf[0] = 'E';
packet_out_buf[1] = digit2hex((val >> 4) & 0xf);
packet_out_buf[2] = digit2hex(val & 0xf);
packet_out_buf[3] = 0;
}
return(packet_out_buf);
}
/*
* g - read registers.
* no params.
* returns a vector of words, size is NUM_REGS.
*/
char *
gdb_read_registers()
{
}
/*
* G - write registers.
* param is a vector of words, size is NUM_REGS.
* returns an OK or an error number.
*/
char *
gdb_write_registers(char *regs)
{
}
/*
* m - read memory.
* params are the address to start the read at and the number of
* bytes to read.
* returns a vector of nbytes or an error number.
* Can be fewer bytes than requested if able to read only part of the
* data.
*/
char *
gdb_read_memory(long addr, int nbytes)
{
if (mem2hex((char *)addr, packet_out_buf, nbytes, MAY_FAULT))
return(packet_out_buf);
else {
return(make_return_packet(3));
}
}
/*
* M write memory
* params are the address to start writing to, the number of
* bytes to write, and the new values of the bytes.
* returns an OK or an error number.
*/
char *