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

Philipp Eppelt philipp.eppelt at mailbox.tu-dresden.de
Wed Nov 27 18:00:21 UTC 2013


---
 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
-- 
1.8.1.4




More information about the devel mailing list