mirror of
https://github.com/anrieff/libcpuid
synced 2024-12-16 16:35:45 +00:00
commit
1e597b9d25
2 changed files with 33 additions and 18 deletions
|
@ -446,18 +446,20 @@ static void print_info(output_data_switch query, struct cpu_raw_data_t* raw,
|
|||
fprintf(fout, " MSR.mperf : %d MHz\n", value);
|
||||
if ((value = cpu_msrinfo(handle, INFO_APERF)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " MSR.aperf : %d MHz\n", value);
|
||||
if ((value = cpu_msrinfo(handle, INFO_MIN_MULTIPLIER)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " min. multi.: %d\n", value / 100.0);
|
||||
if ((value = cpu_msrinfo(handle, INFO_CUR_MULTIPLIER)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " cur. multi.: %d MHz\n", value);
|
||||
fprintf(fout, " cur. multi.: %d\n", value / 100.0);
|
||||
if ((value = cpu_msrinfo(handle, INFO_MAX_MULTIPLIER)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " max. multi.: %d MHz\n", value);
|
||||
fprintf(fout, " max. multi.: %d\n", value / 100.0);
|
||||
if ((value = cpu_msrinfo(handle, INFO_TEMPERATURE)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " temperature: %d degrees Celsius\n", value);
|
||||
if ((value = cpu_msrinfo(handle, INFO_THROTTLING)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " throttling : %s\n", value ? "yes" : "no");
|
||||
if ((value = cpu_msrinfo(handle, INFO_VOLTAGE)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " core volt. : %.2lf Volts\n", value / 100.0);
|
||||
if ((value = cpu_msrinfo(handle, INFO_BCLK)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " base clock : %.2lf MHz\n", value / 100.0);
|
||||
if ((value = cpu_msrinfo(handle, INFO_BUS_CLOCK)) != CPU_INVALID_VALUE)
|
||||
fprintf(fout, " bus clock : %.2lf MHz\n", value / 100.0);
|
||||
cpu_msr_driver_close(handle);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -699,10 +699,30 @@ static int get_amd_multipliers(struct msr_info_t *info, uint32_t pstate, uint64_
|
|||
return err;
|
||||
}
|
||||
|
||||
static uint32_t get_amd_last_pstate_addr(struct msr_info_t *info)
|
||||
{
|
||||
static uint32_t last_addr = 0x0;
|
||||
uint64_t reg = 0x0;
|
||||
|
||||
/* The result is cached, need to be computed once */
|
||||
if(last_addr != 0x0)
|
||||
return last_addr;
|
||||
|
||||
/* Refer links above
|
||||
MSRC001_00[6B:64][63] is PstateEn
|
||||
PstateEn indicates if the rest of the P-state information in the register is valid after a reset */
|
||||
last_addr = MSR_PSTATE_7 + 1;
|
||||
while((reg == 0x0) && (last_addr > MSR_PSTATE_0)) {
|
||||
last_addr--;
|
||||
cpu_rdmsr_range(info->handle, last_addr, 63, 63, ®);
|
||||
}
|
||||
return last_addr;
|
||||
}
|
||||
|
||||
static double get_info_min_multiplier(struct msr_info_t *info)
|
||||
{
|
||||
int err;
|
||||
uint32_t addr = MSR_PSTATE_7 + 1;
|
||||
uint32_t addr;
|
||||
uint64_t reg;
|
||||
|
||||
if(info->id->vendor == VENDOR_INTEL) {
|
||||
|
@ -722,13 +742,9 @@ static double get_info_min_multiplier(struct msr_info_t *info)
|
|||
}
|
||||
else if(info->id->vendor == VENDOR_AMD) {
|
||||
/* N.B.: Find the last P-state
|
||||
MSRC001_00[6B:64][8:0] is { CpuDid, CpuFid }
|
||||
If all bits are 0 in a given P-state, we can consider the P-state is unused */
|
||||
do {
|
||||
addr--;
|
||||
cpu_rdmsr_range(info->handle, addr, 8, 0, ®);
|
||||
} while((reg == 0x0) && (addr > MSR_PSTATE_0));
|
||||
err = get_amd_multipliers(info, addr, ®);
|
||||
get_amd_last_pstate_addr() returns the last P-state, MSR_PSTATE_0 <= addr <= MSR_PSTATE_7 */
|
||||
addr = get_amd_last_pstate_addr(info);
|
||||
err = get_amd_multipliers(info, addr, ®);
|
||||
if (!err) return (double) reg;
|
||||
}
|
||||
|
||||
|
@ -858,7 +874,7 @@ static double get_info_voltage(struct msr_info_t *info)
|
|||
static double get_info_bus_clock(struct msr_info_t *info)
|
||||
{
|
||||
int err;
|
||||
uint32_t addr = MSR_PSTATE_7 + 1;
|
||||
uint32_t addr;
|
||||
uint64_t reg;
|
||||
|
||||
if(info->id->vendor == VENDOR_INTEL) {
|
||||
|
@ -878,12 +894,9 @@ static double get_info_bus_clock(struct msr_info_t *info)
|
|||
/* Refer links above
|
||||
MSRC001_0061[6:4] is PstateMaxVal
|
||||
PstateMaxVal is the the lowest-performance non-boosted P-state */
|
||||
do {
|
||||
addr--;
|
||||
cpu_rdmsr_range(info->handle, addr, 8, 0, ®);
|
||||
} while((reg == 0x0) && (addr > MSR_PSTATE_0));
|
||||
addr = get_amd_last_pstate_addr(info);
|
||||
err = cpu_rdmsr_range(info->handle, MSR_PSTATE_L, 6, 4, ®);
|
||||
err += get_amd_multipliers(info, MSR_PSTATE_0 + (addr - MSR_PSTATE_0 - (uint32_t) reg), ®);
|
||||
err += get_amd_multipliers(info, addr - reg, ®);
|
||||
if (!err) return (double) info->cpu_clock / reg;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue