[rtems commit] riscv: Implement CPU counter

Hesham Almatary heshamelmatary at gmail.com
Fri Jul 6 13:11:25 UTC 2018


On Fri, 6 Jul 2018 at 1:28 pm, Sebastian Huber <sebh at rtems.org> wrote:

> Module:    rtems
> Branch:    master
> Commit:    dd32e2b2d009de525c1a4ad488899fab355d8fed
> Changeset:
> http://git.rtems.org/rtems/commit/?id=dd32e2b2d009de525c1a4ad488899fab355d8fed
>
> Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
> Date:      Fri Jul  6 08:12:40 2018 +0200
>
> riscv: Implement CPU counter
>
> Update #3433.
>
> ---
>
>  bsps/riscv/riscv/clock/clockdrv.c                | 12 ++----------
>  cpukit/score/cpu/riscv/Makefile.am               |  1 -
>  cpukit/score/cpu/riscv/include/rtems/score/cpu.h | 17 ++++++++++++++++-
>  3 files changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/bsps/riscv/riscv/clock/clockdrv.c
> b/bsps/riscv/riscv/clock/clockdrv.c
> index 6a5d2db..d2d7a40 100644
> --- a/bsps/riscv/riscv/clock/clockdrv.c
> +++ b/bsps/riscv/riscv/clock/clockdrv.c
> @@ -87,11 +87,6 @@ static uint32_t riscv_clock_get_timecount(struct
> timecounter *tc)
>    return clint->mtime.val_32[0];
>  }
>
> -CPU_Counter_ticks _CPU_Counter_read(void)
> -{
> -  return riscv_clock_get_timecount(NULL);
> -}
> -
>  static uint32_t riscv_clock_get_timebase_frequency(const void *fdt)
>  {
>    int node;
> @@ -131,12 +126,9 @@ static void riscv_clock_initialize(void)
>    rtems_timecounter_install(&riscv_clock_tc);
>  }
>
> -CPU_Counter_ticks _CPU_Counter_difference(
> -  CPU_Counter_ticks second,
> -  CPU_Counter_ticks first
> -)
> +uint32_t _CPU_Counter_frequency( void )
>  {
> -  return second - first;
> +  return riscv_clock_get_timebase_frequency(bsp_fdt_get());
>  }
>
>  #define Clock_driver_support_at_tick() riscv_clock_at_tick()
> diff --git a/cpukit/score/cpu/riscv/Makefile.am
> b/cpukit/score/cpu/riscv/Makefile.am
> index e771468..3630c03 100644
> --- a/cpukit/score/cpu/riscv/Makefile.am
> +++ b/cpukit/score/cpu/riscv/Makefile.am
> @@ -2,7 +2,6 @@ include $(top_srcdir)/automake/compile.am
>  noinst_LIBRARIES = libscorecpu.a
>  libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS)
>  libscorecpu_a_SOURCES  = cpu.c
> -libscorecpu_a_SOURCES += ../no_cpu/cpucounterfrequency.c
>  libscorecpu_a_SOURCES += riscv-exception-handler.S
>  libscorecpu_a_SOURCES += riscv-exception-default.c
>  libscorecpu_a_SOURCES += riscv-exception-frame-print.c
> diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
> b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
> index e79ce25..f84395c 100644
> --- a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
> +++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
> @@ -370,7 +370,22 @@ typedef uint32_t CPU_Counter_ticks;
>
>  uint32_t _CPU_Counter_frequency( void );
>
> -CPU_Counter_ticks _CPU_Counter_read( void );
> +static inline CPU_Counter_ticks _CPU_Counter_read( void )
> +{
> +  unsigned long ticks;
> +
> +  __asm__ volatile ( "rdtime %0" : "=&r" ( ticks ) );
> +

Shouldn’t this be “rdcycle” instead of “rdtime”?

>
> +  return (uint32_t) ticks;
> +}
> +
> +static inline CPU_Counter_ticks _CPU_Counter_difference(
> +  CPU_Counter_ticks second,
> +  CPU_Counter_ticks first
> +)
> +{
> +  return second - first;
> +}
>
>  #ifdef RTEMS_SMP
>
>
> _______________________________________________
> vc mailing list
> vc at rtems.org
> http://lists.rtems.org/mailman/listinfo/vc
>
-- 
Hesham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20180706/e51ac1c3/attachment-0001.html>


More information about the vc mailing list