ffi.c: Add RTEMS support for cache flushing.

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.

From-SVN: r169938
This commit is contained in:
Joel Sherrill 2011-02-08 19:19:01 +00:00
parent 899fb23dc0
commit 9993cf6070
2 changed files with 46 additions and 0 deletions

View File

@ -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 @@ ffi_prep_cif_machdep (ffi_cif *cif)
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 @@ ffi_prep_closure_loc (ffi_closure* closure,
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;

View File

@ -1,4 +1,5 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 1998 Andreas Schwab
Copyright (c) 2008 Red Hat, Inc.
@ -85,7 +86,12 @@ ffi_call_SYSV:
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 @@ retlongint:
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 @@ ffi_closure_SYSV:
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