Merge cpu_counter.h.

This commit is contained in:
ad 2008-05-10 14:53:54 +00:00
parent dc15915150
commit 9ab200719c
3 changed files with 29 additions and 63 deletions

View File

@ -1,12 +1,9 @@
/* $NetBSD: cpu_counter.h,v 1.6 2008/04/28 20:23:12 martin Exp $ */
/* $NetBSD: cpu_counter.h,v 1.7 2008/05/10 14:53:54 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* Copyright (c) 2008 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:
@ -29,22 +26,4 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _AMD64_CPU_COUNTER_H_
#define _AMD64_CPU_COUNTER_H_
#ifdef _KERNEL
/*
* Machine-specific support for CPU counter.
*/
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <x86/cpu_counter.h>
#define cpu_hascounter() (1)
#endif /* _KERNEL */
#endif /* !_AMD64_CPU_COUNTER_H_ */

View File

@ -1,12 +1,9 @@
/* $NetBSD: cpu_counter.h,v 1.8 2008/04/28 20:23:24 martin Exp $ */
/* $NetBSD: cpu_counter.h,v 1.9 2008/05/10 14:53:54 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* Copyright (c) 2008 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:
@ -29,37 +26,4 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _I386_CPU_COUNTER_H_
#define _I386_CPU_COUNTER_H_
/*
* Machine-specific support for CPU counter.
*/
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#ifdef _KERNEL
#include <x86/cpu_counter.h>
static __inline int
cpu_hascounter(void)
{
/*
* 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 in that if
* you execute "hlt" when in powersave mode, TSC stops counting,
* even though the CPU clock crystal is still ticking (it always has to).
*/
return (cpu_feature & CPUID_TSC) != 0;
}
#endif /* _KERNEL */
#endif /* !_I386_CPU_COUNTER_H_ */

View File

@ -1,7 +1,7 @@
/* $NetBSD: cpu_counter.h,v 1.2 2008/04/28 20:23:40 martin Exp $ */
/* $NetBSD: cpu_counter.h,v 1.3 2008/05/10 14:53:54 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -32,6 +32,12 @@
#ifndef _X86_CPU_COUNTER_H_
#define _X86_CPU_COUNTER_H_
#ifdef _KERNEL
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
/*
* x86 common functions for CPU counter.
*/
@ -57,4 +63,21 @@ cpu_frequency(struct cpu_info *ci)
return ci->ci_tsc_freq;
}
static __inline int
cpu_hascounter(void)
{
/*
* 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 in that if
* you execute "hlt" when in powersave mode, TSC stops counting,
* even though the CPU clock crystal is still ticking (it always has to).
*/
return (cpu_feature & CPUID_TSC) != 0;
}
#endif /* _KERNEL */
#endif /* !_X86_CPU_COUNTER_H_ */