sn_proc_fs.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. static int coherence_id_show(struct seq_file *s, void *p)
  41. {
  42. seq_printf(s, "%d\n", partition_coherence_id());
  43. return 0;
  44. }
  45. static int coherence_id_open(struct inode *inode, struct file *file)
  46. {
  47. return single_open(file, coherence_id_show, NULL);
  48. }
  49. /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
  50. extern int sn_topology_open(struct inode *, struct file *);
  51. extern int sn_topology_release(struct inode *, struct file *);
  52. static const struct file_operations proc_partition_id_fops = {
  53. .open = partition_id_open,
  54. .read = seq_read,
  55. .llseek = seq_lseek,
  56. .release = single_release,
  57. };
  58. static const struct file_operations proc_system_sn_fops = {
  59. .open = system_serial_number_open,
  60. .read = seq_read,
  61. .llseek = seq_lseek,
  62. .release = single_release,
  63. };
  64. static const struct file_operations proc_license_id_fops = {
  65. .open = licenseID_open,
  66. .read = seq_read,
  67. .llseek = seq_lseek,
  68. .release = single_release,
  69. };
  70. static const struct file_operations proc_coherence_id_fops = {
  71. .open = coherence_id_open,
  72. .read = seq_read,
  73. .llseek = seq_lseek,
  74. .release = single_release,
  75. };
  76. static const struct file_operations proc_sn_topo_fops = {
  77. .open = sn_topology_open,
  78. .read = seq_read,
  79. .llseek = seq_lseek,
  80. .release = sn_topology_release,
  81. };
  82. void register_sn_procfs(void)
  83. {
  84. static struct proc_dir_entry *sgi_proc_dir = NULL;
  85. BUG_ON(sgi_proc_dir != NULL);
  86. if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
  87. return;
  88. proc_create("partition_id", 0444, sgi_proc_dir,
  89. &proc_partition_id_fops);
  90. proc_create("system_serial_number", 0444, sgi_proc_dir,
  91. &proc_system_sn_fops);
  92. proc_create("licenseID", 0444, sgi_proc_dir, &proc_license_id_fops);
  93. proc_create("coherence_id", 0444, sgi_proc_dir,
  94. &proc_coherence_id_fops);
  95. proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops);
  96. }
  97. #endif /* CONFIG_PROC_FS */