processor.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * arch/s390/kernel/processor.c
  3. *
  4. * Copyright IBM Corp. 2008
  5. * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
  6. */
  7. #define KMSG_COMPONENT "cpu"
  8. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/smp.h>
  12. #include <linux/seq_file.h>
  13. #include <linux/delay.h>
  14. #include <asm/elf.h>
  15. #include <asm/lowcore.h>
  16. #include <asm/param.h>
  17. void __cpuinit print_cpu_info(void)
  18. {
  19. pr_info("Processor %d started, address %d, identification %06X\n",
  20. S390_lowcore.cpu_nr, S390_lowcore.cpu_addr,
  21. S390_lowcore.cpu_id.ident);
  22. }
  23. /*
  24. * show_cpuinfo - Get information on one CPU for use by procfs.
  25. */
  26. static int show_cpuinfo(struct seq_file *m, void *v)
  27. {
  28. static const char *hwcap_str[9] = {
  29. "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
  30. "edat", "etf3eh"
  31. };
  32. struct _lowcore *lc;
  33. unsigned long n = (unsigned long) v - 1;
  34. int i;
  35. s390_adjust_jiffies();
  36. preempt_disable();
  37. if (!n) {
  38. seq_printf(m, "vendor_id : IBM/S390\n"
  39. "# processors : %i\n"
  40. "bogomips per cpu: %lu.%02lu\n",
  41. num_online_cpus(), loops_per_jiffy/(500000/HZ),
  42. (loops_per_jiffy/(5000/HZ))%100);
  43. seq_puts(m, "features\t: ");
  44. for (i = 0; i < 9; i++)
  45. if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
  46. seq_printf(m, "%s ", hwcap_str[i]);
  47. seq_puts(m, "\n");
  48. }
  49. if (cpu_online(n)) {
  50. #ifdef CONFIG_SMP
  51. lc = (smp_processor_id() == n) ?
  52. &S390_lowcore : lowcore_ptr[n];
  53. #else
  54. lc = &S390_lowcore;
  55. #endif
  56. seq_printf(m, "processor %li: "
  57. "version = %02X, "
  58. "identification = %06X, "
  59. "machine = %04X\n",
  60. n, lc->cpu_id.version,
  61. lc->cpu_id.ident,
  62. lc->cpu_id.machine);
  63. }
  64. preempt_enable();
  65. return 0;
  66. }
  67. static void *c_start(struct seq_file *m, loff_t *pos)
  68. {
  69. return *pos < NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL;
  70. }
  71. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  72. {
  73. ++*pos;
  74. return c_start(m, pos);
  75. }
  76. static void c_stop(struct seq_file *m, void *v)
  77. {
  78. }
  79. const struct seq_operations cpuinfo_op = {
  80. .start = c_start,
  81. .next = c_next,
  82. .stop = c_stop,
  83. .show = show_cpuinfo,
  84. };