Commits

Joseph Poirier committed 2705afc

sync with pull request from github.com/0xe2-0x9a-0x9b, and removed maxStdLevel check to allow reporting of ProcessorFamily

Comments (0)

Files changed (2)

 void cpuid(regs_t* r, uint32_t f1, uint32_t f2) {
     __asm__ __volatile__ (
 #ifdef __i386__
-        "pushl %%ebx\n\t"
-# ifdef __linux__
-        "pushl %%ecx\n\t"
-# endif
+        "push %%ebx; push %%edx;"
 #endif
-        "movl %4, %%eax\n\t"
-        "movl %5, %%ecx\n\t"
-        "cpuid\n\t"
-        "movl %%eax, %0\n\t"
-        "movl %%ebx, %1\n\t"
-        "movl %%ecx, %2\n\t"
-        "movl %%edx, %3\n\t"
+#ifdef __amd64
+        "push %%rbx; push %%rdx;"
+#endif
+        "cpuid;"
+        "movl %%eax, 0(%2);"
+        "movl %%ebx, 4(%2);"
+        "movl %%ecx, 8(%2);"
+        "movl %%edx, 12(%2);"
 #ifdef __i386__
-# ifdef __linux__
-        "popl %%ecx\n\t"
-# endif
-        "popl %%ebx\n\t"
+        "pop %%edx; pop %%ebx;"
 #endif
-        : "=m"(r->eax), "=m"(r->ebx), "=m"(r->ecx), "=m"(r->edx)
-        : "r"(f1), "r"(f2)
-        : "eax",
 #ifdef __amd64
-          "ebx",
+        "pop %%rdx; pop %%rbx;"
 #endif
-#if defined(__amd64) || defined(__i386__) && !defined(__linux__)
-          "ecx",
-#endif
-          "edx", "cc", "memory"
+        : "=a"(f1), "=c"(f2)
+        : "D"(r), "a"(f1), "c"(f2)
+        : "memory"
     );
 }
 
 	"unsafe"
 )
 
-var PackageVersion string = "v0.13.3"
+var PackageVersion string = "v0.14.0"
 
 // Processors is the number of physical processors (that plug in to a socket).
 var Processors uint32
 	// vendor name
 	var r regs
 	Cpuid(&r, 0, 0)
-	maxStdLevel := r.eax
 	Vendor = utos(r.ebx) + utos(r.edx) + utos(r.ecx)
 
 	Cpuid(&r, 0x80000000, 0)
 	maxExtLevel := r.eax
 
-	// this check includes some old processors (P4 & M, Old Xeon)
-	// that we could report processor name on but probably not
-	// worth the time
-	if maxStdLevel < 5  {
-		return
-	}
-
 	if maxExtLevel >= 0x80000004 {
 		Cpuid(&r, 0x80000002, 0)
 		ProcessorFamily = utos(r.eax) + utos(r.ebx) + utos(r.ecx) + utos(r.edx)
 			PhysicalCoresPkg = pow(2, apicid_sz)
 		}
 	} else {
-// TODO: abort? handle other vendors
+		// TODO: handle other vendors?
 		panic("Unknown processor...")
 	}
 
 		LogicalProcsPkg = PhysicalCoresPkg // a hardware problem if this happens!
 	} else if (LogicalProcsPkg - PhysicalCoresPkg) > 0 {
 		HyperThreadingEnabled = true
-//		HyperThreadingProcsPkg = LogicalProcsPkg - PhysicalCoresPkg
+		//HyperThreadingProcsPkg = LogicalProcsPkg - PhysicalCoresPkg
 		HyperThreadingProcsPkg = PhysicalCoresPkg * (LogicalProcsSharingCache - 1)
 	}