blob: 43ddc2eccb965bd3c71d372e1afc6c53505babc4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 *
Russ Anderson5b9021b2005-08-17 10:00:00 -07006 * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9#ifdef CONFIG_PROC_FS
10#include <linux/proc_fs.h>
11#include <linux/seq_file.h>
Jes Sorensen8ed9b2c2006-02-13 05:29:57 -050012#include <asm/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/sn/sn_sal.h>
14
15static int partition_id_show(struct seq_file *s, void *p)
16{
Russ Anderson5b9021b2005-08-17 10:00:00 -070017 seq_printf(s, "%d\n", sn_partition_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 return 0;
19}
20
21static int partition_id_open(struct inode *inode, struct file *file)
22{
23 return single_open(file, partition_id_show, NULL);
24}
25
26static int system_serial_number_show(struct seq_file *s, void *p)
27{
28 seq_printf(s, "%s\n", sn_system_serial_number());
29 return 0;
30}
31
32static int system_serial_number_open(struct inode *inode, struct file *file)
33{
34 return single_open(file, system_serial_number_show, NULL);
35}
36
37static int licenseID_show(struct seq_file *s, void *p)
38{
39 seq_printf(s, "0x%lx\n", sn_partition_serial_number_val());
40 return 0;
41}
42
43static int licenseID_open(struct inode *inode, struct file *file)
44{
45 return single_open(file, licenseID_show, NULL);
46}
47
48/*
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.
53 */
Len Brownd0d59b92005-08-25 12:41:22 -040054extern int sn_force_interrupt_flag;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56static int sn_force_interrupt_show(struct seq_file *s, void *p)
57{
58 seq_printf(s, "Force interrupt is %s\n",
59 sn_force_interrupt_flag ? "enabled" : "disabled");
60 return 0;
61}
62
63static ssize_t sn_force_interrupt_write_proc(struct file *file,
64 const char __user *buffer, size_t count, loff_t *data)
65{
66 char val;
67
68 if (copy_from_user(&val, buffer, 1))
69 return -EFAULT;
70
71 sn_force_interrupt_flag = (val == '0') ? 0 : 1;
72 return count;
73}
74
75static int sn_force_interrupt_open(struct inode *inode, struct file *file)
76{
77 return single_open(file, sn_force_interrupt_show, NULL);
78}
79
80static int coherence_id_show(struct seq_file *s, void *p)
81{
82 seq_printf(s, "%d\n", partition_coherence_id());
83
84 return 0;
85}
86
87static int coherence_id_open(struct inode *inode, struct file *file)
88{
89 return single_open(file, coherence_id_show, NULL);
90}
91
Jes Sorensen8ed9b2c2006-02-13 05:29:57 -050092static struct proc_dir_entry
93*sn_procfs_create_entry(const char *name, struct proc_dir_entry *parent,
94 int (*openfunc)(struct inode *, struct file *),
Andrew Mortonec1b9462006-03-28 01:56:40 -080095 int (*releasefunc)(struct inode *, struct file *),
96 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *))
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
98 struct proc_dir_entry *e = create_proc_entry(name, 0444, parent);
99
100 if (e) {
Andrew Mortonec1b9462006-03-28 01:56:40 -0800101 struct file_operations *f;
102
103 f = kzalloc(sizeof(*f), GFP_KERNEL);
104 if (f) {
105 f->open = openfunc;
106 f->read = seq_read;
107 f->llseek = seq_lseek;
108 f->release = releasefunc;
109 f->write = write;
110 e->proc_fops = f;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 }
112 }
113
114 return e;
115}
116
117/* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
118extern int sn_topology_open(struct inode *, struct file *);
119extern int sn_topology_release(struct inode *, struct file *);
120
121void register_sn_procfs(void)
122{
123 static struct proc_dir_entry *sgi_proc_dir = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
125 BUG_ON(sgi_proc_dir != NULL);
126 if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
127 return;
128
129 sn_procfs_create_entry("partition_id", sgi_proc_dir,
Andrew Mortonec1b9462006-03-28 01:56:40 -0800130 partition_id_open, single_release, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132 sn_procfs_create_entry("system_serial_number", sgi_proc_dir,
Andrew Mortonec1b9462006-03-28 01:56:40 -0800133 system_serial_number_open, single_release, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
135 sn_procfs_create_entry("licenseID", sgi_proc_dir,
Andrew Mortonec1b9462006-03-28 01:56:40 -0800136 licenseID_open, single_release, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Andrew Mortonec1b9462006-03-28 01:56:40 -0800138 sn_procfs_create_entry("sn_force_interrupt", sgi_proc_dir,
139 sn_force_interrupt_open, single_release,
140 sn_force_interrupt_write_proc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142 sn_procfs_create_entry("coherence_id", sgi_proc_dir,
Andrew Mortonec1b9462006-03-28 01:56:40 -0800143 coherence_id_open, single_release, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145 sn_procfs_create_entry("sn_topology", sgi_proc_dir,
Andrew Mortonec1b9462006-03-28 01:56:40 -0800146 sn_topology_open, sn_topology_release, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147}
148
149#endif /* CONFIG_PROC_FS */