60eefbac4a21eb79040bf010b1a9feb134e29327
[linux-flexiantxendom0-3.2.10.git] / arch / ia64 / sn / kernel / sn2 / sn_proc_fs.c
1 /*
2  *
3  * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
4  * 
5  * This program is free software; you can redistribute it and/or modify it 
6  * under the terms of version 2 of the GNU General Public License 
7  * as published by the Free Software Foundation.
8  * 
9  * This program is distributed in the hope that it would be useful, but 
10  * WITHOUT ANY WARRANTY; without even the implied warranty of 
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
12  * 
13  * Further, this software is distributed without any warranty that it is 
14  * free of the rightful claim of any third person regarding infringement 
15  * or the like.  Any license provided herein, whether implied or 
16  * otherwise, applies only to this software file.  Patent licenses, if 
17  * any, provided herein do not apply to combinations of this program with 
18  * other software, or any other product whatsoever.
19  * 
20  * You should have received a copy of the GNU General Public 
21  * License along with this program; if not, write the Free Software 
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23  * 
24  * Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 
25  * Mountain View, CA  94043, or:
26  * 
27  * http://www.sgi.com 
28  * 
29  * For further information regarding this notice, see: 
30  * 
31  * http://oss.sgi.com/projects/GenInfo/NoticeExplan
32  */
33 #include <linux/config.h>
34
35 #ifdef CONFIG_PROC_FS
36 #include <linux/proc_fs.h>
37 #include <asm/sn/sn_sal.h>
38
39
40 static int partition_id_read_proc(char *page, char **start, off_t off,
41                 int count, int *eof, void *data) {
42
43         return sprintf(page, "%d\n", sn_local_partid());
44 }
45
46 struct proc_dir_entry * sgi_proc_dir = NULL;
47
48 void
49 register_sn_partition_id(void) {
50         struct proc_dir_entry *entry;
51
52         if (!sgi_proc_dir) {
53                 sgi_proc_dir = proc_mkdir("sgi_sn", 0);
54         }
55         entry = create_proc_entry("partition_id", 0444, sgi_proc_dir);
56         if (entry) {
57                 entry->nlink = 1;
58                 entry->data = 0;
59                 entry->read_proc = partition_id_read_proc;
60                 entry->write_proc = NULL;
61         }
62 }
63
64 static int
65 system_serial_number_read_proc(char *page, char **start, off_t off,
66                 int count, int *eof, void *data) {
67         return sprintf(page, "%s\n", sn_system_serial_number());
68 }
69
70 static int
71 licenseID_read_proc(char *page, char **start, off_t off,
72                 int count, int *eof, void *data) {
73         return sprintf(page, "0x%lx\n",sn_partition_serial_number_val());
74 }
75
76 void
77 register_sn_serial_numbers(void) {
78         struct proc_dir_entry *entry;
79
80         if (!sgi_proc_dir) {
81                 sgi_proc_dir = proc_mkdir("sgi_sn", 0);
82         }
83         entry = create_proc_entry("system_serial_number", 0444, sgi_proc_dir);
84         if (entry) {
85                 entry->nlink = 1;
86                 entry->data = 0;
87                 entry->read_proc = system_serial_number_read_proc;
88                 entry->write_proc = NULL;
89         }
90         entry = create_proc_entry("licenseID", 0444, sgi_proc_dir);
91         if (entry) {
92                 entry->nlink = 1;
93                 entry->data = 0;
94                 entry->read_proc = licenseID_read_proc;
95                 entry->write_proc = NULL;
96         }
97 }
98
99 // Disable forced interrupts, but leave the code in, just in case.
100 int sn_force_interrupt_flag = 0;
101
102 static int
103 sn_force_interrupt_read_proc(char *page, char **start, off_t off,
104                 int count, int *eof, void *data) {
105         if (sn_force_interrupt_flag) {
106                 return sprintf(page, "Force interrupt is enabled\n");
107         }
108         return sprintf(page, "Force interrupt is disabled\n");
109 }
110
111 static int 
112 sn_force_interrupt_write_proc(struct file *file, const char *buffer,
113                                         unsigned long count, void *data)
114 {
115         if (*buffer == '0') {
116                 sn_force_interrupt_flag = 0;
117         } else {
118                 sn_force_interrupt_flag = 1;
119         }
120         return 1;
121 }
122
123 void
124 register_sn_force_interrupt(void) {
125         struct proc_dir_entry *entry;
126
127         if (!sgi_proc_dir) {
128                 sgi_proc_dir = proc_mkdir("sgi_sn", 0);
129         }
130         entry = create_proc_entry("sn_force_interrupt",0444, sgi_proc_dir);
131         if (entry) {
132                 entry->nlink = 1;
133                 entry->data = 0;
134                 entry->read_proc = sn_force_interrupt_read_proc;
135                 entry->write_proc = sn_force_interrupt_write_proc;
136         }
137 }
138 void
139 register_sn_procfs(void) {
140         register_sn_partition_id();
141         register_sn_serial_numbers();
142         register_sn_force_interrupt();
143 }
144
145 #endif /* CONFIG_PROC_FS */