proc.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #include <linux/seq_file.h>
  2. #include <linux/kernel.h>
  3. #include <linux/module.h>
  4. #include <asm/machvec.h>
  5. #include <asm/processor.h>
  6. static const char *cpu_name[] = {
  7. [CPU_SH7201] = "SH7201",
  8. [CPU_SH7203] = "SH7203", [CPU_SH7263] = "SH7263",
  9. [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619",
  10. [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706",
  11. [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708",
  12. [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710",
  13. [CPU_SH7712] = "SH7712", [CPU_SH7720] = "SH7720",
  14. [CPU_SH7721] = "SH7721", [CPU_SH7729] = "SH7729",
  15. [CPU_SH7750] = "SH7750", [CPU_SH7750S] = "SH7750S",
  16. [CPU_SH7750R] = "SH7750R", [CPU_SH7751] = "SH7751",
  17. [CPU_SH7751R] = "SH7751R", [CPU_SH7760] = "SH7760",
  18. [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501",
  19. [CPU_SH7763] = "SH7763", [CPU_SH7770] = "SH7770",
  20. [CPU_SH7780] = "SH7780", [CPU_SH7781] = "SH7781",
  21. [CPU_SH7343] = "SH7343", [CPU_SH7785] = "SH7785",
  22. [CPU_SH7786] = "SH7786", [CPU_SH7757] = "SH7757",
  23. [CPU_SH7722] = "SH7722", [CPU_SHX3] = "SH-X3",
  24. [CPU_SH5_101] = "SH5-101", [CPU_SH5_103] = "SH5-103",
  25. [CPU_MXG] = "MX-G", [CPU_SH7723] = "SH7723",
  26. [CPU_SH7366] = "SH7366", [CPU_SH7724] = "SH7724",
  27. [CPU_SH7372] = "SH7372", [CPU_SH_NONE] = "Unknown"
  28. };
  29. const char *get_cpu_subtype(struct sh_cpuinfo *c)
  30. {
  31. return cpu_name[c->type];
  32. }
  33. EXPORT_SYMBOL(get_cpu_subtype);
  34. #ifdef CONFIG_PROC_FS
  35. /* Symbolic CPU flags, keep in sync with asm/cpu-features.h */
  36. static const char *cpu_flags[] = {
  37. "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr",
  38. "ptea", "llsc", "l2", "op32", "pteaex", NULL
  39. };
  40. static void show_cpuflags(struct seq_file *m, struct sh_cpuinfo *c)
  41. {
  42. unsigned long i;
  43. seq_printf(m, "cpu flags\t:");
  44. if (!c->flags) {
  45. seq_printf(m, " %s\n", cpu_flags[0]);
  46. return;
  47. }
  48. for (i = 0; cpu_flags[i]; i++)
  49. if ((c->flags & (1 << i)))
  50. seq_printf(m, " %s", cpu_flags[i+1]);
  51. seq_printf(m, "\n");
  52. }
  53. static void show_cacheinfo(struct seq_file *m, const char *type,
  54. struct cache_info info)
  55. {
  56. unsigned int cache_size;
  57. cache_size = info.ways * info.sets * info.linesz;
  58. seq_printf(m, "%s size\t: %2dKiB (%d-way)\n",
  59. type, cache_size >> 10, info.ways);
  60. }
  61. /*
  62. * Get CPU information for use by the procfs.
  63. */
  64. static int show_cpuinfo(struct seq_file *m, void *v)
  65. {
  66. struct sh_cpuinfo *c = v;
  67. unsigned int cpu = c - cpu_data;
  68. if (!cpu_online(cpu))
  69. return 0;
  70. if (cpu == 0)
  71. seq_printf(m, "machine\t\t: %s\n", get_system_type());
  72. else
  73. seq_printf(m, "\n");
  74. seq_printf(m, "processor\t: %d\n", cpu);
  75. seq_printf(m, "cpu family\t: %s\n", init_utsname()->machine);
  76. seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype(c));
  77. if (c->cut_major == -1)
  78. seq_printf(m, "cut\t\t: unknown\n");
  79. else if (c->cut_minor == -1)
  80. seq_printf(m, "cut\t\t: %d.x\n", c->cut_major);
  81. else
  82. seq_printf(m, "cut\t\t: %d.%d\n", c->cut_major, c->cut_minor);
  83. show_cpuflags(m, c);
  84. seq_printf(m, "cache type\t: ");
  85. /*
  86. * Check for what type of cache we have, we support both the
  87. * unified cache on the SH-2 and SH-3, as well as the harvard
  88. * style cache on the SH-4.
  89. */
  90. if (c->icache.flags & SH_CACHE_COMBINED) {
  91. seq_printf(m, "unified\n");
  92. show_cacheinfo(m, "cache", c->icache);
  93. } else {
  94. seq_printf(m, "split (harvard)\n");
  95. show_cacheinfo(m, "icache", c->icache);
  96. show_cacheinfo(m, "dcache", c->dcache);
  97. }
  98. /* Optional secondary cache */
  99. if (c->flags & CPU_HAS_L2_CACHE)
  100. show_cacheinfo(m, "scache", c->scache);
  101. seq_printf(m, "address sizes\t: %u bits physical\n", c->phys_bits);
  102. seq_printf(m, "bogomips\t: %lu.%02lu\n",
  103. c->loops_per_jiffy/(500000/HZ),
  104. (c->loops_per_jiffy/(5000/HZ)) % 100);
  105. return 0;
  106. }
  107. static void *c_start(struct seq_file *m, loff_t *pos)
  108. {
  109. return *pos < NR_CPUS ? cpu_data + *pos : NULL;
  110. }
  111. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  112. {
  113. ++*pos;
  114. return c_start(m, pos);
  115. }
  116. static void c_stop(struct seq_file *m, void *v)
  117. {
  118. }
  119. const struct seq_operations cpuinfo_op = {
  120. .start = c_start,
  121. .next = c_next,
  122. .stop = c_stop,
  123. .show = show_cpuinfo,
  124. };
  125. #endif /* CONFIG_PROC_FS */