hrev51015 adds 1 changeset to branch 'master'
old head: 7fe374670315fadfda7b0268a61215bb7714ce5f
new head: 54066ddbb70fa4b8f2344300f91dd1c69a4e1d99
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=54066ddbb70f+%5E7fe374670315
----------------------------------------------------------------------------
54066ddbb70f: OS.h: Add AMD Ryzen CPU name identification.
* Update cpuidtool.c to new post-smp rework name
calculation
[ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev51015
Commit: 54066ddbb70fa4b8f2344300f91dd1c69a4e1d99
URL: http://cgit.haiku-os.org/haiku/commit/?id=54066ddbb70f
Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date: Sun Mar 12 19:46:02 2017 UTC
----------------------------------------------------------------------------
2 files changed, 20 insertions(+), 28 deletions(-)
headers/private/shared/cpu_type.h | 12 +++++++++++-
src/tools/cpuidtool.c | 36 +++++++++--------------------------
----------------------------------------------------------------------------
diff --git a/headers/private/shared/cpu_type.h
b/headers/private/shared/cpu_type.h
index be64e2b..478fbd0 100644
--- a/headers/private/shared/cpu_type.h
+++ b/headers/private/shared/cpu_type.h
@@ -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)
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 model = ((cpuModel >> 4) & 0xf) | ((cpuModel >> 12) & 0xf0);
uint8 stepping = cpuModel & 0xf;
@@ -315,7 +324,8 @@ get_cpu_model_string(enum cpu_platform platform, enum
cpu_vendor cpuVendor,
return "FX-Series";
if (model == 0x10 || model == 0x13)
return "A-Series";
- }
+ } else if (family == 0x8f)
+ return "Ryzen 7"
// Fallback to manual parsing of the model string
get_cpuid_model_string(cpuidName);
diff --git a/src/tools/cpuidtool.c b/src/tools/cpuidtool.c
index 570fd79..326c3a9 100644
--- a/src/tools/cpuidtool.c
+++ b/src/tools/cpuidtool.c
@@ -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
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("usage: cpuidhaiku <AMD|INTEL> <cpuid_hex>\n");
+ printf("usage: cpuidhaiku <cpuid_hex>\n");
return 1;
}
unsigned int cpuid = 0;
- xtoi(argv[2], &cpuid);
+ xtoi(argv[1], &cpuid);
printf("cpuid: 0x%X\n", cpuid);
- unsigned int extFam = (cpuid & EXT_FAMILY_MASK) >> 20;
- unsigned int extMod = (cpuid & EXT_MODEL_MASK) >> 16;
- unsigned int family = (cpuid & FAMILY_MASK) >> 8;
- unsigned int model = (cpuid & MODEL_MASK) >> 4;
- unsigned int stepping = (cpuid & STEPPING_MASK);
-
- unsigned int cpuidHaiku;
- if (strncmp(argv[1], "AMD", 3) == 0) {
- 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;
- }
+ int family = ((cpuid >> 8) & 0xf) | ((cpuid >> 16) & 0xff0);
+ int model = ((cpuid >> 4) & 0xf) | ((cpuid >> 12) & 0xf0);
+ int stepping = cpuid & 0xf;
- printf("Haiku CPUID: 0x%lx\n", cpuidHaiku);
+ printf("Haiku CPUID: Family: 0x%x, Model: 0x%x, Stepping: 0x%x\n",
family,
+ model, stepping);
return 0;
}