This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] New Target - Fujitsu FRV


J. Johnston wrote:

Dave Brolley wrote:

Hi,

Attached is a patch which adds newlib support for Fujitsu's FRV
architecture targeting frv-elf, including models for the FR400 and
FR500. This patch is part of a larger submission of bfd, gas, ld,
binutils, sim, gdb and newlib for the FRV by Red Hat.

Generated files have been provided in a separate patch in
frv.newlib.gen.patch.txt

Seeking approval to commit.

Dave



Approval granted for the files given, but I would have expected some libgloss files
as well.  They need to be submitted to the newlib list.

-- Jeff J.

Thanks Jeff. Here are the libgloss files. I had submitted them to gdb-patches thinking that they were part of the simulator.

Dave


libgloss/ChangeLog:
2002-06-11  Dave Brolley  <brolley@redhat.com>

	From Catherine Moore, Michael Meissner, Richard Sandiford:
	* configure.in: Support frv*-*-*.
	* frv/Makefile.in: New file.
	* frv/configure: New file.
	* frv/configure.in: New file.
	* frv/crt0.S: New file.
	* frv/fstat.c: New file.
	* frv/getpid.c: New file.
	* frv/isatty.c: New file.
	* frv/kill.c: New file.
	* frv/print.c: New file.
	* frv/putnum.c: New file.
	* frv/sbrk.c: New file.
	* frv/sim-close.S: New file.
	* frv/sim-exit.S: New file.
	* frv/sim-inbyte.c: New file.
	* frv/sim-lseek.S: New file.
	* frv/sim-open.S: New file.
	* frv/sim-read.S: New file.
	* frv/sim-time.c: New file.
	* frv/sim-unlink.S: New file.
	* frv/sim-write.S: New file.
	* frv/stat.c: New file.

Index: libgloss/configure.in
===================================================================
RCS file: /cvs/src/src/libgloss/configure.in,v
retrieving revision 1.3
diff -c -p -d -u -p -r1.3 configure.in
--- libgloss/configure.in	7 Jan 2002 18:12:31 -0000	1.3
+++ libgloss/configure.in	10 Jun 2002 22:02:44 -0000
@@ -85,6 +85,8 @@ case "${target}" in
   fr30-*-*)
 	configdirs="${configdirs} fr30 testsuite"
 	;;
+  frv*-*-*)
+	configdirs="${configdirs} frv testsuite";;
   mcore-*-*)
 	configdirs="${configdirs} mcore testsuite"
 	;;
