sn_proc_fs.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #ifdef CONFIG_PROC_FS
  9. #include <linux/proc_fs.h>
  10. #include <linux/seq_file.h>
  11. #include <asm/uaccess.h>
  12. #include <asm/sn/sn_sal.h>
  13. static int partition_id_show(struct seq_file *s, void *p)
  14. {
  15. seq_printf(s, "%d\n", sn_partition_id);
  16. return 0;
  17. }
  18. static int partition_id_open(struct inode *inode, struct file *file)
  19. {
  20. return single_open(file, partition_id_show, NULL);
  21. }
  22. static int system_serial_number_show(struct seq_file *s, void *p)
  23. {
  24. seq_printf(s, "%s\n", sn_system_serial_number());
  25. return 0;
  26. }
  27. static int system_serial_number_open(struct inode *inode, struct file *file)
  28. {
  29. return single_open(file, system_serial_number_show, NULL);
  30. }
  31. static int licenseID_show(struct seq_file *s, void *p)
  32. {
  33. seq_printf(s, "0x%llx\n", sn_partition_serial_number_val());
  34. return 0;
  35. }
  36. static int licenseID_open(struct inode *inode, struct file *file)
  37. {
  38. return single_open(file, licenseID_show, NULL);
  39. }
  40. /*
  41. * Enable forced interrupt by default.
  42. * When set, the sn interrupt handler writes the force interrupt register on
  43. * the bridge chip. The hardware will then send an interrupt message if the
  44. * interrupt line is active. This mimics a level sensitive interrupt.
  45. */
  46. extern int sn_force_interrupt_flag;
  47. static int sn_force_interrupt_show(struct seq_file *s, void *p)
  48. {
  49. seq_printf(s, "Force interrupt is %s\n",
  50. sn_force_interrupt_flag ? "enabled" : "disabled");
  51. return 0;
  52. }
  53. static ssize_t sn_force_interrupt_write_proc(struct file *file,
  54. const char __user *buffer, size_t count, loff_t *data)
  55. {
  56. char val;
  57. if (copy_from_user(&val, buffer, 1))
  58. return -EFAULT;
  59. sn_force_interrupt_flag = (val == '0') ? 0 : 1;
  60. return count;
  61. }
  62. static int sn_force_interrupt_open(struct inode *inode, struct file *file)
  63. {
  64. return single_open(file, sn_force_interrupt_show, NULL);
  65. }
  66. static int coherence_id_show(struct seq_file *s, void *p)
  67. {
  68. seq_printf(s, "%d\n", partition_coherence_id());
  69. return 0;
  70. }
  71. static int coherence_id_open(struct inode *inode, struct file *file)
  72. {
  73. return single_open(file, coherence_id_show, NULL);
  74. }
  75. /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
  76. extern int sn_topology_open(struct inode *, struct file *);
  77. extern int sn_topology_release(struct inode *, struct file *);
  78. static const struct file_operations proc_partition_id_fops = {
  79. .open = partition_id_open,
  80. .read = seq_read,
  81. .llseek = seq_lseek,
  82. .release = single_release,
  83. };
  84. static const struct file_operations proc_system_sn_fops = {
  85. .open = system_serial_number_open,
  86. .read = seq_read,
  87. .llseek = seq_lseek,
  88. .release = single_release,
  89. };
  90. static const struct file_operations proc_license_id_fops = {
  91. .open = licenseID_open,
  92. .read = seq_read,
  93. .llseek = seq_lseek,
  94. .release = single_release,
  95. };
  96. static const struct file_operations proc_sn_force_intr_fops = {
  97. .open = sn_force_interrupt_open,
  98. .read = seq_read,
  99. .write = sn_force_interrupt_write_proc,
  100. .llseek = seq_lseek,
  101. .release = single_release,
  102. };
  103. static const struct file_operations proc_coherence_id_fops = {
  104. .open = coherence_id_open,
  105. .read = seq_read,
  106. .llseek = seq_lseek,
  107. .release = single_release,
  108. };
  109. static const struct file_operations proc_sn_topo_fops = {
  110. .open = sn_topology_open,
  111. .read = seq_read,
  112. .llseek = seq_lseek,
  113. .release = sn_topology_release,
  114. };
  115. void register_sn_procfs(void)
  116. {
  117. static struct proc_dir_entry *sgi_proc_dir = NULL;
  118. BUG_ON(sgi_proc_dir != NULL);
  119. if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
  120. return;
  121. proc_create("partition_id", 0444, sgi_proc_dir,
  122. &proc_partition_id_fops);
  123. proc_create("system_serial_number", 0444, sgi_proc_dir,
  124. &proc_system_sn_fops);
  125. proc_create("licenseID", 0444, sgi_proc_dir, &proc_license_id_fops);
  126. proc_create("sn_force_interrupt", 0644, sgi_proc_dir,
  127. &proc_sn_force_intr_fops);
  128. proc_create("coherence_id", 0444, sgi_proc_dir,
  129. &proc_coherence_id_fops);
  130. proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops);
  131. }
  132. #endif /* CONFIG_PROC_FS */