]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | * | |
5b9021bc | 6 | * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved. |
1da177e4 | 7 | */ |
1da177e4 LT |
8 | |
9 | #ifdef CONFIG_PROC_FS | |
10 | #include <linux/proc_fs.h> | |
11 | #include <linux/seq_file.h> | |
8ed9b2c7 | 12 | #include <asm/uaccess.h> |
1da177e4 LT |
13 | #include <asm/sn/sn_sal.h> |
14 | ||
15 | static int partition_id_show(struct seq_file *s, void *p) | |
16 | { | |
5b9021bc | 17 | seq_printf(s, "%d\n", sn_partition_id); |
1da177e4 LT |
18 | return 0; |
19 | } | |
20 | ||
21 | static int partition_id_open(struct inode *inode, struct file *file) | |
22 | { | |
23 | return single_open(file, partition_id_show, NULL); | |
24 | } | |
25 | ||
26 | static 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 | ||
32 | static int system_serial_number_open(struct inode *inode, struct file *file) | |
33 | { | |
34 | return single_open(file, system_serial_number_show, NULL); | |
35 | } | |
36 | ||
37 | static 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 | ||
43 | static 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 | */ | |
d0d59b98 | 54 | extern int sn_force_interrupt_flag; |
1da177e4 LT |
55 | |
56 | static 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 | ||
63 | static 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 | ||
75 | static int sn_force_interrupt_open(struct inode *inode, struct file *file) | |
76 | { | |
77 | return single_open(file, sn_force_interrupt_show, NULL); | |
78 | } | |
79 | ||
80 | static 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 | ||
87 | static int coherence_id_open(struct inode *inode, struct file *file) | |
88 | { | |
89 | return single_open(file, coherence_id_show, NULL); | |
90 | } | |
91 | ||
8ed9b2c7 JS |
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 *), | |
ec1b9466 AM |
95 | int (*releasefunc)(struct inode *, struct file *), |
96 | ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *)) | |
1da177e4 LT |
97 | { |
98 | struct proc_dir_entry *e = create_proc_entry(name, 0444, parent); | |
99 | ||
100 | if (e) { | |
ec1b9466 AM |
101 | 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; | |
1da177e4 LT |
111 | } |
112 | } | |
113 | ||
114 | return e; | |
115 | } | |
116 | ||
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 *); | |
120 | ||
121 | void register_sn_procfs(void) | |
122 | { | |
123 | static struct proc_dir_entry *sgi_proc_dir = NULL; | |
1da177e4 LT |
124 | |
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, | |
ec1b9466 | 130 | partition_id_open, single_release, NULL); |
1da177e4 LT |
131 | |
132 | sn_procfs_create_entry("system_serial_number", sgi_proc_dir, | |
ec1b9466 | 133 | system_serial_number_open, single_release, NULL); |
1da177e4 LT |
134 | |
135 | sn_procfs_create_entry("licenseID", sgi_proc_dir, | |
ec1b9466 | 136 | licenseID_open, single_release, NULL); |
1da177e4 | 137 | |
ec1b9466 AM |
138 | sn_procfs_create_entry("sn_force_interrupt", sgi_proc_dir, |
139 | sn_force_interrupt_open, single_release, | |
140 | sn_force_interrupt_write_proc); | |
1da177e4 LT |
141 | |
142 | sn_procfs_create_entry("coherence_id", sgi_proc_dir, | |
ec1b9466 | 143 | coherence_id_open, single_release, NULL); |
1da177e4 LT |
144 | |
145 | sn_procfs_create_entry("sn_topology", sgi_proc_dir, | |
ec1b9466 | 146 | sn_topology_open, sn_topology_release, NULL); |
1da177e4 LT |
147 | } |
148 | ||
149 | #endif /* CONFIG_PROC_FS */ |