> Date: Tue, 7 Jul 2020 22:49:31 +0200
> From: Christian Weisgerber <na...@mips.inka.de>
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> 
> Userland gettime support for alpha.
> 
> Alas, completely untested since I don't have access to that arch.
> 
> Index: lib/libc/arch/alpha/gen/usertc.c
> ===================================================================
> RCS file: /cvs/src/lib/libc/arch/alpha/gen/usertc.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 usertc.c
> --- lib/libc/arch/alpha/gen/usertc.c  6 Jul 2020 13:33:05 -0000       1.1
> +++ lib/libc/arch/alpha/gen/usertc.c  7 Jul 2020 20:40:37 -0000
> @@ -18,4 +18,18 @@
>  #include <sys/types.h>
>  #include <sys/timetc.h>
>  
> -int (*const _tc_get_timecount)(struct timekeep *, u_int *) = NULL;
> +int
> +tc_get_timecount(struct timekeep *tk, u_int *tc)

Need to make this function static to avoid namespace pollution.

> +{
> +     unsigned long val;
> +
> +     if (tk->tk_user != TC_RPCC)
> +             return -1;
> +
> +     __asm volatile("rpcc %0" : "=r" (val));
> +     *tc = val;
> +     return 0;
> +}
> +
> +int (*const _tc_get_timecount)(struct timekeep *, u_int *)
> +     = tc_get_timecount;
> Index: sys/arch/alpha/alpha/clock.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/alpha/alpha/clock.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 clock.c
> --- sys/arch/alpha/alpha/clock.c      6 Jul 2020 13:33:06 -0000       1.24
> +++ sys/arch/alpha/alpha/clock.c      7 Jul 2020 20:29:47 -0000
> @@ -64,7 +64,7 @@ int clk_irq = 0;
>  
>  u_int rpcc_get_timecount(struct timecounter *);
>  struct timecounter rpcc_timecounter = {
> -     rpcc_get_timecount, NULL, ~0u, 0, "rpcc", 0, NULL, 0
> +     rpcc_get_timecount, NULL, ~0u, 0, "rpcc", 0, NULL, TC_RPCC
>  };
>  
>  extern todr_chip_handle_t todr_handle;
> Index: sys/arch/alpha/include/timetc.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/alpha/include/timetc.h,v
> retrieving revision 1.1
> diff -u -p -r1.1 timetc.h
> --- sys/arch/alpha/include/timetc.h   6 Jul 2020 13:33:06 -0000       1.1
> +++ sys/arch/alpha/include/timetc.h   7 Jul 2020 20:42:53 -0000
> @@ -18,6 +18,7 @@
>  #ifndef _MACHINE_TIMETC_H_
>  #define _MACHINE_TIMETC_H_
>  
> -#define      TC_LAST 0
> +#define      TC_RPCC 1
> +#define      TC_LAST 2
>  
>  #endif       /* _MACHINE_TIMETC_H_ */
> -- 
> Christian "naddy" Weisgerber                          na...@mips.inka.de
> 
> 

Reply via email to