[PATCH] bsp/tms570: implemented support functions to satisfy complete

Pavel Pisa pisa at cmp.felk.cvut.cz
Thu Aug 21 11:53:22 UTC 2014


This patch enables to build all RTEMS tests for tms570ls3137_hdk_sdram
BSP variant in in default build (without --enable-rtems-debug set).

---
 Patch not tested on real hardware yet. I check it tomorrow when I am at university.

 c/src/lib/libbsp/arm/tms570/Makefile.am            |  8 +++
 .../lib/libbsp/arm/tms570/clock/benchmark_timer.c  | 63 ++++++++++++++++++++++
 c/src/lib/libbsp/arm/tms570/clock/clock.c          |  1 -
 .../lib/libbsp/arm/tms570/include/system-clocks.h  | 62 +++++++++++++++++++++
 c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c  | 52 ++++++++++++++++++
 c/src/lib/libbsp/arm/tms570/preinstall.am          |  4 ++
 6 files changed, 189 insertions(+), 1 deletion(-)
 create mode 100644 c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c
 create mode 100644 c/src/lib/libbsp/arm/tms570/include/system-clocks.h
 create mode 100644 c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c

diff --git a/c/src/lib/libbsp/arm/tms570/Makefile.am b/c/src/lib/libbsp/arm/tms570/Makefile.am
index 02d7b66..bc0340d 100644
--- a/c/src/lib/libbsp/arm/tms570/Makefile.am
+++ b/c/src/lib/libbsp/arm/tms570/Makefile.am
@@ -39,6 +39,7 @@ include_bsp_HEADERS += include/tms570-rti.h
 include_bsp_HEADERS += include/tms570-vim.h
 include_bsp_HEADERS += include/tms570-pom.h
 include_bsp_HEADERS += include/tms570-sci-driver.h
+include_bsp_HEADERS += include/system-clocks.h
 
 include_HEADERS += ../../shared/include/tm27.h
 
@@ -105,6 +106,7 @@ libbsp_a_SOURCES += console/tms570-sci.c
 # Clock
 libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
 libbsp_a_SOURCES += clock/clock.c
+libbsp_a_SOURCES += clock/benchmark_timer.c
 
 # RTC
 
@@ -115,9 +117,15 @@ libbsp_a_SOURCES += clock/clock.c
 # Benchmark Timer
 
 # Misc
+libbsp_a_SOURCES += misc/cpucounterread.c
 
 # Watchdog
 
+# Cache
+libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
+libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
+libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
+
 # Start hooks
 libbsp_a_SOURCES += startup/bspstarthooks.c
 
