public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* Patch to Enhance m68k Support
@ 2011-02-07 19:34 Joel Sherrill
  2011-02-08 13:15 ` Anthony Green
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Sherrill @ 2011-02-07 19:34 UTC (permalink / raw)
  To: libffi-discuss, Ian Lance Taylor, Ralf Corsepius

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

Hi,

Ian and I have been working on trying to get Go to
work on as many rtems targets as possible.  Go
requires that libffi support be in place and this
is the first time RTEMS has needed libffi.

RTEMS builds a lot of multilibs and the m68k libffi code
did not support anything but 68020-ish CPUs with
HW FPU.  This patch adds support for Coldfire cores,
mc68000 cores, and soft float variants.  It also
adds support for flushing the cache on RTEMS.

I reported this as and got review on the patch as
GCC PR47442 but it appears that Ralf also reported this
in 2004 as PR14555 and I am a CC on that.  But now we
really need it. LOL

Can someone please apply this and bring it into gcc?

Thanks.

2011-02-07  Joel Sherrill <joel.sherrill@oarcorp.com>

         * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing.
         Handle case when CPU variant does not have long double support.
         * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire,
         and cores with soft floating point.

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



[-- Attachment #2: libffi-m68k.diff --]
[-- Type: text/plain, Size: 3098 bytes --]

2011-02-07  Joel Sherrill <joel.sherrill@oarcorp.com>

	* libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing.
	Handle case when CPU variant does not have long double support.
	* libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire,
	and cores with soft floating point.

===================================================================
--- libffi/src/m68k/ffi.c	(revision 169864)
+++ libffi/src/m68k/ffi.c	(working copy)
@@ -9,8 +9,12 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#ifdef __rtems__
+void rtems_cache_flush_multiple_data_lines( const void *, size_t );
+#else
 #include <sys/syscall.h>
 #include <asm/cachectl.h>
+#endif
 
 void ffi_call_SYSV (extended_cif *,
 		    unsigned, unsigned,
@@ -144,9 +148,11 @@
       cif->flags = CIF_FLAGS_DOUBLE;
       break;
 
+#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE)
     case FFI_TYPE_LONGDOUBLE:
       cif->flags = CIF_FLAGS_LDOUBLE;
       break;
+#endif
 
     case FFI_TYPE_POINTER:
       cif->flags = CIF_FLAGS_POINTER;
@@ -266,8 +272,12 @@
   else
     *(void **)(closure->tramp + 8) = ffi_closure_SYSV;
 
+#ifdef __rtems__
+  rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE );
+#else
   syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
 	  FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
+#endif
 
   closure->cif  = cif;
   closure->user_data = user_data;
Index: libffi/src/m68k/sysv.S
===================================================================
--- libffi/src/m68k/sysv.S	(revision 169864)
+++ libffi/src/m68k/sysv.S	(working copy)
@@ -1,4 +1,5 @@
 /* -----------------------------------------------------------------------
+	
    sysv.S - Copyright (c) 1998 Andreas Schwab
 	    Copyright (c) 2008 Red Hat, Inc. 
    
@@ -85,7 +86,12 @@
 	move.l	16(%fp),%d2
 
 	| If the return value pointer is NULL, assume no return value.
+	| NOTE: On the mc68000, tst on an address register is not supported.
+#if defined(__mc68000__) && !defined(__mcoldfire__)
+	cmp.w	#0, %a1
+#else
 	tst.l	%a1
+#endif
 	jbeq	noretval
 
 	btst	#0,%d2
@@ -103,19 +109,34 @@
 retfloat:
 	btst	#2,%d2
 	jbeq	retdouble
+#if defined(__MC68881__)
 	fmove.s	%fp0,(%a1)
+#else
+	move.l	%d0,(%a1)
+#endif
 	jbra	epilogue
 
 retdouble:
 	btst	#3,%d2
 	jbeq	retlongdouble
+#if defined(__MC68881__)
 	fmove.d	%fp0,(%a1)
+#else
+	move.l	%d0,(%a1)+
+	move.l	%d1,(%a1)
+#endif
 	jbra	epilogue
 
 retlongdouble:
 	btst	#4,%d2
 	jbeq	retpointer
+#if defined(__MC68881__)
 	fmove.x	%fp0,(%a1)
+#else
+	move.l	%d0,(%a1)+
+	move.l	%d1,(%a1)+
+	move.l	%d2,(%a1)
+#endif
 	jbra	epilogue
 
 retpointer:
@@ -178,16 +199,31 @@
 	move.l	(%a0),%d1
 	jra	.Lcls_epilogue
 .Lcls_ret_float:
+#if defined(__MC68881__)
 	fmove.s	(%a0),%fp0
+#else
+	move.l	(%a0),%d0
+#endif
 	jra	.Lcls_epilogue
 1:
 	lsr.l	#2,%d0
 	jne	1f
 	jcs	.Lcls_ret_ldouble
+#if defined(__MC68881__)
 	fmove.d	(%a0),%fp0
+#else
+	move.l	(%a0)+,%d0
+	move.l	(%a0),%d1
+#endif
 	jra	.Lcls_epilogue
 .Lcls_ret_ldouble:
+#if defined(__MC68881__)
 	fmove.x	(%a0),%fp0
+#else
+	move.l	(%a0)+,%d0
+	move.l	(%a0)+,%d1
+	move.l	(%a0),%d2
+#endif
 	jra	.Lcls_epilogue
 1:
 	lsr.l	#2,%d0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Patch to Enhance m68k Support
  2011-02-07 19:34 Patch to Enhance m68k Support Joel Sherrill
@ 2011-02-08 13:15 ` Anthony Green
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Green @ 2011-02-08 13:15 UTC (permalink / raw)
  To: Joel Sherrill; +Cc: libffi-discuss, Ian Lance Taylor, Ralf Corsepius

Joel Sherrill <joel.sherrill@oarcorp.com> writes:

> Hi,
>
> Ian and I have been working on trying to get Go to
> work on as many rtems targets as possible.  Go
> requires that libffi support be in place and this
> is the first time RTEMS has needed libffi.
>
> RTEMS builds a lot of multilibs and the m68k libffi code
> did not support anything but 68020-ish CPUs with
> HW FPU.  This patch adds support for Coldfire cores,
> mc68000 cores, and soft float variants.  It also
> adds support for flushing the cache on RTEMS.
>
> I reported this as and got review on the patch as
> GCC PR47442 but it appears that Ralf also reported this
> in 2004 as PR14555 and I am a CC on that.  But now we
> really need it. LOL
>
> Can someone please apply this and bring it into gcc?

Hi Joel,

Please go ahead and check this directly into the GCC tree if you like.
The merge into libffi git from GCC is semi-automated (one happened
earlier today).

AG


>
> Thanks.
>
> 2011-02-07  Joel Sherrill <joel.sherrill@oarcorp.com>
>
>         * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing.
>         Handle case when CPU variant does not have long double support.
>         * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire,
>         and cores with soft floating point.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-08 13:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-07 19:34 Patch to Enhance m68k Support Joel Sherrill
2011-02-08 13:15 ` Anthony Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).