Blame SOURCES/0001-report-CPU-family-model-stepping.patch

33b0a4
From f914f225975bb4a146792c2b0181b8d0e01ff3a6 Mon Sep 17 00:00:00 2001
33b0a4
From: Lyonel Vincent <lyonel@ezix.org>
33b0a4
Date: Sat, 28 Mar 2020 11:54:10 +0100
33b0a4
Subject: [PATCH 01/17] report CPU family/model/stepping
33b0a4
33b0a4
---
33b0a4
 src/core/cpuinfo.cc | 21 +++++++++++++++++++--
33b0a4
 src/core/hw.cc      | 20 ++++++++++++++++++++
33b0a4
 src/core/hw.h       |  1 +
33b0a4
 3 files changed, 40 insertions(+), 2 deletions(-)
33b0a4
33b0a4
diff --git a/src/core/cpuinfo.cc b/src/core/cpuinfo.cc
33b0a4
index 33085fda1159..eceb83aa4e3a 100644
33b0a4
--- a/src/core/cpuinfo.cc
33b0a4
+++ b/src/core/cpuinfo.cc
33b0a4
@@ -463,6 +463,14 @@ string value)
33b0a4
     }
33b0a4
     if (id == "model name")
33b0a4
       cpu->setProduct(value);
33b0a4
+    if (id == "microcode")
33b0a4
+      cpu->setConfig(id, stoll(value, NULL, 0));
33b0a4
+    if (id == "cpu family")
33b0a4
+      cpu->addHint(id, stoll(value, NULL, 0));
33b0a4
+    if (id == "model")
33b0a4
+      cpu->addHint(id, stoll(value, NULL, 0));
33b0a4
+    if (id == "stepping")
33b0a4
+      cpu->addHint(id, stoll(value, NULL, 0));
33b0a4
 //if ((id == "cpu MHz") && (cpu->getSize() == 0))
33b0a4
 //{
33b0a4
 //cpu->setSize((long long) (1000000L * atof(value.c_str())));
33b0a4
@@ -667,8 +675,17 @@ bool scan_cpuinfo(hwNode & n)
33b0a4
   }
33b0a4
 
33b0a4
   hwNode *cpu = getcpu(n, 0);
33b0a4
-  if(cpu && (n.getWidth()==0))
33b0a4
-    n.setWidth(cpu->getWidth());
33b0a4
+  if(cpu)
33b0a4
+  {
33b0a4
+    hw::value family, model, stepping;
33b0a4
+    family = cpu->getHint("cpu family");
33b0a4
+    model = cpu->getHint("model");
33b0a4
+    stepping = cpu->getHint("stepping");
33b0a4
+    if(family.defined() && model.defined() && stepping.defined())
33b0a4
+	    cpu->setVersion(tostring(family.asInteger())+"."+tostring(model.asInteger())+"."+tostring(stepping.asInteger()));
33b0a4
+    if(n.getWidth()==0)
33b0a4
+      n.setWidth(cpu->getWidth());
33b0a4
+  }
33b0a4
 
33b0a4
   return true;
33b0a4
 }
33b0a4
diff --git a/src/core/hw.cc b/src/core/hw.cc
33b0a4
index 4522c1af0fc3..a59273008862 100644
33b0a4
--- a/src/core/hw.cc
33b0a4
+++ b/src/core/hw.cc
33b0a4
@@ -2432,6 +2432,26 @@ string value::asString() const
33b0a4
 }
33b0a4
 
33b0a4
 
33b0a4
+long long value::asInteger() const
33b0a4
+{
33b0a4
+  if(!This) return 0;
33b0a4
+
33b0a4
+  switch(This->type)
33b0a4
+  {
33b0a4
+    case hw::text:
33b0a4
+      return stoll(This->s, NULL, 0);
33b0a4
+    case hw::integer:
33b0a4
+      return This->ll;
33b0a4
+    case hw::boolean:
33b0a4
+      return This->b?1:0;
33b0a4
+    case hw::nil:
33b0a4
+      return 0;
33b0a4
+  };
33b0a4
+
33b0a4
+  return 0;
33b0a4
+}
33b0a4
+
33b0a4
+
33b0a4
 bool value::defined() const
33b0a4
 {
33b0a4
   if(!This) return false;
33b0a4
diff --git a/src/core/hw.h b/src/core/hw.h
33b0a4
index 3cb782b0e635..451e9b3cf26a 100644
33b0a4
--- a/src/core/hw.h
33b0a4
+++ b/src/core/hw.h
33b0a4
@@ -79,6 +79,7 @@ namespace hw
33b0a4
       bool operator ==(const value &) const;
33b0a4
 
33b0a4
       string asString() const;
33b0a4
+      long long asInteger() const;
33b0a4
       bool defined() const;
33b0a4
 
33b0a4
     private:
33b0a4
-- 
33b0a4
2.17.1
33b0a4