This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Altera NIOS II Support
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: "newlib at sources dot redhat dot com" <newlib at sources dot redhat dot com>
- Date: Thu, 19 Mar 2009 16:36:26 -0500
- Subject: Altera NIOS II Support
Hi,
This is based on the Altera tools that
are available from their ftp site.
It updates their work from an old newlib
to 1.17.0.
You will have to regenerate files. I didn't
bother to include them.
This is enough to work with RTEMS if you use
their tool port.
2009-3-19 Joel Sherrill <joel.sherrill@oarcorp.com>
* configure.host, libc/include/machine/ieeefp.h,
libc/include/machine/setjmp.h, libc/include/sys/config.h,
libc/machine/configure.in, libc/machine/nios2/configure.in,
libc/machine/nios2/Makefile.am, libc/machine/nios2/setjmp.S,
libc/sys/rtems/machine/stdint.h, libc/sys/rtems/sys/dirent.h:
Merge Altera NIOS II support.
--joel
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/configure.host newlib-1.17.0/newlib/configure.host
--- newlib-1.17.0-orig/newlib/configure.host 2009-03-19 16:19:45.000000000 -0500
+++ newlib-1.17.0/newlib/configure.host 2009-03-01 09:09:40.000000000 -0600
@@ -164,6 +164,9 @@
lm32)
machine_dir=lm32
;;
+ nios2)
+ machine_dir=nios2
+ ;;
m32c)
machine_dir=m32c
newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DABORT_PROVIDED -DSMALL_MEMORY"
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/include/machine/ieeefp.h newlib-1.17.0/newlib/libc/include/machine/ieeefp.h
--- newlib-1.17.0-orig/newlib/libc/include/machine/ieeefp.h 2009-03-19 16:19:45.000000000 -0500
+++ newlib-1.17.0/newlib/libc/include/machine/ieeefp.h 2009-03-01 10:39:12.000000000 -0600
@@ -50,6 +50,17 @@
*/
+/*
+ * NIOS2 can be big or little endian
+ */
+#ifdef __NIOS2__
+# ifdef __nios2_big_endian__
+# define __IEEE_BIG_ENDIAN
+# else
+# define __IEEE_LITTLE_ENDIAN
+# endif
+#endif
+
#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
/* ARM traditionally used big-endian words; and within those words the
byte ordering was big or little endian depending upon the target.
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/include/machine/setjmp.h newlib-1.17.0/newlib/libc/include/machine/setjmp.h
--- newlib-1.17.0-orig/newlib/libc/include/machine/setjmp.h 2009-03-19 16:19:45.000000000 -0500
+++ newlib-1.17.0/newlib/libc/include/machine/setjmp.h 2009-03-02 06:17:03.000000000 -0600
@@ -97,6 +97,11 @@
#define _JBLEN 21
#endif
+#ifdef __NIOS2__
+#define _JBLEN 40
+#define _JBTYPE unsigned long
+#endif
+
#ifdef __H8300__
#define _JBLEN 5
#define _JBTYPE int
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/include/sys/config.h newlib-1.17.0/newlib/libc/include/sys/config.h
--- newlib-1.17.0-orig/newlib/libc/include/sys/config.h 2008-11-19 15:05:31.000000000 -0600
+++ newlib-1.17.0/newlib/libc/include/sys/config.h 2009-03-01 11:19:22.000000000 -0600
@@ -11,6 +11,14 @@
#define H8300 1
#endif
+#ifdef __NIOS2__
+# ifdef __nios2_big_endian__
+# define __IEEE_BIG_ENDIAN
+# else
+# define __IEEE_LITTLE_ENDIAN
+# endif
+#endif /* __NIOS2__ */
+
/* 16 bit integer machines */
#if defined(__Z8001__) || defined(__Z8002__) || defined(__H8500__) || defined(__W65__) || defined (__mn10200__) || defined (__AVR__)
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/machine/configure.in newlib-1.17.0/newlib/libc/machine/configure.in
--- newlib-1.17.0-orig/newlib/libc/machine/configure.in 2008-12-11 14:05:38.000000000 -0600
+++ newlib-1.17.0/newlib/libc/machine/configure.in 2009-03-01 11:27:16.000000000 -0600
@@ -49,6 +49,7 @@
mn10300) AC_CONFIG_SUBDIRS(mn10300) ;;
mt) AC_CONFIG_SUBDIRS(mt) ;;
necv70) AC_CONFIG_SUBDIRS(necv70) ;;
+ nios2) AC_CONFIG_SUBDIRS(nios2) ;;
powerpc) AC_CONFIG_SUBDIRS(powerpc) ;;
sh) AC_CONFIG_SUBDIRS(sh) ;;
sparc) AC_CONFIG_SUBDIRS(sparc) ;;
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/machine/nios2/configure.in newlib-1.17.0/newlib/libc/machine/nios2/configure.in
--- newlib-1.17.0-orig/newlib/libc/machine/nios2/configure.in 1969-12-31 18:00:00.000000000 -0600
+++ newlib-1.17.0/newlib/libc/machine/nios2/configure.in 2009-03-01 11:26:09.000000000 -0600
@@ -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
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/machine/nios2/Makefile.am newlib-1.17.0/newlib/libc/machine/nios2/Makefile.am
--- newlib-1.17.0-orig/newlib/libc/machine/nios2/Makefile.am 1969-12-31 18:00:00.000000000 -0600
+++ newlib-1.17.0/newlib/libc/machine/nios2/Makefile.am 2009-03-01 08:51:27.000000000 -0600
@@ -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
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/machine/nios2/setjmp.S newlib-1.17.0/newlib/libc/machine/nios2/setjmp.S
--- newlib-1.17.0-orig/newlib/libc/machine/nios2/setjmp.S 1969-12-31 18:00:00.000000000 -0600
+++ newlib-1.17.0/newlib/libc/machine/nios2/setjmp.S 2009-03-01 08:50:48.000000000 -0600
@@ -0,0 +1,54 @@
+;/*
+; * 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.
+; */
+;
+;
+ .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
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/sys/rtems/machine/stdint.h newlib-1.17.0/newlib/libc/sys/rtems/machine/stdint.h
--- newlib-1.17.0-orig/newlib/libc/sys/rtems/machine/stdint.h 2009-03-19 16:19:45.000000000 -0500
+++ newlib-1.17.0/newlib/libc/sys/rtems/machine/stdint.h 2009-03-01 22:05:09.000000000 -0600
@@ -12,7 +12,7 @@
#error machine/stdint.h is an RTEMS specific internal file and must not be used otherwise
#endif
-#if defined(__m32c__) || defined(__m32r__) || defined(__lm32__)
+#if defined(__m32c__) || defined(__m32r__) || defined(__lm32__) ||defined(__nios2__)
#if (__SIZEOF_PTRDIFF_T__ == __SIZEOF_LONG__)
#define __ptrint_t_long_defined 1
#endif
diff -uNr --exclude='*auto*' --exclude=configure newlib-1.17.0-orig/newlib/libc/sys/rtems/sys/dirent.h newlib-1.17.0/newlib/libc/sys/rtems/sys/dirent.h
--- newlib-1.17.0-orig/newlib/libc/sys/rtems/sys/dirent.h 2004-01-08 13:25:21.000000000 -0600
+++ newlib-1.17.0/newlib/libc/sys/rtems/sys/dirent.h 2009-03-01 14:11:27.000000000 -0600
@@ -1,6 +1,8 @@
#ifndef _SYS_DIRENT_H
# define _SYS_DIRENT_H
+#include <sys/syslimits.h>
+
#ifdef __cplusplus
extern "C" {
#endif