libmsr
0.3.0
A friendlier interface to accessing MSRs on Intel platforms
|
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/sysinfo.h>
#include "cpuid.h"
#include "libmsr_error.h"
Functions | |
void | cpuid (uint64_t leaf, uint64_t *rax, uint64_t *rbx, uint64_t *rcx, uint64_t *rdx) |
Get processor identification and feature information to the 32-bit EAX, EBX, ECX, and EDX registers. | |
void | cpuid_detect_core_conf (uint64_t *coresPerSocket, uint64_t *hyperThreads, uint64_t *sockets, int *HTenabled) |
Determine platform configuration (i.e. number of sockets, number of cores/socket, number of logical processors, etc.). | |
void | cpuid_get_model (uint64_t *model) |
Retrieve the CPU model number. | |
void | cpuidInput_rax_rcx (uint64_t leafa, uint64_t leafc, uint64_t *rax, uint64_t *rbx, uint64_t *rcx, uint64_t *rdx) |
Get max number of physical processor cores on the platform. | |
bool | cpuid_mperf_and_aperf_avail (void) |
Check availability of p-state hardware coordination feedback, indicating presence of IA32_APERF and IA32_MPERF. | |
bool | cpuid_timestamp_counter_avail (void) |
Check availability of the time-stamp counter. | |
int | cpuid_num_pmc (void) |
Determine which performance monitoring counters (PMCs) are available. | |
int | cpuid_num_perfevtsel (void) |
Determine which performance event select MSRs (PerfEvtSelX) are available. | |
bool | cpuid_perf_global_ctrl_EN_PMC (void) |
Determine if performance monitoring capabilities are available. | |
bool | cpuid_perf_global_ctrl_EN_FIXED_CTRnum (void) |
Check availability of the three fixed-function performance counters: Instr_Retired.Any, CPU_CLK_Unhalted.Core, and CPU_CLK_Unhalted.Ref. | |
bool | cpuid_misc_enable_TurboModeDisable (void) |
Check if Turbo mode is disabled. | |
bool | cpuid_misc_enable_xTPRMessageDisable (void) |
Check if xTPR messages are disabled. | |
bool | cpuid_misc_enable_XDBitDisable (void) |
bool | cpuid_enable_ExtendedClockMod (void) |
Check if extended on-demand clock modulation is enabled. | |
bool | cpuid_therm_status_enable_ThermalThresholds (void) |
Check if Thermal Threshold #1 status and log and Thermal Threshold #2 status and log are enabled in IA32_THERM_STATUS. | |
bool | cpuid_therm_stat_enable_PowerLimitNotify (void) |
bool | cpuid_therm_status_enable_DigitalReadout (void) |
Check if digital readout is enabled in IA32_THERM_STATUS. | |
bool | cpuid_therm_interrupt_enable_PowerLimitNotify (void) |
Check if power limit notification enable is enabled in IA32_THERM_INTERRUPT. | |
bool | cpuid_pkg_therm_enable_status_and_interrupt (void) |
Check if IA32_PACKAGE_THERM_STATUS and IA32_PACKAGE_THERM_INTERRUPT are enabled on the platform. | |
uint64_t | cpuid_MaxLeaf (void) |
Get highest EAX value (i.e., leaf) supported by the platform. | |
void | cpuid_printVendorID (void) |
Print platform vendor ID. | |
int | cpuid_pkg_MaxPhysicalProcessorCores (void) |
Get max number of addressable IDs attributable to processor cores in the physical package. | |
int | cpuid_pkg_MaxLogicalProcessors (void) |
Get max number of addressable IDs for logical processors in a physical package. | |
int | cpuid_num_fixed_counters (void) |
Get number of fixed-function performance counters on the platform. | |
int | cpuid_width_fixed_counters (void) |
Get bit width of fixed-function performance counters on the platform. | |
void cpuid | ( | uint64_t | leaf, |
uint64_t * | rax, | ||
uint64_t * | rbx, | ||
uint64_t * | rcx, | ||
uint64_t * | rdx | ||
) |
Get processor identification and feature information to the 32-bit EAX, EBX, ECX, and EDX registers.
[in] | leaf | Level of basic processor information to be returned. |
[out] | rax | EAX register contents. |
[out] | rbx | EBX register contents. |
[out] | rcx | ECX register contents. |
[out] | rdx | EDX register contents. |
void cpuid_detect_core_conf | ( | uint64_t * | coresPerSocket, |
uint64_t * | hyperThreads, | ||
uint64_t * | sockets, | ||
int * | HTenabled | ||
) |
Determine platform configuration (i.e. number of sockets, number of cores/socket, number of logical processors, etc.).
[out] | coresPerSocket | Number of cores per socket (including hyperthreads, if enabled). |
[out] | hyperThreads | Number of threads including hyperthreads. |
[out] | sockets | Number of sockets. |
[out] | HTenabled | Hyperthreading enabled/disabled. |
bool cpuid_enable_ExtendedClockMod | ( | void | ) |
Check if extended on-demand clock modulation is enabled.
void cpuid_get_model | ( | uint64_t * | model | ) |
Retrieve the CPU model number.
[out] | model | CPU model number. |
uint64_t cpuid_MaxLeaf | ( | void | ) |
Get highest EAX value (i.e., leaf) supported by the platform.
bool cpuid_misc_enable_TurboModeDisable | ( | void | ) |
Check if Turbo mode is disabled.
bool cpuid_misc_enable_XDBitDisable | ( | void | ) |
bool cpuid_misc_enable_xTPRMessageDisable | ( | void | ) |
Check if xTPR messages are disabled.
bool cpuid_mperf_and_aperf_avail | ( | void | ) |
Check availability of p-state hardware coordination feedback, indicating presence of IA32_APERF and IA32_MPERF.
int cpuid_num_fixed_counters | ( | void | ) |
Get number of fixed-function performance counters on the platform.
int cpuid_num_perfevtsel | ( | void | ) |
Determine which performance event select MSRs (PerfEvtSelX) are available.
If greater than 3, then up to PerfEvtSel3 is usable. If greater than 2, then up to PerfEvtSel2 is usable. If greater than 1, then up to PerfEvtSel1 is usable. If greater than 0, then only PerfEvtSel0 is usable. If equal to 0, then no PerfEvtSel MSRs are usable.
int cpuid_num_pmc | ( | void | ) |
Determine which performance monitoring counters (PMCs) are available.
If greater than 3, then up to PMC3 is usable. If greater than 2, then up to PMC2 is usable. If greater than 1, then up to PMC1 is usable. If greater than 0, then only PMC0 is usable. If equal to 0, then no PMCs are usable.
bool cpuid_perf_global_ctrl_EN_FIXED_CTRnum | ( | void | ) |
Check availability of the three fixed-function performance counters: Instr_Retired.Any, CPU_CLK_Unhalted.Core, and CPU_CLK_Unhalted.Ref.
bool cpuid_perf_global_ctrl_EN_PMC | ( | void | ) |
Determine if performance monitoring capabilities are available.
int cpuid_pkg_MaxLogicalProcessors | ( | void | ) |
Get max number of addressable IDs for logical processors in a physical package.
int cpuid_pkg_MaxPhysicalProcessorCores | ( | void | ) |
Get max number of addressable IDs attributable to processor cores in the physical package.
bool cpuid_pkg_therm_enable_status_and_interrupt | ( | void | ) |
Check if IA32_PACKAGE_THERM_STATUS and IA32_PACKAGE_THERM_INTERRUPT are enabled on the platform.
void cpuid_printVendorID | ( | void | ) |
Print platform vendor ID.
bool cpuid_therm_interrupt_enable_PowerLimitNotify | ( | void | ) |
Check if power limit notification enable is enabled in IA32_THERM_INTERRUPT.
bool cpuid_therm_stat_enable_PowerLimitNotify | ( | void | ) |
bool cpuid_therm_status_enable_DigitalReadout | ( | void | ) |
Check if digital readout is enabled in IA32_THERM_STATUS.
bool cpuid_therm_status_enable_ThermalThresholds | ( | void | ) |
Check if Thermal Threshold #1 status and log and Thermal Threshold #2 status and log are enabled in IA32_THERM_STATUS.
bool cpuid_timestamp_counter_avail | ( | void | ) |
Check availability of the time-stamp counter.
int cpuid_width_fixed_counters | ( | void | ) |
Get bit width of fixed-function performance counters on the platform.
void cpuidInput_rax_rcx | ( | uint64_t | leafa, |
uint64_t | leafc, | ||
uint64_t * | rax, | ||
uint64_t * | rbx, | ||
uint64_t * | rcx, | ||
uint64_t * | rdx | ||
) |
Get max number of physical processor cores on the platform.
[in] | leafa | Initial value for EAX. |
[in] | leafc | Initial value for ECX. |
[out] | rax | EAX register contents. |
[out] | rbx | EBX register contents. |
[out] | rcx | ECX register contents. |
[out] | rdx | EDX register contents. |