Replace machine/rnd.h with more appropriate name to share it

with cycle counter based microtime in kern/kern_microtime.c.
This commit is contained in:
nakayama 2003-02-05 13:57:50 +00:00
parent d364c62597
commit e3e4805068
45 changed files with 118 additions and 285 deletions

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:51 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2001/05/28 16:22:20 thorpej Exp $ */
#include <mips/rnd.h>

View File

@ -1,67 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/08 02:19:20 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _ALPHA_RND_H_
#define _ALPHA_RND_H_
/*
* Machine-specific support for rnd(4)
*/
#ifdef _KERNEL
#include <machine/alpha_cpu.h>
/* Process Cycle Counter is always available. */
#define cpu_hascounter() (1)
static __inline u_int32_t
cpu_counter(void)
{
/*
* Only the lower 32 bits of the PCC are an actual cycle
* counter. Thankfully, the rnd(4) code only wants a
* 32-bit value anyway.
*/
return (alpha_rpcc() & 0xffffffffU);
}
#endif /* _KERNEL */
#endif /* !_ALPHA_RND_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:51 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/11 16:32:42 tsubai Exp $ */
#include <powerpc/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:52 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/06 02:24:00 soren Exp $ */
#include <mips/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:52 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/11 16:32:43 tsubai Exp $ */
#include <powerpc/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:52 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/06 02:24:01 soren Exp $ */
#include <mips/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:52 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2002/03/07 14:44:02 simonb Exp $ */
#include <mips/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:53 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2002/12/09 12:16:15 scw Exp $ */
#include <powerpc/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:53 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/06 02:24:01 soren Exp $ */
#include <mips/rnd.h>

View File

@ -1,78 +0,0 @@
/* $NetBSD: rnd.h,v 1.4 2001/12/06 01:56:19 sommerfeld Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Bill Sommerfeld.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _I386_RND_H_
#define _I386_RND_H_
/*
* Machine-specific support for rnd(4)
*/
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include "opt_cputype.h"
#ifdef _KERNEL
static __inline int
cpu_hascounter(void)
{
#if defined(I586_CPU) || defined(I686_CPU)
/*
* Note that:
* 1) Intel documentation is very specific that code *must* test
* the CPU feature flag, even if you "know" that a particular
* rev of the hardware supports it.
* 2) We know that the TSC is busted on some Cyrix CPU's..
*/
return (cpu_feature & CPUID_TSC) != 0;
#else
return 0;
#endif
}
static __inline u_int64_t
cpu_counter(void)
{
return rdtsc();
}
#endif /* _KERNEL */
#endif /* !_I386_RND_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:53 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/11 16:32:43 tsubai Exp $ */
#include <powerpc/rnd.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: rnd.h,v 1.4 2002/03/05 15:40:10 simonb Exp $ */
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:54 nakayama Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
@ -25,11 +25,11 @@
* SUCH DAMAGE.
*/
#ifndef _MIPS_RND_H_
#define _MIPS_RND_H_
#ifndef _MIPS_CPU_COUNTER_H_
#define _MIPS_CPU_COUNTER_H_
/*
* Machine-specific support for rnd(4)
* Machine-specific support for CPU counter.
*/
#include <machine/cpu.h>
@ -41,6 +41,7 @@
static __inline int
cpu_hascounter(void)
{
/*
* MIPS III and MIPS IV CPU's have a cycle counter
* running at half the internal pipeline rate.
@ -48,12 +49,22 @@ cpu_hascounter(void)
return (MIPS_HAS_CLOCK);
}
static __inline u_int32_t
cpu_counter(void)
#define cpu_counter() cpu_counter32()
static __inline uint32_t
cpu_counter32(void)
{
return mips3_cp0_count_read();
}
#if 0 /* XXX MI microtime() needs frequency of CPU counter. */
static __inline uint64_t
cpu_frequency(struct cpu_info *ci)
{
}
#endif
#endif
#endif /* _KERNEL */
#endif /* !_MIPS_RND_H_ */
#endif /* !_MIPS_CPU_COUNTER_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:54 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2002/02/27 21:02:20 scw Exp $ */
#include <powerpc/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:55 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/06 02:24:02 soren Exp $ */
#include <mips/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:55 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/11 16:32:44 tsubai Exp $ */
#include <powerpc/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:56 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2001/10/16 15:38:50 uch Exp $ */
#include <mips/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:56 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/06 02:24:02 soren Exp $ */
#include <mips/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:58 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2002/05/30 08:51:31 augustss Exp $ */
#include <powerpc/rnd.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: rnd.h,v 1.3 2003/01/23 15:59:38 kleink Exp $ */
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:59 nakayama Exp $ */
/*-
* Copyright (c) 2000 Tsubai Masanari. All rights reserved.
@ -26,23 +26,24 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _POWERPC_RND_H_
#define _POWERPC_RND_H_
#ifndef _POWERPC_CPU_COUNTER_H_
#define _POWERPC_CPU_COUNTER_H_
/*
* Machine-specific support for rnd(4)
* Machine-specific support for CPU counter.
*/
#ifdef _KERNEL
#include <powerpc/spr.h>
#define cpu_hascounter() 1
#define cpu_hascounter() (1)
#define cpu_counter() cpu_counter32()
static __inline u_int32_t
cpu_counter(void)
static __inline uint32_t
cpu_counter32(void)
{
u_int32_t rv, rtcu, scratch;
uint32_t rv, rtcu, scratch;
__asm __volatile (
"mfpvr %0 \n"
@ -66,6 +67,12 @@ cpu_counter(void)
return rv;
}
#if 0 /* XXX MI microtime() needs frequency of CPU counter. */
static __inline uint64_t
cpu_frequency(struct cpu_info *ci)
{
}
#endif
#endif /* _KERNEL */
#endif /* _POWERPC_RND_H_ */
#endif /* _POWERPC_CPU_COUNTER_H_ */

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:57:59 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/11 16:32:44 tsubai Exp $ */
#include <powerpc/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:58:01 nakayama Exp $ */
#include <powerpc/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2001/02/04 18:32:15 briggs Exp $ */
#include <powerpc/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:58:01 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2002/03/06 02:13:48 simonb Exp $ */
#include <mips/rnd.h>

View File

@ -0,0 +1,3 @@
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:58:02 nakayama Exp $ */
#include <mips/cpu_counter.h>

View File

@ -1,3 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2000/06/14 15:40:00 soren Exp $ */
#include <mips/rnd.h>

View File

@ -1,55 +0,0 @@
/* $NetBSD: rnd.h,v 1.1 2002/10/07 13:26:57 martin Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Martin Husemann.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SPARC64_RND_H_
#define _SPARC64_RND_H_
/*
* Machine-specific support for rnd(4)
*/
#include <machine/ctlreg.h>
#ifdef _KERNEL
#define cpu_hascounter() (1)
#define cpu_counter() tick()
#endif /* _KERNEL */
#endif /* !_SPARC64_RND_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rnd.h,v 1.2 2002/06/04 17:52:46 fvdl Exp $ */
/* $NetBSD: cpu_counter.h,v 1.1 2003/02/05 13:58:02 nakayama Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -36,25 +36,40 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _X86_64_RND_H_
#define _X86_64_RND_H_
#ifndef _X86_64_CPU_COUNTER_H_
#define _X86_64_CPU_COUNTER_H_
#ifdef _KERNEL
/*
* Machine-specific support for rnd(4)
* Machine-specific support for CPU counter.
*/
#include <machine/cpufunc.h>
#define cpu_hascounter() (1)
static __inline u_int64_t
static __inline uint64_t
cpu_counter(void)
{
return rdtsc();
return (rdtsc());
}
static __inline uint32_t
cpu_counter32(void)
{
return (rdtsc() & 0xffffffffUL);
}
#if 0 /* XXX MI microtime() needs frequency of CPU counter. */
static __inline uint64_t
cpu_frequency(struct cpu_info *ci)
{
}
#endif
#endif /* _KERNEL */
#endif /* !_X86_64_RND_H_ */
#endif /* !_X86_64_CPU_COUNTER_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rnd.c,v 1.38 2002/11/26 18:49:41 christos Exp $ */
/* $NetBSD: rnd.c,v 1.39 2003/02/05 13:57:50 nakayama Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.38 2002/11/26 18:49:41 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.39 2003/02/05 13:57:50 nakayama Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@ -56,7 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.38 2002/11/26 18:49:41 christos Exp $");
#include <sys/pool.h>
#ifdef __HAVE_CPU_COUNTER
#include <machine/rnd.h>
#include <machine/cpu_counter.h>
#endif
#ifdef RND_DEBUG
@ -189,14 +189,14 @@ rnd_counter(void)
#ifdef __HAVE_CPU_COUNTER
if (cpu_hascounter())
return (cpu_counter() & 0xffffffff);
return (cpu_counter32());
#endif
if (rnd_ready) {
microtime(&tv);
return (tv.tv_sec * 1000000 + tv.tv_usec);
}
/* when called from rnd_init, its too early to call microtime safely */
return 0;
return (0);
}
/*