26 #ifndef __LIBCPUID_H__
27 #define __LIBCPUID_H__
82 #include "libcpuid_types.h"
85 #include "libcpuid_constants.h"
109 #define NUM_CPU_VENDORS NUM_CPU_VENDORS
755 typedef void (*libcpuid_warn_fn_t) (
const char *msg);
884 int cpu_rdmsr(
struct msr_driver_t* handle, uint32_t msr_index, uint64_t* result);
922 int cpu_rdmsr_range(
struct msr_driver_t* handle, uint32_t msr_index, uint8_t highbit,
923 uint8_t lowbit, uint64_t* result);
937 #define CPU_INVALID_VALUE 0x3fffffff
Definition: libcpuid.h:288
Definition: libcpuid.h:331
Definition: libcpuid.h:285
cpu_msrinfo_request_t
Definition: libcpuid.h:887
cpu_error_t
Describes common library error codes.
Definition: libcpuid.h:405
void cpu_tsc_mark(struct cpu_mark_t *mark)
Store TSC and timing info.
Definition: libcpuid.h:411
Definition: libcpuid.h:301
int cpu_clock_by_mark(struct cpu_mark_t *mark)
Calculates the CPU clock.
Definition: libcpuid.h:417
int cpu_identify(struct cpu_raw_data_t *raw, struct cpu_id_t *data)
Identifies the CPU.
Definition: libcpuid.h:304
Definition: libcpuid.h:408
void cpuid_get_cpu_list(cpu_vendor_t vendor, struct cpu_list_t *list)
Gets a list of all known CPU names from a specific vendor.
Definition: libcpuid.h:373
char ** names
Definition: libcpuid.h:800
cpu_vendor_t vendor
Definition: libcpuid.h:147
Definition: libcpuid.h:98
int32_t family
Definition: libcpuid.h:157
void cpu_exec_cpuid_ext(uint32_t *regs)
Executes the CPUID instruction with the given input registers.
Definition: libcpuid.h:295
Definition: libcpuid.h:312
void cpu_rdtsc(uint64_t *result)
Executes RDTSC.
int32_t l1_data_cache
Definition: libcpuid.h:195
Definition: libcpuid.h:375
int cpu_msr_driver_close(struct msr_driver_t *handle)
Closes an open MSR driver.
Definition: libcpuid.h:370
Definition: libcpuid.h:346
char cpu_codename[64]
Definition: libcpuid.h:246
Internal structure, used in cpu_tsc_mark, cpu_tsc_unmark and cpu_clock_by_mark.
Definition: libcpuid.h:429
int cpuid_get_raw_data(struct cpu_raw_data_t *data)
Obtains the raw CPUID data from the current CPU.
Definition: libcpuid.h:280
int32_t num_cores
Definition: libcpuid.h:172
Definition: libcpuid.h:297
void cpu_tsc_unmark(struct cpu_mark_t *mark)
Calculate TSC and timing difference.
Definition: libcpuid.h:347
Definition: libcpuid.h:315
Definition: libcpuid.h:362
Definition: libcpuid.h:413
Definition: libcpuid.h:298
Definition: libcpuid.h:383
Definition: libcpuid.h:329
Definition: libcpuid.h:397
int cpu_clock_measure(int millis, int quad_check)
Measure the CPU clock frequency.
Definition: libcpuid.h:338
int cpuid_serialize_raw_data(struct cpu_raw_data_t *data, const char *filename)
Writes the raw CPUID data to a text file.
Definition: libcpuid.h:353
Definition: libcpuid.h:310
Definition: libcpuid.h:891
Definition: libcpuid.h:103
Definition: libcpuid.h:382
Definition: libcpuid.h:376
void cpuid_set_verbosiness_level(int level)
Sets the verbosiness level.
char vendor_str[VENDOR_STR_MAX]
Definition: libcpuid.h:141
Definition: libcpuid.h:904
cpu_hint_t
CPU detection hints identifiers.
Definition: libcpuid.h:396
Definition: libcpuid.h:349
Definition: libcpuid.h:337
Definition: libcpuid.h:379
int32_t total_logical_cpus
Definition: libcpuid.h:189
Definition: libcpuid.h:281
Definition: libcpuid.h:414
Definition: libcpuid.h:300
Definition: libcpuid.h:419
int cpu_rdmsr(struct msr_driver_t *handle, uint32_t msr_index, uint64_t *result)
Reads a Model-Specific Register (MSR)
int cpuid_deserialize_raw_data(struct cpu_raw_data_t *data, const char *filename)
Reads raw CPUID data from file.
const char * cpuid_lib_version(void)
Returns the libcpuid version.
Definition: libcpuid.h:364
Definition: libcpuid.h:380
Definition: libcpuid.h:366
Definition: libcpuid.h:341
Definition: libcpuid.h:309
Definition: libcpuid.h:319
int32_t l1_cacheline
Definition: libcpuid.h:224
a structure that holds a list of processor names
Definition: libcpuid.h:796
Definition: libcpuid.h:321
Definition: libcpuid.h:320
Definition: libcpuid.h:355
int32_t l3_cacheline
Definition: libcpuid.h:230
Definition: libcpuid.h:372
Definition: libcpuid.h:336
Definition: libcpuid.h:313
Definition: libcpuid.h:104
This contains the recognized CPU features/info.
Definition: libcpuid.h:139
Definition: libcpuid.h:358
Definition: libcpuid.h:416
int cpu_clock(void)
Get the CPU clock frequency (all-in-one method)
Definition: libcpuid.h:328
Definition: libcpuid.h:283
Definition: libcpuid.h:344
Definition: libcpuid.h:322
Definition: libcpuid.h:340
Definition: libcpuid.h:326
uint32_t intel_fn11[MAX_INTELFN11_LEVEL][4]
Definition: libcpuid.h:133
const char * cpu_feature_str(cpu_feature_t feature)
Returns the short textual representation of a CPU flag.
uint32_t intel_fn4[MAX_INTELFN4_LEVEL][4]
Definition: libcpuid.h:128
int32_t l2_cacheline
Definition: libcpuid.h:227
int32_t l2_assoc
Definition: libcpuid.h:218
int32_t num_logical_cpus
Definition: libcpuid.h:179
uint64_t sys_clock
Definition: libcpuid.h:431
Definition: libcpuid.h:335
struct msr_driver_t * cpu_msr_driver_open(void)
Starts/opens a driver, needed to read MSRs (Model Specific Registers)
Definition: libcpuid.h:363
int num_entries
Definition: libcpuid.h:798
int cpu_clock_by_ic(int millis, int runs)
Measure the CPU clock frequency using instruction-counting.
Definition: libcpuid.h:292
Definition: libcpuid.h:334
Definition: libcpuid.h:339
Definition: libcpuid.h:316
int cpuid_present(void)
Checks if the CPUID instruction is supported.
int32_t l1_assoc
Definition: libcpuid.h:215
int cpuid_get_total_cpus(void)
Returns the total number of CPUs even if CPUID is not present.
Definition: libcpuid.h:378
Definition: libcpuid.h:365
Definition: libcpuid.h:299
Definition: libcpuid.h:888
int32_t ext_model
Definition: libcpuid.h:169
Definition: libcpuid.h:345
Definition: libcpuid.h:101
Definition: libcpuid.h:286
Definition: libcpuid.h:343
int32_t l3_cache
Definition: libcpuid.h:212
Definition: libcpuid.h:303
Definition: libcpuid.h:284
Definition: libcpuid.h:308
Definition: libcpuid.h:290
Definition: libcpuid.h:305
Definition: libcpuid.h:371
Definition: libcpuid.h:422
Definition: libcpuid.h:342
Definition: libcpuid.h:314
Definition: libcpuid.h:410
Definition: libcpuid.h:100
Definition: libcpuid.h:384
Definition: libcpuid.h:95
int32_t l3_assoc
Definition: libcpuid.h:221
Definition: libcpuid.h:102
Definition: libcpuid.h:361
Definition: libcpuid.h:332
Definition: libcpuid.h:323
Definition: libcpuid.h:291
uint64_t tsc
Definition: libcpuid.h:430
Definition: libcpuid.h:377
Definition: libcpuid.h:406
Definition: libcpuid.h:306
Definition: libcpuid.h:409
Definition: libcpuid.h:352
int cpu_rdmsr_range(struct msr_driver_t *handle, uint32_t msr_index, uint8_t highbit, uint8_t lowbit, uint64_t *result)
Similar to cpu_rdmsr, but extract a range of bits.
Definition: libcpuid.h:421
Definition: libcpuid.h:324
Definition: libcpuid.h:368
Definition: libcpuid.h:294
Definition: libcpuid.h:296
cpu_vendor_t
CPU vendor, as guessed from the Vendor String.
Definition: libcpuid.h:94
Definition: libcpuid.h:350
Definition: libcpuid.h:302
uint8_t detection_hints[CPU_HINTS_MAX]
Definition: libcpuid.h:256
int cpu_msrinfo(struct msr_driver_t *handle, cpu_msrinfo_request_t which)
Reads extended CPU information from Model-Specific Registers.
Definition: libcpuid.h:902
Definition: libcpuid.h:97
uint32_t basic_cpuid[MAX_CPUID_LEVEL][4]
Definition: libcpuid.h:120
Definition: libcpuid.h:357
int32_t sse_size
Definition: libcpuid.h:249
Definition: libcpuid.h:359
Definition: libcpuid.h:385
cpu_vendor_t cpuid_get_vendor(void)
Obtains the CPU vendor from CPUID from the current CPU.
Definition: libcpuid.h:99
Definition: libcpuid.h:311
Definition: libcpuid.h:289
Definition: libcpuid.h:325
Definition: libcpuid.h:330
Definition: libcpuid.h:367
Definition: libcpuid.h:318
Definition: libcpuid.h:348
Definition: libcpuid.h:287
int32_t l1_instruction_cache
Definition: libcpuid.h:203
Definition: libcpuid.h:354
libcpuid_warn_fn_t cpuid_set_warn_function(libcpuid_warn_fn_t warn_fun)
Sets the warning print function.
void cpuid_free_cpu_list(struct cpu_list_t *list)
Frees a CPU list.
Definition: libcpuid.h:897
uint8_t flags[CPU_FLAGS_MAX]
Definition: libcpuid.h:154
uint32_t ext_cpuid[MAX_EXT_CPUID_LEVEL][4]
Definition: libcpuid.h:123
char brand_str[BRAND_STR_MAX]
Definition: libcpuid.h:144
int32_t stepping
Definition: libcpuid.h:163
const char * cpuid_error(void)
Returns textual description of the last error.
Definition: libcpuid.h:418
Definition: libcpuid.h:420
Definition: libcpuid.h:899
Definition: libcpuid.h:386
Definition: libcpuid.h:317
Definition: libcpuid.h:356
int32_t model
Definition: libcpuid.h:160
Definition: libcpuid.h:106
Definition: libcpuid.h:407
Definition: libcpuid.h:369
Definition: libcpuid.h:307
Definition: libcpuid.h:894
Definition: libcpuid.h:360
struct msr_driver_t * cpu_msr_driver_open_core(unsigned core_num)
Similar to cpu_msr_driver_open, but accept one parameter.
Definition: libcpuid.h:415
Definition: libcpuid.h:900
void cpu_exec_cpuid(uint32_t eax, uint32_t *regs)
Executes the CPUID instruction.
int32_t l2_cache
Definition: libcpuid.h:209
Definition: libcpuid.h:381
Definition: libcpuid.h:333
int cpu_clock_by_os(void)
Returns the CPU clock, as reported by the OS.
Definition: libcpuid.h:412
Definition: libcpuid.h:374
Definition: libcpuid.h:282
Definition: libcpuid.h:96
cpu_feature_t
CPU feature identifiers.
Definition: libcpuid.h:279
int32_t ext_family
Definition: libcpuid.h:166
Definition: libcpuid.h:293
Definition: libcpuid.h:327
Contains just the raw CPUID data.
Definition: libcpuid.h:118
Definition: libcpuid.h:351