|
Packit |
577717 |
/* $Id: x86_compat.h,v 1.33.2.5 2009/01/23 17:01:02 mikpe Exp $
|
|
Packit |
577717 |
* Performance-monitoring counters driver.
|
|
Packit |
577717 |
* x86/x86_64-specific compatibility definitions for 2.6 kernels.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Copyright (C) 2000-2007, 2009 Mikael Pettersson
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
#include <linux/version.h>
|
|
Packit |
577717 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
|
|
Packit |
577717 |
#include <linux/config.h>
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* missing from <asm-i386/cpufeature.h> */
|
|
Packit |
577717 |
#define cpu_has_msr boot_cpu_has(X86_FEATURE_MSR)
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* 2.6.24-rc1 changed cpu_data from behaving like an array indexed
|
|
Packit |
577717 |
by cpu to being a macro with a cpu parameter. This emulates the
|
|
Packit |
577717 |
macro-with-parameter form in older kernels. */
|
|
Packit |
577717 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
|
|
Packit |
577717 |
static inline struct cpuinfo_x86 *perfctr_cpu_data(int cpu)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
return &cpu_data[cpu];
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
#undef cpu_data
|
|
Packit |
577717 |
#define cpu_data(cpu) (*perfctr_cpu_data((cpu)))
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) && !defined(CONFIG_X86_64)
|
|
Packit |
577717 |
/* Stop speculative execution */
|
|
Packit |
577717 |
static inline void sync_core(void)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int tmp;
|
|
Packit |
577717 |
asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* cpuid_count() was added in the 2.6.12 standard kernel, but it's been
|
|
Packit |
577717 |
backported to some distribution kernels including the 2.6.9-22 RHEL4
|
|
Packit |
577717 |
kernel. For simplicity, always use our version in older kernels. */
|
|
Packit |
577717 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
|
|
Packit |
577717 |
/* Some CPUID calls want 'count' to be placed in ecx */
|
|
Packit |
577717 |
static inline void perfctr_cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
|
|
Packit |
577717 |
int *edx)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
__asm__("cpuid"
|
|
Packit |
577717 |
: "=a" (*eax),
|
|
Packit |
577717 |
"=b" (*ebx),
|
|
Packit |
577717 |
"=c" (*ecx),
|
|
Packit |
577717 |
"=d" (*edx)
|
|
Packit |
577717 |
: "0" (op), "c" (count));
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
#undef cpuid_count
|
|
Packit |
577717 |
#define cpuid_count(o,c,eax,ebx,ecx,edx) perfctr_cpuid_count((o),(c),(eax),(ebx),(ecx),(edx))
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
|
|
Packit |
577717 |
extern unsigned int perfctr_cpu_khz(void);
|