From 7d9b72e7d33187d134150286713fb5f01bf13cbd Mon Sep 17 00:00:00 2001 From: Daniel Hellstrom Date: Thu, 5 Jun 2014 11:43:02 +0200 Subject: SPARC: support for runtime FPU detection With this patch it is possible to compile a kernel that works on both FPU and non-FPU SPARC systems. The SPARC PSR register contains a bit indicating if FPU is present. It is a minimal increase to the foot-print. --- cpukit/score/cpu/sparc/cpu_asm.S | 17 +++++++++++++++-- cpukit/score/cpu/sparc/rtems/score/sparc.h | 10 +++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cpukit/score/cpu/sparc/cpu_asm.S b/cpukit/score/cpu/sparc/cpu_asm.S index 92674de783..15f9dd26e1 100644 --- a/cpukit/score/cpu/sparc/cpu_asm.S +++ b/cpukit/score/cpu/sparc/cpu_asm.S @@ -55,7 +55,13 @@ SYM(_CPU_Context_save_fp): or %l1, %lo(SPARC_PSR_EF_MASK), %l1 or %l0, %l1, %l0 mov %l0, %psr ! **** ENABLE FLOAT ACCESS **** - nop; nop; nop; ! Need three nops before EF is + nop; nop; nop; ! Need three nops before EF is +#ifdef SPARC_DYNAMIC_FPU_DETECTION + mov %psr, %l0 ! **** check whether fpu present **** + andcc %l0,%l1,%g0 + beq 1f + nop +#endif ld [%i0], %l0 ! active due to pipeline delay!!! std %f0, [%l0 + FO_F1_OFFSET] std %f2, [%l0 + F2_F3_OFFSET] @@ -104,7 +110,13 @@ SYM(_CPU_Context_restore_fp): or %l1, %lo(SPARC_PSR_EF_MASK), %l1 or %l0, %l1, %l0 mov %l0, %psr ! **** ENABLE FLOAT ACCESS **** - nop; nop; nop; ! Need three nops before EF is + nop; nop; nop; ! Need three nops before EF is +#ifdef SPARC_DYNAMIC_FPU_DETECTION + mov %psr, %l0 ! **** check whether fpu present **** + andcc %l0,%l1,%g0 + beq 1f + nop +#endif ld [%i0], %l0 ! active due to pipeline delay!!! ldd [%l0 + FO_F1_OFFSET], %f0 ldd [%l0 + F2_F3_OFFSET], %f2 @@ -123,6 +135,7 @@ SYM(_CPU_Context_restore_fp): ldd [%l0 + F28_F29_OFFSET], %f28 ldd [%l0 + F3O_F31_OFFSET], %f30 ld [%l0 + FSR_OFFSET], %fsr +1: ret restore diff --git a/cpukit/score/cpu/sparc/rtems/score/sparc.h b/cpukit/score/cpu/sparc/rtems/score/sparc.h index abd0f8b987..e3251d8473 100644 --- a/cpukit/score/cpu/sparc/rtems/score/sparc.h +++ b/cpukit/score/cpu/sparc/rtems/score/sparc.h @@ -62,12 +62,20 @@ extern "C" { */ #define SPARC_NUMBER_OF_REGISTER_WINDOWS 8 +/** + * Compile the SPARC kernel with runtime FPU detection. This is used + * by RTEMS kernels built without FPU but still need to be able to + * run tasks with FPU enabled. This way the kernel is SPARC (v7/v8) + * with or without FPU compatible. + */ +#define SPARC_DYNAMIC_FPU_DETECTION 1 + /** * This macro indicates whether this multilib variation has hardware * floating point or not. We use the gcc cpp predefine _SOFT_FLOAT * to determine that. */ -#if defined(_SOFT_FLOAT) +#if !defined(SPARC_DYNAMIC_FPU_DETECTION) && defined(_SOFT_FLOAT) #define SPARC_HAS_FPU 0 #else #define SPARC_HAS_FPU 1 -- cgit v1.2.3