From 9993cf60700c3242fffaaa60e53ecfa42d971b85 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 8 Feb 2011 19:19:01 +0000 Subject: ffi.c: Add RTEMS support for cache flushing. 2011-02-07 Joel Sherrill * 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 --- libffi/src/m68k/ffi.c | 10 ++++++++++ libffi/src/m68k/sysv.S | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) (limited to 'libffi') diff --git a/libffi/src/m68k/ffi.c b/libffi/src/m68k/ffi.c index 600cf20..0d4df1e 100644 --- a/libffi/src/m68k/ffi.c +++ b/libffi/src/m68k/ffi.c @@ -9,8 +9,12 @@ #include #include +#ifdef __rtems__ +void rtems_cache_flush_multiple_data_lines( const void *, size_t ); +#else #include #include +#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; diff --git a/libffi/src/m68k/sysv.S b/libffi/src/m68k/sysv.S index 58822e0..c782f51 100644 --- a/libffi/src/m68k/sysv.S +++ b/libffi/src/m68k/sysv.S @@ -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 -- cgit v1.1