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

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