[PATCH 3/3] use RTEMS_PARAVIRT as guard to distinguish between virtual and native functionality on i386

Gedare Bloom gedare at rtems.org
Wed Nov 27 19:13:45 UTC 2013


On Wed, Nov 27, 2013 at 1:00 PM, Philipp Eppelt
<philipp.eppelt at mailbox.tu-dresden.de> wrote:
> ---
>  cpukit/score/cpu/i386/cpu.c                    | 18 +++++++++
>  cpukit/score/cpu/i386/rtems/score/cpu.h        | 51 ++++++++++++++++++++------
>  cpukit/score/cpu/i386/rtems/score/interrupts.h | 31 ++++++++++++++++
>  3 files changed, 88 insertions(+), 12 deletions(-)
>
> diff --git a/cpukit/score/cpu/i386/cpu.c b/cpukit/score/cpu/i386/cpu.c
> index c87a76d..0a6139f 100644
> --- a/cpukit/score/cpu/i386/cpu.c
> +++ b/cpukit/score/cpu/i386/cpu.c
> @@ -97,6 +97,22 @@ uint32_t   _CPU_ISR_Get_level( void )
>    return level;
>  }
>
> +
> +#if defined(RTEMS_PARAVIRT)
> +
> +#include <virtualizationlayercpu.h>
> +
> +void *_CPU_Thread_Idle_body( uintptr_t ignored )
> +{
> +  while(1)
> +  {
> +    _CPU_Virtual_idle_thread();
> +  }
> +  return NULL;
> +}
> +
> +#else
> +
>  void *_CPU_Thread_Idle_body( uintptr_t ignored )
>  {
>    while(1){
> @@ -105,6 +121,8 @@ void *_CPU_Thread_Idle_body( uintptr_t ignored )
>    return NULL;
>  }
>
> +#endif /*RTEMS_PARAVIRT*/
> +
>  struct Frame_ {
>         struct Frame_  *up;
>         uintptr_t               pc;
> diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h
> index 43422ed..a8c2ed3 100644
> --- a/cpukit/score/cpu/i386/rtems/score/cpu.h
> +++ b/cpukit/score/cpu/i386/rtems/score/cpu.h
> @@ -376,11 +376,24 @@ SCORE_EXTERN Context_Control_fp  _CPU_Null_fp_context;
>
>  #define _CPU_ISR_Flash( _level )   i386_flash_interrupts( _level )
>
> -#define _CPU_ISR_Set_level( _new_level ) \
> -  { \
> -    if ( _new_level ) __asm__ volatile ( "cli" ); \
> -    else              __asm__ volatile ( "sti" ); \
> -  }
> +#if defined(RTEMS_PARAVIRT)
> +  #include <virtualizationlayercpu.h>
We want all patches to "build" in the order they appear. This header
file should be included with this patch please. (Merge the next patch
with this one if you don't mind.)

> +
> +  #define _CPU_ISR_Set_level( _new_level ) \
> +    { \
> +      if( _new_level )  _CPU_Virtual_Interrupts_close(); \
> +      else             _CPU_Virtual_Interrupts_open(); \
> +    }
> +
> +#else
> +
> +  #define _CPU_ISR_Set_level( _new_level ) \
> +    { \
> +      if ( _new_level ) __asm__ volatile ( "cli" ); \
> +      else              __asm__ volatile ( "sti" ); \
> +    }
> +
> +#endif /*RTEMS_PARAVIRT*/
>
>  uint32_t   _CPU_ISR_Get_level( void );
>
> @@ -497,16 +510,30 @@ uint32_t   _CPU_ISR_Get_level( void );
>   *    + disable interrupts and halt the CPU
>   */
>
> -#define _CPU_Fatal_halt( _error ) \
> +#if defined(RTEMS_PARAVIRT)
> +
> +  #include <virtualizationlayercpu.h>
> +
This include should be unnecessary as cpu.h will get pulled in.
However if you want to keep the explicit include it should get put to
the top of this cpu.c file (unless you refactor to cpuidle.c file).

> +  #define _CPU_Fatal_halt( _error ) \
>    { \
> -    uint32_t _error_lvalue = ( _error ); \
> -    __asm__ volatile ( "cli ; \
> -                    movl %0,%%eax ; \
> -                    hlt" \
> -                    : "=r" ((_error_lvalue)) : "0" ((_error_lvalue)) \
> -    ); \
> +    _CPU_Virtual_Interrupts_close(); \
> +    _CPU_Virtual_exec_stop_error( _error ); \
>    }
>
> +#else
> +
> +  #define _CPU_Fatal_halt( _error ) \
> +    { \
> +      uint32_t _error_lvalue = ( _error ); \
> +      __asm__ volatile ( "cli ; \
> +                      movl %0,%%eax ; \
> +                      hlt" \
> +                      : "=r" ((_error_lvalue)) : "0" ((_error_lvalue)) \
> +      ); \
> +    }
> +
> +#endif /*RTEMS_PARAVIRT*/
> +
>  #endif /* ASM */
>
>  /* end of Fatal Error manager macros */
> diff --git a/cpukit/score/cpu/i386/rtems/score/interrupts.h b/cpukit/score/cpu/i386/rtems/score/interrupts.h
> index bed6330..1bc9391 100644
> --- a/cpukit/score/cpu/i386/rtems/score/interrupts.h
> +++ b/cpukit/score/cpu/i386/rtems/score/interrupts.h
> @@ -33,6 +33,36 @@ typedef int  (*rtems_raw_irq_is_enabled)     (const struct __rtems_raw_irq_connect_d
>   *
>   */
>  /**@{**/
> +#if defined(RTEMS_PARAVIRT)
> +  #include <virtualizationlayercpu.h>
> +
> +#define i386_disable_interrupts( _level ) \
> +  { \
> +    _CPU_Virtual_Interrupts_disable( _level ); \
> +  }
> +
> +#define i386_enable_interrupts( _level )  \
> +  { \
> +    _CPU_Virtual_Interrupts_enable( _level ); \
> +  }
> +
> +#define i386_flash_interrupts( _level ) \
> +  { \
> +    _CPU_Virtual_Interrupts_enable(_level); \
> +    _CPU_Virtual_Interrupts_disable(_level); \
> +  }
> +
> +#define i386_get_interrupt_level( _level ) \
> +  { \
> +    _CPU_Virtual_Interrupts_get_level( _level ); \
> +  }
> +
> +#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level )
> +#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level )
> +
> +
> +#else /*RTEMS_PARAVIRT*/
> +
>
>  #define i386_disable_interrupts( _level ) \
>    { \
> @@ -75,6 +105,7 @@ typedef int  (*rtems_raw_irq_is_enabled)     (const struct __rtems_raw_irq_connect_d
>  #define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level )
>  #define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level )
>
> +#endif /*RTEMS_PARAVIRT*/
>  /** @} */
>
>  #endif
> --
> 1.8.1.4
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel



More information about the devel mailing list