[PATCH 2/3] score: Add _CPU_Instruction_no_operation()
Gedare Bloom
gedare at rtems.org
Fri Jul 20 14:22:33 UTC 2018
This seems fine to me.
On Fri, Jul 20, 2018 at 2:53 AM, Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
> This helps to reduce the use of architecture-specific defines throughout
> the code base.
> ---
> cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h | 10 ++++++++++
> cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h | 5 +++++
> cpukit/score/cpu/x86_64/include/rtems/score/cpuimpl.h | 5 +++++
> testsuites/sptests/spcache01/init.c | 7 ++-----
> 20 files changed, 102 insertions(+), 5 deletions(-)
>
> diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h
> index edc452530f..d007a7982b 100644
> --- a/cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h
> @@ -106,6 +106,11 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
>
> void _CPU_Context_validate( uintptr_t pattern );
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h
> index 19afb254fd..a291aabe2f 100644
> --- a/cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h
> @@ -29,6 +29,11 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
>
> void _CPU_Context_validate( uintptr_t pattern );
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h
> index 1e970cb11d..c13180a06d 100644
> --- a/cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h
> @@ -104,6 +104,16 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
> */
> void _CPU_Context_validate( uintptr_t pattern );
>
> +/**
> + * @brief Emits a no operation instruction (nop).
> + *
> + * This function is used only in test sptests/spcache01.
> + */
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h
> index 19afb254fd..148e23c309 100644
> --- a/cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h
> @@ -29,6 +29,11 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
>
> void _CPU_Context_validate( uintptr_t pattern );
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "l.nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h
> index 6dd8196130..4f5efe5ba3 100644
> --- a/cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h
> @@ -242,6 +242,11 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
>
> void _CPU_Context_validate( uintptr_t pattern );
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h
> index 8bc7778496..8c29b86c4d 100644
> --- a/cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h
> @@ -317,6 +317,11 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
>
> void _CPU_Context_validate( uintptr_t pattern );
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h
> index 7b47b1fb75..93e5b45437 100644
> --- a/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h
> @@ -150,6 +150,11 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
>
> void _CPU_Context_validate( uintptr_t pattern );
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h
> index ee188bebce..5d8bd77161 100644
> --- a/cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h
> @@ -37,6 +37,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/cpukit/score/cpu/x86_64/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/x86_64/include/rtems/score/cpuimpl.h
> index a16a3d040b..543c0918d2 100644
> --- a/cpukit/score/cpu/x86_64/include/rtems/score/cpuimpl.h
> +++ b/cpukit/score/cpu/x86_64/include/rtems/score/cpuimpl.h
> @@ -54,6 +54,11 @@ RTEMS_INLINE_ROUTINE void _CPU_Context_validate( uintptr_t pattern )
> }
> }
>
> +RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
> +{
> + __asm__ volatile ( "nop" );
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/testsuites/sptests/spcache01/init.c b/testsuites/sptests/spcache01/init.c
> index 09bb300ef3..8f5623c241 100644
> --- a/testsuites/sptests/spcache01/init.c
> +++ b/testsuites/sptests/spcache01/init.c
> @@ -23,17 +23,14 @@
>
> #include <rtems.h>
> #include <rtems/counter.h>
> +#include <rtems/score/cpuimpl.h>
> #include <rtems/score/sysstate.h>
>
> #include "tmacros.h"
>
> const char rtems_test_name[] = "SPCACHE 1";
>
> -#ifdef __or1k__
> - #define I() __asm__ volatile ("l.nop")
> -#else
> - #define I() __asm__ volatile ("nop")
> -#endif
> +#define I() _CPU_Instruction_no_operation()
>
> #define I8() I(); I(); I(); I(); I(); I(); I(); I()
>
> --
> 2.13.7
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list