This is the mail archive of the newlib@sourceware.org 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]

[patch] Altera Nios II support (revised)


Here is a revised version of the Nios II patch. It is identical to the one previously posted

http://sourceware.org/ml/newlib/2013/msg00264.html

except that setjmp.s now has a copyright notice (provided by Altera).

OK to commit?

-Sandra

2013-05-03  Sandra Loosemore  <sandra@codesourcery.com>

	Based on patches from Altera Corporation.

	* configure.ac (noconfigdirs [nios2-*-*]): Add target-libgloss.
	* configure: Regenerated.

	newlib/
	* configure.host (machine_dir, sys_dir, syscall_dir, newlib_cflags):
	Add settings for nios2*.
	* libc/include/machine/ieeefp.h (IEEE_BIG_ENDIAN, IEEE_LITTLE_ENDIAN):
	Likewise.
	* libc/include/machine/setjmp.h (JBLEN, JBTYPE): Likewise.
	* libc/machine/configure.in: Add nios2 subdir.
	* libc/machine/configure: Regenerated.
	* libc/machine/nios2/Makefile.am: New.
	* libc/machine/nios2/Makefile.in: New (autogenerated).
	* libc/machine/nios2/aclocal.m4: New (copied from mips version).
	* libc/machine/nios2/configure.in: New.
	* libc/machine/nios2/configure: New (autogenerated).
	* libc/machine/nios2/setjmp.s: New.
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/configure.ac,v
retrieving revision 1.188
diff -u -p -r1.188 configure.ac
--- configure.ac	22 Apr 2013 15:25:09 -0000	1.188
+++ configure.ac	3 May 2013 19:48:38 -0000
@@ -1057,6 +1057,9 @@ case "${target}" in
   mt-*-*)
     noconfigdirs="$noconfigdirs sim"
     ;;
+  nios2-*-*)
+    noconfigdirs="$noconfigdirs target-libgloss"
+    ;;
   powerpc-*-aix*)
     # copied from rs6000-*-* entry
     noconfigdirs="$noconfigdirs gprof"
Index: newlib/configure.host
===================================================================
RCS file: /cvs/src/src/newlib/configure.host,v
retrieving revision 1.127
diff -u -p -r1.127 configure.host
--- newlib/configure.host	4 Dec 2012 21:43:20 -0000	1.127
+++ newlib/configure.host	3 May 2013 19:48:38 -0000
@@ -227,6 +227,9 @@ case "${host_cpu}" in
   mt*)
 	machine_dir=mt
 	;;
+  nios2*)
+	machine_dir=nios2
+	;;
   or16)
 	;;
   or32)
@@ -476,6 +479,9 @@ case "${host}" in
   moxie*)
         sys_dir=
         ;;
+  nios2*)
+	sys_dir=
+	;;
   powerpcle-*-pe)
 	posix_dir=posix
 	;;
@@ -703,6 +709,10 @@ case "${host}" in
         syscall_dir=syscalls
 	default_newlib_io_long_long="yes"
         ;;
+  nios2*)
+	syscall_dir=
+	newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DHAVE_SYSTEM -DMISSING_SYSCALL_NAMES"
+	;;
   powerpc*-*-eabialtivec*)
 	default_newlib_io_long_long="yes"
 	newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
Index: newlib/libc/include/machine/ieeefp.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/machine/ieeefp.h,v
retrieving revision 1.52
diff -u -p -r1.52 ieeefp.h
--- newlib/libc/include/machine/ieeefp.h	26 Sep 2012 20:06:47 -0000	1.52
+++ newlib/libc/include/machine/ieeefp.h	3 May 2013 19:48:38 -0000
@@ -388,6 +388,14 @@
 #define __SMALL_BITFIELDS	/* 16 Bit INT */
 #endif
 
+#ifdef __NIOS2__
+# ifdef __nios2_big_endian__
+#  define __IEEE_BIG_ENDIAN
+# else
+#  define __IEEE_LITTLE_ENDIAN
+# endif
+#endif
+
 #ifndef __IEEE_BIG_ENDIAN
 #ifndef __IEEE_LITTLE_ENDIAN
 #error Endianess not declared!!
Index: newlib/libc/include/machine/setjmp.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/machine/setjmp.h,v
retrieving revision 1.49
diff -u -p -r1.49 setjmp.h
--- newlib/libc/include/machine/setjmp.h	23 Apr 2013 09:42:25 -0000	1.49
+++ newlib/libc/include/machine/setjmp.h	3 May 2013 19:48:38 -0000
@@ -287,6 +287,24 @@ _BEGIN_STD_C
 #define _JBTYPE unsigned char
 #endif
 
+/*
+ * There are two versions of setjmp()/longjmp():
+ *   1) Compiler (gcc) built-in versions.
+ *   2) Function-call versions.
+ *
+ * The built-in versions are used most of the time.  When used, gcc replaces
+ * calls to setjmp()/longjmp() with inline assembly code.  The built-in 
+ * versions save/restore a variable number of registers.
+
+ * _JBLEN is set to 40 to be ultra-safe with the built-in versions.
+ * It only needs to be 12 for the function-call versions
+ * but this data structure is used by both versions.
+ */
+#ifdef __NIOS2__
+#define _JBLEN 40
+#define _JBTYPE unsigned long
+#endif
+
 #ifdef __RX__
 #define _JBLEN 0x44
 #endif
