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
6 * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
10 #include <linux/proc_fs.h>
11 #include <linux/seq_file.h>
12 #include <asm/uaccess.h>
13 #include <asm/sn/sn_sal.h>
15 static int partition_id_show(struct seq_file *s, void *p)
17 seq_printf(s, "%d\n", sn_partition_id);
21 static int partition_id_open(struct inode *inode, struct file *file)
23 return single_open(file, partition_id_show, NULL);
26 static int system_serial_number_show(struct seq_file *s, void *p)
28 seq_printf(s, "%s\n", sn_system_serial_number());
32 static int system_serial_number_open(struct inode *inode, struct file *file)
34 return single_open(file, system_serial_number_show, NULL);
37 static int licenseID_show(struct seq_file *s, void *p)
39 seq_printf(s, "0x%lx\n", sn_partition_serial_number_val());
43 static int licenseID_open(struct inode *inode, struct file *file)
45 return single_open(file, licenseID_show, NULL);
49 * Enable forced interrupt by default.
50 * When set, the sn interrupt handler writes the force interrupt register on
51 * the bridge chip. The hardware will then send an interrupt message if the
52 * interrupt line is active. This mimics a level sensitive interrupt.
54 extern int sn_force_interrupt_flag;
56 static int sn_force_interrupt_show(struct seq_file *s, void *p)
58 seq_printf(s, "Force interrupt is %s\n",
59 sn_force_interrupt_flag ? "enabled" : "disabled");
63 static ssize_t sn_force_interrupt_write_proc(struct file *file,
64 const char __user *buffer, size_t count, loff_t *data)
68 if (copy_from_user(&val, buffer, 1))
71 sn_force_interrupt_flag = (val == '0') ? 0 : 1;
75 static int sn_force_interrupt_open(struct inode *inode, struct file *file)
77 return single_open(file, sn_force_interrupt_show, NULL);
80 static int coherence_id_show(struct seq_file *s, void *p)
82 seq_printf(s, "%d\n", partition_coherence_id());
87 static int coherence_id_open(struct inode *inode, struct file *file)
89 return single_open(file, coherence_id_show, NULL);
92 static struct proc_dir_entry
93 *sn_procfs_create_entry(const char *name, struct proc_dir_entry *parent,
94 int (*openfunc)(struct inode *, struct file *),
95 int (*releasefunc)(struct inode *, struct file *),
96 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *))
98 struct proc_dir_entry *e = create_proc_entry(name, 0444, parent);
101 struct file_operations *f;
103 f = kzalloc(sizeof(*f), GFP_KERNEL);
107 f->llseek = seq_lseek;
108 f->release = releasefunc;
117 /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
118 extern int sn_topology_open(struct inode *, struct file *);
119 extern int sn_topology_release(struct inode *, struct file *);
121 void register_sn_procfs(void)
123 static struct proc_dir_entry *sgi_proc_dir = NULL;
125 BUG_ON(sgi_proc_dir != NULL);
126 if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
129 sn_procfs_create_entry("partition_id", sgi_proc_dir,
130 partition_id_open, single_release, NULL);
132 sn_procfs_create_entry("system_serial_number", sgi_proc_dir,
133 system_serial_number_open, single_release, NULL);
135 sn_procfs_create_entry("licenseID", sgi_proc_dir,
136 licenseID_open, single_release, NULL);
138 sn_procfs_create_entry("sn_force_interrupt", sgi_proc_dir,
139 sn_force_interrupt_open, single_release,
140 sn_force_interrupt_write_proc);
142 sn_procfs_create_entry("coherence_id", sgi_proc_dir,
143 coherence_id_open, single_release, NULL);
145 sn_procfs_create_entry("sn_topology", sgi_proc_dir,
146 sn_topology_open, sn_topology_release, NULL);
149 #endif /* CONFIG_PROC_FS */