<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 11, 2016 at 1:25 PM, Marcos Díaz <span dir="ltr"><<a href="mailto:marcos.diaz@tallertechnologies.com" target="_blank">marcos.diaz@tallertechnologies.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well, we could still use the patch you sent with the protection in is pending, but I think this will break the BSPs I mentioned, since you changed timecounter functions signatures. Am I right?</div><div class="gmail_extra"><div><div class="h5"><br></div></div></div></blockquote><div><br></div><div>Let's just fix it right. The timecounters are new so getting them right in the first release with</div><div>them is important. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div><div class="h5"><div class="gmail_quote">On Mon, Jan 11, 2016 at 4:18 PM, Sebastian Huber <span dir="ltr"><<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I already created a ticket which blocks the 4.11 release for this bug:<br>
<br>
<a href="https://devel.rtems.org/ticket/2502" rel="noreferrer" target="_blank">https://devel.rtems.org/ticket/2502</a><br>
<br>
I sent a new version of the patch to one of your previous threads some days ago:<br>
<br>
<a href="https://lists.rtems.org/pipermail/devel/2016-January/013289.html" rel="noreferrer" target="_blank">https://lists.rtems.org/pipermail/devel/2016-January/013289.html</a><br>
<br>
There is still a bug in it, since we must disable interrupts in the is pending function, but the general approach should work.<br>
<span><br>
----- Am 11. Jan 2016 um 20:05 schrieb Marcos Díaz <a href="mailto:marcos.diaz@tallertechnologies.com" target="_blank">marcos.diaz@tallertechnologies.com</a>:<br>
<br>
> I made a fast search:<br>
</span>> These BSPs use *rtems_timecounter_simple_downcounter*:<br>
<span>> arm/shared/armv7m<br>
> m68k/mcf52235<br>
> m68k/mcf5225x<br>
> m68k/mcf5329<br>
> m68k/uC5282<br>
> powerpc/mpc55xxevb<br>
> sparc/erc32<br>
> sparc/leon2<br>
> sparc/leon3<br>
> sparc/shared<br>
><br>
</span>> These use *rtems_timecounter_simple_upcounter*:<br>
<div><div>> powerpc/mpc55xxevb<br>
> arm/lpc22xx<br>
><br>
> We should search a little more for the other changes but at least these<br>
> BSPs will be affected. Maybe we should wait Sebastian's opinion, since he<br>
> suggested the change in timecounter's signatures.<br>
><br>
> On Mon, Jan 11, 2016 at 3:44 PM, Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>> wrote:<br>
><br>
>><br>
>><br>
>> On Mon, Jan 11, 2016 at 12:28 PM, Marcos Díaz <<br>
>> <a href="mailto:marcos.diaz@tallertechnologies.com" target="_blank">marcos.diaz@tallertechnologies.com</a>> wrote:<br>
>><br>
>>> I will issue a ticket. But I noticed that in my patch I include changes<br>
>>> to common code that Sebastian suggested, and this will break any other BSP<br>
>>> that uses rtems timecounter simple downcounter or upcounter, since these<br>
>>> function's signatures changed. Should we update all BSPs? Or make changes<br>
>>> more locally to our BSP?  Meanwhile please do not apply the patch I sent.<br>
>>><br>
>>><br>
>> I would prefer not to ship BSPs with bugs but fixing them comes with risks.<br>
>> So I would lean to the same fix on the master and 4.11 branch fixing it<br>
>> where it needs to be fixed.<br>
>><br>
>> What BSPs does this change impact?<br>
>><br>
>> --joel<br>
>><br>
>><br>
>>><br>
>>> On Mon, Jan 11, 2016 at 3:16 PM, Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>> wrote:<br>
>>><br>
>>>> At this point, a ticket is needed for anything applied to 4.11 that is<br>
>>>> not release<br>
>>>> mechanics related.<br>
>>>><br>
>>>> --joel<br>
>>>><br>
>>>> On Mon, Jan 11, 2016 at 11:47 AM, Marcos Diaz <<br>
>>>> <a href="mailto:marcos.diaz@tallertechnologies.com" target="_blank">marcos.diaz@tallertechnologies.com</a>> wrote:<br>
>>>><br>
>>>>> Hi Sebastian,<br>
>>>>><br>
>>>>> we did some more testing and found out what's causing the problem.<br>
>>>>> Based on what<br>
>>>>> I posted at<br>
>>>>> <a href="https://lists.rtems.org/pipermail/devel/2015-December/013235.html" rel="noreferrer" target="_blank">https://lists.rtems.org/pipermail/devel/2015-December/013235.html</a>,<br>
>>>>> the problem arises when the ticker interrupt occurs while a task is<br>
>>>>> executing<br>
>>>>> one of the instructions that make up the following line:<br>
>>>>><br>
>>>>> is_count_pending = (systick->csr & ARMV7M_SYSTICK_CSR_COUNTFLAG) != 0;<br>
>>>>><br>
>>>>> which compiling with -O3 are:<br>
>>>>><br>
>>>>> ldr.w r3, [r9]<br>
>>>>> ubfx r5, r3, #16, #1<br>
>>>>> strb.w r5, [r8, #64]<br>
>>>>><br>
>>>>> If the SysTick counts to 0 and the ldr executes before the interrupt<br>
>>>>> occurs,<br>
>>>>> R3 will have the CSR.COUNTFLAG bit set. Even though _ARMV7M_TC_at_tick<br>
>>>>> will<br>
>>>>> clear the is_count_pending boolean, the task will still see it as true.<br>
>>>>><br>
>>>>> The solution we found is to simply disable interrupts while reading<br>
>>>>> that flag.<br>
>>>>> We also use a local variable inside _ARMV7M_TC_is_pending instead of<br>
>>>>> directly<br>
>>>>> returning the current value of the is_count_pending global, just in<br>
>>>>> case.<br>
>>>>><br>
>>>>> Here's the patch that fixes it; this applies to the 4.11 branch.<br>
>>>>> Do we have to open a new thread for it to be applied to the mainline,<br>
>>>>> or will<br>
>>>>> this suffice? Should we open a ticket for 4.11?<br>
>>>>><br>
>>>>> ---<br>
>>>>>  .../arm/shared/armv7m/clock/armv7m-clock-config.c  | 38<br>
>>>>> +++++++++++++++-------<br>
>>>>>  c/src/lib/libbsp/shared/clockdrv_shell.h           | 16 ++++++++-<br>
>>>>>  cpukit/rtems/src/clocktick.c                       |  6 +++-<br>
>>>>>  cpukit/sapi/include/rtems/timecounter.h            | 35<br>
>>>>> ++++++++++++++++----<br>
>>>>>  cpukit/score/include/rtems/score/timecounter.h     | 37<br>
>>>>> +++++++++++++++++++--<br>
>>>>>  cpukit/score/src/kern_tc.c                         | 16 ++++-----<br>
>>>>>  doc/bsp_howto/clock.t                              | 13 +++++++-<br>
>>>>>  7 files changed, 130 insertions(+), 31 deletions(-)<br>
>>>>><br>
>>>>> diff --git<br>
>>>>> a/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c<br>
>>>>> b/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c<br>
>>>>> index e78684c..53bd7cf 100644<br>
>>>>> --- a/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c<br>
>>>>> +++ b/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c<br>
>>>>> @@ -25,6 +25,8 @@ static void Clock_isr(void *arg);<br>
>>>>><br>
>>>>>  static rtems_timecounter_simple _ARMV7M_TC;<br>
>>>>><br>
>>>>> +static bool is_count_pending = false;<br>
>>>>> +<br>
>>>>>  static uint32_t _ARMV7M_TC_get(rtems_timecounter_simple *tc)<br>
>>>>>  {<br>
>>>>>    volatile ARMV7M_Systick *systick = _ARMV7M_Systick;<br>
>>>>> @@ -34,9 +36,20 @@ static uint32_t<br>
>>>>> _ARMV7M_TC_get(rtems_timecounter_simple *tc)<br>
>>>>><br>
>>>>>  static bool _ARMV7M_TC_is_pending(rtems_timecounter_simple *tc)<br>
>>>>>  {<br>
>>>>> -  volatile ARMV7M_SCB *scb = _ARMV7M_SCB;<br>
>>>>> +  volatile ARMV7M_Systick *systick = _ARMV7M_Systick;<br>
>>>>> +  ISR_lock_Context lock_context;<br>
>>>>> +<br>
>>>>> +  _Timecounter_Acquire( &lock_context );<br>
>>>>> +  /* We use this bool since the hardware flag is reset each time it is<br>
>>>>> read. */<br>
>>>>> +  if (!is_count_pending)<br>
>>>>> +  {<br>
>>>>> +    is_count_pending = ((systick->csr & ARMV7M_SYSTICK_CSR_COUNTFLAG)<br>
>>>>> != 0 );<br>
>>>>> +  }<br>
>>>>><br>
>>>>> -  return ((scb->icsr & ARMV7M_SCB_ICSR_PENDSTSET) != 0);<br>
>>>>> +  const bool is_pending_local = is_count_pending;<br>
>>>>> +<br>
>>>>> +  _Timecounter_Release( &lock_context );<br>
>>>>> +  return is_pending_local;<br>
>>>>>  }<br>
>>>>><br>
>>>>>  static uint32_t _ARMV7M_TC_get_timecount(struct timecounter *tc)<br>
>>>>> @@ -48,19 +61,23 @@ static uint32_t _ARMV7M_TC_get_timecount(struct<br>
>>>>> timecounter *tc)<br>
>>>>>    );<br>
>>>>>  }<br>
>>>>><br>
>>>>> -static void _ARMV7M_TC_tick(void)<br>
>>>>> -{<br>
>>>>> -  rtems_timecounter_simple_downcounter_tick(&_ARMV7M_TC,<br>
>>>>> _ARMV7M_TC_get);<br>
>>>>> -}<br>
>>>>> -<br>
>>>>> -static void _ARMV7M_Systick_at_tick(void)<br>
>>>>> +static void _ARMV7M_TC_at_tick(rtems_timecounter_simple *tc)<br>
>>>>>  {<br>
>>>>>    volatile ARMV7M_Systick *systick = _ARMV7M_Systick;<br>
>>>>> -<br>
>>>>> +  is_count_pending = false;<br>
>>>>>    /* Clear COUNTFLAG */<br>
>>>>>    systick->csr;<br>
>>>>>  }<br>
>>>>><br>
>>>>> +static void _ARMV7M_TC_tick(void)<br>
>>>>> +{<br>
>>>>> +  rtems_timecounter_simple_downcounter_tick(<br>
>>>>> +    &_ARMV7M_TC,<br>
>>>>> +    _ARMV7M_TC_get,<br>
>>>>> +    _ARMV7M_TC_at_tick<br>
>>>>> +  );<br>
>>>>> +}<br>
>>>>> +<br>
>>>>>  static void _ARMV7M_Systick_handler(void)<br>
>>>>>  {<br>
>>>>>    _ARMV7M_Interrupt_service_enter();<br>
>>>>> @@ -111,9 +128,6 @@ static void _ARMV7M_Systick_cleanup(void)<br>
>>>>><br>
>>>>>  #define Clock_driver_timecounter_tick() _ARMV7M_TC_tick()<br>
>>>>><br>
>>>>> -#define Clock_driver_support_at_tick() \<br>
>>>>> -  _ARMV7M_Systick_at_tick()<br>
>>>>> -<br>
>>>>>  #define Clock_driver_support_initialize_hardware() \<br>
>>>>>    _ARMV7M_Systick_initialize()<br>
>>>>><br>
>>>>> diff --git a/c/src/lib/libbsp/shared/clockdrv_shell.h<br>
>>>>> b/c/src/lib/libbsp/shared/clockdrv_shell.h<br>
>>>>> index d546fb8..96b962f 100644<br>
>>>>> --- a/c/src/lib/libbsp/shared/clockdrv_shell.h<br>
>>>>> +++ b/c/src/lib/libbsp/shared/clockdrv_shell.h<br>
>>>>> @@ -44,6 +44,13 @@<br>
>>>>>    #define Clock_driver_support_find_timer()<br>
>>>>>  #endif<br>
>>>>><br>
>>>>> +/**<br>
>>>>> + * @brief Do nothing by default.<br>
>>>>> + */<br>
>>>>> +#ifndef Clock_driver_support_at_tick<br>
>>>>> +  #define Clock_driver_support_at_tick()<br>
>>>>> +#endif<br>
>>>>> +<br>
>>>>>  /*<br>
>>>>>   * A specialized clock driver may use for example<br>
>>>>> rtems_timecounter_tick_simple()<br>
>>>>>   * instead of the default.<br>
>>>>> @@ -108,7 +115,14 @@ rtems_isr Clock_isr(<br>
>>>>>            && _Thread_Executing->Start.entry_point<br>
>>>>>              == (Thread_Entry) rtems_configuration_get_idle_task()<br>
>>>>>        ) {<br>
>>>>> -        _Timecounter_Tick_simple(interval,<br>
>>>>> (*tc->tc_get_timecount)(tc));<br>
>>>>> +        ISR_lock_Context lock_context;<br>
>>>>> +<br>
>>>>> +        _Timecounter_Acquire(&lock_context);<br>
>>>>> +        _Timecounter_Tick_simple(<br>
>>>>> +          interval,<br>
>>>>> +          (*tc->tc_get_timecount)(tc),<br>
>>>>> +          &lock_context<br>
>>>>> +        );<br>
>>>>>        }<br>
>>>>><br>
>>>>>        Clock_driver_support_at_tick();<br>
>>>>> diff --git a/cpukit/rtems/src/clocktick.c b/cpukit/rtems/src/clocktick.c<br>
>>>>> index e2cd35f..a6bf26d 100644<br>
>>>>> --- a/cpukit/rtems/src/clocktick.c<br>
>>>>> +++ b/cpukit/rtems/src/clocktick.c<br>
>>>>> @@ -23,9 +23,13 @@<br>
>>>>><br>
>>>>>  rtems_status_code rtems_clock_tick( void )<br>
>>>>>  {<br>
>>>>> +  ISR_lock_Context lock_context;<br>
>>>>> +<br>
>>>>> +  _Timecounter_Acquire( &lock_context );<br>
>>>>>    _Timecounter_Tick_simple(<br>
>>>>>      rtems_configuration_get_microseconds_per_tick(),<br>
>>>>> -    0<br>
>>>>> +    0,<br>
>>>>> +    &lock_context<br>
>>>>>    );<br>
>>>>><br>
>>>>>    return RTEMS_SUCCESSFUL;<br>
>>>>> diff --git a/cpukit/sapi/include/rtems/timecounter.h<br>
>>>>> b/cpukit/sapi/include/rtems/timecounter.h<br>
>>>>> index 04bc534..06b3973 100644<br>
>>>>> --- a/cpukit/sapi/include/rtems/timecounter.h<br>
>>>>> +++ b/cpukit/sapi/include/rtems/timecounter.h<br>
>>>>> @@ -94,6 +94,13 @@ typedef struct {<br>
>>>>>  } rtems_timecounter_simple;<br>
>>>>><br>
>>>>>  /**<br>
>>>>> + * @brief At tick handling done under protection of the timecounter<br>
>>>>> lock.<br>
>>>>> + */<br>
>>>>> +typedef uint32_t rtems_timecounter_simple_at_tick(<br>
>>>>> +  rtems_timecounter_simple *tc<br>
>>>>> +);<br>
>>>>> +<br>
>>>>> +/**<br>
>>>>>   * @brief Returns the current value of a simple timecounter.<br>
>>>>>   */<br>
>>>>>  typedef uint32_t rtems_timecounter_simple_get(<br>
>>>>> @@ -199,20 +206,28 @@ RTEMS_INLINE_ROUTINE uint32_t<br>
>>>>> rtems_timecounter_simple_scale(<br>
>>>>>   *<br>
>>>>>   * @param[in] tc The simple timecounter.<br>
>>>>>   * @param[in] get The method to get the value of the simple<br>
>>>>> timecounter.<br>
>>>>> + * @param[in] at_tick The method to perform work under timecounter lock<br>
>>>>> + * protection at this tick, e.g. clear a pending flag.<br>
>>>>>   */<br>
>>>>>  RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_downcounter_tick(<br>
>>>>> -  rtems_timecounter_simple     *tc,<br>
>>>>> -  rtems_timecounter_simple_get  get<br>
>>>>> +  rtems_timecounter_simple         *tc,<br>
>>>>> +  rtems_timecounter_simple_get      get,<br>
>>>>> +  rtems_timecounter_simple_at_tick  at_tick<br>
>>>>>  )<br>
>>>>>  {<br>
>>>>> +  ISR_lock_Context lock_context;<br>
>>>>>    uint32_t current;<br>
>>>>><br>
>>>>> +  _Timecounter_Acquire( &lock_context );<br>
>>>>> +<br>
>>>>> +  ( *at_tick )( tc );<br>
>>>>> +<br>
>>>>>    current = rtems_timecounter_simple_scale(<br>
>>>>>      tc,<br>
>>>>>      tc->real_interval - ( *get )( tc )<br>
>>>>>    );<br>
>>>>><br>
>>>>> -  _Timecounter_Tick_simple( tc->binary_interval, current );<br>
>>>>> +  _Timecounter_Tick_simple( tc->binary_interval, current,<br>
>>>>> &lock_context );<br>
>>>>>  }<br>
>>>>><br>
>>>>>  /**<br>
>>>>> @@ -220,17 +235,25 @@ RTEMS_INLINE_ROUTINE void<br>
>>>>> rtems_timecounter_simple_downcounter_tick(<br>
>>>>>   *<br>
>>>>>   * @param[in] tc The simple timecounter.<br>
>>>>>   * @param[in] get The method to get the value of the simple<br>
>>>>> timecounter.<br>
>>>>> + * @param[in] at_tick The method to perform work under timecounter lock<br>
>>>>> + * protection at this tick, e.g. clear a pending flag.<br>
>>>>>   */<br>
>>>>>  RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_upcounter_tick(<br>
>>>>> -  rtems_timecounter_simple     *tc,<br>
>>>>> -  rtems_timecounter_simple_get  get<br>
>>>>> +  rtems_timecounter_simple         *tc,<br>
>>>>> +  rtems_timecounter_simple_get      get,<br>
>>>>> +  rtems_timecounter_simple_at_tick  at_tick<br>
>>>>>  )<br>
>>>>>  {<br>
>>>>> +  ISR_lock_Context lock_context;<br>
>>>>>    uint32_t current;<br>
>>>>><br>
>>>>> +  _Timecounter_Acquire( &lock_context );<br>
>>>>> +<br>
>>>>> +  ( *at_tick )( tc );<br>
>>>>> +<br>
>>>>>    current = rtems_timecounter_simple_scale( tc, ( *get )( tc ) );<br>
>>>>><br>
>>>>> -  _Timecounter_Tick_simple( tc->binary_interval, current );<br>
>>>>> +  _Timecounter_Tick_simple( tc->binary_interval, current,<br>
>>>>> &lock_context );<br>
>>>>>  }<br>
>>>>><br>
>>>>>  /**<br>
>>>>> diff --git a/cpukit/score/include/rtems/score/timecounter.h<br>
>>>>> b/cpukit/score/include/rtems/score/timecounter.h<br>
>>>>> index 0d17cc7..0e611b5 100644<br>
>>>>> --- a/cpukit/score/include/rtems/score/timecounter.h<br>
>>>>> +++ b/cpukit/score/include/rtems/score/timecounter.h<br>
>>>>> @@ -26,6 +26,8 @@<br>
>>>>>  #include <sys/time.h><br>
>>>>>  #include <sys/timetc.h><br>
>>>>><br>
>>>>> +#include <rtems/score/isrlock.h><br>
>>>>> +<br>
>>>>>  #ifdef __cplusplus<br>
>>>>>  extern "C" {<br>
>>>>>  #endif /* __cplusplus */<br>
>>>>> @@ -161,6 +163,31 @@ void _Timecounter_Install( struct timecounter *tc<br>
>>>>> );<br>
>>>>>  void _Timecounter_Tick( void );<br>
>>>>><br>
>>>>>  /**<br>
>>>>> + * @brief Lock to protect the timecounter mechanic.<br>
>>>>> + */<br>
>>>>> +ISR_LOCK_DECLARE( extern, _Timecounter_Lock )<br>
>>>>> +<br>
>>>>> +/**<br>
>>>>> + * @brief Acquires the timecounter lock.<br>
>>>>> + *<br>
>>>>> + * @param[in] lock_context The lock context.<br>
>>>>> + *<br>
>>>>> + * See _Timecounter_Tick_simple().<br>
>>>>> + */<br>
>>>>> +#define _Timecounter_Acquire( lock_context ) \<br>
>>>>> +  _ISR_lock_ISR_disable_and_acquire( &_Timecounter_Lock, lock_context )<br>
>>>>> +<br>
>>>>> +/**<br>
>>>>> + * @brief Releases the timecounter lock.<br>
>>>>> + *<br>
>>>>> + * @param[in] lock_context The lock context.<br>
>>>>> + *<br>
>>>>> + * See _Timecounter_Tick_simple().<br>
>>>>> + */<br>
>>>>> +#define _Timecounter_Release(lock_context) \<br>
>>>>> +  _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, lock_context)<br>
>>>>> +<br>
>>>>> +/**<br>
>>>>>   * @brief Performs a simple timecounter tick.<br>
>>>>>   *<br>
>>>>>   * This is a special purpose tick function for simple timecounter to<br>
>>>>> support<br>
>>>>> @@ -169,8 +196,14 @@ void _Timecounter_Tick( void );<br>
>>>>>   * @param[in] delta The time in timecounter ticks elapsed since the<br>
>>>>> last call<br>
>>>>>   * to _Timecounter_Tick_simple().<br>
>>>>>   * @param[in] offset The current value of the timecounter.<br>
>>>>> - */<br>
>>>>> -void _Timecounter_Tick_simple( uint32_t delta, uint32_t offset );<br>
>>>>> + * @param[in] lock_context The lock context of the corresponding<br>
>>>>> + * _Timecounter_Acquire().<br>
>>>>> + */<br>
>>>>> +void _Timecounter_Tick_simple(<br>
>>>>> +  uint32_t delta,<br>
>>>>> +  uint32_t offset,<br>
>>>>> +  ISR_lock_Context *lock_context<br>
>>>>> +);<br>
>>>>><br>
>>>>>  /**<br>
>>>>>   * @brief The wall clock time in seconds.<br>
>>>>> diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c<br>
>>>>> index f6a1136..4257533 100644<br>
>>>>> --- a/cpukit/score/src/kern_tc.c<br>
>>>>> +++ b/cpukit/score/src/kern_tc.c<br>
>>>>> @@ -64,7 +64,9 @@ __FBSDID("$FreeBSD r284178 2015-06-09T11:49:56Z$");<br>
>>>>>  #ifdef __rtems__<br>
>>>>>  #include <limits.h><br>
>>>>>  #include <rtems.h><br>
>>>>> -ISR_LOCK_DEFINE(static, _Timecounter_Lock, "Timecounter");<br>
>>>>> +ISR_LOCK_DEFINE(, _Timecounter_Lock, "Timecounter")<br>
>>>>> +#define _Timecounter_Release(lock_context) \<br>
>>>>> +  _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock, lock_context)<br>
>>>>>  #define hz rtems_clock_get_ticks_per_second()<br>
>>>>>  #define printf(...)<br>
>>>>>  #define log(...)<br>
>>>>> @@ -1383,7 +1385,7 @@ tc_windup(void)<br>
>>>>>  #ifdef __rtems__<br>
>>>>>         ISR_lock_Context lock_context;<br>
>>>>><br>
>>>>> -       _ISR_lock_ISR_disable_and_acquire(&_Timecounter_Lock,<br>
>>>>> &lock_context);<br>
>>>>> +       _Timecounter_Acquire(&lock_context);<br>
>>>>>  #endif /* __rtems__ */<br>
>>>>><br>
>>>>>         /*<br>
>>>>> @@ -1538,7 +1540,7 @@ tc_windup(void)<br>
>>>>>         timekeep_push_vdso();<br>
>>>>>  #endif /* __rtems__ */<br>
>>>>>  #ifdef __rtems__<br>
>>>>> -       _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock,<br>
>>>>> &lock_context);<br>
>>>>> +       _Timecounter_Release(&lock_context);<br>
>>>>>  #endif /* __rtems__ */<br>
>>>>>  }<br>
>>>>><br>
>>>>> @@ -1963,14 +1965,12 @@ _Timecounter_Tick(void)<br>
>>>>>  }<br>
>>>>>  #ifdef __rtems__<br>
>>>>>  void<br>
>>>>> -_Timecounter_Tick_simple(uint32_t delta, uint32_t offset)<br>
>>>>> +_Timecounter_Tick_simple(uint32_t delta, uint32_t offset,<br>
>>>>> +    ISR_lock_Context *lock_context)<br>
>>>>>  {<br>
>>>>>         struct bintime bt;<br>
>>>>>         struct timehands *th;<br>
>>>>>         uint32_t ogen;<br>
>>>>> -       ISR_lock_Context lock_context;<br>
>>>>> -<br>
>>>>> -       _ISR_lock_ISR_disable_and_acquire(&_Timecounter_Lock,<br>
>>>>> &lock_context);<br>
>>>>><br>
>>>>>         th = timehands;<br>
>>>>>         ogen = th->th_generation;<br>
>>>>> @@ -1997,7 +1997,7 @@ _Timecounter_Tick_simple(uint32_t delta, uint32_t<br>
>>>>> offset)<br>
>>>>>         time_second = th->th_microtime.tv_sec;<br>
>>>>>         time_uptime = th->th_offset.sec;<br>
>>>>><br>
>>>>> -       _ISR_lock_Release_and_ISR_enable(&_Timecounter_Lock,<br>
>>>>> &lock_context);<br>
>>>>> +       _Timecounter_Release(lock_context);<br>
>>>>><br>
>>>>>         _Watchdog_Tick();<br>
>>>>>  }<br>
>>>>> diff --git a/doc/bsp_howto/clock.t b/doc/bsp_howto/clock.t<br>
>>>>> index f58b898..2891bb2 100644<br>
>>>>> --- a/doc/bsp_howto/clock.t<br>
>>>>> +++ b/doc/bsp_howto/clock.t<br>
>>>>> @@ -89,6 +89,13 @@ static uint32_t some_tc_get(<br>
>>>>> rtems_timecounter_simple *tc )<br>
>>>>>    return some.counter;<br>
>>>>>  @}<br>
>>>>><br>
>>>>> +static void some_tc_at_tick( rtems_timecounter_simple *tc )<br>
>>>>> +@{<br>
>>>>> +  /*<br>
>>>>> +   * Do work necessary at the clock tick interrupt, e.g. clear a<br>
>>>>> pending flag.<br>
>>>>> +   */<br>
>>>>> +@}<br>
>>>>> +<br>
>>>>>  static bool some_tc_is_pending( rtems_timecounter_simple *tc )<br>
>>>>>  @{<br>
>>>>>    return some.is_pending;<br>
>>>>> @@ -105,7 +112,11 @@ static uint32_t some_tc_get_timecount( struct<br>
>>>>> timecounter *tc )<br>
>>>>><br>
>>>>>  static void some_tc_tick( void )<br>
>>>>>  @{<br>
>>>>> -  rtems_timecounter_simple_downcounter_tick( &some_tc, some_tc_get );<br>
>>>>> +  rtems_timecounter_simple_downcounter_tick(<br>
>>>>> +    &some_tc,<br>
>>>>> +    some_tc_get,<br>
>>>>> +    some_tc_at_tick<br>
>>>>> +  );<br>
>>>>>  @}<br>
>>>>><br>
>>>>>  static void some_support_initialize_hardware( void )<br>
>>>>> --<br>
>>>>> 2.7.0<br>
>>>>><br>
>>>>> _______________________________________________<br>
>>>>> devel mailing list<br>
>>>>> <a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
>>>>> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
>>>>><br>
>>>><br>
>>>><br>
>>><br>
>>><br>
>>> --<br>
>>><br>
>>> ______________________________<br>
>>><br>
</div></div>>>> <<a href="http://www.tallertechnologies.com" rel="noreferrer" target="_blank">http://www.tallertechnologies.com</a>><br>
<span>>>><br>
>>><br>
>>> Marcos Díaz<br>
>>><br>
>>> Software Engineer<br>
>>><br>
>>><br>
>>> San Lorenzo 47, 3rd Floor, Office 5<br>
>>><br>
>>> Córdoba, Argentina<br>
>>><br>
>>><br>
>>> Phone: <a href="tel:%2B54%20351%204217888" value="+543514217888" target="_blank">+54 351 4217888</a> / <a href="tel:%2B54%20351%204218211" value="+543514218211" target="_blank">+54 351 4218211</a>/ <a href="tel:%2B54%20351%207617452" value="+543517617452" target="_blank">+54 351 7617452</a><br>
>>><br>
>>> Skype: markdiaz22<br>
>>><br>
>>><br>
>><br>
><br>
><br>
> --<br>
><br>
> ______________________________<br>
><br>
</span>> <<a href="http://www.tallertechnologies.com" rel="noreferrer" target="_blank">http://www.tallertechnologies.com</a>><br>
<div><div>><br>
><br>
> Marcos Díaz<br>
><br>
> Software Engineer<br>
><br>
><br>
> San Lorenzo 47, 3rd Floor, Office 5<br>
><br>
> Córdoba, Argentina<br>
><br>
><br>
> Phone: <a href="tel:%2B54%20351%204217888" value="+543514217888" target="_blank">+54 351 4217888</a> / <a href="tel:%2B54%20351%204218211" value="+543514218211" target="_blank">+54 351 4218211</a>/ <a href="tel:%2B54%20351%207617452" value="+543517617452" target="_blank">+54 351 7617452</a><br>
><br>
> Skype: markdiaz22<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br></font></span><div><div dir="ltr"><span><span class="HOEnZb"><font color="#888888"><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">______________________________</span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><a href="http://www.tallertechnologies.com" target="_blank"><img src="http://www.tallertechnologies.com/templates/tallertechnologies/images/signature.png" width="200" height="78"></a></p></font></span><span class=""><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><b style="font-weight:normal"><br><span style="font-size:16px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span></b></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><font face="verdana, sans-serif" size="4">Marcos Díaz</font></span></p><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt"><font color="#000000" face="verdana, sans-serif" size="2"><span style="line-height:17px;white-space:pre-wrap">Software Engineer</span></font></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><b style="font-weight:normal"><br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span></b></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><font face="arial, helvetica, sans-serif" size="1">San Lorenzo 47, 3rd Floor, Office 5</font></span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><font face="arial, helvetica, sans-serif" size="1">Córdoba, Argentina </font></span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><b style="font-weight:normal"><font face="arial, helvetica, sans-serif" size="1"><br><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span></font></b></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><font face="arial, helvetica, sans-serif" size="1"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Phone:</span><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> <a href="tel:%2B54%20351%204217888" value="+543514217888" target="_blank">+54 351 4217888</a> / <a href="tel:%2B54%20351%204218211" value="+543514218211" target="_blank">+54 351 4218211</a>/ </span><span style="color:rgb(0,0,0);line-height:12px;white-space:pre-wrap"><a href="tel:%2B54%20351%207617452" value="+543517617452" target="_blank">+54 351 7617452</a></span></font></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><font face="arial, helvetica, sans-serif" size="1"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Skype:</span><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> markdiaz22</span></font></p><div><span style="font-size:11px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br></span></div></span></span></div></div>
</div>
</blockquote></div><br></div></div>