summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/leon3
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 12:08:42 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:52:19 +0200
commite0dd8a5ad830798bc8082b03b8c42c32fb9660e0 (patch)
treed147bfc4d670fcdfbd2e2d2e75eb209f92e07df1 /c/src/lib/libbsp/sparc/leon3
parentbsps: Move startup files to bsps (diff)
downloadrtems-e0dd8a5ad830798bc8082b03b8c42c32fb9660e0.tar.bz2
bsps: Move benchmark timer to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'c/src/lib/libbsp/sparc/leon3')
-rw-r--r--c/src/lib/libbsp/sparc/leon3/Makefile.am10
-rw-r--r--c/src/lib/libbsp/sparc/leon3/timer/timer.c85
-rw-r--r--c/src/lib/libbsp/sparc/leon3/timer/watchdog.c90
3 files changed, 5 insertions, 180 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index df75c03552..71a020cd17 100644
--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -60,9 +60,9 @@ librtemsbsp_a_SOURCES += ../shared/amba/ambapp_show.c
librtemsbsp_a_SOURCES += ../shared/amba/ahbstat.c
# Clock Driver and Timer Library
-librtemsbsp_a_SOURCES += ../shared/timer/gptimer.c
-librtemsbsp_a_SOURCES += ../shared/timer/tlib.c
-librtemsbsp_a_SOURCES += ../shared/timer/tlib_ckinit.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/btimer/gptimer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/btimer/tlib.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/shared/btimer/tlib_ckinit.c
# non-Driver Manager Clock Implementation
librtemsbsp_a_SOURCES +=../../../../../../bsps/sparc/leon3/clock/ckinit.c
@@ -151,8 +151,8 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/start/cache.c
# griommu
librtemsbsp_a_SOURCES += ../shared/iommu/griommu.c
# timer
-librtemsbsp_a_SOURCES += timer/timer.c
-librtemsbsp_a_SOURCES += timer/watchdog.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/btimer/btimer.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/btimer/watchdog.c
# GR712
librtemsbsp_a_SOURCES += ../shared/ascs/grascs.c
diff --git a/c/src/lib/libbsp/sparc/leon3/timer/timer.c b/c/src/lib/libbsp/sparc/leon3/timer/timer.c
deleted file mode 100644
index 40bdeb87bb..0000000000
--- a/c/src/lib/libbsp/sparc/leon3/timer/timer.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* timer.c
- *
- * This file implements a benchmark timer using timer 2.
- *
- * COPYRIGHT (c) 1989-1998.
- * On-Line Applications Research Corporation (OAR).
- *
- * 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.
- *
- * Ported to LEON implementation of the SPARC by On-Line Applications
- * Research Corporation (OAR) under contract to the European Space
- * Agency (ESA).
- *
- * LEON modifications of respective RTEMS file: COPYRIGHT (c) 1995.
- * European Space Agency.
- */
-
-
-#include <bsp.h>
-#include <rtems/btimer.h>
-
-#if defined(RTEMS_MULTIPROCESSING)
- #define LEON3_TIMER_INDEX \
- ((rtems_configuration_get_user_multiprocessing_table()) ? \
- (rtems_configuration_get_user_multiprocessing_table()->node) - 1 : 1)
-#else
- #define LEON3_TIMER_INDEX 0
-#endif
-
-bool benchmark_timer_find_average_overhead;
-
-bool benchmark_timer_is_initialized = false;
-
-extern volatile struct gptimer_regs *LEON3_Timer_Regs;
-
-void benchmark_timer_initialize(void)
-{
- /*
- * Timer runs long and accurate enough not to require an interrupt.
- */
- if (LEON3_Timer_Regs) {
- if ( benchmark_timer_is_initialized == false ) {
- /* approximately 1 us per countdown */
- LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX].reload = 0xffffff;
- LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX].value = 0xffffff;
- } else {
- benchmark_timer_is_initialized = true;
- }
- LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX].ctrl =
- GPTIMER_TIMER_CTRL_EN | GPTIMER_TIMER_CTRL_LD;
- }
-}
-
-#define AVG_OVERHEAD 3 /* It typically takes 3.0 microseconds */
- /* to start/stop the timer. */
-#define LEAST_VALID 2 /* Don't trust a value lower than this */
-
-benchmark_timer_t benchmark_timer_read(void)
-{
- uint32_t total;
-
- if (LEON3_Timer_Regs) {
- total = LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX].value;
-
- total = 0xffffff - total;
-
- if ( benchmark_timer_find_average_overhead == true )
- return total; /* in one microsecond units */
-
- if ( total < LEAST_VALID )
- return 0; /* below timer resolution */
-
- return total - AVG_OVERHEAD;
- }
- return 0;
-}
-
-void benchmark_timer_disable_subtracting_average_overhead(
- bool find_flag
-)
-{
- benchmark_timer_find_average_overhead = find_flag;
-}
diff --git a/c/src/lib/libbsp/sparc/leon3/timer/watchdog.c b/c/src/lib/libbsp/sparc/leon3/timer/watchdog.c
deleted file mode 100644
index 5ce8e32354..0000000000
--- a/c/src/lib/libbsp/sparc/leon3/timer/watchdog.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* GPTIMER Watchdog timer routines. On some systems the first GPTIMER
- * core's last Timer instance underflow signal is connected to system
- * reset.
- *
- * COPYRIGHT (c) 2012.
- * Cobham Gaisler AB.
- *
- * 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 <bsp.h>
-#include <bsp/watchdog.h>
-#include <grlib.h>
-
-extern volatile struct gptimer_regs *LEON3_Timer_Regs;
-
-struct gptimer_watchdog_priv {
- struct gptimer_regs *regs;
- struct gptimer_timer_regs *timer;
- int timerno;
-};
-
-struct gptimer_watchdog_priv bsp_watchdogs[1];
-int bsp_watchdog_count = 0;
-
-int bsp_watchdog_init(void)
-{
- int timercnt;
-
- if (!LEON3_Timer_Regs)
- return 0;
-
- /* Get Watchdogs in system, this is implemented for one GPTIMER core
- * only.
- *
- * First watchdog is a special case, we can get the first timer core by
- * looking at LEON3_Timer_Regs, the watchdog within a timer core is
- * always the last timer. Unfortunately we can not know it the watchdog
- * functionality is available or not, we assume that it is if we
- * reached this function.
- */
- bsp_watchdogs[0].regs = (struct gptimer_regs *)LEON3_Timer_Regs;
-
- /* Find Timer that has watchdog functionality */
- timercnt = bsp_watchdogs[0].regs->cfg & 0x7;
- if (timercnt < 2) /* First timer system clock timer */
- return 0;
-
- bsp_watchdogs[0].timerno = timercnt - 1;
- bsp_watchdogs[0].timer = &bsp_watchdogs[0].regs->timer[bsp_watchdogs[0].timerno];
-
- bsp_watchdog_count = 1;
- return bsp_watchdog_count;
-}
-
-void bsp_watchdog_reload(int watchdog, unsigned int reload_value)
-{
- if (bsp_watchdog_count == 0)
- bsp_watchdog_init();
-
- if (bsp_watchdog_count <= watchdog)
- return;
-
- /* Kick watchdog, and clear interrupt pending bit */
- bsp_watchdogs[watchdog].timer->reload = reload_value;
- bsp_watchdogs[watchdog].timer->ctrl =
- (GPTIMER_TIMER_CTRL_LD | GPTIMER_TIMER_CTRL_EN) |
- (bsp_watchdogs[watchdog].timer->ctrl & ~(1<<4));
-}
-
-void bsp_watchdog_stop(int watchdog)
-{
- if (bsp_watchdog_count == 0)
- bsp_watchdog_init();
-
- if (bsp_watchdog_count <= watchdog)
- return;
-
- /* Stop watchdog timer */
- bsp_watchdogs[watchdog].timer->ctrl = 0;
-}
-
-/* Use watchdog timer to reset system */
-void bsp_watchdog_system_reset(void)
-{
- sparc_disable_interrupts();
- bsp_watchdog_reload(0, 1);
-}