Index: libgloss/frv/Makefile.in
===================================================================
RCS file: libgloss/frv/Makefile.in
diff -N libgloss/frv/Makefile.in
--- libgloss/frv/Makefile.in	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/Makefile.in	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,124 @@
+# Copyright (c) 1999, 2001 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.
+
+# Makefile for libgloss/frv. This is the board support
+# code for the various frv targets.
+
+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@
+AR_FLAGS = rc
+
+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`
+
+CRT0 = crt0.o
+SIM_BSP = libsim.a
+SIM_OBJS = fstat.o \
+	   getpid.o \
+	   isatty.o \
+	   kill.o \
+	   putnum.o \
+	   sbrk.o \
+	   sim-close.o \
+	   sim-exit.o \
+	   sim-inbyte.o \
+	   sim-lseek.o \
+	   sim-open.o \
+	   sim-read.o \
+	   sim-time.o \
+	   sim-unlink.o \
+	   sim-write.o \
+	   stat.o
+
+#### Host specific Makefile fragment comes in here.
+@host_makefile_frag@
+
+all: $(CRT0) $(SIM_BSP)
+
+$(SIM_BSP): $(SIM_OBJS)
+	$(AR) $(ARFLAGS) $@ $?
+	$(RANLIB) $@
+
+fstat.o: $(srcdir)/fstat.c
+getpid.o: $(srcdir)/getpid.c
+isatty.o: $(srcdir)/isatty.c
+kill.o: $(srcdir)/kill.c
+putnum.o: $(srcdir)/putnum.c
+sbrk.o: $(srcdir)/sbrk.c
+sim-close.o: $(srcdir)/sim-close.S
+sim-exit.o: $(srcdir)/sim-exit.S
+sim-inbyte.o: $(srcdir)/sim-inbyte.c
+sim-lseek.o: $(srcdir)/sim-lseek.S
+sim-open.o: $(srcdir)/sim-open.S
+sim-read.o: $(srcdir)/sim-read.S
+sim-time.o: $(srcdir)/sim-time.c
+sim-unlink.o: $(srcdir)/sim-unlink.S
+sim-write.o: $(srcdir)/sim-write.S
+stat.o: $(srcdir)/stat.c
+
+install: $($(CPU)_INSTALL)
+	$(INSTALL_DATA) $(CRT0) $(tooldir)/lib${MULTISUBDIR}/$(CRT0)
+	$(INSTALL_DATA) $(SIM_BSP) $(tooldir)/lib${MULTISUBDIR}/$(SIM_BSP)
+
+clean mostlyclean:
+	rm -f *.o *.a
+
+distclean maintainer-clean realclean: clean
+	rm -f Makefile config.cache config.log config.status
+
+.PHONY: info dvi doc install-info clean-info
+info doc dvi:
+install-info:
+clean-info:
+
+Makefile: Makefile.in config.status @host_makefile_frag_path@
+	$(SHELL) config.status
+
+config.status: configure
+	$(SHELL) config.status --recheck
Index: libgloss/frv/configure.in
===================================================================
RCS file: libgloss/frv/configure.in
diff -N libgloss/frv/configure.in
--- libgloss/frv/configure.in	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/configure.in	10 Jun 2002 22:02:44 -0000
@@ -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}
+)
Index: libgloss/frv/crt0.S
===================================================================
RCS file: libgloss/frv/crt0.S
diff -N libgloss/frv/crt0.S
--- libgloss/frv/crt0.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/crt0.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,231 @@
+/* crt0.S -- startup file for frv.
+ * 
+ * Copyright (c) 1999, 2000 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+	/* statically store .Lcall's address so we can see if we are running
+	   at the location we were linked for or a different location.  */
+	.data
+	.type	EXT(__start_cmp),@object
+	.size	EXT(__start_cmp),4
+	.p2align 2
+EXT(__start_cmp):
+	.picptr	 .Lcall
+	
+	.globl	__start
+	.weak	_start
+	.text
+	.type	__start,@function
+__start:
+_start:
+	call	.Lcall				/* set up _gp in a pic-friendly manor */
+.Lcall:	movsg	lr, gr4
+	P(sethi) #gprelhi(.Lcall), gr5
+	setlo	 #gprello(.Lcall), gr5
+	P(sub)	 gr4, gr5, gr16
+
+	sethi	 #gprelhi(EXT(_stack)), sp	/* load up stack pointer */
+	P(setlo) #gprello(EXT(_stack)), sp
+	setlos   #0, fp				/* zero fp to allow unwinders to stop */
+	P(add)	 sp, gr16, sp
+
+	sethi	 #gprelhi(EXT(__start_cmp)), gr5
+	setlo    #gprello(EXT(__start_cmp)), gr5
+	ld	 @(gr5,gr16), gr6
+	subcc	gr4, gr6, gr8, icc0
+	beq	icc0, 0, .Lfixed
+
+	P(st)	gr4, @(gr5, gr16)	/* update so if we restart no need to fixup */
+
+					/* fixup the .ctors list */
+	sethi	 #gprelhi(EXT(__CTOR_LIST__)), gr9
+	P(sethi) #gprelhi(EXT(__CTOR_END__)), gr10
+	setlo	 #gprello(EXT(__CTOR_LIST__)), gr9
+	P(setlo) #gprello(EXT(__CTOR_END__)), gr10
+	add	 gr9, gr16, gr9
+	P(add)	 gr10, gr16, gr10
+	addi	 gr9, 4, gr9
+	P(subi)	 gr10, 4, gr10
+	setlos	 4, gr11
+	call	 EXT(__frv_fixptrs)
+
+					/* fixup the .dtors list */
+	P(sethi) #gprelhi(EXT(__DTOR_LIST__)), gr9
+	sethi	 #gprelhi(EXT(__DTOR_END__)), gr10
+	P(setlo) #gprello(EXT(__DTOR_LIST__)), gr9
+	setlo	 #gprello(EXT(__DTOR_END__)), gr10
+	P(add)	 gr9, gr16, gr9
+	add	 gr10, gr16, gr10
+	P(addi)	 gr9, 4, gr9
+	subi	 gr10, 4, gr10
+	call	 EXT(__frv_fixptrs)
+
+					/* fixup the .dtors list */
+	P(sethi) #gprelhi(EXT(__ROFIXUP_LIST__)), gr9
+	sethi	 #gprelhi(EXT(__ROFIXUP_END__)), gr10
+	P(setlo) #gprello(EXT(__ROFIXUP_LIST__)), gr9
+	setlo	 #gprello(EXT(__ROFIXUP_END__)), gr10
+	P(add)	 gr9, gr16, gr9
+	add	 gr10, gr16, gr10
+	call	 EXT(__frv_fix_usrptrs)
+
+.Lfixed:
+
+/* HSR flags */
+#define HSR_ICE  0x80000000		/* Instruction cache enable */
+#define HSR_DCE  0x40000000		/* Data cache enable */
+#define HSR_CBM  0x08000000		/* Cache copy back mode */
+#define HSR_EIMM 0x04000000		/* Enable Instruction MMU */
+#define HSR_EDMM 0x02000000		/* Enable Data MMU */
+#define HSR_EMEM 0x00800000		/* Enable MMU miss exception mask */
+#define HSR_RME  0x00400000		/* Ram mode enable */
+#define HSR_SA   0x00001000		/* Start address */
+#define HSR_FRN  0x00000800		/* Number of FPRs */
+#define HSR_GRN  0x00000400		/* Number of GPRs */
+#define HSR_FRHE 0x00000200		/* FR Higher Enable */
+#define HSR_FRLE 0x00000100		/* FR Lower Enable */
+#define HSR_GRHE 0x00000080		/* GR Higher Enable */
+#define HSR_GRLE 0x00000040		/* GR Lower Enable */
+
+#ifndef HSR_CLEAR
+#define HSR_CLEAR 0
+#endif
+
+#ifndef HSR_SET
+#ifndef FRV_NO_CACHE
+#define HSR_SET (HSR_ICE|HSR_DCE|HSR_FRHE|HSR_FRLE|HSR_GRHE|HSR_GRLE)
+#else
+#define HSR_SET (HSR_FRHE|HSR_FRLE|HSR_GRHE|HSR_GRLE)
+#endif
+#endif
+
+/* PSR flags */
+#define PSR_ICE  0x00010000		/* In circuit emulation mode */
+#define PSR_NEM  0x00004000		/* Non-exception mode */
+#define PSR_CM   0x00002000		/* Conditional mode */
+#define PSR_BE   0x00001000		/* Big endian mode */
+#define PSR_EF   0x00000100		/* Enable floating point */
+#define PSR_EM   0x00000080		/* Enable media instructions */
+#define PSR_S    0x00000004		/* Enable supervisor mode */
+#define PSR_PS   0x00000002		/* Previous supervisor mode */
+#define PSR_ET   0x00000001		/* Enable interrupts */
+
+#ifndef PSR_CLEAR
+#if __FRV_FPR__
+#define PSR_CLEAR 0
+#else
+#define PSR_CLEAR (PSR_EF|PSR_EM)
+#endif
+#endif
+
+#ifndef PSR_SET
+#if __FRV_FPR__
+#define PSR_SET (PSR_NEM|PSR_CM|PSR_EF|PSR_EM)
+#else
+#define PSR_SET (PSR_NEM|PSR_CM)
+#endif
+#endif
+
+	/* Enable floating point */
+	movsg	  hsr0, gr4
+	P(sethi)  #hi(HSR_SET), gr5
+	setlo	  #lo(HSR_SET), gr5
+	P(sethi)  #hi(~HSR_CLEAR), gr6
+	setlo     #lo(~HSR_CLEAR), gr6
+	or	  gr4, gr5, gr4
+	and	  gr4, gr6, gr4
+	movgs	  gr4, hsr0
+
+	movsg	  psr, gr4
+	P(sethi)  #hi(PSR_SET), gr5
+	setlo	  #lo(PSR_SET), gr5
+	P(sethi)  #hi(~PSR_CLEAR), gr6
+	setlo     #lo(~PSR_CLEAR), gr6
+	or	  gr4, gr5, gr4
+	and	  gr4, gr6, gr4
+	movgs	  gr4, psr
+
+	/* zero the bss area */
+	P(sethi)  #gprelhi(__bss_start), gr8
+	sethi	  #gprelhi(__end), gr4
+	P(setlo)  #gprello(__bss_start), gr8
+	setlo	  #gprello(__end), gr4
+	P(add)	  gr8, gr16, gr8
+	add	  gr4, gr16, gr4
+	P(setlos) #0, gr9
+	sub	  gr4, gr8, gr10
+	call	  EXT(memset)
+
+	P(setlos) #0, gr8		/* zero argc, argv, envp */
+	setlos	  #0, gr9
+	P(setlos) #0, gr10
+
+	call	  EXT(main)
+	call	  EXT(exit)
+.Lend:
+	.size	__start,(.Lend-__start)
+
+	/* Routine to adjust pointers
+	   gr8  = difference to adjust by
+	   gr9  = starting address
+	   gr10 = ending address + 4
+	   gr11 = amount to add to the pointer each iteration.  */
+	.globl	EXT(__frv_fixptrs)
+	.type	EXT(__frv_fixptrs),@function
+EXT(__frv_fixptrs):
+	P(sub)	gr9, gr11, gr9
+	sub	gr10, gr11, gr10
+.Lloop2:
+	cmp	gr10, gr9, icc0
+	bls	icc0, 0, .Lret2
+
+	ldu	@(gr9,gr11), gr5
+	add	gr8, gr5, gr5
+	P(st)	gr5, @(gr9,gr0)
+	bra	.Lloop2
+
+.Lret2:	ret
+.Lend2:
+	.size	EXT(__frv_fixptrs),.Lend2-EXT(__frv_fixptrs)
+
+	/* Routine to adjust statically initialized pointers
+	   Note since these are pointers to pointers, they
+	   need to be adjusted themsevles.
+
+	   gr8  = difference to adjust by
+	   gr9  = starting address
+	   gr10 = ending address + 4
+	   gr11 = amount to add to the pointer each iteration.  */
+	.globl	EXT(__frv_fix_usrptrs)
+	.type	EXT(__frv_fix_usrptrs),@function
+EXT(__frv_fix_usrptrs):
+	P(sub)	gr9, gr11, gr9
+	sub	gr10, gr11, gr10
+.Lloop3:
+	cmp	gr10, gr9, icc0
+	bls	icc0, 0, .Lret3
+
+	ldu	@(gr9,gr11), gr5
+	ld	@(gr5, gr8), gr6
+	cmp	gr6, gr0, icc0		/* skip pointers initialized to 0 */
+	beq	icc0, 0, .Lloop3
+
+	add	gr8, gr6, gr6
+	P(st)	gr6, @(gr5,gr8)
+	bra	.Lloop3
+
+.Lret3:	ret
+.Lend3:
+	.size	EXT(__frv_fix_usrptrs),.Lend2-EXT(__frv_fix_usrptrs)
Index: libgloss/frv/fstat.c
===================================================================
RCS file: libgloss/frv/fstat.c
diff -N libgloss/frv/fstat.c
--- libgloss/frv/fstat.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/fstat.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,30 @@
+/* fstat.c -- get status of a file.
+ *
+ * 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 <sys/stat.h>
+#include "glue.h"
+
+/*
+ * fstat -- Since we have no file system, we just return an error.
+ */
+int
+_DEFUN (_fstat, (fd, buf),
+       int fd _AND
+       struct stat *buf)
+{
+  buf->st_mode = S_IFCHR;	/* Always pretend to be a tty */
+  buf->st_blksize = 0;
+
+  return (0);
+}
Index: libgloss/frv/getpid.c
===================================================================
RCS file: libgloss/frv/getpid.c
diff -N libgloss/frv/getpid.c
--- libgloss/frv/getpid.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/getpid.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,25 @@
+/* getpid.c -- get the current process id.
+ *
+ * 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"
+
+/*
+ * getpid -- only one process, so just return 1.
+ */
+int
+_DEFUN (_getpid, (),
+        )
+{
+  return __MYPID;
+}
Index: libgloss/frv/isatty.c
===================================================================
RCS file: libgloss/frv/isatty.c
diff -N libgloss/frv/isatty.c
--- libgloss/frv/isatty.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/isatty.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,27 @@
+/* isatty.c -- chek the terminal device.
+ * 
+ * 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"
+
+/*
+ * isatty -- returns 1 if connected to a terminal device,
+ *           returns 0 if not. Since we're hooked up to a
+ *           serial port, we'll say yes _AND return a 1.
+ */
+int
+_DEFUN (isatty, (fd),
+       int fd)
+{
+  return (1);
+}
Index: libgloss/frv/kill.c
===================================================================
RCS file: libgloss/frv/kill.c
diff -N libgloss/frv/kill.c
--- libgloss/frv/kill.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/kill.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,30 @@
+/* kill.c -- remove a process.
+ *
+ * Copyright (c) 1995, 2000 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"
+
+extern void _exit (int) __attribute__((__noreturn__));
+
+/*
+ * kill -- go out via exit...
+ */
+int
+_DEFUN (_kill, (pid, sig),
+        int pid _AND 
+        int sig)
+{
+  if(pid == __MYPID)
+    _exit(sig);
+  return 0;
+}
Index: libgloss/frv/print.c
===================================================================
RCS file: libgloss/frv/print.c
diff -N libgloss/frv/print.c
--- libgloss/frv/print.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/print.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,27 @@
+/* print.c -- print a string on the output device.
+ *
+ * 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"
+
+/*
+ * print -- do a raw print of a string
+ */ 
+void
+_DEFUN (_print, (ptr),
+char *ptr)
+{
+  while (*ptr) {
+    outbyte (*ptr++);
+  }
+}
Index: libgloss/frv/putnum.c
===================================================================
RCS file: libgloss/frv/putnum.c
diff -N libgloss/frv/putnum.c
--- libgloss/frv/putnum.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/putnum.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,41 @@
+/* putnum.c -- put a hex number on the output device.
+ * 
+ * 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"
+
+/*
+ * putnum -- print a 32 bit number in hex
+ */
+void
+_DEFUN (_putnum, (num),
+	unsigned int num)
+{
+  char  buf[9];
+  int   cnt;
+  char  *ptr;
+  int   digit;
+  
+  ptr = buf;
+  for (cnt = 7 ; cnt >= 0 ; cnt--) {
+    digit = (num >> (cnt * 4)) & 0xf;
+    
+    if (digit <= 9)
+      *ptr++ = (char) ('0' + digit);
+    else
+      *ptr++ = (char) ('a' - 10 + digit);
+  }
+
+  *ptr = (char) 0;
+  print (buf);
+}
Index: libgloss/frv/sbrk.c
===================================================================
RCS file: libgloss/frv/sbrk.c
diff -N libgloss/frv/sbrk.c
--- libgloss/frv/sbrk.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sbrk.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,54 @@
+/* sbrk.c -- allocate memory dynamically.
+ * 
+ * Copyright (c) 1995,1996, 1999 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 <errno.h>
+#include "glue.h"
+
+/* just in case, most boards have at least some memory */
+#ifndef RAMSIZE
+#  define RAMSIZE             (caddr_t)0x100000
+#endif
+
+char *__heap_ptr = (char *)&_end;
+
+/*
+ * sbrk -- changes heap size size. Get nbytes more
+ *         RAM. We just increment a pointer in what's
+ *         left of memory on the board.
+ */
+char *
+_sbrk (nbytes)
+     int nbytes;
+{
+  char *base;
+  char *sp;
+
+  base = __heap_ptr;
+  __heap_ptr += nbytes;
+
+  return base;
+/* FIXME: We really want to make sure we don't run out of RAM, but this
+ *       isn't very portable.
+ */
+#if 0
+  if ((RAMSIZE - heap_ptr - nbytes) >= 0) {
+    base = heap_ptr;
+    heap_ptr += nbytes;
+    return (base);
+  } else {
+    errno = ENOMEM;
+    return ((char *)-1);
+  }
+#endif
+}
Index: libgloss/frv/sim-close.S
===================================================================
RCS file: libgloss/frv/sim-close.S
diff -N libgloss/frv/sim-close.S
--- libgloss/frv/sim-close.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-close.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,40 @@
+/*
+ * sim-close.S -- close interface for frv simulator
+ * 
+ * Copyright (c) 2001 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+#include "syscall.h"
+
+/*
+ * Input:
+ * gr8	  -- File descriptor to close.
+ *
+ * Output:
+ * gr8	  -- 0 or -1.
+ * errno  -- Set if an error
+ */
+
+	.globl	EXT(_close)
+	.type	EXT(_close),@function
+	.weak	EXT(close)
+	.text
+EXT(_close):
+EXT(close):
+	setlos	#SYS_close,gr7
+	tira	gr0,#0
+	ret
+.Lend:
+	.size	EXT(_close),.Lend-EXT(_close)
Index: libgloss/frv/sim-exit.S
===================================================================
RCS file: libgloss/frv/sim-exit.S
diff -N libgloss/frv/sim-exit.S
--- libgloss/frv/sim-exit.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-exit.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,36 @@
+/*
+ * sim-exit.S -- _exit interface for frv simulator
+ * 
+ * Copyright (c) 1999, 2000, 2001 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+#include "syscall.h"
+
+/*
+ * Input:
+ * gr8	-- exit value
+ *
+ * Output:
+ * none
+ */
+
+	.globl	EXT(_exit)
+	.type	EXT(_exit),@function
+	.text
+EXT(_exit):
+	setlos	#SYS_exit,gr7
+	tira	gr0,#0
+.Lend:
+	.size	EXT(_exit),.Lend-EXT(_exit)
Index: libgloss/frv/sim-inbyte.c
===================================================================
RCS file: libgloss/frv/sim-inbyte.c
diff -N libgloss/frv/sim-inbyte.c
--- libgloss/frv/sim-inbyte.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-inbyte.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,26 @@
+/*
+ * sim-inbyte.c -- read a character from standard input.
+ *
+ * Copyright (c) 1999 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 ()
+{
+  char c;
+
+  if (read (0, &c, 1) <= 0)
+    return -1;
+
+  return c;
+}
Index: libgloss/frv/sim-lseek.S
===================================================================
RCS file: libgloss/frv/sim-lseek.S
diff -N libgloss/frv/sim-lseek.S
--- libgloss/frv/sim-lseek.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-lseek.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,42 @@
+/*
+ * sim-lseek.S -- write interface for frv simulator
+ * 
+ * Copyright (c) 1999, 2000, 2001 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+#include "syscall.h"
+
+/*
+ * Input:
+ * gr8	  -- File descriptor
+ * gr9	  -- Offset
+ * gr10   -- Base from which offset should be taken
+ *
+ * Output:
+ * gr8	  -- Zero on success, -1 on failure.
+ * errno  -- Set if an error
+ */
+
+	.globl	EXT(_lseek)
+	.type	EXT(_lseek),@function
+	.weak	EXT(lseek)
+	.text
+EXT(_lseek):
+EXT(lseek):
+	setlos	#SYS_lseek,gr7
+	tira	gr0,#0
+	ret
+.Lend:
+	.size	EXT(_lseek),.Lend-EXT(_lseek)
Index: libgloss/frv/sim-open.S
===================================================================
RCS file: libgloss/frv/sim-open.S
diff -N libgloss/frv/sim-open.S
--- libgloss/frv/sim-open.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-open.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,42 @@
+/*
+ * sim-open.S -- open interface for frv simulator
+ * 
+ * Copyright (c) 2001 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+#include "syscall.h"
+
+/*
+ * Input:
+ * gr8	  -- File name to open.
+ * gr9	  -- open mode.
+ * gr10	  -- optionally, the permission bits to set the file to.
+ *
+ * Output:
+ * gr8	  -- file descriptor or -1.
+ * errno  -- Set if an error
+ */
+
+	.globl	EXT(_open)
+	.type	EXT(_open),@function
+	.weak	EXT(open)
+	.text
+EXT(_open):
+EXT(open):
+	setlos	#SYS_open,gr7
+	tira	gr0,#0
+	ret
+.Lend:
+	.size	EXT(_open),.Lend-EXT(_open)
Index: libgloss/frv/sim-read.S
===================================================================
RCS file: libgloss/frv/sim-read.S
diff -N libgloss/frv/sim-read.S
--- libgloss/frv/sim-read.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-read.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,42 @@
+/*
+ * sim-read.S -- read interface for frv simulator
+ * 
+ * Copyright (c) 2001 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+#include "syscall.h"
+
+/*
+ * Input:
+ * gr8	  -- File descriptor.
+ * gr9	  -- Buffer to be read into.
+ * gr10	  -- Length of the buffer.
+ *
+ * Output:
+ * gr8	  -- Length read or -1.
+ * errno  -- Set if an error
+ */
+
+	.globl	EXT(_read)
+	.type	EXT(_read),@function
+	.weak	EXT(read)
+	.text
+EXT(_read):
+EXT(read):
+	setlos	#SYS_read,gr7
+	tira	gr0,#0
+	ret
+.Lend:
+	.size	EXT(_read),.Lend-EXT(_read)
Index: libgloss/frv/sim-time.c
===================================================================
RCS file: libgloss/frv/sim-time.c
diff -N libgloss/frv/sim-time.c
--- libgloss/frv/sim-time.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-time.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,78 @@
+/* sim-time.c -- stubs so clock can be linked in.
+ *
+ * Copyright (c) 2001 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 <errno.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include "glue.h"
+
+/*
+ * time -- simulator interface to return current time in seconds.
+ */
+__asm__ ("\
+	.text\n\
+	.globl	_sim_time\n\
+	.type	_sim_time,@function\n\
+_sim_time:\n\
+	setlos	#18, gr7\n\
+	tira	gr0, #0\n\
+	ret\n\
+.Lsim:\n\
+	.size	_sim_time,.Lsim-_sim_time");
+
+extern time_t _sim_time (void) __asm__("_sim_time");
+
+
+/*
+ * time -- return current time in seconds.
+ */
+time_t
+_DEFUN (time, time (t),
+	time_t *t)
+{
+  time_t ret = _sim_time ();
+
+  if (t)
+    *t = ret;
+
+  return ret;
+}
+
+/*
+ * _times -- no clock, so return an error.
+ */
+int
+_DEFUN (_times, _times (buf),
+	struct tms *buf)
+{
+  errno = EINVAL;
+  return (-1);
+}
+
+/*
+ * _gettimeofday -- implement in terms of time, which means we can't return the
+ * microseconds.
+ */
+int
+_DEFUN (_gettimeofday, _gettimeofday (tv, tz),
+	struct timeval *tv _AND
+	struct timezone *tz)
+{
+  if (tz)
+    tz->tz_minuteswest = tz->tz_dsttime = 0;
+
+  tv->tv_usec = 0;
+  tv->tv_sec = _sim_time ();
+  return 0;
+}
Index: libgloss/frv/sim-unlink.S
===================================================================
RCS file: libgloss/frv/sim-unlink.S
diff -N libgloss/frv/sim-unlink.S
--- libgloss/frv/sim-unlink.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-unlink.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,40 @@
+/*
+ * sim-unlink.S -- write interface for frv simulator
+ * 
+ * Copyright (c) 1999, 2000, 2001 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+#include "syscall.h"
+
+/*
+ * Input:
+ * gr8	  -- Filename
+ *
+ * Output:
+ * gr8	  -- Zero on success, -1 on failure.
+ * errno  -- Set if an error
+ */
+
+	.globl	EXT(_unlink)
+	.type	EXT(_unlink),@function
+	.weak	EXT(unlink)
+	.text
+EXT(_unlink):
+EXT(unlink):
+	setlos	#SYS_unlink,gr7
+	tira	gr0,#0
+	ret
+.Lend:
+	.size	EXT(_unlink),.Lend-EXT(_unlink)
Index: libgloss/frv/sim-write.S
===================================================================
RCS file: libgloss/frv/sim-write.S
diff -N libgloss/frv/sim-write.S
--- libgloss/frv/sim-write.S	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/sim-write.S	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,42 @@
+/*
+ * sim-write.S -- write interface for frv simulator
+ * 
+ * Copyright (c) 1999, 2000, 2001 Cygnus Solutions
+ *
+ * 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 <frv-asm.h>
+
+#include "syscall.h"
+
+/*
+ * Input:
+ * gr8	  -- File descriptor.
+ * gr9	  -- String to be printed.
+ * gr10	  -- Length of the string.
+ *
+ * Output:
+ * gr8	  -- Length written or -1.
+ * errno  -- Set if an error
+ */
+
+	.globl	EXT(_write)
+	.type	EXT(_write),@function
+	.weak	EXT(write)
+	.text
+EXT(_write):
+EXT(write):
+	setlos	#SYS_write,gr7
+	tira	gr0,#0
+	ret
+.Lend:
+	.size	EXT(_write),.Lend-EXT(_write)
Index: libgloss/frv/stat.c
===================================================================
RCS file: libgloss/frv/stat.c
diff -N libgloss/frv/stat.c
--- libgloss/frv/stat.c	1 Jan 1970 00:00:00 -0000
+++ libgloss/frv/stat.c	10 Jun 2002 22:02:44 -0000
@@ -0,0 +1,30 @@
+/* stat.c -- Get the status of a file.
+ *
+ * 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 <sys/stat.h>
+#include <errno.h>
+#include "glue.h"
+
+/*
+ * stat -- Since we have no file system, we just return an error.
+ */
+int
+_DEFUN (_stat, (path, buf),
+       const char *path _AND
+       struct stat *buf)
+{
+  errno = EIO;
+  return (-1);
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]