proc.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. #include <linux/cpufreq.h>
  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. /* AMD-defined */
  27. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  28. NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
  29. NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
  30. NULL, "fxsr_opt", "rdtscp", NULL, NULL, "lm", "3dnowext", "3dnow",
  31. /* Transmeta-defined */
  32. "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
  33. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  34. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  35. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  36. /* Other (Linux-defined) */
  37. "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
  38. NULL, NULL, NULL, NULL,
  39. "constant_tsc", "up", NULL, NULL, NULL, NULL, NULL, NULL,
  40. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  41. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  42. /* Intel-defined (#2) */
  43. "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
  44. "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
  45. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  46. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  47. /* VIA/Cyrix/Centaur-defined */
  48. NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
  49. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  50. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  51. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  52. /* AMD-defined (#2) */
  53. "lahf_lm", "cmp_legacy", "svm", NULL, "cr8legacy", NULL, NULL, NULL,
  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. static char *x86_power_flags[] = {
  59. "ts", /* temperature sensor */
  60. "fid", /* frequency id control */
  61. "vid", /* voltage id control */
  62. "ttp", /* thermal trip */
  63. "tm",
  64. "stc",
  65. NULL,
  66. /* nothing */ /* constant_tsc - moved to flags */
  67. };
  68. struct cpuinfo_x86 *c = v;
  69. int i, n = c - cpu_data;
  70. int fpu_exception;
  71. #ifdef CONFIG_SMP
  72. if (!cpu_online(n))
  73. return 0;
  74. #endif
  75. seq_printf(m, "processor\t: %d\n"
  76. "vendor_id\t: %s\n"
  77. "cpu family\t: %d\n"
  78. "model\t\t: %d\n"
  79. "model name\t: %s\n",
  80. n,
  81. c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
  82. c->x86,
  83. c->x86_model,
  84. c->x86_model_id[0] ? c->x86_model_id : "unknown");
  85. if (c->x86_mask || c->cpuid_level >= 0)
  86. seq_printf(m, "stepping\t: %d\n", c->x86_mask);
  87. else
  88. seq_printf(m, "stepping\t: unknown\n");
  89. if ( cpu_has(c, X86_FEATURE_TSC) ) {
  90. unsigned int freq = cpufreq_quick_get(n);
  91. if (!freq)
  92. freq = cpu_khz;
  93. seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
  94. freq / 1000, (freq % 1000));
  95. }
  96. /* Cache size */
  97. if (c->x86_cache_size >= 0)
  98. seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
  99. #ifdef CONFIG_X86_HT
  100. if (c->x86_max_cores * smp_num_siblings > 1) {
  101. seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]);
  102. seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
  103. seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]);
  104. seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
  105. }
  106. #endif
  107. /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
  108. fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
  109. seq_printf(m, "fdiv_bug\t: %s\n"
  110. "hlt_bug\t\t: %s\n"
  111. "f00f_bug\t: %s\n"
  112. "coma_bug\t: %s\n"
  113. "fpu\t\t: %s\n"
  114. "fpu_exception\t: %s\n"
  115. "cpuid level\t: %d\n"
  116. "wp\t\t: %s\n"
  117. "flags\t\t:",
  118. c->fdiv_bug ? "yes" : "no",
  119. c->hlt_works_ok ? "no" : "yes",
  120. c->f00f_bug ? "yes" : "no",
  121. c->coma_bug ? "yes" : "no",
  122. c->hard_math ? "yes" : "no",
  123. fpu_exception ? "yes" : "no",
  124. c->cpuid_level,
  125. c->wp_works_ok ? "yes" : "no");
  126. for ( i = 0 ; i < 32*NCAPINTS ; i++ )
  127. if ( test_bit(i, c->x86_capability) &&
  128. x86_cap_flags[i] != NULL )
  129. seq_printf(m, " %s", x86_cap_flags[i]);
  130. for (i = 0; i < 32; i++)
  131. if (c->x86_power & (1 << i)) {
  132. if (i < ARRAY_SIZE(x86_power_flags) &&
  133. x86_power_flags[i])
  134. seq_printf(m, "%s%s",
  135. x86_power_flags[i][0]?" ":"",
  136. x86_power_flags[i]);
  137. else
  138. seq_printf(m, " [%d]", i);
  139. }
  140. seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n",
  141. c->loops_per_jiffy/(500000/HZ),
  142. (c->loops_per_jiffy/(5000/HZ)) % 100);
  143. return 0;
  144. }
  145. static void *c_start(struct seq_file *m, loff_t *pos)
  146. {
  147. return *pos < NR_CPUS ? cpu_data + *pos : NULL;
  148. }
  149. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  150. {
  151. ++*pos;
  152. return c_start(m, pos);
  153. }
  154. static void c_stop(struct seq_file *m, void *v)
  155. {
  156. }
  157. struct seq_operations cpuinfo_op = {
  158. .start = c_start,
  159. .next = c_next,
  160. .stop = c_stop,
  161. .show = show_cpuinfo,
  162. };