diff --git a/c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c b/c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c
new file mode 100644
index 0000000..31c9579
--- /dev/null
+++ b/c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c
@@ -0,0 +1,63 @@
+/**
+ * @file benchmark_timer.c
+ *
+ * @ingroup tms570
+ *
+ * @brief clock functions definitions.
+ */
+
+/*
+ * Copyright (c) 2014 Pavel Pisa <pisa at cmp.felk.cvut.cz>
+ *
+ * Czech Technical University in Prague
+ * Zikova 1903/4
+ * 166 36 Praha 6
+ * Czech Republic
+ *
+ * Based on LPC24xx and LPC1768 BSP
+ * by embedded brains GmbH and others
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <stdlib.h>
+
+#include <rtems.h>
+#include <bsp.h>
+#include <bsp/irq.h>
+#include <bsp/tms570-rti.h>
+#include <bsp/system-clocks.h>
+#include <rtems/btimer.h>
+#include <rtems/timerdrv.h>
+
+bool benchmark_timer_find_average_overhead = false;
+
+static uint32_t benchmark_timer_base;
+
+void benchmark_timer_initialize(void)
+{
+  benchmark_timer_base = tms570_timer();
+}
+
+uint32_t benchmark_timer_read(void)
+{
+  uint32_t delta = tms570_timer() - benchmark_timer_base;
+
+  if (benchmark_timer_find_average_overhead) {
+    return delta;
+  } else {
+    /* TODO check on hardware */
+    if (delta > 74) {
+      return delta - 74;
+    } else {
+      return 0;
+    }
+  }
+}
+
+void benchmark_timer_disable_subtracting_average_overhead(bool find_average_overhead )
+{
+  benchmark_timer_find_average_overhead = find_average_overhead;
+}
diff --git a/c/src/lib/libbsp/arm/tms570/clock/clock.c b/c/src/lib/libbsp/arm/tms570/clock/clock.c
index 2a8bb5f..2fb0b37 100644
--- a/c/src/lib/libbsp/arm/tms570/clock/clock.c
+++ b/c/src/lib/libbsp/arm/tms570/clock/clock.c
@@ -80,7 +80,6 @@ static void tms570_clock_driver_support_at_tick( void )
 {
   TMS570_RTI.RTIINTFLAG = 0x00000001;
   tms570_rti_last_tick_fcr0 = TMS570_RTI.RTICOMP0 - TMS570_RTI.RTIUDCP0;
-  /* TMS570_RTI.RTICOMP0 += 1000; */
 }
 
 /**
diff --git a/c/src/lib/libbsp/arm/tms570/include/system-clocks.h b/c/src/lib/libbsp/arm/tms570/include/system-clocks.h
new file mode 100644
index 0000000..d441ec4
--- /dev/null
+++ b/c/src/lib/libbsp/arm/tms570/include/system-clocks.h
@@ -0,0 +1,62 @@
+/**
+ * @file benchmark_timer.c
+ *
+ * @ingroup tms570
+ *
+ * @brief System clocks.
+ */
+
+/*
+ * Copyright (c) 2014 Pavel Pisa <pisa at cmp.felk.cvut.cz>
+ *
+ * Czech Technical University in Prague
+ * Zikova 1903/4
+ * 166 36 Praha 6
+ * Czech Republic
+ *
+ * Based on LPC24xx and LPC1768 BSP
+ * by embedded brains GmbH and others
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef LIBBSP_ARM_TMS570_SYSTEM_CLOCKS_H
+#define LIBBSP_ARM_TMS570_SYSTEM_CLOCKS_H
+
+#include <bsp/tms570-rti.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup tms570_clock System Clocks
+ *
+ * @ingroup tms570
+ *
+ * @brief System clocks.
+ *
+ * @{
+ */
+
+/**
+ * @brief Returns current standard timer value in microseconds.
+ *
+ * This function uses RTI module free running counter 0 used
+ * which is used as system tick timebase as well.
+ */
+static inline unsigned tms570_timer(void)
+{
+  uint32_t actual_fcr0 = TMS570_RTI.RTIFRC0;
+  return actual_fcr0;
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LIBBSP_ARM_TMS570_SYSTEM_CLOCKS_H */
diff --git a/c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c b/c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c
new file mode 100644
index 0000000..0d57ecd
--- /dev/null
+++ b/c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c
@@ -0,0 +1,52 @@
+/**
+ * @file
+ *
+ * @ingroup tms570_clocks
+ *
+ * @brief System clocks.
+ */
+
+/*
+ * Copyright (c) 2014 Pavel Pisa <pisa at cmp.felk.cvut.cz>
+ *
+ * Czech Technical University in Prague
+ * Zikova 1903/4
+ * 166 36 Praha 6
+ * Czech Republic
+ *
+ * Based on LPC24xx and LPC1768 BSP
+ * by embedded brains GmbH and others
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <stdlib.h>
+
+#include <rtems.h>
+#include <bsp.h>
+
+
+/**
+ * @brief returns the actual value of Cortex-R cycle counter register
+ *
+ * The register is incremented at each core clock period
+ *
+ * @retval x actual core clock counter value
+ *
+ */
+CPU_Counter_ticks _CPU_Counter_read(void)
+{
+  uint32_t ticks;
+  asm volatile ("mrc p15, 0, %0, c9, c13, 0\n": "=r" (ticks));
+  return ticks;
+}
+
+inline CPU_Counter_ticks _CPU_Counter_difference(
+  CPU_Counter_ticks second,
+  CPU_Counter_ticks first
+)
+{
+  return second - first;
+}
diff --git a/c/src/lib/libbsp/arm/tms570/preinstall.am b/c/src/lib/libbsp/arm/tms570/preinstall.am
index 81dbad1..d7ac628 100644
--- a/c/src/lib/libbsp/arm/tms570/preinstall.am
+++ b/c/src/lib/libbsp/arm/tms570/preinstall.am
@@ -109,6 +109,10 @@ $(PROJECT_INCLUDE)/bsp/tms570-sci-driver.h: include/tms570-sci-driver.h $(PROJEC
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/tms570-sci-driver.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/tms570-sci-driver.h
 
+$(PROJECT_INCLUDE)/bsp/system-clocks.h: include/system-clocks.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/system-clocks.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/system-clocks.h
+
 $(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
-- 
1.9.1



More information about the devel mailing list