patch-1.3.76 linux/arch/i386/kernel/setup.c

Next file: linux/arch/i386/kernel/smp.c
Previous file: linux/arch/i386/kernel/irq.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.75/linux/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c
@@ -36,14 +36,15 @@
 /*
  * Tell us the machine setup..
  */
-char hard_math = 0;		/* set by boot/head.S */
-char x86 = 0;			/* set by boot/head.S to 3 or 4 */
-char x86_model = 0;		/* set by boot/head.S */
-char x86_mask = 0;		/* set by boot/head.S */
-int x86_capability = 0;		/* set by boot/head.S */
+char hard_math = 0;		/* set by kernel/head.S */
+char x86 = 0;			/* set by kernel/head.S to 3..6 */
+char x86_model = 0;		/* set by kernel/head.S */
+char x86_mask = 0;		/* set by kernel/head.S */
+int x86_capability = 0;		/* set by kernel/head.S */
 int fdiv_bug = 0;		/* set if Pentium(TM) with FP bug */
+int have_cpuid = 0;             /* set if CPUID instruction works */
 
-char x86_vendor_id[13] = "Unknown";
+char x86_vendor_id[13] = "unknown";
 
 char ignore_irq13 = 0;		/* set if exception 16 works */
 char wp_works_ok = -1;		/* set if paging hardware honours WP */ 
@@ -211,7 +212,7 @@
 	};
 	if (nr < sizeof(model)/sizeof(char *))
 		return model[nr];
-	return "Unknown";
+	return NULL;
 }
 
 static const char * i586model(unsigned int nr)
@@ -221,144 +222,96 @@
 	};
 	if (nr < sizeof(model)/sizeof(char *))
 		return model[nr];
