summaryrefslogtreecommitdiffstats
path: root/cpukit/sapi
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/sapi
parentbsps/arm: Fix broken switch statement (diff)
downloadrtems-2145853b009e939dfbe14869b710133f50500a26.tar.bz2
score: Fix simple timecounter support
Close #2502.
Diffstat (limited to 'cpukit/sapi')
-rw-r--r--cpukit/sapi/include/rtems/timecounter.h35
1 files changed, 29 insertions, 6 deletions
diff --git a/cpukit/sapi/include/rtems/timecounter.h b/cpukit/sapi/include/rtems/timecounter.h
index 04bc534d55..db0a7eee72 100644
--- a/cpukit/sapi/include/rtems/timecounter.h
+++ b/cpukit/sapi/include/rtems/timecounter.h
@@ -94,6 +94,13 @@ typedef struct {
} rtems_timecounter_simple;
/**
+ * @brief At tick handling done under protection of the timecounter lock.
+ */
+typedef void rtems_timecounter_simple_at_tick(
+ rtems_timecounter_simple *tc
+);
+
+/**
* @brief Returns the current value of a simple timecounter.
*/
typedef uint32_t rtems_timecounter_simple_get(
@@ -199,20 +206,28 @@ RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_scale(
*
* @param[in] tc The simple timecounter.
* @param[in] get The method to get the value of the simple timecounter.
+ * @param[in] at_tick The method to perform work under timecounter lock
+ * protection at this tick, e.g. clear a pending flag.
*/
RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_downcounter_tick(
- rtems_timecounter_simple *tc,
- rtems_timecounter_simple_get get
+ rtems_timecounter_simple *tc,
+ rtems_timecounter_simple_get get,
+ rtems_timecounter_simple_at_tick at_tick
)
{
+ ISR_lock_Context lock_context;
uint32_t current;
+ _Timecounter_Acquire( &lock_context );
+
+ ( *at_tick )( tc );
+
current = rtems_timecounter_simple_scale(
tc,
tc->real_interval - ( *get )( tc )
);
- _Timecounter_Tick_simple( tc->binary_interval, current );
+ _Timecounter_Tick_simple( tc->binary_interval, current, &lock_context );
}
/**
@@ -220,17 +235,25 @@ RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_downcounter_tick(
*
* @param[in] tc The simple timecounter.
* @param[in] get The method to get the value of the simple timecounter.
+ * @param[in] at_tick The method to perform work under timecounter lock
+ * protection at this tick, e.g. clear a pending flag.
*/
RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_upcounter_tick(
- rtems_timecounter_simple *tc,
- rtems_timecounter_simple_get get
+ rtems_timecounter_simple *tc,
+ rtems_timecounter_simple_get get,
+ rtems_timecounter_simple_at_tick at_tick
)
{
+ ISR_lock_Context lock_context;
uint32_t current;
+ _Timecounter_Acquire( &lock_context );
+
+ ( *at_tick )( tc );
+
current = rtems_timecounter_simple_scale( tc, ( *get )( tc ) );
- _Timecounter_Tick_simple( tc->binary_interval, current );
+ _Timecounter_Tick_simple( tc->binary_interval, current, &lock_context );
}
/**