source: rtems/c/src/lib/libcpu/i386/displayCpu.c @ 4a238002

4.104.114.84.95
Last change on this file since 4a238002 was 564d2c3a, checked in by Joel Sherrill <joel.sherrill@…>, on 08/24/98 at 16:59:20

Patch from Eric Valette <valette@…> to add an extra newline.

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*  displayCpu.c
2 *
3 *  This file contains code for displaying the Intel Cpu identification
4 *  that has been performed by checkCPUtypeSetCr0 function.
5 *
6 *  COPYRIGHT (c) 1998 valette@crf.canon.fr
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15/*
16 * Tell us the machine setup..
17 */
18#include <stdio.h>
19#include <libcpu/cpu.h>
20#include <string.h>
21#include <libcpu/cpuModel.h>
22#include <bspIo.h>
23
24unsigned char Cx86_step = 0;
25static const char *Cx86_type[] = {
26        "unknown", "1.3", "1.4", "1.5", "1.6", "2.4", "2.5", "2.6", "2.7 or 3.7", "4.2"
27        };
28
29static const char * i486model(unsigned int nr)
30{
31        static const char *model[] = {
32                "0","DX","SX","DX/2","4","SX/2","6","DX/2-WB","DX/4","DX/4-WB",
33                "10","11","12","13","Am5x86-WT","Am5x86-WB"
34        };
35        if (nr < sizeof(model)/sizeof(char *))
36                return model[nr];
37        return NULL;
38}
39
40static const char * i586model(unsigned int nr)
41{
42        static const char *model[] = {
43                "0", "Pentium 60/66","Pentium 75+","OverDrive PODP5V83",
44                "Pentium MMX", NULL, NULL, "Mobile Pentium 75+",
45                "Mobile Pentium MMX"
46        };
47        if (nr < sizeof(model)/sizeof(char *))
48                return model[nr];
49        return NULL;
50}
51
52static const char * Cx86model(void)
53{
54        unsigned char nr6x86 = 0;
55        static const char *model[] = {
56                "unknown", "6x86", "6x86L", "6x86MX", "MII"
57        };
58        switch (x86) {
59                case 5:
60                        nr6x86 = ((x86_capability & (1 << 8)) ? 2 : 1); /* cx8 flag only on 6x86L */
61                        break;
62                case 6:
63                        nr6x86 = 3;
64                        break;
65                default:
66                        nr6x86 = 0;
67        }
68
69        /* We must get the stepping number by reading DIR1 */
70        i386_outport_byte(0x22,0xff) ; i386_inport_byte(0x23, x86_mask);
71        switch (x86_mask) {
72                case 0x03:
73                        Cx86_step =  1; /* 6x86MX Rev 1.3 */
74                        break;
75                case 0x04:
76                        Cx86_step =  2; /* 6x86MX Rev 1.4 */
77                        break;
78                case 0x05:
79                        Cx86_step =  3; /* 6x86MX Rev 1.5 */
80                        break;
81                case 0x06:
82                        Cx86_step =  4; /* 6x86MX Rev 1.6 */
83                        break;
84                case 0x14:
85                        Cx86_step =  5; /* 6x86 Rev 2.4 */
86                        break;
87                case 0x15:
88                        Cx86_step =  6; /* 6x86 Rev 2.5 */
89                        break;
90                case 0x16:
91                        Cx86_step =  7; /* 6x86 Rev 2.6 */
92                        break;
93                case 0x17:
94                        Cx86_step =  8; /* 6x86 Rev 2.7 or 3.7 */
95                        break;
96                case 0x22:
97                        Cx86_step =  9; /* 6x86L Rev 4.2 */
98                        break;
99                default:
100                        Cx86_step = 0;
101        }
102        return model[nr6x86];
103}
104
105static const char * i686model(unsigned int nr)
106{
107        static const char *model[] = {
108                "PPro A-step", "Pentium Pro"
109        };
110        if (nr < sizeof(model)/sizeof(char *))
111                return model[nr];
112        return NULL;
113}
114
115struct cpu_model_info {
116        int x86;
117        char *model_names[16];
118};
119
120static struct cpu_model_info amd_models[] = {
121        { 4,
122          { NULL, NULL, NULL, "DX/2", NULL, NULL, NULL, "DX/2-WB", "DX/4",
123            "DX/4-WB", NULL, NULL, NULL, NULL, "Am5x86-WT", "Am5x86-WB" }},
124        { 5,
125          { "K5/SSA5 (PR-75, PR-90, PR-100)", "K5 (PR-120, PR-133)",
126            "K5 (PR-166)", "K5 (PR-200)", NULL, NULL,
127            "K6 (166 - 266)", "K6 (166 - 300)", "K6-2 (200 - 450)",
128            "K6-3D-Plus (200 - 450)", NULL, NULL, NULL, NULL, NULL, NULL }},
129};
130
131static const char * AMDmodel(void)
132{
133        const char *p=NULL;
134        int i;
135       
136        if (x86_model < 16)
137                for (i=0; i<sizeof(amd_models)/sizeof(struct cpu_model_info); i++)
138                        if (amd_models[i].x86 == x86) {
139                                p = amd_models[i].model_names[(int)x86_model];
140                                break;
141                        }
142        return p;
143}
144
145static const char * getmodel(int x86, int model)
146{
147        const char *p = NULL;
148        static char nbuf[12];
149        if (strncmp(x86_vendor_id, "Cyrix", 5) == 0)
150                p = Cx86model();
151        else if(strcmp(x86_vendor_id, "AuthenticAMD")==0)
152                p = AMDmodel();
153        else {
154                switch (x86) {
155                        case 4:
156                                p = i486model(model);
157                                break;
158                        case 5:
159                                p = i586model(model);
160                                break;
161                        case 6:
162                                p = i686model(model);
163                                break;
164                }
165        }
166        if (p)
167                return p;
168
169        sprintf(nbuf, "%d", model);
170        return nbuf;
171}
172
173void printCpuInfo()
174{
175  int i;
176  static const char *x86_cap_flags[] = {
177    "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
178    "cx8", "apic", "10", "11", "mtrr", "pge", "mca", "cmov",
179    "16", "17", "18", "19", "20", "21", "22", "mmx",
180    "24", "25", "26", "27", "28", "29", "30", "31"
181  };
182       
183  printk("cpu\t\t\t: %c86\n", x86+'0');
184  printk("model\t\t: %s\n",
185         have_cpuid ? getmodel(x86, x86_model) : "unknown");
186  if (x86_vendor_id [0] == '\0')
187    strcpy(x86_vendor_id, "unknown");
188  printk("vendor_id\t: %s\n", x86_vendor_id);
189       
190  if (x86_mask)
191    if (strncmp(x86_vendor_id, "Cyrix", 5) != 0) {
192      printk("stepping\t: %d\n", x86_mask);
193    }
194    else {                      /* we have a Cyrix */
195      printk("stepping\t: %s\n", Cx86_type[Cx86_step]);
196    }
197  else
198    printk("stepping\t: unknown\n");
199       
200  printk("fpu\t\t\t: %s\n", (hard_math ? "yes" : "no"));
201  printk("cpuid\t\t: %s\n", (have_cpuid ? "yes" : "no"));
202  printk("flags\t\t:");
203  for ( i = 0 ; i < 32 ; i++ ) {
204    if ( x86_capability & (1 << i) ) {
205      printk(" %s", x86_cap_flags[i]);
206    }
207  }
208  printk("\n");
209}
Note: See TracBrowser for help on using the repository browser.