[PATCH] Optional Clock_driver_support_shutdown_hardware()

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Aug 3 12:49:20 UTC 2017


Make Clock_driver_support_shutdown_hardware() optional.  This avoids
the atexit() support on memory constrained targets.
---
 c/src/lib/libbsp/lm32/shared/clock/ckinit.c           | 13 ++++++-------
 c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c | 10 +++++-----
 c/src/lib/libbsp/m68k/mcf52235/clock/clock.c          |  8 ++++----
 c/src/lib/libbsp/m68k/mcf5225x/clock/clock.c          |  8 ++++----
 c/src/lib/libbsp/m68k/mcf5329/clock/clock.c           |  8 ++++----
 c/src/lib/libbsp/shared/clockdrv_shell.h              |  6 ++++++
 c/src/lib/libcpu/arm/at91rm9200/clock/clock.c         |  8 ++++----
 c/src/lib/libcpu/arm/pxa255/clock/clock.c             |  8 ++++----
 8 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/c/src/lib/libbsp/lm32/shared/clock/ckinit.c b/c/src/lib/libbsp/lm32/shared/clock/ckinit.c
index fd2cae81dc..6a30583853 100644
--- a/c/src/lib/libbsp/lm32/shared/clock/ckinit.c
+++ b/c/src/lib/libbsp/lm32/shared/clock/ckinit.c
@@ -67,13 +67,12 @@ static void Clock_driver_support_initialize_hardware(void)
   lm32_interrupt_unmask(CLOCK_IRQMASK);
 }
 
-static void Clock_driver_support_shutdown_hardware(void)
-{
-  /* Disable clock interrupts and stop */
-
-  lm32_interrupt_unmask(CLOCK_IRQMASK);
-  clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP);
-}
+#define Clock_driver_support_shutdown_hardware() \
+  do { \
+    /* Disable clock interrupts and stop */ \
+    lm32_interrupt_unmask(CLOCK_IRQMASK); \
+    clockwrite(LM32_CLOCK_CR, LM32_CLOCK_CR_STOP); \
+  } while (0)
 
 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
 
diff --git a/c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c b/c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c
index 3230d83325..35b4b818e6 100644
--- a/c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c
+++ b/c/src/lib/libbsp/lm32/shared/milkymist_clock/ckinit.c
@@ -40,11 +40,11 @@ static void Clock_driver_support_initialize_hardware(void)
   bsp_interrupt_vector_enable(MM_IRQ_TIMER0);
 }
 
-static void Clock_driver_support_shutdown_hardware(void)
-{
-  bsp_interrupt_vector_disable(MM_IRQ_TIMER0);
-  MM_WRITE(MM_TIMER0_CONTROL, 0);
-}
+#define Clock_driver_support_shutdown_hardware() \
+  do { \
+    bsp_interrupt_vector_disable(MM_IRQ_TIMER0); \
+    MM_WRITE(MM_TIMER0_CONTROL, 0); \
+  } while (0)
 
 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
 
diff --git a/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c b/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c
index 4b5f4afc51..aa0d0b7945 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c
+++ b/c/src/lib/libbsp/m68k/mcf52235/clock/clock.c
@@ -57,10 +57,10 @@ static void mcf52235_tc_tick(void)
 /*
  * Turn off the clock
  */
-static void Clock_driver_support_shutdown_hardware(void)
-{
-  MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN;
-}
+#define Clock_driver_support_shutdown_hardware() \
+  do { \
+    MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN; \
+  } while (0)
 
 /*
  * Set up the clock hardware
diff --git a/c/src/lib/libbsp/m68k/mcf5225x/clock/clock.c b/c/src/lib/libbsp/m68k/mcf5225x/clock/clock.c
index ee97e5035c..cc2f7d11fa 100644
--- a/c/src/lib/libbsp/m68k/mcf5225x/clock/clock.c
+++ b/c/src/lib/libbsp/m68k/mcf5225x/clock/clock.c
@@ -57,10 +57,10 @@ static void mcf5225x_tc_tick(void)
 /*
  * Turn off the clock
  */
