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] LatticeMico32 changes


Hi,

this patch adds support for the Lattice Mico32 soft CPU. I have been working on a Mico32 port for RTEMS. The patch is based on the Lattice tool sources by Jon Beniston.

2008-12-10 Jukka Pietarinen <jukka.pietarinen@mrf.fi>

	* config.sub: Add lm32
	* configure.ac: Add lm32
	* newlib/configure.host: Add lm32
	* newlib/libc/include/machine/ieeefp.h: Add __lm32__
	* newlib/libc/include/machine/setjmp.h: Add __lm32__
	* newlib/libc/machine/configure.in: Add lm32
	* newlib/libc/machine/lm32/configure.in: New file
	* newlib/libc/machine/lm32/Makefile.am: New file
	* newlib/libc/machine/lm32/setjmp.s: New file

--
Jukka Pietarinen
Micro-Research Finland
diff -uNr newlib-1.16.0.cvs.20081127/config.sub newlib-1.16.0/config.sub
--- newlib-1.16.0.cvs.20081127/config.sub	2008-11-17 08:00:35.000000000 +0200
+++ newlib-1.16.0/config.sub	2008-12-04 15:06:29.000000000 +0200
@@ -249,6 +249,7 @@
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
 	| maxq | mb | microblaze | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
diff -uNr newlib-1.16.0.cvs.20081127/configure.ac newlib-1.16.0/configure.ac
--- newlib-1.16.0.cvs.20081127/configure.ac	2008-11-17 08:00:36.000000000 +0200
+++ newlib-1.16.0/configure.ac	2008-12-04 15:06:29.000000000 +0200
@@ -753,6 +753,9 @@
   i[[3456789]]86-*-rdos*)
     noconfigdirs="$noconfigdirs gdb target-newlib target-libgloss"
     ;;
+  lm32-*-*)
+    noconfigdirs="$noconfigdirs ${libgcj} target-libf2c target-libojc target-liberty gprof"
+    ;;
   m32r-*-*)
     noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
diff -uNr newlib-1.16.0.cvs.20081127/newlib/configure.host newlib-1.16.0/newlib/configure.host
--- newlib-1.16.0.cvs.20081127/newlib/configure.host	2008-11-19 07:08:18.000000000 +0200
+++ newlib-1.16.0/newlib/configure.host	2008-12-04 15:06:29.000000000 +0200
@@ -161,6 +161,9 @@
   iq2000)
 	machine_dir=iq2000
 	;;
+  lm32)
+	machine_dir=lm32
+	;;
   m32c)
 	machine_dir=m32c
 	newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DABORT_PROVIDED -DSMALL_MEMORY"
diff -uNr newlib-1.16.0.cvs.20081127/newlib/libc/include/machine/ieeefp.h newlib-1.16.0/newlib/libc/include/machine/ieeefp.h
--- newlib-1.16.0.cvs.20081127/newlib/libc/include/machine/ieeefp.h	2008-08-19 13:34:05.000000000 +0300
+++ newlib-1.16.0/newlib/libc/include/machine/ieeefp.h	2008-12-04 15:06:29.000000000 +0200
@@ -149,6 +149,10 @@
 #define __IEEE_LITTLE_ENDIAN
 #endif
 
+#ifdef __lm32__
+#define __IEEE_BIG_ENDIAN
+#endif
+
 #ifdef __M32R__
 #define __IEEE_BIG_ENDIAN
 #endif
diff -uNr newlib-1.16.0.cvs.20081127/newlib/libc/include/machine/setjmp.h newlib-1.16.0/newlib/libc/include/machine/setjmp.h
--- newlib-1.16.0.cvs.20081127/newlib/libc/include/machine/setjmp.h	2008-08-19 13:34:05.000000000 +0300
+++ newlib-1.16.0/newlib/libc/include/machine/setjmp.h	2008-12-04 15:06:29.000000000 +0200
@@ -232,6 +232,10 @@
 #define _JBLEN 18
 #endif
 
+#ifdef __lm32__
+#define _JBLEN 19
+#endif
+
 #ifdef __m32c__
 #if defined(__r8c_cpu__) || defined(__m16c_cpu__)
 #define _JBLEN (22/2)
diff -uNr newlib-1.16.0.cvs.20081127/newlib/libc/machine/configure.in newlib-1.16.0/newlib/libc/machine/configure.in
--- newlib-1.16.0.cvs.20081127/newlib/libc/machine/configure.in	2007-12-11 09:26:14.000000000 +0200
+++ newlib-1.16.0/newlib/libc/machine/configure.in	2008-12-04 15:06:29.000000000 +0200
@@ -37,6 +37,7 @@
 	i386) AC_CONFIG_SUBDIRS(i386) ;;
 	i960) AC_CONFIG_SUBDIRS(i960) ;;
 	iq2000) AC_CONFIG_SUBDIRS(iq2000) ;;
