OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [i386/] [displayCpu.c] - Blame information for rev 507

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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: displayCpu.c,v 1.2 2001-09-27 12:01:22 chris Exp $
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
 
24
unsigned char Cx86_step = 0;
25
static 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
 
29
static 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
 
40
static 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
 
52
static 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
        outport_byte(0x22,0xff);
71
        inport_byte(0x23, x86_mask);
72
        switch (x86_mask) {
73
                case 0x03:
74
                        Cx86_step =  1; /* 6x86MX Rev 1.3 */
75
                        break;
76
                case 0x04:
77
                        Cx86_step =  2; /* 6x86MX Rev 1.4 */
78
                        break;
79
                case 0x05:
80
                        Cx86_step =  3; /* 6x86MX Rev 1.5 */
81
                        break;
82
                case 0x06:
83
                        Cx86_step =  4; /* 6x86MX Rev 1.6 */
84
                        break;
85
                case 0x14:
86
                        Cx86_step =  5; /* 6x86 Rev 2.4 */
87
                        break;
88
                case 0x15:
89
                        Cx86_step =  6; /* 6x86 Rev 2.5 */
90
                        break;
91
                case 0x16:
92
                        Cx86_step =  7; /* 6x86 Rev 2.6 */
93
                        break;
94
                case 0x17:
95
                        Cx86_step =  8; /* 6x86 Rev 2.7 or 3.7 */
96
                        break;
97
                case 0x22:
98
                        Cx86_step =  9; /* 6x86L Rev 4.2 */
99
                        break;
100
                default:
101
                        Cx86_step = 0;
102
        }
103
        return model[nr6x86];
104
}
105
 
106
static const char * i686model(unsigned int nr)
107
{
108
        static const char *model[] = {
109
                "PPro A-step", "Pentium Pro"
110
        };
111
        if (nr < sizeof(model)/sizeof(char *))
112
                return model[nr];
113
        return NULL;
114
}
115
 
116
struct cpu_model_info {
117
        int x86;
118
        char *model_names[16];
119
};
120
 
121
static struct cpu_model_info amd_models[] = {
122
        { 4,
123
          { NULL, NULL, NULL, "DX/2", NULL, NULL, NULL, "DX/2-WB", "DX/4",
124
            "DX/4-WB", NULL, NULL, NULL, NULL, "Am5x86-WT", "Am5x86-WB" }},
125
        { 5,
126
          { "K5/SSA5 (PR-75, PR-90, PR-100)", "K5 (PR-120, PR-133)",
127
            "K5 (PR-166)", "K5 (PR-200)", NULL, NULL,
128
            "K6 (166 - 266)", "K6 (166 - 300)", "K6-2 (200 - 450)",
129
            "K6-3D-Plus (200 - 450)", NULL, NULL, NULL, NULL, NULL, NULL }},
130
};
131
 
132
static const char * AMDmodel(void)
133
{
134
        const char *p=NULL;
135
        int i;
136
 
137
        if (x86_model < 16)
138
                for (i=0; i<sizeof(amd_models)/sizeof(struct cpu_model_info); i++)
139
                        if (amd_models[i].x86 == x86) {
140
                                p = amd_models[i].model_names[(int)x86_model];
141
                                break;
142
                        }
143
        return p;
144
}
145
 
146
static const char * getmodel(int x86, int model)
147
{
148
        const char *p = NULL;
149
        static char nbuf[12];
150
        if (strncmp(x86_vendor_id, "Cyrix", 5) == 0)
151
                p = Cx86model();
152
        else if(strcmp(x86_vendor_id, "AuthenticAMD")==0)
153
                p = AMDmodel();
154
        else {
155
                switch (x86) {
156
                        case 4:
157
                                p = i486model(model);
158
                                break;
159
                        case 5:
160
                                p = i586model(model);
161
                                break;
162
                        case 6:
163
                                p = i686model(model);
164
                                break;
165
                }
166
        }
167
        if (p)
168
                return p;
169
 
170
        sprintf(nbuf, "%d", model);
171
        return nbuf;
172
}
173
 
174
void printCpuInfo()
175
{
176
  int i;
177
  static const char *x86_cap_flags[] = {
178
    "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
179
    "cx8", "apic", "10", "11", "mtrr", "pge", "mca", "cmov",
180
    "16", "17", "18", "19", "20", "21", "22", "mmx",
181
    "24", "25", "26", "27", "28", "29", "30", "31"
182
  };
183
 
184
  printk("cpu\t\t\t: %c86\n", x86+'0');
185
  printk("model\t\t: %s\n",
186
         have_cpuid ? getmodel(x86, x86_model) : "unknown");
187
  if (x86_vendor_id [0] == '\0')
188
    strcpy(x86_vendor_id, "unknown");
189
  printk("vendor_id\t: %s\n", x86_vendor_id);
190
 
191
  if (x86_mask)
192
    if (strncmp(x86_vendor_id, "Cyrix", 5) != 0) {
193
      printk("stepping\t: %d\n", x86_mask);
194
    }
195
    else {                      /* we have a Cyrix */
196
      printk("stepping\t: %s\n", Cx86_type[Cx86_step]);
197
    }
198
  else
199
    printk("stepping\t: unknown\n");
200
 
201
  printk("fpu\t\t\t: %s\n", (hard_math ? "yes" : "no"));
202
  printk("cpuid\t\t: %s\n", (have_cpuid ? "yes" : "no"));
203
  printk("flags\t\t:");
204
  for ( i = 0 ; i < 32 ; i++ ) {
205
    if ( x86_capability & (1 << i) ) {
206
      printk(" %s", x86_cap_flags[i]);
207
    }
208
  }
209
  printk("\n");
210
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.