[PATCH v2] score: Add CPU counter support

Chris Johns chrisj at rtems.org
Wed Feb 12 12:38:22 UTC 2014


On 12/02/2014 8:27 pm, Sebastian Huber wrote:
> Add a CPU counter interface to allow access to a free-running counter.
> It is useful to measure short time intervals.

What is meant by a short time interval and also what would a long time 
mean ?

Is an overflow or wrap around status available and/or important ?

> This can be used for
> example to enable profiling of critical low-level functions.

Why use this rather than the existing rtems_clock_get_uptime_nanoseconds ?

Are you looking at sub-nano second times ?

I would be concerned about trace data based on this unless the over was 
handled or interrupts are masked.

>
> Add two busy wait functions rtems_counter_delay_ticks() and
> rtems_counter_delay_nanoseconds() implemented via the CPU counter.
>

How is the user protected in a portable way across different cpus ?
Is there range checking or is overflows used ?
Are the calls re-entrant ?

> diff --git a/doc/cpu_supplement/general.t b/doc/cpu_supplement/general.t
> index cf28eef..3608705 100644
> --- a/doc/cpu_supplement/general.t
> +++ b/doc/cpu_supplement/general.t
> @@ -341,6 +341,26 @@ _TLS_Size = _TLS_BSS_end - _TLS_Data_begin;
>   _TLS_Alignment = ALIGNOF (.tdata);
>   @end example
>
> + at section CPU counter
> +
> +The CPU support must implement the CPU counter interface.  A CPU counter is
> +some free-running counter.  It ticks usually with a frequency close to the CPU
> +or system bus clock.  On some architectures the actual implementation is board
> +support package dependent.  The CPU counter is used for profiling of low-level
> +functions.  It is also used to implement two busy wait functions
> + at code{rtems_counter_delay_ticks()} and @code{rtems_counter_delay_nanoseconds()}
> +which may be used in device drivers.  It may be also used as an entropy source
> +for random number generators.
> +
> +The CPU counter interface uses a CPU port specific unsigned integer type
> + at code{CPU_Counter_Ticks} to represent CPU counter values.  The CPU port must
> +provide the following two functions
> +
> + at itemize
> + at item @code{_CPU_counter_Read()} to read the current CPU counter value, and
> + at item @code{_CPU_counter_Subtract()} to subtract two the CPU counter values.
> + at end itemize

Is overflows handled in the maths ? I could not see it if important.

Should the user be able to ask the range of the counter ?

Chris



More information about the devel mailing list