mirror of
https://github.com/anrieff/libcpuid
synced 2024-12-16 16:35:45 +00:00
Replace decode_intel_number_of_cores() by decode_number_of_cores_x86()
This commit is contained in:
parent
7974741993
commit
14c19f9195
3 changed files with 30 additions and 30 deletions
|
@ -348,6 +348,31 @@ void assign_cache_data(uint8_t on, cache_type_t cache, int size, int assoc, int
|
|||
}
|
||||
}
|
||||
|
||||
void decode_number_of_cores_x86(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
|
||||
{
|
||||
int logical_cpus = -1, num_cores = -1;
|
||||
|
||||
if (raw->basic_cpuid[0][EAX] >= 1) {
|
||||
logical_cpus = (raw->basic_cpuid[1][EBX] >> 16) & 0xff;
|
||||
if (raw->basic_cpuid[0][EAX] >= 4) {
|
||||
num_cores = 1 + ((raw->basic_cpuid[4][EAX] >> 26) & 0x3f);
|
||||
}
|
||||
}
|
||||
if (data->flags[CPU_FEATURE_HT]) {
|
||||
if (num_cores > 1) {
|
||||
data->num_cores = num_cores;
|
||||
data->num_logical_cpus = logical_cpus;
|
||||
} else {
|
||||
data->num_cores = 1;
|
||||
data->num_logical_cpus = (logical_cpus >= 1 ? logical_cpus : 1);
|
||||
if (data->num_logical_cpus == 1)
|
||||
data->flags[CPU_FEATURE_HT] = 0;
|
||||
}
|
||||
} else {
|
||||
data->num_cores = data->num_logical_cpus = (logical_cpus >= 1 ? logical_cpus : 1);
|
||||
}
|
||||
}
|
||||
|
||||
void decode_deterministic_cache_info_x86(uint32_t cache_regs[][NUM_REGS],
|
||||
uint8_t subleaf_count,
|
||||
struct cpu_id_t* data,
|
||||
|
|
|
@ -124,6 +124,9 @@ void clear_affinity_mask_bit(logical_cpu_t logical_cpu, cpu_affinity_mask_t *aff
|
|||
/* assign cache values in cpu_id_t type */
|
||||
void assign_cache_data(uint8_t on, cache_type_t cache, int size, int assoc, int linesize, struct cpu_id_t* data);
|
||||
|
||||
/* generic way to retrieve core count for x86 CPUs */
|
||||
void decode_number_of_cores_x86(struct cpu_raw_data_t* raw, struct cpu_id_t* data);
|
||||
|
||||
/* generic way to retrieve cache topology for x86 CPUs */
|
||||
void decode_deterministic_cache_info_x86(uint32_t cache_regs[][NUM_REGS],
|
||||
uint8_t subleaf_count,
|
||||
|
|
|
@ -712,35 +712,6 @@ static int decode_intel_extended_topology(struct cpu_raw_data_t* raw, struct cpu
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void decode_intel_number_of_cores(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
|
||||
{
|
||||
int logical_cpus = -1, num_cores = -1;
|
||||
|
||||
if (raw->basic_cpuid[0][EAX] >= 11) {
|
||||
if (decode_intel_extended_topology(raw, data)) return;
|
||||
}
|
||||
|
||||
if (raw->basic_cpuid[0][EAX] >= 1) {
|
||||
logical_cpus = (raw->basic_cpuid[1][EBX] >> 16) & 0xff;
|
||||
if (raw->basic_cpuid[0][EAX] >= 4) {
|
||||
num_cores = 1 + ((raw->basic_cpuid[4][EAX] >> 26) & 0x3f);
|
||||
}
|
||||
}
|
||||
if (data->flags[CPU_FEATURE_HT]) {
|
||||
if (num_cores > 1) {
|
||||
data->num_cores = num_cores;
|
||||
data->num_logical_cpus = logical_cpus;
|
||||
} else {
|
||||
data->num_cores = 1;
|
||||
data->num_logical_cpus = (logical_cpus >= 1 ? logical_cpus : 1);
|
||||
if (data->num_logical_cpus == 1)
|
||||
data->flags[CPU_FEATURE_HT] = 0;
|
||||
}
|
||||
} else {
|
||||
data->num_cores = data->num_logical_cpus = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static intel_code_and_bits_t get_brand_code_and_bits(struct cpu_id_t* data)
|
||||
{
|
||||
intel_code_t code = (intel_code_t) NC;
|
||||
|
@ -1055,7 +1026,8 @@ int cpuid_identify_intel(struct cpu_raw_data_t* raw, struct cpu_id_t* data, stru
|
|||
} else if (raw->basic_cpuid[0][EAX] >= 2) {
|
||||
decode_intel_oldstyle_cache_info(raw, data);
|
||||
}
|
||||
decode_intel_number_of_cores(raw, data);
|
||||
if ((raw->basic_cpuid[0][EAX] < 11) || (decode_intel_extended_topology(raw, data) == 0))
|
||||
decode_number_of_cores_x86(raw, data);
|
||||
data->purpose = cpuid_identify_purpose_intel(raw);
|
||||
|
||||
brand = get_brand_code_and_bits(data);
|
||||
|
|
Loading…
Reference in a new issue