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-2004 Silicon Graphics, Inc. All rights reserved.
8 #include <linux/config.h>
9 #include <asm/uaccess.h>
12 #include <linux/proc_fs.h>
13 #include <linux/seq_file.h>
14 #include <asm/sn/sgi.h>
15 #include <asm/sn/sn_sal.h>
17 static int partition_id_show(struct seq_file *s, void *p)
19 seq_printf(s, "%d\n", sn_local_partid());
23 static int partition_id_open(struct inode *inode, struct file *file)
25 return single_open(file, partition_id_show, NULL);
28 static int system_serial_number_show(struct seq_file *s, void *p)
30 seq_printf(s, "%s\n", sn_system_serial_number());
34 static int system_serial_number_open(struct inode *inode, struct file *file)
36 return single_open(file, system_serial_number_show, NULL);
39 static int licenseID_show(struct seq_file *s, void *p)
41 seq_printf(s, "0x%lx\n", sn_partition_serial_number_val());
45 static int licenseID_open(struct inode *inode, struct file *file)
47 return single_open(file, licenseID_show, NULL);
51 * Enable forced interrupt by default.
52 * When set, the sn interrupt handler writes the force interrupt register on
53 * the bridge chip. The hardware will then send an interrupt message if the
54 * interrupt line is active. This mimics a level sensitive interrupt.
56 int sn_force_interrupt_flag = 1;
58 static int sn_force_interrupt_show(struct seq_file *s, void *p)
60 seq_printf(s, "Force interrupt is %s\n",
61 sn_force_interrupt_flag ? "enabled" : "disabled");
65 static ssize_t sn_force_interrupt_write_proc(struct file *file,
66 const __user char *buffer, size_t count, loff_t *data)
68 sn_force_interrupt_flag = (*buffer == '0') ? 0 : 1;
72 static int sn_force_interrupt_open(struct inode *inode, struct file *file)
74 return single_open(file, sn_force_interrupt_show, NULL);
77 static int coherence_id_show(struct seq_file *s, void *p)
79 seq_printf(s, "%d\n", cpuid_to_coherence_id(smp_processor_id()));
83 static int coherence_id_open(struct inode *inode, struct file *file)
85 return single_open(file, coherence_id_show, NULL);
88 static struct proc_dir_entry *sn_procfs_create_entry(
89 const char *name, struct proc_dir_entry *parent,
90 int (*openfunc)(struct inode *, struct file *),
91 int (*releasefunc)(struct inode *, struct file *))
93 struct proc_dir_entry *e = create_proc_entry(name, 0444, parent);
96 e->proc_fops = (struct file_operations *)kmalloc(
97 sizeof(struct file_operations), GFP_KERNEL);
99 memset(e->proc_fops, 0, sizeof(struct file_operations));
100 e->proc_fops->open = openfunc;
101 e->proc_fops->read = seq_read;
102 e->proc_fops->llseek = seq_lseek;
103 e->proc_fops->release = releasefunc;
110 /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
111 extern int sn_topology_open(struct inode *, struct file *);
112 extern int sn_topology_release(struct inode *, struct file *);
114 void register_sn_procfs(void)
116 static struct proc_dir_entry *sgi_proc_dir = NULL;
117 struct proc_dir_entry *e;
119 BUG_ON(sgi_proc_dir != NULL);
120 if (!(sgi_proc_dir = proc_mkdir("sgi_sn", 0)))
123 sn_procfs_create_entry("partition_id", sgi_proc_dir,
124 partition_id_open, single_release);
126 sn_procfs_create_entry("system_serial_number", sgi_proc_dir,
127 system_serial_number_open, single_release);
129 sn_procfs_create_entry("licenseID", sgi_proc_dir,
130 licenseID_open, single_release);
132 e = sn_procfs_create_entry("sn_force_interrupt", sgi_proc_dir,
133 sn_force_interrupt_open, single_release);
135 e->proc_fops->write = sn_force_interrupt_write_proc;
137 sn_procfs_create_entry("coherence_id", sgi_proc_dir,
138 coherence_id_open, single_release);
140 sn_procfs_create_entry("sn_topology", sgi_proc_dir,
141 sn_topology_open, sn_topology_release);
144 #endif /* CONFIG_PROC_FS */