summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-12-23 07:29:47 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-01-27 08:09:05 +0100
commit2145853b009e939dfbe14869b710133f50500a26 (patch)
treecb4504a3f442a83ea508a03b31aa8379b42790ed /cpukit/score
parentbsps/arm: Fix broken switch statement (diff)
downloadrtems-2145853b009e939dfbe14869b710133f50500a26.tar.bz2
score: Fix simple timecounter support
Close #2502.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/timecounter.h27
-rw-r--r--cpukit/score/src/kern_tc.c16
2 files changed, 33 insertions, 10 deletions
diff --git a/cpukit/score/include/rtems/score/timecounter.h b/cpukit/score/include/rtems/score/timecounter.h
index 0d17cc7ce3..33de269ec8 100644
--- a/cpukit/score/include/rtems/score/timecounter.h
+++ b/cpukit/score/include/rtems/score/timecounter.h
@@ -26,6 +26,8 @@
#include <sys/time.h>
#include <sys/timetc.h>
+#include <rtems/score/isrlock.h>
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -161,6 +163,21 @@ void _Timecounter_Install( struct timecounter *tc );
void _Timecounter_Tick( void );
/**
+ * @brief Lock to protect the timecounter mechanic.
+ */
+ISR_LOCK_DECLARE( extern, _Timecounter_Lock )
+
+/**
+ * @brief Acquires the timecounter lock.
+ *
+ * @param[in] lock_context The lock context.
+ *
+ * See _Timecounter_Tick_simple().
+ */
+#define _Timecounter_Acquire( lock_context ) \
+ _ISR_lock_ISR_disable_and_acquire( &_Timecounter_Lock, lock_context )
+
+/**
* @brief Performs a simple timecounter tick.
*
* This is a special purpose tick function for simple timecounter to support
@@ -169,8 +186,14 @@ void _Timecounter_Tick( void );
* @param[in] delta The time in timecounter ticks elapsed since the last call
* to _Timecounter_Tick_simple().
* @param[in] offset The current value of the timecounter.
- */
-void _Timecounter_Tick_simple( uint32_t delta, uint32_t offset );
+ * @param[in] lock_context The lock context of the corresponding
+ * _Timecounter_Acquire().
+ */
+void _Timecounter_Tick_simple(
+ uint32_t delta,
+ uint32_t offset,
+ ISR_lock_Context *lock_context
+);
/**
* @brief The wall clock time in seconds.
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index f6a1136d31..4257533455 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -64,7 +64,9 @@ __FBSDID("$FreeBSD r284178 2015-06-09T11:49:56Z$");
#ifdef __rtems__
#include <limits.h>
#include <rtems.h>
-ISR_LOCK_DEFINE(static, _Timecounter_Lock, "Timecounter");
+ISR_LOCK_DEFINE(, _Timecounter_Lock, "Timecounter")
+#define _Timecounter_Release(lock_context) \
+ _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, lock_context)
#define hz rtems_clock_get_ticks_per_second()
#define printf(...)
#define log(...)
@@ -1383,7 +1385,7 @@ tc_windup(void)
#ifdef __rtems__
ISR_lock_Context lock_context;
- _ISR_lock_ISR_disable_and_acquire(&_Timecounter_Lock, &lock_context);
+ _Timecounter_Acquire(&lock_context);
#endif /* __rtems__ */
/*
@@ -1538,7 +1540,7 @@ tc_windup(void)
timekeep_push_vdso();
#endif /* __rtems__ */
#ifdef __rtems__
- _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, &lock_context);
+ _Timecounter_Release(&lock_context);
#endif /* __rtems__ */
}
@@ -1963,14 +1965,12 @@ _Timecounter_Tick(void)
}
#ifdef __rtems__
void
-_Timecounter_Tick_simple(uint32_t delta, uint32_t offset)
+_Timecounter_Tick_simple(uint32_t delta, uint32_t offset,
+ ISR_lock_Context *lock_context)
{
struct bintime bt;
struct timehands *th;
uint32_t ogen;
- ISR_lock_Context lock_context;
-
- _ISR_lock_ISR_disable_and_acquire(&_Timecounter_Lock, &lock_context);
th = timehands;
ogen = th->th_generation;
@@ -1997,7 +1997,7 @@ _Timecounter_Tick_simple(uint32_t delta, uint32_t offset)
time_second = th->th_microtime.tv_sec;
time_uptime = th->th_offset.sec;
- _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, &lock_context);
+ _Timecounter_Release(lock_context);
_Watchdog_Tick();
}