-	return "Unknown";
+	return NULL;
 }
 
 static const char * getmodel(int x86, int model)
 {
+        const char *p = NULL;
+        static char nbuf[12];
 	switch (x86) {
 		case 4:
-			return i486model(model);
+			p = i486model(model);
 		case 5:
-			return i586model(model);
+			p = i586model(model);
 	}
-	return "Unknown";
+        if (p)
+                return p;
+
+        sprintf(nbuf, "%d", model);
+        return nbuf;
 }
 
 int get_cpuinfo(char * buffer)
 {
-	char mask[2];
-#ifndef __SMP__	
-	mask[0] = x86_mask+'@';
-	mask[1] = '\0';
-	return sprintf(buffer,"cpu\t\t: %c86\n"
-			      "model\t\t: %s\n"
-			      "mask\t\t: %s\n"
-			      "vid\t\t: %s\n"
-			      "fdiv_bug\t: %s\n"
-			      "math\t\t: %s\n"
-			      "hlt\t\t: %s\n"
-			      "wp\t\t: %s\n"
-			      "Integrated NPU\t: %s\n"
-			      "Enhanced VM86\t: %s\n"
-			      "IO Breakpoints\t: %s\n"
-			      "4MB Pages\t: %s\n"
-			      "TS Counters\t: %s\n"
-			      "Pentium MSR\t: %s\n"
-			      "Mach. Ch. Exep.\t: %s\n"
-			      "CMPXCHGB8B\t: %s\n"
-		              "BogoMips\t: %lu.%02lu\n",
-			      x86+'0', 
-			      getmodel(x86, x86_model),
-			      x86_mask ? mask : "Unknown",
-			      x86_vendor_id,
-			      fdiv_bug ? "yes" : "no",
-			      hard_math ? "yes" : "no",
-			      hlt_works_ok ? "yes" : "no",
-			      wp_works_ok ? "yes" : "no",
-			      x86_capability & 1 ? "yes" : "no",
-			      x86_capability & 2 ? "yes" : "no",
-			      x86_capability & 4 ? "yes" : "no",
-			      x86_capability & 8 ? "yes" : "no",
-			      x86_capability & 16 ? "yes" : "no",
-			      x86_capability & 32 ? "yes" : "no",
-			      x86_capability & 128 ? "yes" : "no",
-			      x86_capability & 256 ? "yes" : "no",
-		              loops_per_sec/500000, (loops_per_sec/5000) % 100
-			      );
+        int i, len = 0;
+        static const char *x86_cap_flags[] = {
+                "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
+                "cx8", "apic", "10", "11", "mtrr", "pge", "mca", "cmov",
+                "16", "17", "18", "19", "20", "21", "22", "mmx",
+                "24", "25", "26", "27", "28", "29", "30", "31"
+        };
+        
+#ifdef __SMP__
+        int n;
+
+#define CD(X) (cpu_data[n].(X))
+#define CPUN n
+
+        for ( n = 0 ; n < 32 ; n++ ) {
+                if ( cpu_present_map & (1<<n) ) {
+                        if (len) buffer[len++] = '\n'; 
+
 #else
-	char *bp=buffer;
-	int i;	
-	bp+=sprintf(bp,"cpu\t\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%c86             ",cpu_data[i].x86+'0');
-	bp+=sprintf(bp,"\nmodel\t\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s",getmodel(cpu_data[i].x86,cpu_data[i].x86_model));
-	bp+=sprintf(bp,"\nmask\t\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-		{
-			mask[0] = cpu_data[i].x86_mask+'@';
-			mask[1] = '\0';		
-			bp+=sprintf(bp,"%-16s", cpu_data[i].x86_mask ? mask : "Unknown");
-		}
-	bp+=sprintf(bp,"\nvid\t\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", cpu_data[i].x86_vendor_id);
-	bp+=sprintf(bp,"\nfdiv_bug\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", cpu_data[i].fdiv_bug?"yes":"no");
-	bp+=sprintf(bp,"\nmath\t\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", cpu_data[i].hard_math?"yes":"no");
-	bp+=sprintf(bp,"\nhlt\t\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", cpu_data[i].hlt_works_ok?"yes":"no");
-	bp+=sprintf(bp,"\nwp\t\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", cpu_data[i].wp_works_ok?"yes":"no");
-	bp+=sprintf(bp,"\nIntegrated NPU\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&1?"yes":"no");
-	bp+=sprintf(bp,"\nEnhanced VM86\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", cpu_data[i].x86_capability&2?"yes":"no");
-	bp+=sprintf(bp,"\nIO Breakpoints\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&4)?"yes":"no");
-	bp+=sprintf(bp,"\n4MB Pages\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability)&8?"yes":"no");
-	bp+=sprintf(bp,"\nTS Counters\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&16)?"yes":"no");
-	bp+=sprintf(bp,"\nPentium MSR\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&32)?"yes":"no");
-	bp+=sprintf(bp,"\nMach. Ch. Exep.\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&128)?"yes":"no");
-	bp+=sprintf(bp,"\nCMPXCHG8B\t: ");
-	for(i=0;i<32;i++)
-		if(cpu_present_map&(1<<i))
-			bp+=sprintf(bp,"%-16s", (cpu_data[i].x86_capability&256)?"yes":"no");
-	bp+=sprintf(bp,"\nBogoMips\t: ");
-	for(i=0;i<32;i++)
-	{
-		char tmp[17];
-		if(cpu_present_map&(1<<i))
-		{
-			sprintf(tmp,"%lu.%02lu",cpu_data[i].udelay_val/500000L,
-						   (cpu_data[i].udelay_val/5000L)%100);
-			bp+=sprintf(bp,"%-16s",tmp);
-		}
-	}
-	*bp++='\n';
-	return bp-buffer;
-#endif			      
+#define CD(X) (X)
+#define CPUN 0
+#endif
+
+                        len += sprintf(buffer+len,"processor\t: %d\n"
+                                       "cpu\t\t: %c86\n"
+                                       "model\t\t: %s\n"
+                                       "vendor_id\t: %s\n",
+                                       CPUN,
+                                       CD(x86)+'0',
+                                       CD(have_cpuid) ? 
+                                         getmodel(CD(x86), CD(x86_model)) :
+                                         "unknown",
+                                       CD(x86_vendor_id));
+        
+                        if (CD(x86_mask))
+                                len += sprintf(buffer+len,
+                                               "stepping\t: %d\n",
+                                               CD(x86_mask));
+                        else
+                                len += sprintf(buffer+len, 
+                                               "stepping\t: unknown\n");
+        
+                        len += sprintf(buffer+len,
+                                       "fdiv_bug\t: %s\n"
+                                       "hlt_bug\t\t: %s\n"
+                                       "fpu\t\t: %s\n"
+                                       "cpuid\t\t: %s\n"
+                                       "wp\t\t: %s\n"
+                                       "flags\t\t:",
+                                       CD(fdiv_bug) ? "yes" : "no",
+                                       CD(hlt_works_ok) ? "no" : "yes",
+                                       CD(hard_math) ? "yes" : "no",
+                                       CD(have_cpuid) ? "yes" : "no",
+                                       CD(wp_works_ok) ? "yes" : "no");
+        
+                        for ( i = 0 ; i < 32 ; i++ ) {
+                                if ( CD(x86_capability) & (1 << i) ) {
+                                        len += sprintf(buffer+len, " %s",
+                                                       x86_cap_flags[i]);
+                                }
+                        }
+                        len += sprintf(buffer+len,
+                                       "\nbogomips:\t: %lu.%02lu\n",
+                                       CD(loops_per_sec)/500000,
+                                       (CD(loops_per_sec)/5000) % 100);
+#ifdef __SMP__
+                }
+        }
+#endif
+        return len;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this