~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/power/cpupower/utils/helpers/helpers.h

Version: ~ [ linux-5.8-rc5 ] ~ [ linux-5.7.8 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.51 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.132 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.188 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.230 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.230 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  (C) 2010,2011       Thomas Renninger <trenn@suse.de>, Novell Inc.
  3  *
  4  *  Licensed under the terms of the GNU GPL License version 2.
  5  *
  6  * Miscellaneous helpers which do not fit or are worth
  7  * to put into separate headers
  8  */
  9 
 10 #ifndef __CPUPOWERUTILS_HELPERS__
 11 #define __CPUPOWERUTILS_HELPERS__
 12 
 13 #include <libintl.h>
 14 #include <locale.h>
 15 
 16 #include "helpers/bitmask.h"
 17 
 18 /* Internationalization ****************************/
 19 #ifdef NLS
 20 
 21 #define _(String) gettext(String)
 22 #ifndef gettext_noop
 23 #define gettext_noop(String) String
 24 #endif
 25 #define N_(String) gettext_noop(String)
 26 
 27 #else /* !NLS */
 28 
 29 #define _(String) String
 30 #define N_(String) String
 31 
 32 #endif
 33 /* Internationalization ****************************/
 34 
 35 extern int run_as_root;
 36 extern struct bitmask *cpus_chosen;
 37 
 38 /* Global verbose (-d) stuff *********************************/
 39 /*
 40  * define DEBUG via global Makefile variable
 41  * Debug output is sent to stderr, do:
 42  * cpupower monitor 2>/tmp/debug
 43  * to split debug output away from normal output
 44 */
 45 #ifdef DEBUG
 46 extern int be_verbose;
 47 
 48 #define dprint(fmt, ...) {                                      \
 49                 if (be_verbose) {                               \
 50                         fprintf(stderr, "%s: " fmt,             \
 51                                 __func__, ##__VA_ARGS__);       \
 52                 }                                               \
 53         }
 54 #else
 55 static inline void dprint(const char *fmt, ...) { }
 56 #endif
 57 extern int be_verbose;
 58 /* Global verbose (-v) stuff *********************************/
 59 
 60 /* cpuid and cpuinfo helpers  **************************/
 61 enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,
 62                           X86_VENDOR_AMD, X86_VENDOR_MAX};
 63 
 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
 71 
 72 #define MAX_HW_PSTATES 10
 73 
 74 struct cpupower_cpu_info {
 75         enum cpupower_cpu_vendor vendor;
 76         unsigned int family;
 77         unsigned int model;
 78         unsigned int stepping;
 79         /* CPU capabilities read out from cpuid */
 80         unsigned long long caps;
 81 };
 82 
 83 /* get_cpu_info
 84  *
 85  * Extract CPU vendor, family, model, stepping info from /proc/cpuinfo
 86  *
 87  * Returns 0 on success or a negativ error code
 88  * Only used on x86, below global's struct values are zero/unknown on
 89  * other archs
 90  */
 91 extern int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info);
 92 extern struct cpupower_cpu_info cpupower_cpu_info;
 93 /* cpuid and cpuinfo helpers  **************************/
 94 
 95 struct cpuid_core_info {
 96         int pkg;
 97         int core;
 98         int cpu;
 99 
100         /* flags */
101         unsigned int is_online:1;
102 };
103 
104 /* CPU topology/hierarchy parsing ******************/
105 struct cpupower_topology {
106         /* Amount of CPU cores, packages and threads per core in the system */
107         unsigned int cores;
108         unsigned int pkgs;
109         unsigned int threads; /* per core */
110 
111         /* Array gets mallocated with cores entries, holding per core info */
112         struct cpuid_core_info *core_info;
113 };
114 
115 extern int get_cpu_topology(struct cpupower_topology *cpu_top);
116 extern void cpu_topology_release(struct cpupower_topology cpu_top);
117 
118 /* CPU topology/hierarchy parsing ******************/
119 
120 /* X86 ONLY ****************************************/
121 #if defined(__i386__) || defined(__x86_64__)
122 
123 #include <pci/pci.h>
124 
125 /* Read/Write msr ****************************/
126 extern int read_msr(int cpu, unsigned int idx, unsigned long long *val);
127 extern int write_msr(int cpu, unsigned int idx, unsigned long long val);
128 
129 extern int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val);
130 extern int msr_intel_get_perf_bias(unsigned int cpu);
131 extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu);
132 
133 /* Read/Write msr ****************************/
134 
135 /* PCI stuff ****************************/
136 extern int amd_pci_get_num_boost_states(int *active, int *states);
137 extern struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain,
138                                     int bus, int slot, int func, int vendor,
139                                     int dev);
140 extern struct pci_dev *pci_slot_func_init(struct pci_access **pacc,
141                                               int slot, int func);
142 
143 /* PCI stuff ****************************/
144 
145 /* AMD HW pstate decoding **************************/
146 
147 extern int decode_pstates(unsigned int cpu, unsigned int cpu_family,
148                           int boost_states, unsigned long *pstates, int *no);
149 
150 /* AMD HW pstate decoding **************************/
151 
152 extern int cpufreq_has_boost_support(unsigned int cpu, int *support,
153                                      int *active, int * states);
154 /*
155  * CPUID functions returning a single datum
156  */
157 unsigned int cpuid_eax(unsigned int op);
158 unsigned int cpuid_ebx(unsigned int op);
159 unsigned int cpuid_ecx(unsigned int op);
160 unsigned int cpuid_edx(unsigned int op);
161 
162 /* cpuid and cpuinfo helpers  **************************/
163 /* X86 ONLY ********************************************/
164 #else
165 static inline int decode_pstates(unsigned int cpu, unsigned int cpu_family,
166                                  int boost_states, unsigned long *pstates,
167                                  int *no)
168 { return -1; };
169 
170 static inline int read_msr(int cpu, unsigned int idx, unsigned long long *val)
171 { return -1; };
172 static inline int write_msr(int cpu, unsigned int idx, unsigned long long val)
173 { return -1; };
174 static inline int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val)
175 { return -1; };
176 static inline int msr_intel_get_perf_bias(unsigned int cpu)
177 { return -1; };
178 static inline unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu)
179 { return 0; };
180 
181 /* Read/Write msr ****************************/
182 
183 static inline int cpufreq_has_boost_support(unsigned int cpu, int *support,
184                                             int *active, int * states)
185 { return -1; }
186 
187 /* cpuid and cpuinfo helpers  **************************/
188 
189 static inline unsigned int cpuid_eax(unsigned int op) { return 0; };
190 static inline unsigned int cpuid_ebx(unsigned int op) { return 0; };
191 static inline unsigned int cpuid_ecx(unsigned int op) { return 0; };
192 static inline unsigned int cpuid_edx(unsigned int op) { return 0; };
193 #endif /* defined(__i386__) || defined(__x86_64__) */
194 
195 #endif /* __CPUPOWERUTILS_HELPERS__ */
196 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp