]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - arch/i386/kernel/cpu/proc.c
Linux-2.6.12-rc2
[linux-3.10.git] / arch / i386 / kernel / cpu / proc.c
1 #include <linux/smp.h>
2 #include <linux/timex.h>
3 #include <linux/string.h>
4 #include <asm/semaphore.h>
5 #include <linux/seq_file.h>
6
7 /*
8  *      Get CPU information for use by the procfs.
9  */
10 static int show_cpuinfo(struct seq_file *m, void *v)
11 {
12         /* 
13          * These flag bits must match the definitions in <asm/cpufeature.h>.
14          * NULL means this bit is undefined or reserved; either way it doesn't
15          * have meaning as far as Linux is concerned.  Note that it's important
16          * to realize there is a difference between this table and CPUID -- if
17          * applications want to get the raw CPUID data, they should access
18          * /dev/cpu/<cpu_nr>/cpuid instead.
19          */
20         static char *x86_cap_flags[] = {
21                 /* Intel-defined */
22                 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
23                 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
24                 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
25                 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
26
27                 /* AMD-defined */
28                 "pni", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
29                 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
30                 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
31                 NULL, "fxsr_opt", NULL, NULL, NULL, "lm", "3dnowext", "3dnow",
32
33                 /* Transmeta-defined */
34                 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
35                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
36                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
37                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
38
39                 /* Other (Linux-defined) */
40                 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
41                 NULL, NULL, NULL, NULL,
42                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
43                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
44                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
45
46                 /* Intel-defined (#2) */
47                 "pni", NULL, NULL, "monitor", "ds_cpl", NULL, NULL, "est",
48                 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
49                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
50                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
51
52                 /* VIA/Cyrix/Centaur-defined */
53                 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
54                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
55                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
56                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
57
58                 /* AMD-defined (#2) */
59                 "lahf_lm", "cmp_legacy", NULL, NULL, NULL, NULL, NULL, NULL,
60                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
61                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
62                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
63         };
64         struct cpuinfo_x86 *c = v;
65         int i, n = c - cpu_data;
66         int fpu_exception;
67
68 #ifdef CONFIG_SMP
69         if (!cpu_online(n))
70                 return 0;
71 #endif
72         seq_printf(m, "processor\t: %d\n"
73                 "vendor_id\t: %s\n"
74                 "cpu family\t: %d\n"
75                 "model\t\t: %d\n"
76                 "model name\t: %s\n",
77                 n,
78                 c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
79                 c->x86,
80                 c->x86_model,
81                 c->x86_model_id[0] ? c->x86_model_id : "unknown");
82
83         if (c->x86_mask || c->cpuid_level >= 0)
84                 seq_printf(m, "stepping\t: %d\n", c->x86_mask);
85         else
86                 seq_printf(m, "stepping\t: unknown\n");
87
88         if ( cpu_has(c, X86_FEATURE_TSC) ) {
89                 seq_printf(m, "cpu MHz\t\t: %lu.%03lu\n",
90                         cpu_khz / 1000, (cpu_khz % 1000));
91         }
92
93         /* Cache size */
94         if (c->x86_cache_size >= 0)
95                 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
96 #ifdef CONFIG_X86_HT
97         seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]);
98         seq_printf(m, "siblings\t: %d\n", c->x86_num_cores * smp_num_siblings);
99 #endif
100         
101         /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
102         fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
103         seq_printf(m, "fdiv_bug\t: %s\n"
104                         "hlt_bug\t\t: %s\n"
105                         "f00f_bug\t: %s\n"
106                         "coma_bug\t: %s\n"
107                         "fpu\t\t: %s\n"
108                         "fpu_exception\t: %s\n"
109                         "cpuid level\t: %d\n"
110                         "wp\t\t: %s\n"
111                         "flags\t\t:",
112                      c->fdiv_bug ? "yes" : "no",
113                      c->hlt_works_ok ? "no" : "yes",
114                      c->f00f_bug ? "yes" : "no",
115                      c->coma_bug ? "yes" : "no",
116                      c->hard_math ? "yes" : "no",
117                      fpu_exception ? "yes" : "no",
118                      c->cpuid_level,
119                      c->wp_works_ok ? "yes" : "no");
120
121         for ( i = 0 ; i < 32*NCAPINTS ; i++ )
122                 if ( test_bit(i, c->x86_capability) &&
123                      x86_cap_flags[i] != NULL )
124                         seq_printf(m, " %s", x86_cap_flags[i]);
125
126         seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
127                      c->loops_per_jiffy/(500000/HZ),
128                      (c->loops_per_jiffy/(5000/HZ)) % 100);
129         return 0;
130 }
131
132 static void *c_start(struct seq_file *m, loff_t *pos)
133 {
134         return *pos < NR_CPUS ? cpu_data + *pos : NULL;
135 }
136 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
137 {
138         ++*pos;
139         return c_start(m, pos);
140 }
141 static void c_stop(struct seq_file *m, void *v)
142 {
143 }
144 struct seq_operations cpuinfo_op = {
145         .start  = c_start,
146         .next   = c_next,
147         .stop   = c_stop,
148         .show   = show_cpuinfo,
149 };