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

Add AMD support for INFO_VOLTAGE in cpu_msrinfo()

This commit is contained in:
Xorg 2016-05-18 14:11:33 +02:00
parent 1145fdc116
commit b5e82df407

View file

@ -417,6 +417,8 @@ static int perfmsr_measure(struct msr_driver_t* handle, int msr)
#define PLATFORM_INFO_MSR 206 #define PLATFORM_INFO_MSR 206
#define PLATFORM_INFO_MSR_low 8 #define PLATFORM_INFO_MSR_low 8
#define PLATFORM_INFO_MSR_high 15 #define PLATFORM_INFO_MSR_high 15
#define MSR_PSTATE_S 0xC0010063
#define MSR_PSTATE_0 0xC0010064
static int get_bits_value(uint64_t val, int highbit, int lowbit) static int get_bits_value(uint64_t val, int highbit, int lowbit)
{ {
@ -534,6 +536,17 @@ int cpu_msrinfo(struct msr_driver_t* handle, cpu_msrinfo_request_t which)
double ret = (double) val / (1 << 13); double ret = (double) val / (1 << 13);
return (ret > 0) ? (int) (ret * 100) : CPU_INVALID_VALUE; return (ret > 0) ? (int) (ret * 100) : CPU_INVALID_VALUE;
} }
else if(cpuid_get_vendor() == VENDOR_AMD)
{
/* http://support.amd.com/TechDocs/42301_15h_Mod_00h-0Fh_BKDG.pdf
MSRC001_0063[2:0] = CurPstate
MSRC001_00[6B:64][15:9] = CpuVid */
uint64_t CurPstate = cpu_rdmsr_range(handle, MSR_PSTATE_S, 2, 0, &error_indx);
if(0 <= CurPstate && CurPstate <= 7) { // Support 8 P-states
uint64_t CpuVid = cpu_rdmsr_range(handle, MSR_PSTATE_0 + CurPstate, 15, 9, &error_indx);
return (int) (1.550 - 0.0125 * CpuVid) * 100; // 2.4.1.6.3 - Serial VID (SVI) Encodings
}
}
return CPU_INVALID_VALUE; return CPU_INVALID_VALUE;
} }
case INFO_BCLK: case INFO_BCLK: