OS.h: Add AMD Ryzen CPU name identification.
* Update cpuidtool.c to new post-smp rework name calculation
This commit is contained in:
parent
7fe3746703
commit
54066ddbb7
@ -255,6 +255,15 @@ get_cpu_model_string(enum cpu_platform platform, enum cpu_vendor cpuVendor,
|
|||||||
if (platform != B_CPU_x86 && platform != B_CPU_x86_64)
|
if (platform != B_CPU_x86 && platform != B_CPU_x86_64)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
// XXX: This *really* isn't accurate. There is differing math
|
||||||
|
// based on the CPU vendor.. Don't use these numbers anywhere
|
||||||
|
// except "fast and dumb" identification of processor names.
|
||||||
|
//
|
||||||
|
// see cpuidtool.c to decode cpuid signatures (sysinfo) into a
|
||||||
|
// value for this function.
|
||||||
|
//
|
||||||
|
// sysinfo has code in it which obtains the proper fam/mod/step ids
|
||||||
|
|
||||||
uint16 family = ((cpuModel >> 8) & 0xf) | ((cpuModel >> 16) & 0xff0);
|
uint16 family = ((cpuModel >> 8) & 0xf) | ((cpuModel >> 16) & 0xff0);
|
||||||
uint16 model = ((cpuModel >> 4) & 0xf) | ((cpuModel >> 12) & 0xf0);
|
uint16 model = ((cpuModel >> 4) & 0xf) | ((cpuModel >> 12) & 0xf0);
|
||||||
uint8 stepping = cpuModel & 0xf;
|
uint8 stepping = cpuModel & 0xf;
|
||||||
@ -315,7 +324,8 @@ get_cpu_model_string(enum cpu_platform platform, enum cpu_vendor cpuVendor,
|
|||||||
return "FX-Series";
|
return "FX-Series";
|
||||||
if (model == 0x10 || model == 0x13)
|
if (model == 0x10 || model == 0x13)
|
||||||
return "A-Series";
|
return "A-Series";
|
||||||
}
|
} else if (family == 0x8f)
|
||||||
|
return "Ryzen 7"
|
||||||
|
|
||||||
// Fallback to manual parsing of the model string
|
// Fallback to manual parsing of the model string
|
||||||
get_cpuid_model_string(cpuidName);
|
get_cpuid_model_string(cpuidName);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pass a standard CPUID in hex, and get out a CPUID for OS.h
|
* Pass a standard CPUID in hex, and get out a CPUID for cpu_type.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -71,41 +71,23 @@ xtoi(const char* xs, unsigned int* result)
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc != 3) {
|
if (argc != 2) {
|
||||||
printf("Provide the cpuid in hex, and you will get how we id it\n");
|
printf("Provide the cpuid in hex, and you will get how we id it\n");
|
||||||
printf("usage: cpuidhaiku <AMD|INTEL> <cpuid_hex>\n");
|
printf("usage: cpuidhaiku <cpuid_hex>\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cpuid = 0;
|
unsigned int cpuid = 0;
|
||||||
xtoi(argv[2], &cpuid);
|
xtoi(argv[1], &cpuid);
|
||||||
|
|
||||||
printf("cpuid: 0x%X\n", cpuid);
|
printf("cpuid: 0x%X\n", cpuid);
|
||||||
|
|
||||||
unsigned int extFam = (cpuid & EXT_FAMILY_MASK) >> 20;
|
int family = ((cpuid >> 8) & 0xf) | ((cpuid >> 16) & 0xff0);
|
||||||
unsigned int extMod = (cpuid & EXT_MODEL_MASK) >> 16;
|
int model = ((cpuid >> 4) & 0xf) | ((cpuid >> 12) & 0xf0);
|
||||||
unsigned int family = (cpuid & FAMILY_MASK) >> 8;
|
int stepping = cpuid & 0xf;
|
||||||
unsigned int model = (cpuid & MODEL_MASK) >> 4;
|
|
||||||
unsigned int stepping = (cpuid & STEPPING_MASK);
|
|
||||||
|
|
||||||
unsigned int cpuidHaiku;
|
printf("Haiku CPUID: Family: 0x%x, Model: 0x%x, Stepping: 0x%x\n", family,
|
||||||
if (strncmp(argv[1], "AMD", 3) == 0) {
|
model, stepping);
|
||||||
if (family == 0xF) {
|
|
||||||
cpuidHaiku = (extFam << 20) + (extMod << 16)
|
|
||||||
+ (family << 4) + model;
|
|
||||||
} else
|
|
||||||
cpuidHaiku = (family << 4) + model;
|
|
||||||
cpuidHaiku += 0x1100; // AMD vendor id
|
|
||||||
} else if (strncmp(argv[1], "INTEL", 5) == 0) {
|
|
||||||
cpuidHaiku = (extFam << 20) + (extMod << 16)
|
|
||||||
+ (family << 4) + model;
|
|
||||||
cpuidHaiku += 0x1000; // Intel vendor id
|
|
||||||
} else {
|
|
||||||
printf("Vendor should be AMD or INTEL\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Haiku CPUID: 0x%lx\n", cpuidHaiku);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user