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