Index: newlib/libc/machine/configure.in
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/configure.in,v
retrieving revision 1.21
diff -u -p -r1.21 configure.in
--- newlib/libc/machine/configure.in	26 Sep 2012 20:06:47 -0000	1.21
+++ newlib/libc/machine/configure.in	3 May 2013 19:48:38 -0000
@@ -55,6 +55,7 @@ if test -n "${machine_dir}"; then
 	moxie) AC_CONFIG_SUBDIRS(moxie) ;;
 	mt) AC_CONFIG_SUBDIRS(mt) ;;
 	necv70) AC_CONFIG_SUBDIRS(necv70) ;;
+	nios2) AC_CONFIG_SUBDIRS(nios2) ;;
 	powerpc) AC_CONFIG_SUBDIRS(powerpc) ;;
 	rl78) AC_CONFIG_SUBDIRS(rl78) ;;
 	rx) AC_CONFIG_SUBDIRS(rx) ;;
Index: newlib/libc/machine/nios2/Makefile.am
===================================================================
RCS file: newlib/libc/machine/nios2/Makefile.am
diff -N newlib/libc/machine/nios2/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ newlib/libc/machine/nios2/Makefile.am	3 May 2013 19:48:38 -0000
@@ -0,0 +1,16 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+AM_CCASFLAGS = $(INCLUDES)
+
+noinst_LIBRARIES = lib.a
+
+lib_a_SOURCES = setjmp.s
+lib_a_CCASFLAGS=$(AM_CCASFLAGS)
+lib_a_CFLAGS=$(AM_CFLAGS)
+
+ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
+CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
Index: newlib/libc/machine/nios2/configure.in
===================================================================
RCS file: newlib/libc/machine/nios2/configure.in
diff -N newlib/libc/machine/nios2/configure.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ newlib/libc/machine/nios2/configure.in	3 May 2013 19:48:38 -0000
@@ -0,0 +1,14 @@
+dnl This is the newlib/libc/machine/nios2 configure.in file.
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.59)
+AC_INIT([newlib],[NEWLIB_VERSION])
+AC_CONFIG_SRCDIR([setjmp.s])
+
+dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake. 
+AC_CONFIG_AUX_DIR(../../../..)
+
+NEWLIB_CONFIGURE(../../..)
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
Index: newlib/libc/machine/nios2/setjmp.s
===================================================================
RCS file: newlib/libc/machine/nios2/setjmp.s
diff -N newlib/libc/machine/nios2/setjmp.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ newlib/libc/machine/nios2/setjmp.s	3 May 2013 19:48:38 -0000
@@ -0,0 +1,82 @@
+;/*
+; * C library -- _setjmp, _longjmp
+; *
+; *      _longjmp(a,v)
+; * will generate a "return(v?v:1)" from
+; * the last call to
+; *      _setjmp(a)
+; * by unwinding the call stack.
+; * The previous signal state is NOT restored.
+; *
+; *
+; * Copyright (c) 2003 Altera Corporation
+; * All rights reserved.
+; * 
+; * Redistribution and use in source and binary forms, with or without
+; * modification, are permitted provided that the following conditions
+; * are met:
+; * 
+; *    o Redistributions of source code must retain the above copyright
+; *      notice, this list of conditions and the following disclaimer. 
+; *    o Redistributions in binary form must reproduce the above copyright
+; *      notice, this list of conditions and the following disclaimer in the 
+; *      documentation and/or other materials provided with the distribution. 
+; *    o Neither the name of Altera Corporation nor the names of its 
+; *      contributors may be used to endorse or promote products derived from
+; *      this software without specific prior written permission. 
+; *  
+; * THIS SOFTWARE IS PROVIDED BY ALTERA CORPORATION, THE COPYRIGHT HOLDER,
+; * AND ITS CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+; * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+; * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+; * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+; * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+; * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+; * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+; * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+; * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+; * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+; */
+
+	.section	.text
+	.align	3
+	.globl	setjmp
+	.type	setjmp,@function
+	.globl	longjmp
+	.type	longjmp,@function
+
+
+setjmp:
+	stw	r16, 0(r4)
+	stw	r17, 4(r4)
+	stw	r18, 8(r4)
+	stw	r19, 12(r4)
+	stw	r20, 16(r4)
+	stw	r21, 20(r4)
+	stw	r22, 24(r4)
+	stw	r23, 28(r4)
+	stw	gp, 32(r4)
+	stw	sp, 36(r4)
+	stw	fp, 40(r4)
+	stw	ra, 44(r4)
+	mov	r2, zero
+	ret
+
+longjmp:
+	ldw	r16, 0(r4)
+	ldw	r17, 4(r4)
+	ldw	r18, 8(r4)
+	ldw	r19, 12(r4)
+	ldw	r20, 16(r4)
+	ldw	r21, 20(r4)
+	ldw	r22, 24(r4)
+	ldw	r23, 28(r4)
+	ldw	gp, 32(r4)
+	ldw	sp, 36(r4)
+	ldw	fp, 40(r4)
+	ldw	ra, 44(r4)
+	mov	r2, r5
+	bne	r2, zero, 1f
+	movi	r2, 1	
+1:
+	ret

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