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

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