lkml.org 
[lkml]   [1996]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectEnhanced CPU detection

Hi,

after all this discussion about CPU detection i revived an old patch i created against
1.3.95.
It streamlines the code quite a bit (in my opinion) and makes extensions trivial.

I'd be interested, if people with AMD or UMC Cpus would test this. There is no Cyrix
vendor line there, since i've never seen a Cyrix running Linux yet.

Clemens

--- linux-2.0.26/arch/i386/kernel/setup.c Fri Sep 20 16:00:34 1996
+++ linux/arch/i386/kernel/setup.c Sun Dec 1 14:55:06 1996
@@ -204,59 +204,6 @@
request_region(0xf0,0x10,"npu");
}

-static const char * i486model(unsigned int nr)
-{
- static const char *model[] = {
- "0","DX","SX","DX/2","4","SX/2","6","DX/2-WB","DX/4","DX/4-WB",
- "10","11","12","13","Am5x86-WT","Am5x86-WB"
- };
- if (nr < sizeof(model)/sizeof(char *))
- return model[nr];
- return NULL;
-}
-
-static const char * i586model(unsigned int nr)
-{
- static const char *model[] = {
- "0", "Pentium 60/66","Pentium 75+","OverDrive PODP5V83"
- };
- if (nr < sizeof(model)/sizeof(char *))
- return model[nr];
- return NULL;
-}
-
-static const char * i686model(unsigned int nr)
-{
- static const char *model[] = {
- "PPro A-step", "Pentium Pro"
- };
- if (nr < sizeof(model)/sizeof(char *))
- return model[nr];
- return NULL;
-}
-
-static const char * getmodel(int x86, int model)
-{
- const char *p = NULL;
- static char nbuf[12];
- switch (x86) {
- case 4:
- p = i486model(model);
- break;
- case 5:
- p = i586model(model);
- break;
- case 6:
- p = i686model(model);
- break;
- }
- if (p)
- return p;
-
- sprintf(nbuf, "%d", model);
- return nbuf;
-}
-
int get_cpuinfo(char * buffer)
{
int i, len = 0;
@@ -266,6 +213,30 @@
"16", "17", "18", "19", "20", "21", "22", "mmx",
"24", "25", "26", "27", "28", "29", "30", "31"
};
+
+ struct vendorinfo_t
+ {
+ char *vendor_id;
+ char x86_type;
+ char *model[16];
+ };
+ struct vendorinfo_t vendorinfo[] = {
+ {"GenuineIntel",4,{"0","DX","SX","DX/2-WT","4","SX/2",
+ "6","DX/2-WB","DX/4","DX/4-WB","A","B","C","D","E","F"}},
+ {"GenuineIntel",5,{"0","Pentium 60/66","Pentium 75+",
+ "OverDrive PODP5V83","4","5","6","7","8","9","A","B","C",
+ "D","E","F"}},
+ {"GenuineIntel",6,{"PPro A-step", "Pentium Pro","3","4","5",
+ "6","7","8","9","A","B","C","D","E","F"}},
+ {"AuthenticAMD",4,{"0","1","2","DX/2-WT","4","5","6","DX/2-WB",
+ "DX/4-WT","DX/4-WB","A","B","C","D","Am5x86-WT","Am5x86-WB"}},
+ {"UMCUMCUMCUMC",4,{"0","1","2","3","4","5","6","7","8",
+ "9","A","B","C","D","E","F"}},
+ {(char *)0,0,{"0","1","2","3","4","5","6","7","8","9",
+ "A","B","C","D","E","F"}}};
+
+ int vendor_nr;
+

#ifdef __SMP__
int n;
@@ -283,6 +254,23 @@
#define CD(X) (X)
#define CPUN 0
#endif
+ for(vendor_nr=0;vendorinfo[vendor_nr].vendor_id;
+ vendor_nr++)
+ {
+ int flag=1;
+ int j;
+ if(vendorinfo[vendor_nr].x86_type!=x86)
+ continue;
+ for(j=0;j<12;j++)
+ if(vendorinfo[vendor_nr].vendor_id[j]!=
+ x86_vendor_id[j])
+ {
+ flag=0;
+ break;
+ }
+ if(flag)
+ break;
+ }

len += sprintf(buffer+len,"processor\t: %d\n"
"cpu\t\t: %c86\n"
@@ -291,13 +279,13 @@
CPUN,
CD(x86)+'0',
CD(have_cpuid) ?
- getmodel(CD(x86), CD(x86_model)) :
- "unknown",
+ vendorinfo[vendor_nr].model[x86_model]
+ : "unknown",
CD(x86_vendor_id));

if (CD(x86_mask))
len += sprintf(buffer+len,
- "stepping\t: %d\n",
+ "stepping\t: %X\n",
CD(x86_mask));
else
len += sprintf(buffer+len,
\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.023 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site