source: rtems/c/src/lib/libcpu/i386/displayCpu.c @ 754ca4b1

4.104.114.84.95
Last change on this file since 754ca4b1 was 1715986, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:53:01

2003-09-04 Joel Sherrill <joel@…>

  • cpu.c, cpu.h, cpuModel.S, cpuModel.h, displayCpu.c, idtr.S, page.c: URL for license changed.
  • 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.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()
176{
177  int i;
178  static const char *x86_cap_flags[] = {
179    "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
180    "cx8", "apic", "10", "11", "mtrr", "pge", "mca", "cmov",
181    "16", "17", "18", "19", "20", "21", "22", "mmx",
182    "24", "25", "26", "27", "28", "29", "30", "31"
183  };
184       
185  printk("cpu\t\t\t: %c86\n", x86+'0');
186  printk("model\t\t: %s\n",
187         have_cpuid ? getmodel(x86, x86_model) : "unknown");
188  if (x86_vendor_id [0] == '\0')
189    strcpy(x86_vendor_id, "unknown");
190  printk("vendor_id\t: %s\n", x86_vendor_id);
191       
192  if (x86_mask)
193    if (strncmp(x86_vendor_id, "Cyrix", 5) != 0) {
194      printk("stepping\t: %d\n", x86_mask);
195    }
196    else {                      /* we have a Cyrix */
197      printk("stepping\t: %s\n", Cx86_type[Cx86_step]);
198    }
199  else
200    printk("stepping\t: unknown\n");
201       
202  printk("fpu\t\t\t: %s\n", (hard_math ? "yes" : "no"));
203  printk("cpuid\t\t: %s\n", (have_cpuid ? "yes" : "no"));
204  printk("flags\t\t:");
205  for ( i = 0 ; i < 32 ; i++ ) {
206    if ( x86_capability & (1 << i) ) {
207      printk(" %s", x86_cap_flags[i]);
208    }
209  }
210  printk("\n");
211}
Note: See TracBrowser for help on using the repository browser.