proc.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 <arch/chip.h>
  30. /*
  31. * Support /proc/cpuinfo
  32. */
  33. #define cpu_to_ptr(n) ((void *)((long)(n)+1))
  34. #define ptr_to_cpu(p) ((long)(p) - 1)
  35. static int show_cpuinfo(struct seq_file *m, void *v)
  36. {
  37. int n = ptr_to_cpu(v);
  38. if (n == 0) {
  39. char buf[NR_CPUS*5];
  40. cpulist_scnprintf(buf, sizeof(buf), cpu_online_mask);
  41. seq_printf(m, "cpu count\t: %d\n", num_online_cpus());
  42. seq_printf(m, "cpu list\t: %s\n", buf);
  43. seq_printf(m, "model name\t: %s\n", chip_model);
  44. seq_printf(m, "flags\t\t:\n"); /* nothing for now */
  45. seq_printf(m, "cpu MHz\t\t: %llu.%06llu\n",
  46. get_clock_rate() / 1000000,
  47. (get_clock_rate() % 1000000));
  48. seq_printf(m, "bogomips\t: %lu.%02lu\n\n",
  49. loops_per_jiffy/(500000/HZ),
  50. (loops_per_jiffy/(5000/HZ)) % 100);
  51. }
  52. #ifdef CONFIG_SMP
  53. if (!cpu_online(n))
  54. return 0;
  55. #endif
  56. seq_printf(m, "processor\t: %d\n", n);
  57. /* Print only num_online_cpus() blank lines total. */
  58. if (cpumask_next(n, cpu_online_mask) < nr_cpu_ids)
  59. seq_printf(m, "\n");
  60. return 0;
  61. }
  62. static void *c_start(struct seq_file *m, loff_t *pos)
  63. {
  64. return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
  65. }
  66. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  67. {
  68. ++*pos;
  69. return c_start(m, pos);
  70. }
  71. static void c_stop(struct seq_file *m, void *v)
  72. {
  73. }
  74. const struct seq_operations cpuinfo_op = {
  75. .start = c_start,
  76. .next = c_next,
  77. .stop = c_stop,
  78. .show = show_cpuinfo,
  79. };