tools/power/cpupower/utils/helpers/helpers.h
Source file repositories/reference/linux-study-clean/tools/power/cpupower/utils/helpers/helpers.h
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/utils/helpers/helpers.h- Extension
.h- Size
- 6892 bytes
- Lines
- 225
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
libintl.hlocale.hstdbool.hhelpers/bitmask.hcpupower.hpci/pci.h
Detected Declarations
struct cpupower_cpu_infoenum cpupower_cpu_vendorfunction dprintfunction decode_pstatesfunction read_msrfunction write_msrfunction cpupower_intel_set_perf_biasfunction cpupower_intel_get_perf_biasfunction msr_intel_get_turbo_ratiofunction cpupower_set_eppfunction cpupower_set_amd_pstate_modefunction cpufreq_has_x86_boost_supportfunction cpupower_set_intel_turbo_boostfunction cpupower_amd_pstate_enabledfunction amd_pstate_boost_initfunction cpuid_ebxfunction cpuid_ecxfunction cpuid_edx
Annotated Snippet
struct cpupower_cpu_info {
enum cpupower_cpu_vendor vendor;
unsigned int family;
unsigned int model;
unsigned int stepping;
/* CPU capabilities read out from cpuid */
unsigned long long caps;
};
/* get_cpu_info
*
* Extract CPU vendor, family, model, stepping info from /proc/cpuinfo
*
* Returns 0 on success or a negative error code
* Only used on x86, below global's struct values are zero/unknown on
* other archs
*/
extern int get_cpu_info(struct cpupower_cpu_info *cpu_info);
extern struct cpupower_cpu_info cpupower_cpu_info;
/* cpuid and cpuinfo helpers **************************/
int cpufreq_has_generic_boost_support(bool *active);
int cpupower_set_generic_turbo_boost(int turbo_boost);
/* X86 ONLY ****************************************/
#if defined(__i386__) || defined(__x86_64__)
#include <pci/pci.h>
/* Read/Write msr ****************************/
extern int read_msr(int cpu, unsigned int idx, unsigned long long *val);
extern int write_msr(int cpu, unsigned int idx, unsigned long long val);
extern int cpupower_intel_set_perf_bias(unsigned int cpu, unsigned int val);
extern int cpupower_intel_get_perf_bias(unsigned int cpu);
extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu);
extern int cpupower_set_epp(unsigned int cpu, char *epp);
extern int cpupower_set_amd_pstate_mode(char *mode);
/* Read/Write msr ****************************/
/* PCI stuff ****************************/
extern int amd_pci_get_num_boost_states(int *active, int *states);
extern struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain,
int bus, int slot, int func, int vendor,
int dev);
extern struct pci_dev *pci_slot_func_init(struct pci_access **pacc,
int slot, int func);
/* PCI stuff ****************************/
/* AMD HW pstate decoding **************************/
extern int decode_pstates(unsigned int cpu, int boost_states,
unsigned long *pstates, int *no);
/* AMD HW pstate decoding **************************/
int cpufreq_has_x86_boost_support(unsigned int cpu, int *support,
int *active, int *states);
int cpupower_set_intel_turbo_boost(int turbo_boost);
/* AMD P-State stuff **************************/
bool cpupower_amd_pstate_enabled(void);
void amd_pstate_boost_init(unsigned int cpu,
int *support, int *active);
void amd_pstate_show_perf_and_freq(unsigned int cpu,
int no_rounding);
/* AMD P-State stuff **************************/
/*
* CPUID functions returning a single datum
*/
unsigned int cpuid_eax(unsigned int op);
unsigned int cpuid_ebx(unsigned int op);
unsigned int cpuid_ecx(unsigned int op);
unsigned int cpuid_edx(unsigned int op);
/* cpuid and cpuinfo helpers **************************/
/* X86 ONLY ********************************************/
#else
static inline int decode_pstates(unsigned int cpu, int boost_states,
unsigned long *pstates, int *no)
{ return -1; };
static inline int read_msr(int cpu, unsigned int idx, unsigned long long *val)
Annotation
- Immediate include surface: `libintl.h`, `locale.h`, `stdbool.h`, `helpers/bitmask.h`, `cpupower.h`, `pci/pci.h`.
- Detected declarations: `struct cpupower_cpu_info`, `enum cpupower_cpu_vendor`, `function dprint`, `function decode_pstates`, `function read_msr`, `function write_msr`, `function cpupower_intel_set_perf_bias`, `function cpupower_intel_get_perf_bias`, `function msr_intel_get_turbo_ratio`, `function cpupower_set_epp`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.