proc.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * This program is free software; you can distribute it and/or modify it
  3. * under the terms of the GNU General Public License (Version 2) as
  4. * published by the Free Software Foundation.
  5. *
  6. * This program is distributed in the hope it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  8. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  9. * for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License along
  12. * with this program; if not, write to the Free Software Foundation, Inc.,
  13. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/proc_fs.h>
  17. #include <linux/irq.h>
  18. #include <linux/sched.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/kernel_stat.h>
  21. #include <linux/random.h>
  22. #include <asm/io.h>
  23. #include <int.h>
  24. #include <uart.h>
  25. static int pnx8550_timers_read(char* page, char** start, off_t offset, int count, int* eof, void* data)
  26. {
  27. int len = 0;
  28. int configPR = read_c0_config7();
  29. if (offset==0) {
  30. len += sprintf(&page[len], "Timer: count, compare, tc, status\n");
  31. len += sprintf(&page[len], " 1: %11i, %8i, %1i, %s\n",
  32. read_c0_count(), read_c0_compare(),
  33. (configPR>>6)&0x1, ((configPR>>3)&0x1)? "off":"on");
  34. len += sprintf(&page[len], " 2: %11i, %8i, %1i, %s\n",
  35. read_c0_count2(), read_c0_compare2(),
  36. (configPR>>7)&0x1, ((configPR>>4)&0x1)? "off":"on");
  37. len += sprintf(&page[len], " 3: %11i, %8i, %1i, %s\n",
  38. read_c0_count3(), read_c0_compare3(),
  39. (configPR>>8)&0x1, ((configPR>>5)&0x1)? "off":"on");
  40. }
  41. return len;
  42. }
  43. static int pnx8550_registers_read(char* page, char** start, off_t offset, int count, int* eof, void* data)
  44. {
  45. int len = 0;
  46. if (offset==0) {
  47. len += sprintf(&page[len], "config1: %#10.8x\n", read_c0_config1());
  48. len += sprintf(&page[len], "config2: %#10.8x\n", read_c0_config2());
  49. len += sprintf(&page[len], "config3: %#10.8x\n", read_c0_config3());
  50. len += sprintf(&page[len], "configPR: %#10.8x\n", read_c0_config7());
  51. len += sprintf(&page[len], "status: %#10.8x\n", read_c0_status());
  52. len += sprintf(&page[len], "cause: %#10.8x\n", read_c0_cause());
  53. len += sprintf(&page[len], "count: %#10.8x\n", read_c0_count());
  54. len += sprintf(&page[len], "count_2: %#10.8x\n", read_c0_count2());
  55. len += sprintf(&page[len], "count_3: %#10.8x\n", read_c0_count3());
  56. len += sprintf(&page[len], "compare: %#10.8x\n", read_c0_compare());
  57. len += sprintf(&page[len], "compare_2: %#10.8x\n", read_c0_compare2());
  58. len += sprintf(&page[len], "compare_3: %#10.8x\n", read_c0_compare3());
  59. }
  60. return len;
  61. }
  62. static struct proc_dir_entry* pnx8550_dir;
  63. static struct proc_dir_entry* pnx8550_timers;
  64. static struct proc_dir_entry* pnx8550_registers;
  65. static int pnx8550_proc_init( void )
  66. {
  67. // Create /proc/pnx8550
  68. pnx8550_dir = proc_mkdir("pnx8550", NULL);
  69. if (!pnx8550_dir) {
  70. printk(KERN_ERR "Can't create pnx8550 proc dir\n");
  71. return -1;
  72. }
  73. // Create /proc/pnx8550/timers
  74. pnx8550_timers = create_proc_read_entry(
  75. "timers",
  76. 0,
  77. pnx8550_dir,
  78. pnx8550_timers_read,
  79. NULL);
  80. if (!pnx8550_timers)
  81. printk(KERN_ERR "Can't create pnx8550 timers proc file\n");
  82. // Create /proc/pnx8550/registers
  83. pnx8550_registers = create_proc_read_entry(
  84. "registers",
  85. 0,
  86. pnx8550_dir,
  87. pnx8550_registers_read,
  88. NULL);
  89. if (!pnx8550_registers)
  90. printk(KERN_ERR "Can't create pnx8550 registers proc file\n");
  91. return 0;
  92. }
  93. __initcall(pnx8550_proc_init);