1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00

Add INFO_VOLTAGE in cpu_msrinfo()

This commit is contained in:
Xorg 2015-10-06 15:14:35 +02:00
parent 36f24eae94
commit fc72fdee74
2 changed files with 14 additions and 1 deletions

View file

@ -863,6 +863,8 @@ typedef enum {
INFO_TEMPERATURE, /*!< The current core temperature in Celsius */
INFO_THROTTLING, /*!< 1 if the current logical processor is
throttling. 0 if it is running normally. */
INFO_VOLTAGE, /*!< The current core voltage in Volt,
multiplied by 100. */
} cpu_msrinfo_request_t;
/**

View file

@ -452,7 +452,7 @@ uint64_t cpu_rdmsr_range(struct msr_driver_t* handle, uint32_t reg, unsigned int
int cpu_msrinfo(struct msr_driver_t* handle, cpu_msrinfo_request_t which)
{
uint64_t r;
int err;
int err, error_indx;;
if (handle == NULL)
return set_error(ERR_HANDLE);
@ -475,6 +475,17 @@ int cpu_msrinfo(struct msr_driver_t* handle, cpu_msrinfo_request_t which)
}
case INFO_TEMPERATURE:
case INFO_THROTTLING:
return CPU_INVALID_VALUE;
case INFO_VOLTAGE:
{
if(cpu_vendor() == VENDOR_INTEL)
{
unsigned long val = cpu_rdmsr_range(handle, MSR_PERF_STATUS, 47, 32, &error_indx);
double ret = (double) val / (1 << 13);
return (ret > 0) ? ret * 100 : CPU_INVALID_VALUE;
}
return CPU_INVALID_VALUE;
}
default:
return CPU_INVALID_VALUE;
}