TIC4x setjmp patch

Joel Sherrill <joel@OARcorp.com> joel.sherrill@OARcorp.com
Wed Jan 7 14:45:00 GMT 2004


Hi,

This is setjmp support and the minimal core of a very old 
patch to support more on the tic4x target.  I believe this
was originally against 1.8.2 and I have pulled it along 
as part of the 1.11.0 RTEMS patch.  The attached diff is
the tic4x subset of the RTEMS 1.11.0 and no attempt has
been made to update it to CVS so the configurery might
be a bit out of date.  It only impacts this one target so
should be ok.  

Hmm.. does something need to set a machine_dir?  I gutted
that part of the RTEMS patch since none of it applied 
cleanly to CVS source.

2004-01-07      Joel Sherrill <joel@oarcorp.com>

        * libc/include/machine/ieeefp.h: Add enough to make target
compile.
        * libc/include/machine/setjmp.h: Add tic4x support.
        * libc/machine/tic4x/Makefile.am,
libc/machine/tic4x/configure.in,
        libc/machine/tic4x/setjmp.S: New files.


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel@OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985
-------------- next part --------------
2004-01-07	Joel Sherrill <joel@oarcorp.com>

	* libc/include/machine/ieeefp.h: Add enough to make target compile.
	* libc/include/machine/setjmp.h: Add tic4x support.
	* libc/machine/tic4x/Makefile.am, libc/machine/tic4x/configure.in,
	libc/machine/tic4x/setjmp.S: New files.

diff -uNr /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/include/machine/ieeefp.h newlib-1.11.0/newlib/libc/include/machine/ieeefp.h
--- /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/include/machine/ieeefp.h	Wed Jul 24 10:44:23 2002

+++ newlib-1.11.0/newlib/libc/include/machine/ieeefp.h	Tue Jun  3 13:16:55 2003
@@ -119,6 +119,11 @@
 #define __IEEE_BIG_ENDIAN
 #endif
 
+#if defined(_C4x) || defined(_C3x)
+#define __IEEE_BIG_ENDIAN
+#define _DOUBLE_IS_32BITS
+#endif
+
 #ifdef __TIC80__
 #define __IEEE_LITTLE_ENDIAN
 #endif

diff -uNr /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/include/machine/setjmp.h newlib-1.11.0/newlib/libc/include/machine/setjmp.h
--- /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/include/machine/setjmp.h	Tue Dec 10 13:46:49 2002
+++ newlib-1.11.0/newlib/libc/include/machine/setjmp.h	Wed Jun  4 09:40:54 2003
@@ -145,6 +145,13 @@
 #define _JBLEN 16
 #endif
 
+#if defined(_C4x)
+#define _JBLEN 10
+#endif
+#if defined(_C3x)
+#define _JBLEN 9
+#endif
+
 #ifdef __TIC80__
 #define _JBLEN 13
 #endif
diff -uNr /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/machine/tic4x/Makefile.am newlib-1.11.0/newlib/libc/machine/tic4x/Makefile.am
--- /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/machine/tic4x/Makefile.am	Wed Dec 31 18:00:00 1969
+++ newlib-1.11.0/newlib/libc/machine/tic4x/Makefile.am	Wed Jun  4 09:46:23 2003
@@ -0,0 +1,12 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+noinst_LIBRARIES = lib.a
+
+lib_a_SOURCES = setjmp.S
+
+ACLOCAL_AMFLAGS = -I ../../..
+CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff -uNr /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/machine/tic4x/configure.in newlib-1.11.0/newlib/libc/machine/tic4x/configure.in
--- /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/machine/tic4x/configure.in	Wed Dec 31 18:00:00 1969
+++ newlib-1.11.0/newlib/libc/machine/tic4x/configure.in	Wed Jun  4 09:45:50 2003
@@ -0,0 +1,12 @@
+dnl This is the newlib/libc/machine/tic4x configure.in file.
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.5)
+AC_INIT(setjmp.S)
+
+dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake. 
+AC_CONFIG_AUX_DIR(../../../..)
+
+NEWLIB_CONFIGURE(../../..)
+
+AC_OUTPUT(Makefile)
diff -uNr /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/machine/tic4x/setjmp.S newlib-1.11.0/newlib/libc/machine/tic4x/setjmp.S
--- /usr1/rtems/work-tools/original/newlib-1.11.0/newlib/libc/machine/tic4x/setjmp.S	Wed Dec 31 18:00:00 1969
+++ newlib-1.11.0/newlib/libc/machine/tic4x/setjmp.S	Wed Jun  4 09:43:27 2003
@@ -0,0 +1,84 @@
+	;; setjmp, longjmp for c40 copied from:	
+	;; File:          $RCSfile: ctx.asm,v $
+	;; Module:        kernel
+	;; Part of:       mphos
+	;;
+	;; Revision:      $Revision: 1.1 $
+	;; Last Edited:   $Date: 1999/05/17 03:44:49 $
+	;; Author:        $Author: mph $
+	;; Copyright:     Michael P. Hayes 1995-98
+	;;
+	;; 
+	;; 
+	.file	"setjmp.S"
+	.section .text
+
+	.global	_setjmp
+	.global _longjmp
+
+_setjmp:
+         
+        pop     r1                      ; get return address
+        ldi     sp, ar0		
+	.if .REGPARM == 0
+	ldi     *ar0, ar2               ; get the location of jmp_buf arg.
+	.endif
+ 
+	;;
+	;; Only save regs guaranteed to be preserved across
+	;; calls in the jmp_buf
+	;; 
+        sti     r4, *ar2++      ; save register variables
+        sti     r5, *ar2++      ;   (r4 - ar7)
+        stf     r6, *ar2++
+        stf     r7, *ar2++
+	.if .TMS320C40
+	sti     r8, *ar2++
+	.endif
+        sti     ar3, *ar2++     ; save callers fp
+        sti     ar4, *ar2++
+        sti     ar5, *ar2++
+        sti     ar6, *ar2++
+        sti     ar7, *ar2++
+        bd      r1              ; delayed branch to return
+        sti     r1, *ar2++      ; save return address
+        sti     ar0, *ar2       ; save callers sp
+        ldi     0, r0           ; setjmp returns zero
+	;; branch occurs here
+
+	;; 
+	;; Longjmp
+	;; 
+_longjmp:
+        .if .REGPARM == 0
+        ldi     sp, ar0
+        ldi     *-ar0(1), ar2   ; get location of jmp_buf
+        ldi     *-ar0(2), r0    ; get return value
+        ldiz    1, r0           ; ensure non-zero return value
+        .else
+        ldi     r2, r0          ; return value
+        ldiz    1, r0           ; ensure non-zero return value
+        .endif
+
+	;;
+	;; restore env from saved jmp_buf
+	;; 
+        ldi     *ar2++, r4      ; restore register variables
+        ldi     *ar2++, r5      ;    (r4 - ar7)
+        ldf     *ar2++, r6
+        ldf     *ar2++, r7
+        .if .TMS320C40
+        ldi     *ar2++, r8
+        .endif
+        ldi     *ar2++, ar3     ; restore fp
+        ldi     *ar2++, ar4
+        ldi     *ar2++, ar5
+        ldi     *ar2++, ar6
+        ldi     *ar2++, ar7
+        ldi     *ar2++, r1      ; get return address
+        ldi     *ar2, sp        ; restore sp
+ 
+        b       r1              ; branch to setjmp for return
+        .end
+ 
+


More information about the Newlib mailing list