<br><tt><font size=2><br>
> I repeat.  It is the responsibility of the clock tick device
driver<br>
> to reliably and correctly report the number of nanoseconds since<br>
> the last time rtems_clock_tick was called.  If that was slightly<br>
> greater than 1 tick ago, then it needs to return a number of nanoseconds<br>
> slightly greater than 1 tick.</font></tt>
<br>
<br><tt><font size=2>I agree but...</font></tt>
<br>
<br><tt><font size=2>I think bsp_clock_nanoseconds_since_last_tick() for
LEON2 and ERC32 are well implemented. They return the precise amount of
nanoseconds since last tick and I dont really see the proposed workaround
(see bellow)</font></tt>
<br>
<br><tt><font size=2 color=blue>LEON2:</font></tt>
<br>
<br><tt><font size=2 color=blue>uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{</font></tt>
<br><tt><font size=2 color=blue>   uint32_t clicks;</font></tt>
<br>
<br><tt><font size=2 color=blue>   clicks = LEON_REG.Timer_Counter_1;</font></tt>
<br>
<br><tt><font size=2 color=blue>   /* Down counter */</font></tt>
<br><tt><font size=2 color=blue>   clicks = (uint32_t) (BSP_Configuration.microseconds_per_tick
- clicks) *</font></tt>
<br><tt><font size=2 color=blue>1000;</font></tt>
<br>
<br><tt><font size=2 color=red>   /* if an interrupt occurred
while interrupts were disabled and the</font></tt>
<br><tt><font size=2 color=red>nanoseconds is too little */</font></tt>
<br><tt><font size=2 color=red>   /* means that a clock interrupt
occurred BEFORE the nanoseconds were</font></tt>
<br><tt><font size=2 color=red>read */</font></tt>
<br><tt><font size=2 color=red>   if (LEON_Is_interrupt_pending(LEON_INTERRUPT_TIMER1)
&& clicks <</font></tt>
<br><tt><font size=2 color=red>BSP_Configuration.microseconds_per_tick
/ 2)</font></tt>
<br><tt><font size=2 color=red>       clicks += BSP_Configuration.microseconds_per_tick
* 1000;</font></tt>
<br>
<br><tt><font size=2 color=red>   return clicks;</font></tt>
<br><tt><font size=2 color=blue>}</font></tt>
<br>
<br><tt><font size=2>This implementation does not make sense without the
framework of the _TOD_Get_uptime() function where the problem is an interrupt
between getting _TOD_Uptime and getting nanoseconds since last tick.</font></tt>
<br>
<br><tt><font size=2>Moreover, CONFIGURE_MICROSECONDS_PER_TICK  defines
the RTEMS time granularity so I dont see the point making this ad-hoc modification
in bsp_clock_nanoseconds_since_last_tick() function to make _TOD_Get_Uptime()
work properly when we can do it applying this simple patch</font></tt>
<br>
<br><tt><font size=2>=== modified file 'cpukit/score/src/coretodgetuptime.c'</font></tt>
<br><tt><font size=2>--- cpukit/score/src/coretodgetuptime.c 2009-03-31
07:56:38 +0000</font></tt>
<br><tt><font size=2>+++ cpukit/score/src/coretodgetuptime.c 2009-03-31
11:58:51 +0000</font></tt>
<br><tt><font size=2>@@ -46,8 +46,8 @@</font></tt>
<br>
<br><tt><font size=2>   _ISR_Disable( level );</font></tt>
<br><tt><font size=2>     *uptime = _TOD_Uptime;</font></tt>
<br><tt><font size=2>-    if ( _Watchdog_Nanoseconds_since_tick_handler
)</font></tt>
<br><tt><font size=2>-      offset.tv_nsec = (*_Watchdog_Nanoseconds_since_tick_handler)();</font></tt>
<br><tt><font size=2>+//    if ( _Watchdog_Nanoseconds_since_tick_handler
)</font></tt>
<br><tt><font size=2>+//      offset.tv_nsec = (*_Watchdog_Nanoseconds_since_tick_handler)();</font></tt>
<br>
<br><tt><font size=2>   _ISR_Enable( level );</font></tt>
<br>
<br><tt><font size=2>loosing no resolution.</font></tt>
<br>
<br><tt><font size=2>BTW this patch is tested and working.</font></tt>
<br>
<br>
<br>