sn_proc_fs.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <linux/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 system_serial_number_show(struct seq_file *s, void *p)
  19. {
  20. seq_printf(s, "%s\n", sn_system_serial_number());
  21. return 0;
  22. }
  23. static int licenseID_show(struct seq_file *s, void *p)
  24. {
  25. seq_printf(s, "0x%llx\n", sn_partition_serial_number_val());
  26. return 0;
  27. }
  28. static int coherence_id_show(struct seq_file *s, void *p)
  29. {
  30. seq_printf(s, "%d\n", partition_coherence_id());
  31. return 0;
  32. }
  33. /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
  34. extern int sn_topology_open(struct inode *, struct file *);
  35. extern int sn_topology_release(struct inode *, struct file *);
  36. static const struct file_operations proc_sn_topo_fops = {
  37. .open = sn_topology_open,
  38. .read = seq_read,
  39. .llseek = seq_lseek,
  40. .release = sn_topology_release,
  41. };
  42. void register_sn_procfs(void)
  43. {
  44. static struct proc_dir_entry *sgi_proc_dir = NULL;
  45. BUG_ON(sgi_proc_dir != NULL);
  46. if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
  47. return;
  48. proc_create_single("partition_id", 0444, sgi_proc_dir,
  49. partition_id_show);
  50. proc_create_single("system_serial_number", 0444, sgi_proc_dir,
  51. system_serial_number_show);
  52. proc_create_single("licenseID", 0444, sgi_proc_dir, licenseID_show);
  53. proc_create_single("coherence_id", 0444, sgi_proc_dir,
  54. coherence_id_show);
  55. proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops);
  56. }
  57. #endif /* CONFIG_PROC_FS */