I'm running this, seems to be working correctly.
Christian Weisgerber wrote:
> Here's a cpu_rnd_messybits() for hppa. This just steals from
> itmr_get_timecount(). If we want to use the mfctl() macro, we need
> to include into cpu.h. I don't know if we want
> that, so I went with the explicit asm() instead.
>
> Completely untested.
>
>
> Index: sys/arch/hppa/hppa/machdep.c
> ===
> RCS file: /cvs/src/sys/arch/hppa/hppa/machdep.c,v
> retrieving revision 1.259
> diff -u -p -r1.259 machdep.c
> --- sys/arch/hppa/hppa/machdep.c 31 May 2020 06:23:57 - 1.259
> +++ sys/arch/hppa/hppa/machdep.c 5 Jun 2020 15:17:23 -
> @@ -1496,12 +1496,3 @@ blink_led_timeout(void *vsc)
> t = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1));
> timeout_add(&sc->bls_to, t);
> }
> -
> -unsigned int
> -cpu_rnd_messybits(void)
> -{
> - struct timespec ts;
> -
> - nanotime(&ts);
> - return (ts.tv_nsec ^ (ts.tv_sec << 20));
> -}
> Index: sys/arch/hppa/include/cpu.h
> ===
> RCS file: /cvs/src/sys/arch/hppa/include/cpu.h,v
> retrieving revision 1.92
> diff -u -p -r1.92 cpu.h
> --- sys/arch/hppa/include/cpu.h 31 May 2020 06:23:57 - 1.92
> +++ sys/arch/hppa/include/cpu.h 5 Jun 2020 15:17:23 -
> @@ -54,6 +54,7 @@
> #ifdef _KERNEL
> #include
> #include
> +#include
> #endif /* _KERNEL */
>
> /*
> @@ -237,7 +238,16 @@ int copy_on_fault(void);
> void switch_trampoline(void);
> int cpu_dumpsize(void);
> int cpu_dump(void);
> -unsigned int cpu_rnd_messybits(void);
> +
> +static inline unsigned int
> +cpu_rnd_messybits(void)
> +{
> +unsigned int __itmr;
> +
> + __asm volatile("mfctl %1,%0": "=r" (__itmr) : "i" (CR_ITMR));
> +
> +return (__itmr);
> +}
>
> #ifdef MULTIPROCESSOR
> void cpu_boot_secondary_processors(void);
>
> --
> Christian "naddy" Weisgerber na...@mips.inka.de
>