detect CPU on zArch
authorDan Horák <dan@danny.cz>
Thu, 20 Apr 2017 19:13:41 +0000 (21:13 +0200)
committerDan Horák <dan@danny.cz>
Thu, 20 Apr 2017 19:13:41 +0000 (21:13 +0200)
cpuid_zarch.c

index e2e3b04..4e19354 100644 (file)
@@ -42,9 +42,27 @@ static char *cpuname_lower[] = {
 
 int detect(void)
 {
-   // return CPU_GENERIC;
- return CPU_Z13; 
-    
+  FILE *infile;
+  char buffer[512], *p;
+
+  p = (char *)NULL;
+  infile = fopen("/proc/sysinfo", "r");
+  while (fgets(buffer, sizeof(buffer), infile)){
+    if (!strncmp("Type", buffer, 4)){
+        p = strchr(buffer, ':') + 2;
+#if 0
+        fprintf(stderr, "%s\n", p);
+#endif
+        break;
+      }
+  }
+
+  fclose(infile);
+
+  if (strstr(p, "2964")) return CPU_Z13;
+  if (strstr(p, "2965")) return CPU_Z13;
+
+  return CPU_GENERIC;
 }
 
 void get_libname(void)