source: rtems/c/src/lib/libcpu/i386/displayCpu.c @ 42e243e

4.104.115
Last change on this file since 42e243e was 42e243e, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/04/09 at 04:27:21

Whitespace removal.

  • Property mode set to 100644
File size: 5.4 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.rtems.com/license/LICENSE.
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 <rtems/bspIo.h>
23#include <rtems.h>
24
25unsigned char Cx86_step = 0;
26static const char *Cx86_type[] = {
27        "unknown", "1.3", "1.4", "1.5", "1.6", "2.4", "2.5", "2.6", "2.7 or 3.7", "4.2"
28        };
29
30static const char * i486model(unsigned int nr)
31{
32        static const char *model[] = {
33                "0","DX","SX","DX/2","4","SX/2","6","DX/2-WB","DX/4","DX/4-WB",
34                "10","11","12","13","Am5x86-WT","Am5x86-WB"
35        };
36        if (nr < sizeof(model)/sizeof(char *))
37                return model[nr];
38        return NULL;
39}
40
41static const char * i586model(unsigned int nr)
42{
43        static const char *model[] = {
44                "0", "Pentium 60/66","Pentium 75+","OverDrive PODP5V83",
45                "Pentium MMX", NULL, NULL, "Mobile Pentium 75+",
46                "Mobile Pentium MMX"
47        };
48        if (nr < sizeof(model)/sizeof(char *))
49                return model[nr];
50        return NULL;
51}
52
53static const char * Cx86model(void)
54{
55        unsigned char nr6x86 = 0;
56        static const char *model[] = {
57                "unknown", "6x86", "6x86L", "6x86MX", "MII"
58        };
59        switch (x86) {
60                case 5:
61                        nr6x86 = ((x86_capability & (1 << 8)) ? 2 : 1); /* cx8 flag only on 6x86L */
62                        break;
63                case 6:
64                        nr6x86 = 3;
65                        break;
66                default:
67                        nr6x86 = 0;
68        }
69
70        /* We must get the stepping number by reading DIR1 */
71        outport_byte(0x22,0xff);
72        inport_byte(0x23, x86_mask);
73        switch (x86_mask) {
74                case 0x03:
75                        Cx86_step =  1; /* 6x86MX Rev 1.3 */
76                        break;
77                case 0x04:
78                        Cx86_step =  2; /* 6x86MX Rev 1.4 */
79                        break;
80                case 0x05:
81                        Cx86_step =  3; /* 6x86MX Rev 1.5 */
82                        break;
83                case 0x06:
84                        Cx86_step =  4; /* 6x86MX Rev 1.6 */
85                        break;
86                case 0x14:
87                        Cx86_step =  5; /* 6x86 Rev 2.4 */
88                        break;
89                case 0x15:
90                        Cx86_step =  6; /* 6x86 Rev 2.5 */
91                        break;
92                case 0x16:
93                        Cx86_step =  7; /* 6x86 Rev 2.6 */
94                        break;
95                case 0x17:
96                        Cx86_step =  8; /* 6x86 Rev 2.7 or 3.7 */
97                        break;
98                case 0x22:
99                        Cx86_step =  9; /* 6x86L Rev 4.2 */
100                        break;
101                default:
102                        Cx86_step = 0;
103        }
104        return model[nr6x86];
105}
106
107static const char * i686model(unsigned int nr)
108{
109        static const char *model[] = {
110                "PPro A-step", "Pentium Pro"
111        };
112        if (nr < sizeof(model)/sizeof(char *))
113                return model[nr];
114        return NULL;
115}
116
117struct cpu_model_info {
118        int x86;
119        char *model_names[16];
120};
121
122static struct cpu_model_info amd_models[] = {
123        { 4,
124          { NULL, NULL, NULL, "DX/2", NULL, NULL, NULL, "DX/2-WB", "DX/4",
125            "DX/4-WB", NULL, NULL, NULL, NULL, "Am5x86-WT", "Am5x86-WB" }},
126        { 5,
127          { "K5/SSA5 (PR-75, PR-90, PR-100)", "K5 (PR-120, PR-133)",
128            "K5 (PR-166)", "K5 (PR-200)", NULL, NULL,
129            "K6 (166 - 266)", "K6 (166 - 300)", "K6-2 (200 - 450)",
130            "K6-3D-Plus (200 - 450)", NULL, NULL, NULL, NULL, NULL, NULL }},
131};
132
133static const char * AMDmodel(void)
134{
135        const char *p=NULL;
136        int i;
137
138        if (x86_model < 16)
139                for (i=0; i<sizeof(amd_models)/sizeof(struct cpu_model_info); i++)
140                        if (amd_models[i].x86 == x86) {
141                                p = amd_models[i].model_names[(int)x86_model];
142                                break;
143                        }
144        return p;
145}
146
147static const char * getmodel(int x86, int model)
148{
149        const char *p = NULL;
150        static char nbuf[12];
151        if (strncmp(x86_vendor_id, "Cyrix", 5) == 0)
152                p = Cx86model();
153        else if(strcmp(x86_vendor_id, "AuthenticAMD")==0)
154                p = AMDmodel();
155        else {
156                switch (x86) {
157                        case 4:
158                                p = i486model(model);
159                                break;
160                        case 5:
161                                p = i586model(model);
162                                break;
163                        case 6:
164                                p = i686model(model);
165                                break;
166                }
167        }
168        if (p)
169                return p;
170
171        sprintf(nbuf, "%d", model);
172        return nbuf;
173}
174
175void printCpuInfo(void)
176{
177  int i,j;
178  static const char *x86_cap_flags[] = {
179    "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
180    "cx8", "apic", "10", "sep", "mtrr", "pge", "mca", "cmov",
181    "pat", "pse36", "psn", "cflsh", "20", "ds", "acpi", "mmx",
182    "fxsr", "sse", "sse2", "ss", "htt", "tm", "30", "pbe"
183  };
184  static const char *x86_cap_x_flags[] = {
185    "sse3", "1", "2", "monitor", "ds-cpl", "vmx", "6", "est",
186    "tm2", "9", "cnxt-id", "11", "12", "cmpxchg16b", "14", "15",
187        "16",  "17", "18", "19", "20", "21", "22", "23"
188        "24",  "25", "26", "27", "28", "29", "30", "31"
189  };
190
191  printk("cpu         : %c86\n", x86+'0');
192  printk("model       : %s\n",
193         have_cpuid ? getmodel(x86, x86_model) : "unknown");
194  if (x86_vendor_id [0] == '\0')
195    strcpy(x86_vendor_id, "unknown");
196  printk("vendor_id   : %s\n", x86_vendor_id);
197
198  if (x86_mask)
199    if (strncmp(x86_vendor_id, "Cyrix", 5) != 0) {
200      printk("stepping    : %d\n", x86_mask);
201    }
202    else {                      /* we have a Cyrix */
203      printk("stepping    : %s\n", Cx86_type[Cx86_step]);
204    }
205  else
206    printk("stepping    : unknown\n");
207
208  printk("fpu         : %s\n", (hard_math ? "yes" : "no"));
209  printk("cpuid       : %s\n", (have_cpuid ? "yes" : "no"));
210  printk("flags       :");
211  for ( i = j = 0 ; i < 32 ; i++ ) {
212    if ( x86_capability & (1 << i) ) {
213      if ( j && 0 == (j & 7) )
214                printk("\n             ");
215      printk(" %s", x86_cap_flags[i]);
216      j++;
217    }
218  }
219  printk("\n");
220  printk("flags (ext.):");
221  for ( i = j = 0 ; i < 32 ; i++ ) {
222    if ( x86_capability_x & (1 << i) ) {
223      if ( j && 0 == (j & 7) )
224                printk("\n             ");
225      printk(" %s", x86_cap_x_flags[i]);
226      j++;
227    }
228  }
229  printk("\n");
230}
Note: See TracBrowser for help on using the repository browser.