proc.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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/hugetlb.h>
  25. #include <linux/mman.h>
  26. #include <asm/unaligned.h>
  27. #include <asm/pgtable.h>
  28. #include <asm/processor.h>
  29. #include <asm/sections.h>
  30. #include <asm/homecache.h>
  31. #include <asm/hardwall.h>
  32. #include <arch/chip.h>
  33. /*
  34. * Support /proc/cpuinfo
  35. */
  36. #define cpu_to_ptr(n) ((void *)((long)(n)+1))
  37. #define ptr_to_cpu(p) ((long)(p) - 1)
  38. static int show_cpuinfo(struct seq_file *m, void *v)
  39. {
  40. int n = ptr_to_cpu(v);
  41. if (n == 0) {
  42. char buf[NR_CPUS*5];
  43. cpulist_scnprintf(buf, sizeof(buf), cpu_online_mask);
  44. seq_printf(m, "cpu count\t: %d\n", num_online_cpus());
  45. seq_printf(m, "cpu list\t: %s\n", buf);
  46. seq_printf(m, "model name\t: %s\n", chip_model);
  47. seq_printf(m, "flags\t\t:\n"); /* nothing for now */
  48. seq_printf(m, "cpu MHz\t\t: %llu.%06llu\n",
  49. get_clock_rate() / 1000000,
  50. (get_clock_rate() % 1000000));
  51. seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
  52. loops_per_jiffy/(500000/HZ),
  53. (loops_per_jiffy/(5000/HZ)) % 100);
  54. }
  55. #ifdef CONFIG_SMP
  56. if (!cpu_online(n))
  57. return 0;
  58. #endif
  59. seq_printf(m, "processor\t: %d\n", n);
  60. /* Print only num_online_cpus() blank lines total. */
  61. if (cpumask_next(n, cpu_online_mask) < nr_cpu_ids)
  62. seq_printf(m, "\n");
  63. return 0;
  64. }
  65. static void *c_start(struct seq_file *m, loff_t *pos)
  66. {
  67. return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
  68. }
  69. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  70. {
  71. ++*pos;
  72. return c_start(m, pos);
  73. }
  74. static void c_stop(struct seq_file *m, void *v)
  75. {
  76. }
  77. const struct seq_operations cpuinfo_op = {
  78. .start = c_start,
  79. .next = c_next,
  80. .stop = c_stop,
  81. .show = show_cpuinfo,
  82. };
  83. /*
  84. * Support /proc/tile directory
  85. */
  86. static int __init proc_tile_init(void)
  87. {
  88. struct proc_dir_entry *root = proc_mkdir("tile", NULL);
  89. if (root == NULL)
  90. return 0;
  91. proc_tile_hardwall_init(root);
  92. return 0;
  93. }
  94. arch_initcall(proc_tile_init);
  95. /*
  96. * Support /proc/sys/tile directory
  97. */
  98. #ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */
  99. static ctl_table unaligned_subtable[] = {
  100. {
  101. .procname = "enabled",
  102. .data = &unaligned_fixup,
  103. .maxlen = sizeof(int),
  104. .mode = 0644,
  105. .proc_handler = &proc_dointvec
  106. },
  107. {
  108. .procname = "printk",
  109. .data = &unaligned_printk,
  110. .maxlen = sizeof(int),
  111. .mode = 0644,
  112. .proc_handler = &proc_dointvec
  113. },
  114. {
  115. .procname = "count",
  116. .data = &unaligned_fixup_count,
  117. .maxlen = sizeof(int),
  118. .mode = 0644,
  119. .proc_handler = &proc_dointvec
  120. },
  121. {}
  122. };
  123. static ctl_table unaligned_table[] = {
  124. {
  125. .procname = "unaligned_fixup",
  126. .mode = 0555,
  127. .child = unaligned_subtable
  128. },
  129. {}
  130. };
  131. static struct ctl_path tile_path[] = {
  132. { .procname = "tile" },
  133. { }
  134. };
  135. static int __init proc_sys_tile_init(void)
  136. {
  137. register_sysctl_paths(tile_path, unaligned_table);
  138. return 0;
  139. }
  140. arch_initcall(proc_sys_tile_init);
  141. #endif