10 #ifndef __CPUPOWERUTILS_HELPERS__
11 #define __CPUPOWERUTILS_HELPERS__
21 #define _(String) gettext(String)
23 #define gettext_noop(String) String
25 #define N_(String) gettext_noop(String)
29 #define _(String) String
30 #define N_(String) String
48 #define dprint(fmt, ...) { \
50 fprintf(stderr, "%s: " fmt, \
51 __func__, ##__VA_ARGS__); \
55 static inline void dprint(
const char *
fmt, ...) { }
64 #define CPUPOWER_CAP_INV_TSC 0x00000001
65 #define CPUPOWER_CAP_APERF 0x00000002
66 #define CPUPOWER_CAP_AMD_CBP 0x00000004
67 #define CPUPOWER_CAP_PERF_BIAS 0x00000008
68 #define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010
69 #define CPUPOWER_CAP_IS_SNB 0x00000020
70 #define CPUPOWER_CAP_INTEL_IDA 0x00000040
72 #define MAX_HW_PSTATES 10
119 #if defined(__i386__) || defined(__x86_64__)
124 extern int read_msr(
int cpu,
unsigned int idx,
unsigned long long *
val);
125 extern int write_msr(
int cpu,
unsigned int idx,
unsigned long long val);
127 extern int msr_intel_set_perf_bias(
unsigned int cpu,
unsigned int val);
128 extern int msr_intel_get_perf_bias(
unsigned int cpu);
129 extern unsigned long long msr_intel_get_turbo_ratio(
unsigned int cpu);
134 extern int amd_pci_get_num_boost_states(
int *
active,
int *states);
135 extern struct pci_dev *pci_acc_init(
struct pci_access **pacc,
int domain,
138 extern struct pci_dev *pci_slot_func_init(
struct pci_access **pacc,
145 extern int decode_pstates(
unsigned int cpu,
unsigned int cpu_family,
146 int boost_states,
unsigned long *pstates,
int *
no);
150 extern int cpufreq_has_boost_support(
unsigned int cpu,
int *
support,
151 int *
active,
int * states);
155 unsigned int cpuid_eax(
unsigned int op);
156 unsigned int cpuid_ebx(
unsigned int op);
157 unsigned int cpuid_ecx(
unsigned int op);
158 unsigned int cpuid_edx(
unsigned int op);
163 static inline int decode_pstates(
unsigned int cpu,
unsigned int cpu_family,
164 int boost_states,
unsigned long *pstates,
168 static inline int read_msr(
int cpu,
unsigned int idx,
unsigned long long *
val)
170 static inline int write_msr(
int cpu,
unsigned int idx,
unsigned long long val)
172 static inline int msr_intel_set_perf_bias(
unsigned int cpu,
unsigned int val)
174 static inline int msr_intel_get_perf_bias(
unsigned int cpu)
176 static inline unsigned long long msr_intel_get_turbo_ratio(
unsigned int cpu)
181 static inline int cpufreq_has_boost_support(
unsigned int cpu,
int *
support,
182 int *
active,
int * states)
187 static inline unsigned int cpuid_eax(
unsigned int op) {
return 0; };
188 static inline unsigned int cpuid_ebx(
unsigned int op) {
return 0; };
189 static inline unsigned int cpuid_ecx(
unsigned int op) {
return 0; };
190 static inline unsigned int cpuid_edx(
unsigned int op) {
return 0; };