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

Joel Sherrill joel.sherrill at OARcorp.com
Wed Nov 27 18:07:36 UTC 2013


Generally looks good except you are mentioning a
new .h file which is not present.

+#include <virtualizationlayercpu.h>

I would assume that should be part of a patch in this
series and that it should be "rtems/virtualizationlayercpu.h".

My only other comment is that the use of only cpu.c
and cpu_asm.c dates to the dawn of RTEMS. If you
want to add score/cpu/i386/cpuidle.c and move that
code into its own file, I wouldn't be opposed to it.
But I don't consider that a hard requirement.

The other two patches look OK if folks like the name.

--joel

On 11/27/2013 12:00 PM, Philipp Eppelt 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>
> +
> +  #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>
> +  
> +  #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
> 



-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985



More information about the devel mailing list