[rtems commit] grlib: Add and use irqmp_has_timestamp()

Sebastian Huber sebh at rtems.org
Sat Oct 10 12:01:32 UTC 2020


Module:    rtems
Branch:    master
Commit:    e1a0e0c30829a0da4174085ee5109fba337dba11
Changeset: http://git.rtems.org/rtems/commit/?id=e1a0e0c30829a0da4174085ee5109fba337dba11

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Oct  8 07:50:10 2020 +0200

grlib: Add and use irqmp_has_timestamp()

Replace leon3_irqmp_has_timestamp() with irqmp_has_timestamp() and move
it to grlib.h.

Close #4128.

---

 bsps/include/grlib/grlib.h             | 9 +++++++++
 bsps/riscv/griscv/clock/clockdrv.c     | 2 +-
 bsps/shared/grlib/btimer/tlib_ckinit.c | 2 +-
 bsps/sparc/leon3/clock/ckinit.c        | 4 ++--
 bsps/sparc/leon3/include/leon.h        | 7 -------
 bsps/sparc/leon3/start/cpucounter.c    | 2 +-
 6 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/bsps/include/grlib/grlib.h b/bsps/include/grlib/grlib.h
index fb7085d..49d9999 100644
--- a/bsps/include/grlib/grlib.h
+++ b/bsps/include/grlib/grlib.h
@@ -16,6 +16,8 @@
 #ifndef __GRLIB_H__
 #define __GRLIB_H__
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -51,6 +53,13 @@ struct irqmp_timestamp_regs {
   volatile unsigned int ack;         /* 0x0c */
 };
 
+static inline bool irqmp_has_timestamp(
+  volatile struct irqmp_timestamp_regs *irqmp_ts
+)
+{
+  return (irqmp_ts->control >> 27) > 0;
+}
+
 /* IRQMP and IRQAMP interrupt controllers */
 struct irqmp_regs {
   volatile unsigned int ilevel;      /* 0x00 */
diff --git a/bsps/riscv/griscv/clock/clockdrv.c b/bsps/riscv/griscv/clock/clockdrv.c
index c94c167..4cf15fe 100644
--- a/bsps/riscv/griscv/clock/clockdrv.c
+++ b/bsps/riscv/griscv/clock/clockdrv.c
@@ -171,7 +171,7 @@ static void grlib_clock_initialize(void)
   volatile struct irqmp_timestamp_regs *irqmp_ts =
     &GRLIB_IrqCtrl_Regs->timestamp[0];
 
-    if (!grlib_irqmp_has_timestamp(irqmp_ts)) {
+    if (!irqmp_has_timestamp(irqmp_ts)) {
       bsp_fatal(GRLIB_FATAL_CLOCK_NO_IRQMP_TIMESTAMP_SUPPORT);
     }
 #endif
diff --git a/bsps/shared/grlib/btimer/tlib_ckinit.c b/bsps/shared/grlib/btimer/tlib_ckinit.c
index 4f67998..5a34d97 100644
--- a/bsps/shared/grlib/btimer/tlib_ckinit.c
+++ b/bsps/shared/grlib/btimer/tlib_ckinit.c
@@ -126,7 +126,7 @@ static rtems_device_driver tlib_clock_find_timer(void)
     volatile struct irqmp_timestamp_regs *irqmp_ts;
 
     irqmp_ts = &LEON3_IrqCtrl_Regs->timestamp[0];
-    if (leon3_irqmp_has_timestamp(irqmp_ts)) {
+    if (irqmp_has_timestamp(irqmp_ts)) {
       priv.ops = &ops_irqamp;
       return RTEMS_SUCCESSFUL;
     }
diff --git a/bsps/sparc/leon3/clock/ckinit.c b/bsps/sparc/leon3/clock/ckinit.c
index f485123..bf0c506 100644
--- a/bsps/sparc/leon3/clock/ckinit.c
+++ b/bsps/sparc/leon3/clock/ckinit.c
@@ -176,13 +176,13 @@ static void leon3_clock_initialize(void)
     tc->tc_frequency = leon3_up_counter_frequency();
 
 #ifdef RTEMS_PROFILING
-    if (!leon3_irqmp_has_timestamp(irqmp_ts)) {
+    if (!irqmp_has_timestamp(irqmp_ts)) {
       bsp_fatal(LEON3_FATAL_CLOCK_NO_IRQMP_TIMESTAMP_SUPPORT);
     }
 #endif
 
     leon3_tc_tick = leon3_tc_tick_irqmp_timestamp_init;
-  } else if (leon3_irqmp_has_timestamp(irqmp_ts)) {
+  } else if (irqmp_has_timestamp(irqmp_ts)) {
     /* Use the interrupt controller timestamp counter if available */
     tc->tc_get_timecount = _SPARC_Get_timecount_up;
     tc->tc_frequency = ambapp_freq_get(&ambapp_plb, LEON3_Timer_Adev);
diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
index afe0d91..d25825c 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -454,13 +454,6 @@ static inline uint32_t leon3_get_data_cache_config_register(void)
   return leon3_get_system_register(0xc);
 }
 
-static inline bool leon3_irqmp_has_timestamp(
-  volatile struct irqmp_timestamp_regs *irqmp_ts
-)
-{
-  return (irqmp_ts->control >> 27) > 0;
-}
-
 static inline uint32_t leon3_up_counter_low(void)
 {
   uint32_t asr23;
diff --git a/bsps/sparc/leon3/start/cpucounter.c b/bsps/sparc/leon3/start/cpucounter.c
index 007bb6d..1d96e3b 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -43,7 +43,7 @@ static void leon3_counter_initialize(void)
     counter->read = _SPARC_Counter_read_asr23;
 
     leon3_counter_frequency = leon3_up_counter_frequency();
-  } else if (leon3_irqmp_has_timestamp(irqmp_ts)) {
+  } else if (irqmp_has_timestamp(irqmp_ts)) {
     /* Use the interrupt controller timestamp counter if available */
     counter->read_isr_disabled = _SPARC_Counter_read_up;
     counter->read = _SPARC_Counter_read_up;



More information about the vc mailing list