[PATCH] mpci: Simplify MPCI configuration

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Dec 10 07:10:21 UTC 2019


Use watchdog for shared memory driver instead of a Classic API Timer.
---
 bsps/include/shm_driver.h       |  1 +
 bsps/shared/shmdr/shmdr-poll.c  | 43 ++++++++++++++++++++++++-----------------
 cpukit/include/rtems/confdefs.h | 11 ++---------
 3 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/bsps/include/shm_driver.h b/bsps/include/shm_driver.h
index cb94cec0cb..e357b46e5e 100644
--- a/bsps/include/shm_driver.h
+++ b/bsps/include/shm_driver.h
@@ -17,6 +17,7 @@
 #ifndef __SHM_h
 #define __SHM_h
 
+#include <rtems.h>
 #include <rtems/clockdrv.h>
 
 #ifdef __cplusplus
diff --git a/bsps/shared/shmdr/shmdr-poll.c b/bsps/shared/shmdr/shmdr-poll.c
index 39eab7d352..e61e4ae4d6 100644
--- a/bsps/shared/shmdr/shmdr-poll.c
+++ b/bsps/shared/shmdr/shmdr-poll.c
@@ -13,18 +13,29 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
-#include <rtems.h>
 #include <rtems/score/sysstate.h>
-#include <rtems/libio.h>
-
-#include <assert.h>
+#include <rtems/score/watchdogimpl.h>
 
 #include "shm_driver.h"
 
-static rtems_timer_service_routine Shm_Poll_TSR(
-  rtems_id  id,
-  void     *ignored_address
-)
+static void Shm_Poll_Set_timer( Watchdog_Control *the_watchdog )
+{
+  Per_CPU_Control  *cpu;
+  ISR_lock_Context  lock_context;
+
+  cpu = _Watchdog_Get_CPU( the_watchdog );
+  _ISR_lock_ISR_disable( &lock_context );
+  _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context );
+  _Watchdog_Insert(
+    &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ],
+    the_watchdog,
+    cpu->Watchdog.ticks + 1
+  );
+  _Watchdog_Per_CPU_release_critical( cpu, &lock_context );
+  _ISR_lock_ISR_enable( &lock_context );
+}
+
+static void Shm_Poll_TSR( Watchdog_Control *the_watchdog )
 {
   uint32_t tmpfront;
 
@@ -40,18 +51,14 @@ static rtems_timer_service_routine Shm_Poll_TSR(
     Shm_Interrupt_count++;
   }
 
-  (void) rtems_timer_reset( id );
+  Shm_Poll_Set_timer( the_watchdog );
 }
 
+static Watchdog_Control Shm_Poll_Watchdog = WATCHDOG_INITIALIZER(
+  Shm_Poll_TSR
+);
+
 void Shm_install_timer(void)
 {
-  rtems_id          id;
-  rtems_status_code status;
-
-  status = rtems_timer_create( rtems_build_name( 'S', 'H', 'P', 'L' ), &id );
-  assert( !status );
-
-  status = rtems_timer_fire_after( id, 1, Shm_Poll_TSR, NULL );
-  assert( !status );
+  Shm_Poll_Set_timer( &Shm_Poll_Watchdog );
 }
-
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index 3f949b2cfa..922e4d7a9d 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -1817,8 +1817,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
    */
 
   #ifdef CONFIGURE_MP_APPLICATION
-    #define _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 1
-
     #ifndef CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE
 
       #ifndef CONFIGURE_MP_NODE_NUMBER
@@ -1868,11 +1866,9 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
     #endif /* CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE */
   #else
     #define CONFIGURE_MULTIPROCESSING_TABLE NULL
-    #define _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 0
     #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0
   #endif /* CONFIGURE_MP_APPLICATION */
 #else
-  #define _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 0
   #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0
 #endif /* RTEMS_MULTIPROCESSING */
 /**@}*/ /* end of Multiprocessing Configuration */
@@ -1992,9 +1988,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
   #define CONFIGURE_MAXIMUM_TIMERS             0
 #endif
 
-#define _CONFIGURE_TIMERS \
-  (CONFIGURE_MAXIMUM_TIMERS + _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER)
-
 #ifndef CONFIGURE_MAXIMUM_SEMAPHORES
   /** This specifies the maximum number of Classic API semaphores. */
   #define CONFIGURE_MAXIMUM_SEMAPHORES                 0
@@ -2775,8 +2768,8 @@ struct _reent *__getreent(void)
     );
   #endif
 
-  #if _CONFIGURE_TIMERS > 0
-    TIMER_INFORMATION_DEFINE( _CONFIGURE_TIMERS );
+  #if CONFIGURE_MAXIMUM_TIMERS > 0
+    TIMER_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_TIMERS );
   #endif
 
   #if _CONFIGURE_TASKS > 0
-- 
2.16.4



More information about the devel mailing list