George Koehler:

> --- lib/libc/arch/powerpc/gen/usertc.c.before Sat Jun 13 21:28:50 2020
> +++ lib/libc/arch/powerpc/gen/usertc.c        Sat Jun 13 21:38:52 2020
> @@ -18,4 +18,19 @@
>  #include <sys/types.h>
>  #include <sys/timetc.h>
>  
> -int (*const _tc_get_timecount)(struct timekeep *, uint64_t *) = NULL;
> +int
> +tc_get_timecount(struct timekeep *tk, uint64_t *tc)
> +{
> +     uint64_t tb;
> +     uint32_t scratch;
> +
> +     if (tk->tk_user != 1)
> +             return -1;
> +
> +     __asm volatile ("1: mftbu %0; mftb %L0; mftbu %1;"
> +         " cmpw 0,%0,%1; bne 1b" : "=r"(tb), "=r"(scratch));

You only need the lower register.  Compare the kernel timecounter:

    u_int
    tb_get_timecount(struct timecounter *tc)
    {
          return ppc_mftbl();
    }

As I mentioned before, the declaration of the timecounter value as
uint64_t is confusing and should be changed.

-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to