proc.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #include <linux/smp.h>
  15. #include <linux/seq_file.h>
  16. #include <linux/threads.h>
  17. #include <linux/cpumask.h>
  18. #include <linux/timex.h>
  19. #include <linux/delay.h>
  20. #include <linux/fs.h>
  21. #include <linux/proc_fs.h>
  22. #include <linux/sysctl.h>
  23. #include <linux/hardirq.h>
  24. #include <linux/mman.h>
  25. #include <asm/pgtable.h>
  26. #include <asm/processor.h>
  27. #include <asm/sections.h>
  28. #include <asm/homecache.h>
  29. #include <asm/hardwall.h>
  30. #include <arch/chip.h>
  31. /*
  32. * Support /proc/cpuinfo
  33. */
  34. #define cpu_to_ptr(n) ((void *)((long)(n)+1))
  35. #define ptr_to_cpu(p) ((long)(p) - 1)
  36. static int show_cpuinfo(struct seq_file *m, void *v)
  37. {
  38. int n = ptr_to_cpu(v);
  39. if (n == 0) {
  40. char buf[NR_CPUS*5];
  41. cpulist_scnprintf(buf, sizeof(buf), cpu_online_mask);
  42. seq_printf(m, "cpu count\t: %d\n", num_online_cpus());
  43. seq_printf(m, "cpu list\t: %s\n", buf);
  44. seq_printf(m, "model name\t: %s\n", chip_model);
  45. seq_printf(m, "flags\t\t:\n"); /* nothing for now */
  46. seq_printf(m, "cpu MHz\t\t: %llu.%06llu\n",
  47. get_clock_rate() / 1000000,
  48. (get_clock_rate() % 1000000));
  49. seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
  50. loops_per_jiffy/(500000/HZ),
  51. (loops_per_jiffy/(5000/HZ)) % 100);
  52. }
  53. #ifdef CONFIG_SMP
  54. if (!cpu_online(n))
  55. return 0;
  56. #endif
  57. seq_printf(m, "processor\t: %d\n", n);
  58. /* Print only num_online_cpus() blank lines total. */
  59. if (cpumask_next(n, cpu_online_mask) < nr_cpu_ids)
  60. seq_printf(m, "\n");
  61. return 0;
  62. }
  63. static void *c_start(struct seq_file *m, loff_t *pos)
  64. {
  65. return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
  66. }
  67. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  68. {
  69. ++*pos;
  70. return c_start(m, pos);
  71. }
  72. static void c_stop(struct seq_file *m, void *v)
  73. {
  74. }
  75. const struct seq_operations cpuinfo_op = {
  76. .start = c_start,
  77. .next = c_next,
  78. .stop = c_stop,
  79. .show = show_cpuinfo,
  80. };
  81. /*
  82. * Support /proc/tile directory
  83. */
  84. static int __init proc_tile_init(void)
  85. {
  86. struct proc_dir_entry *root = proc_mkdir("tile", NULL);
  87. if (root == NULL)
  88. return 0;
  89. proc_tile_hardwall_init(root);
  90. return 0;
  91. }
  92. arch_initcall(proc_tile_init);
  93. /*
  94. * Support /proc/sys/tile directory
  95. */
  96. #ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */
  97. static ctl_table unaligned_subtable[] = {
  98. {
  99. .procname = "enabled",
  100. .data = &unaligned_fixup,
  101. .maxlen = sizeof(int),
  102. .mode = 0644,
  103. .proc_handler = &proc_dointvec
  104. },
  105. {
  106. .procname = "printk",
  107. .data = &unaligned_printk,
  108. .maxlen = sizeof(int),
  109. .mode = 0644,
  110. .proc_handler = &proc_dointvec
  111. },
  112. {
  113. .procname = "count",
  114. .data = &unaligned_fixup_count,
  115. .maxlen = sizeof(int),
  116. .mode = 0644,
  117. .proc_handler = &proc_dointvec
  118. },
  119. {}
  120. };
  121. static ctl_table unaligned_table[] = {
  122. {
  123. .procname = "unaligned_fixup",
  124. .mode = 0555,
  125. .child = unaligned_subtable
  126. },
  127. {}
  128. };
  129. #endif
  130. static struct ctl_path tile_path[] = {
  131. { .procname = "tile" },
  132. { }
  133. };
  134. static int __init proc_sys_tile_init(void)
  135. {
  136. #ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */
  137. register_sysctl_paths(tile_path, unaligned_table);
  138. #endif
  139. return 0;
  140. }
  141. arch_initcall(proc_sys_tile_init);