-static void Clock_driver_support_shutdown_hardware(void)
-{
-  MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN;
-}
+#define Clock_driver_support_shutdown_hardware() \
+  do { \
+    MCF_PIT1_PCSR &= ~MCF_PIT_PCSR_EN; \
+  } while (0)
 
 /*
  * Set up the clock hardware
diff --git a/c/src/lib/libbsp/m68k/mcf5329/clock/clock.c b/c/src/lib/libbsp/m68k/mcf5329/clock/clock.c
index 5741b3081d..5f6006e717 100644
--- a/c/src/lib/libbsp/m68k/mcf5329/clock/clock.c
+++ b/c/src/lib/libbsp/m68k/mcf5329/clock/clock.c
@@ -57,10 +57,10 @@ static void mcf5329_tc_tick(void)
 /*
  * Turn off the clock
  */
-static void Clock_driver_support_shutdown_hardware(void)
-{
-  MCF_PIT3_PCSR &= ~MCF_PIT_PCSR_EN;
-}
+#define Clock_driver_support_shutdown_hardware() \
+  do { \
+    MCF_PIT3_PCSR &= ~MCF_PIT_PCSR_EN; \
+  } while (0)
 
 /*
  * Set up the clock hardware
diff --git a/c/src/lib/libbsp/shared/clockdrv_shell.h b/c/src/lib/libbsp/shared/clockdrv_shell.h
index a4d1b2df91..0d40c84d91 100644
--- a/c/src/lib/libbsp/shared/clockdrv_shell.h
+++ b/c/src/lib/libbsp/shared/clockdrv_shell.h
@@ -102,7 +102,9 @@ static void Clock_driver_timecounter_tick( void )
  */
 volatile uint32_t    Clock_driver_ticks;
 
+#ifdef Clock_driver_support_shutdown_hardware
 void Clock_exit( void );
+#endif
 
 /**
  *  @brief Clock_isr
@@ -181,6 +183,7 @@ rtems_isr Clock_isr(
   #endif
 }
 
+#ifdef Clock_driver_support_shutdown_hardware
 /**
  *  @brief Clock_exit
  *
@@ -193,6 +196,7 @@ void Clock_exit( void )
 
   /* do not restore old vector */
 }
+#endif
 
 /**
  * @brief Clock_initialize
@@ -237,7 +241,9 @@ rtems_device_driver Clock_initialize(
    */
   Clock_driver_support_initialize_hardware();
 
+#ifdef Clock_driver_support_shutdown_hardware
   atexit( Clock_exit );
+#endif
 
   /*
    *  If we are counting ISRs per tick, then initialize the counter.
diff --git a/c/src/lib/libcpu/arm/at91rm9200/clock/clock.c b/c/src/lib/libcpu/arm/at91rm9200/clock/clock.c
index 42b85f3f98..ac7f5fe783 100644
--- a/c/src/lib/libcpu/arm/at91rm9200/clock/clock.c
+++ b/c/src/lib/libcpu/arm/at91rm9200/clock/clock.c
@@ -106,10 +106,10 @@ static void Clock_driver_support_initialize_hardware(void)
     (void) st_str; /* avoid set but not used warning */ \
   } while (0)
 
-static void Clock_driver_support_shutdown_hardware( void )
-{
-  BSP_remove_rtems_irq_handler(&clock_isr_data);
-}
+#define Clock_driver_support_shutdown_hardware() \
+  do { \
+    BSP_remove_rtems_irq_handler(&clock_isr_data); \
+  } while (0)
 
 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
 
diff --git a/c/src/lib/libcpu/arm/pxa255/clock/clock.c b/c/src/lib/libcpu/arm/pxa255/clock/clock.c
index 69b684926c..979e6fbd00 100644
--- a/c/src/lib/libcpu/arm/pxa255/clock/clock.c
+++ b/c/src/lib/libcpu/arm/pxa255/clock/clock.c
@@ -111,10 +111,10 @@ static void Clock_driver_support_initialize_hardware(void)
     XSCALE_OS_TIMER_MR0 = XSCALE_OS_TIMER_TCR + period_num; \
   } while (0)
 
-static void Clock_driver_support_shutdown_hardware( void )
-{
-  BSP_remove_rtems_irq_handler(&clock_isr_data);
-}
+#define Clock_driver_support_shutdown_hardware() \
+  do { \
+    BSP_remove_rtems_irq_handler(&clock_isr_data); \
+  } while (0)
 
 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
 
-- 
2.12.3



More information about the devel mailing list