mirror of
https://github.com/anrieff/libcpuid
synced 2024-12-16 16:35:45 +00:00
parent
779b403aa0
commit
94507ded22
2 changed files with 135 additions and 5 deletions
|
@ -64,6 +64,13 @@ enum _amd_bits_t {
|
|||
};
|
||||
typedef enum _amd_bits_t amd_bits_t;
|
||||
|
||||
enum _amd_model_codes_t {
|
||||
// Only for Ryzen CPUs:
|
||||
_1400,
|
||||
_1500,
|
||||
_1600,
|
||||
};
|
||||
|
||||
|
||||
const struct match_entry_t cpudb_amd[] = {
|
||||
{ -1, -1, -1, -1, -1, 1, -1, -1, NC, 0 , 0, "Unknown AMD CPU" },
|
||||
|
@ -283,10 +290,11 @@ const struct match_entry_t cpudb_amd[] = {
|
|||
{ 15, 0, -1, 22, 48, 4, -1, -1, FUSION_A, 0 , 0, "Mullins X4" },
|
||||
|
||||
/* Family 17h: Zen Architecture (2017) */
|
||||
//{ 15, -1, -1, 23, 1, 8, -1, -1, NC, 0 , 0, "Ryzen 7" }, //FIXME
|
||||
//{ 15, -1, -1, 23, 1, 6, -1, -1, NC, 0 , 0, "Ryzen 5" }, //TBA
|
||||
//{ 15, -1, -1, 23, 1, 4, -1, -1, NC, 0 , 0, "Ryzen 5" }, //TBA
|
||||
//{ 15, -1, -1, 23, 1, 4, -1, -1, NC, 0 , 0, "Ryzen 3" }, //TBA
|
||||
{ 15, -1, -1, 23, 1, 8, -1, -1, NC, 0 , 0, "Ryzen 7" },
|
||||
{ 15, -1, -1, 23, 1, 6, -1, -1, NC, 0 , _1600, "Ryzen 5" },
|
||||
{ 15, -1, -1, 23, 1, 4, -1, -1, NC, 0 , _1500, "Ryzen 5" },
|
||||
{ 15, -1, -1, 23, 1, 4, -1, -1, NC, 0 , _1400, "Ryzen 5" },
|
||||
{ 15, -1, -1, 23, 1, 4, -1, -1, NC, 0 , 0, "Ryzen 3" },
|
||||
//{ 15, -1, -1, 23, 1, 4, -1, -1, NC, 0 , 0, "Raven Ridge" }, //TBA
|
||||
|
||||
/* Newer Opterons: */
|
||||
|
@ -390,6 +398,8 @@ static void decode_amd_number_of_cores(struct cpu_raw_data_t* raw, struct cpu_id
|
|||
}
|
||||
if (data->flags[CPU_FEATURE_HT]) {
|
||||
if (num_cores > 1) {
|
||||
if (data->ext_family >= 23)
|
||||
num_cores /= 2; // e.g., Ryzen 7 reports 16 "real" cores, but they are really just 8.
|
||||
data->num_cores = num_cores;
|
||||
data->num_logical_cpus = logical_cpus;
|
||||
} else {
|
||||
|
@ -467,6 +477,25 @@ static struct amd_code_and_bits_t decode_amd_codename_part1(const char *bs)
|
|||
return result;
|
||||
}
|
||||
|
||||
static int decode_amd_ryzen_model_code(const char* bs)
|
||||
{
|
||||
const struct {
|
||||
int model_code;
|
||||
const char* match_str;
|
||||
} patterns[] = {
|
||||
{ _1600, "1600" },
|
||||
{ _1500, "1500" },
|
||||
{ _1400, "1400" },
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < COUNT_OF(patterns); i++)
|
||||
if (strstr(bs, patterns[i].match_str))
|
||||
return patterns[i].model_code;
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void decode_amd_codename(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal)
|
||||
{
|
||||
struct amd_code_and_bits_t code_and_bits = decode_amd_codename_part1(data->brand_str);
|
||||
|
@ -486,9 +515,14 @@ static void decode_amd_codename(struct cpu_raw_data_t* raw, struct cpu_id_t* dat
|
|||
debugf(2, "Detected AMD brand code: %d (%s)\n", code_and_bits.code, code_str);
|
||||
else
|
||||
debugf(2, "Detected AMD brand code: %d\n", code_and_bits.code);
|
||||
|
||||
// is it Ryzen? if so, we need to detect discern between the four-core 1400/1500 (Ryzen 5) and the four-core Ryzen 3:
|
||||
int model_code = (data->ext_family == 23) ? decode_amd_ryzen_model_code(data->brand_str) : 0;
|
||||
|
||||
internal->code.amd = code_and_bits.code;
|
||||
internal->bits = code_and_bits.bits;
|
||||
internal->score = match_cpu_codename(cpudb_amd, COUNT_OF(cpudb_amd), data, code_and_bits.code, code_and_bits.bits, 0);
|
||||
internal->score = match_cpu_codename(cpudb_amd, COUNT_OF(cpudb_amd), data, code_and_bits.code,
|
||||
code_and_bits.bits, model_code);
|
||||
}
|
||||
|
||||
int cpuid_identify_amd(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct internal_id_info_t* internal)
|
||||
|
|
96
tests/amd/zen/ryzen7.test
Normal file
96
tests/amd/zen/ryzen7.test
Normal file
|
@ -0,0 +1,96 @@
|
|||
basic_cpuid[0]=0000000d 68747541 444d4163 69746e65
|
||||
basic_cpuid[1]=00800f11 00100800 7ed8320b 178bfbff
|
||||
basic_cpuid[2]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[3]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[4]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[5]=00000040 00000040 00000003 00000000
|
||||
basic_cpuid[6]=00000004 00000000 00000001 00000000
|
||||
basic_cpuid[7]=00000000 209c01a9 00000000 00000000
|
||||
basic_cpuid[8]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[9]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[10]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[11]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[12]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[13]=00000007 00000340 00000340 00000000
|
||||
basic_cpuid[14]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[15]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[16]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[17]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[18]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[19]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[20]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[21]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[22]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[23]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[24]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[25]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[26]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[27]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[28]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[29]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[30]=00000000 00000000 00000000 00000000
|
||||
basic_cpuid[31]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[0]=8000001f 68747541 444d4163 69746e65
|
||||
ext_cpuid[1]=00800f11 20000000 35c233ff 2fd3fbff
|
||||
ext_cpuid[2]=20444d41 657a7952 2037206e 30303831
|
||||
ext_cpuid[3]=69452058 2d746867 65726f43 6f725020
|
||||
ext_cpuid[4]=73736563 2020726f 20202020 00202020
|
||||
ext_cpuid[5]=ff40ff40 ff40ff40 20080140 40040140
|
||||
ext_cpuid[6]=26006400 66006400 02006140 00808140
|
||||
ext_cpuid[7]=00000000 0000001b 00000000 00006599
|
||||
ext_cpuid[8]=00003030 00000007 0000400f 00000000
|
||||
ext_cpuid[9]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[10]=00000001 00008000 00000000 0001bcff
|
||||
ext_cpuid[11]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[12]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[13]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[14]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[15]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[16]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[17]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[18]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[19]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[20]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[21]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[22]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[23]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[24]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[25]=f040f040 00000000 00000000 00000000
|
||||
ext_cpuid[26]=00000003 00000000 00000000 00000000
|
||||
ext_cpuid[27]=000003ff 00000000 00000000 00000000
|
||||
ext_cpuid[28]=00000000 00000000 00000000 00000000
|
||||
ext_cpuid[29]=00004121 01c0003f 0000003f 00000000
|
||||
ext_cpuid[30]=00000000 00000100 00000000 00000000
|
||||
ext_cpuid[31]=00000007 0000016f 0000000f 00000000
|
||||
intel_fn4[0]=00000000 00000000 00000000 00000000
|
||||
intel_fn4[1]=00000000 00000000 00000000 00000000
|
||||
intel_fn4[2]=00000000 00000000 00000000 00000000
|
||||
intel_fn4[3]=00000000 00000000 00000000 00000000
|
||||
intel_fn11[0]=00000000 00000000 00000000 00000000
|
||||
intel_fn11[1]=00000000 00000000 00000000 00000000
|
||||
intel_fn11[2]=00000000 00000000 00000000 00000000
|
||||
intel_fn11[3]=00000000 00000000 00000000 00000000
|
||||
--------------------------------------------------------------------------------
|
||||
15
|
||||
1
|
||||
1
|
||||
23
|
||||
1
|
||||
8
|
||||
16
|
||||
32
|
||||
64
|
||||
512
|
||||
16384
|
||||
-1
|
||||
8
|
||||
8
|
||||
16
|
||||
-1
|
||||
64
|
||||
64
|
||||
64
|
||||
-1
|
||||
128 (authoritative)
|
||||
Ryzen 7
|
||||
fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht pni pclmul monitor ssse3 cx16 sse4_1 sse4_2 syscall movbe popcnt aes xsave osxsave avx mmxext nx fxsr_opt rdtscp lm lahf_lm cmp_legacy svm abm misalignsse sse4a 3dnowprefetch osvw skinit wdt ts ttp tm_amd hwpstate constant_tsc fma3 f16c rdrand aperfmperf avx2 bmi1 bmi2
|
Loading…
Reference in a new issue