+	lm32) AC_CONFIG_SUBDIRS(lm32) ;;
 	m32c) AC_CONFIG_SUBDIRS(m32c) ;;
 	m32r) AC_CONFIG_SUBDIRS(m32r) ;;
 	m68hc11) AC_CONFIG_SUBDIRS(m68hc11) ;;
diff -uNr newlib-1.16.0.cvs.20081127/newlib/libc/machine/lm32/configure.in newlib-1.16.0/newlib/libc/machine/lm32/configure.in
--- newlib-1.16.0.cvs.20081127/newlib/libc/machine/lm32/configure.in	1970-01-01 02:00:00.000000000 +0200
+++ newlib-1.16.0/newlib/libc/machine/lm32/configure.in	2008-12-04 15:06:29.000000000 +0200
@@ -0,0 +1,14 @@
+dnl This is the newlib/libc/machine/lm32 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 newlib-1.16.0.cvs.20081127/newlib/libc/machine/lm32/Makefile.am newlib-1.16.0/newlib/libc/machine/lm32/Makefile.am
--- newlib-1.16.0.cvs.20081127/newlib/libc/machine/lm32/Makefile.am	1970-01-01 02:00:00.000000000 +0200
+++ newlib-1.16.0/newlib/libc/machine/lm32/Makefile.am	2008-12-04 15:06:29.000000000 +0200
@@ -0,0 +1,13 @@
+## Process this file with automake to generate Makefile.in
+
+INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+noinst_LIBRARIES = lib.a
+
+lib_a_SOURCES = setjmp.s
+lib_a_CCASFLAGS=$(AM_CCASFLAGS)
+lib_a_CFLAGS=$(AM_CFLAGS)
+
+ACLOCAL_AMFLAGS = -I ../../..
+CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
+
diff -uNr newlib-1.16.0.cvs.20081127/newlib/libc/machine/lm32/setjmp.s newlib-1.16.0/newlib/libc/machine/lm32/setjmp.s
--- newlib-1.16.0.cvs.20081127/newlib/libc/machine/lm32/setjmp.s	1970-01-01 02:00:00.000000000 +0200
+++ newlib-1.16.0/newlib/libc/machine/lm32/setjmp.s	2008-12-04 15:06:29.000000000 +0200
@@ -0,0 +1,94 @@
+/* 
+ * setjmp/longjmp for LatticeMico32.
+ * Contributed by Jon Beniston <jon@beniston.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND 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 AUTHOR 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	4
+
+	.globl	setjmp
+	.type	setjmp,@function
+	.globl	longjmp
+	.type	longjmp,@function
+
+/* setjmp: save all callee saves into jmp_buf
+   r1 - Address of jmp_buf
+*/
+
+setjmp:
+        sw      (r1+0), r11
+        sw      (r1+4), r12
+        sw      (r1+8), r13
+        sw      (r1+12), r14
+        sw      (r1+16), r15
+        sw      (r1+20), r16
+        sw      (r1+24), r17
+        sw      (r1+28), r18
+        sw      (r1+32), r19
+        sw      (r1+36), r20
+        sw      (r1+40), r21
+        sw      (r1+44), r22
+        sw      (r1+48), r23
+        sw      (r1+52), r24
+        sw      (r1+56), r25
+        sw      (r1+60), gp
+        sw      (r1+64), fp
+        sw      (r1+68), sp
+        sw      (r1+72), ra
+        mvi     r1, 0
+        ret
+
+/* longjmp: restore all callee saves from jmp_buf
+   r1 - Address of jmb_buf
+   r2 - Value to return with
+*/
+
+        .global     longjmp
+        .type       longjmp,@function
+        .align      4
+
+longjmp:
+        lw      r11, (r1+0)
+        lw      r12, (r1+4)
+        lw      r13, (r1+8)
+        lw      r14, (r1+12)
+        lw      r15, (r1+16)
+        lw      r16, (r1+20)
+        lw      r17, (r1+24)
+        lw      r18, (r1+28)
+        lw      r19, (r1+32)
+        lw      r20, (r1+36)
+        lw      r21, (r1+40)
+        lw      r22, (r1+44)
+        lw      r23, (r1+48)
+        lw      r24, (r1+52)
+        lw      r25, (r1+56)
+        lw      gp, (r1+60)
+        lw      fp, (r1+64)
+        lw      sp, (r1+68)
+        lw      ra, (r1+72)
+        mv      r1, r2
+        ret
+
+

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