mirror of
https://github.com/anrieff/libcpuid
synced 2024-11-10 22:59:13 +00:00
Replace hardcoded addresses by define in cpu_msrinfo()
This commit is contained in:
parent
e631e62ce6
commit
cba9a1e19a
1 changed files with 7 additions and 5 deletions
|
@ -488,8 +488,11 @@ int cpu_msrinfo(struct msr_driver_t* driver, cpu_msrinfo_request_t which)
|
||||||
#define MSR_PSTATE_7 0xC001006B
|
#define MSR_PSTATE_7 0xC001006B
|
||||||
|
|
||||||
/* Intel MSRs addresses */
|
/* Intel MSRs addresses */
|
||||||
|
#define IA32_MPERF 0xE7
|
||||||
|
#define IA32_APERF 0xE8
|
||||||
#define IA32_PERF_STATUS 0x198
|
#define IA32_PERF_STATUS 0x198
|
||||||
#define IA32_THERM_STATUS 0x19C
|
#define IA32_THERM_STATUS 0x19C
|
||||||
|
#define MSR_EBL_CR_POWERON 0x2A
|
||||||
#define MSR_TURBO_RATIO_LIMIT 0x1AD
|
#define MSR_TURBO_RATIO_LIMIT 0x1AD
|
||||||
#define MSR_TEMPERATURE_TARGET 0x1A2
|
#define MSR_TEMPERATURE_TARGET 0x1A2
|
||||||
#define MSR_PERF_STATUS 0x198
|
#define MSR_PERF_STATUS 0x198
|
||||||
|
@ -582,7 +585,7 @@ static double get_info_cur_multiplier(struct msr_driver_t* handle, struct cpu_id
|
||||||
uint64_t reg;
|
uint64_t reg;
|
||||||
|
|
||||||
if(id->vendor == VENDOR_INTEL && internal->code.intel == PENTIUM) {
|
if(id->vendor == VENDOR_INTEL && internal->code.intel == PENTIUM) {
|
||||||
err = cpu_rdmsr(handle, 0x2a, ®);
|
err = cpu_rdmsr(handle, MSR_EBL_CR_POWERON, ®);
|
||||||
if (!err) return (reg>>22) & 0x1f;
|
if (!err) return (reg>>22) & 0x1f;
|
||||||
}
|
}
|
||||||
else if(id->vendor == VENDOR_INTEL && internal->code.intel != PENTIUM) {
|
else if(id->vendor == VENDOR_INTEL && internal->code.intel != PENTIUM) {
|
||||||
|
@ -611,7 +614,7 @@ static double get_info_max_multiplier(struct msr_driver_t* handle, struct cpu_id
|
||||||
uint64_t reg;
|
uint64_t reg;
|
||||||
|
|
||||||
if(id->vendor == VENDOR_INTEL && internal->code.intel == PENTIUM) {
|
if(id->vendor == VENDOR_INTEL && internal->code.intel == PENTIUM) {
|
||||||
err = cpu_rdmsr(handle, 0x198, ®);
|
err = cpu_rdmsr(handle, IA32_PERF_STATUS, ®);
|
||||||
if (!err) return (reg >> 40) & 0x1f;
|
if (!err) return (reg >> 40) & 0x1f;
|
||||||
}
|
}
|
||||||
else if(id->vendor == VENDOR_INTEL && internal->code.intel != PENTIUM) {
|
else if(id->vendor == VENDOR_INTEL && internal->code.intel != PENTIUM) {
|
||||||
|
@ -641,7 +644,6 @@ static double get_info_max_multiplier(struct msr_driver_t* handle, struct cpu_id
|
||||||
if (!err) return reg;
|
if (!err) return reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return CPU_INVALID_VALUE;
|
return CPU_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,9 +775,9 @@ int cpu_msrinfo(struct msr_driver_t* handle, cpu_msrinfo_request_t which)
|
||||||
|
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case INFO_MPERF:
|
case INFO_MPERF:
|
||||||
return perfmsr_measure(handle, 0xe7);
|
return perfmsr_measure(handle, IA32_MPERF);
|
||||||
case INFO_APERF:
|
case INFO_APERF:
|
||||||
return perfmsr_measure(handle, 0xe8);
|
return perfmsr_measure(handle, IA32_APERF);
|
||||||
case INFO_MIN_MULTIPLIER:
|
case INFO_MIN_MULTIPLIER:
|
||||||
return get_info_min_multiplier(handle, &id, &internal) * 100;
|
return get_info_min_multiplier(handle, &id, &internal) * 100;
|
||||||
case INFO_CUR_MULTIPLIER:
|
case INFO_CUR_MULTIPLIER:
|
||||||
|
|
Loading…
Reference in a new issue