Hi, everyone

Is there any consideration why the FAST_IDLE is separated from normal
path,can I change the FAST_IDLE like the following?

#if defined(BSP_FEATURE_IRQ_EXTENSION) || \
    (CPU_SIMPLE_VECTORED_INTERRUPTS != TRUE)
void Clock_isr(void *arg);
void Clock_isr(void *arg)
{
#else
rtems_isr Clock_isr(rtems_vector_number vector);
rtems_isr Clock_isr(
  rtems_vector_number vector
)
{
#endif
  /*
   *  Accurate count of ISRs
   */
  Clock_driver_ticks += 1;

  #if CLOCK_DRIVER_ISRS_PER_TICK
    /*
     *  The driver is multiple ISRs per clock tick.
     */
    if ( !Clock_driver_isrs ) {
      Clock_driver_timecounter_tick();

      Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK_VALUE;
    }
    Clock_driver_isrs--;
  #else
    /*
     *  The driver is one ISR per clock tick.
     */
    Clock_driver_timecounter_tick();

    #if CLOCK_DRIVER_USE_FAST_IDLE
      if (_SMP_Get_processor_maximum() == 1) {
        struct timecounter *tc;
        uint64_t            us_per_tick;
        uint32_t            interval;
        Per_CPU_Control    *cpu_self;

        cpu_self = _Per_CPU_Get();
        tc = _Timecounter;
        us_per_tick = rtems_configuration_get_microseconds_per_tick();
        interval = (uint32_t) ((tc->tc_frequency * us_per_tick) / 1000000);

        while (
          cpu_self->thread_dispatch_disable_level == cpu_self->isr_nest_level
            && cpu_self->heir == cpu_self->executing
            && cpu_self->executing->is_idle
        ) {
          ISR_lock_Context lock_context;

          _Timecounter_Acquire(&lock_context);
          _Timecounter_Tick_simple(
            interval,
            (*tc->tc_get_timecount)(tc),
            &lock_context
          );
        }
      }
    #endif
  #endif
    /*
     *  Do the hardware specific per-tick action.
     *
     *  The counter/timer may or may not be set to automatically reload.
     */
    Clock_driver_support_at_tick();
}
diff --git a/bsps/shared/dev/clock/clockimpl.h b/bsps/shared/dev/clock/clockimpl.h
index dad71307f4..635c52b54e 100644
--- a/bsps/shared/dev/clock/clockimpl.h
+++ b/bsps/shared/dev/clock/clockimpl.h
@@ -141,10 +141,23 @@ rtems_isr Clock_isr(
    */
   Clock_driver_ticks += 1;
 
-  #if CLOCK_DRIVER_USE_FAST_IDLE
-    {
+  #if CLOCK_DRIVER_ISRS_PER_TICK
+    /*
+     *  The driver is multiple ISRs per clock tick.
+     */
+    if ( !Clock_driver_isrs ) {
       Clock_driver_timecounter_tick();
 
+      Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK_VALUE;
+    }
+    Clock_driver_isrs--;
+  #else
+    /*
+     *  The driver is one ISR per clock tick.
+     */
+    Clock_driver_timecounter_tick();
+
+    #if CLOCK_DRIVER_USE_FAST_IDLE
       if (_SMP_Get_processor_maximum() == 1) {
         struct timecounter *tc;
         uint64_t            us_per_tick;
@@ -171,34 +184,14 @@ rtems_isr Clock_isr(
           );
         }
       }
-
-      Clock_driver_support_at_tick();
-    }
-  #else
+    #endif
+  #endif
     /*
      *  Do the hardware specific per-tick action.
      *
      *  The counter/timer may or may not be set to automatically reload.
      */
     Clock_driver_support_at_tick();
-
-    #if CLOCK_DRIVER_ISRS_PER_TICK
-      /*
-       *  The driver is multiple ISRs per clock tick.
-       */
-      if ( !Clock_driver_isrs ) {
-        Clock_driver_timecounter_tick();
-
-        Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK_VALUE;
-      }
-      Clock_driver_isrs--;
-    #else
-      /*
-       *  The driver is one ISR per clock tick.
-       */
-      Clock_driver_timecounter_tick();
-    #endif
-  #endif
 }
 
 void _Clock_Initialize( void )
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to