3 * Copyright (C) 2001 Kyle A. Lucke IBM Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include <linux/init.h>
20 #include <asm/uaccess.h>
21 #include <asm/iSeries/mf.h>
23 static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
24 int count, int *eof, void *data)
29 len = mf_getCmdLine(page, &len, (u64)data);
33 if ((*p == 0) || (*p == ' '))
58 static int proc_mf_dump_vmlinux(char *page, char **start, off_t off,
59 int count, int *eof, void *data)
61 int sizeToGet = count;
63 if (!capable(CAP_SYS_ADMIN))
66 if (mf_getVmlinuxChunk(page, &sizeToGet, off, (u64)data) == 0) {
79 static int proc_mf_dump_side(char *page, char **start, off_t off,
80 int count, int *eof, void *data)
83 char mf_current_side = mf_getSide();
85 len = sprintf(page, "%c\n", mf_current_side);
87 if (len <= (off + count))
98 static int proc_mf_change_side(struct file *file, const char __user *buffer,
99 unsigned long count, void *data)
103 if (!capable(CAP_SYS_ADMIN))
106 if (count > (sizeof(stkbuf) - 1))
107 count = sizeof(stkbuf) - 1;
108 if (copy_from_user(stkbuf, buffer, count))
111 if ((*stkbuf != 'A') && (*stkbuf != 'B') &&
112 (*stkbuf != 'C') && (*stkbuf != 'D')) {
113 printk(KERN_ERR "mf_proc.c: proc_mf_change_side: invalid side\n");
122 static int proc_mf_dump_src(char *page, char **start, off_t off,
123 int count, int *eof, void *data)
127 mf_getSrcHistory(page, count);
140 static int proc_mf_change_src(struct file *file, const char __user *buffer,
141 unsigned long count, void *data)
145 if (!capable(CAP_SYS_ADMIN))
148 if ((count < 4) && (count != 1)) {
149 printk(KERN_ERR "mf_proc: invalid src\n");
153 if (count > (sizeof(stkbuf) - 1))
154 count = sizeof(stkbuf) - 1;
155 if (copy_from_user(stkbuf, buffer, count))
158 if ((count == 1) && (*stkbuf == '\0'))
161 mf_displaySrc(*(u32 *)stkbuf);
166 static int proc_mf_change_cmdline(struct file *file, const char *buffer,
167 unsigned long count, void *data)
169 if (!capable(CAP_SYS_ADMIN))
172 mf_setCmdLine(buffer, count, (u64)data);
177 static int proc_mf_change_vmlinux(struct file *file, const char *buffer,
178 unsigned long count, void *data)
181 if (!capable(CAP_SYS_ADMIN))
184 rc = mf_setVmlinuxChunk(buffer, count, file->f_pos, (u64)data);
188 file->f_pos += count;
193 static int __init mf_proc_init(void)
195 struct proc_dir_entry *mf_proc_root;
196 struct proc_dir_entry *ent;
197 struct proc_dir_entry *mf;
201 mf_proc_root = proc_mkdir("iSeries/mf", NULL);
206 for (i = 0; i < 4; i++) {
208 mf = proc_mkdir(name, mf_proc_root);
212 ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
216 ent->data = (void *)(long)i;
217 ent->read_proc = proc_mf_dump_cmdline;
218 ent->write_proc = proc_mf_change_cmdline;
220 if (i == 3) /* no vmlinux entry for 'D' */
223 ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf);
227 ent->data = (void *)(long)i;
231 * if we had a 'D' vmlinux entry, it would only
234 ent->read_proc = proc_mf_dump_vmlinux;
235 ent->write_proc = NULL;
239 ent->write_proc = proc_mf_change_vmlinux;
240 ent->read_proc = NULL;
244 ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
248 ent->data = (void *)0;
249 ent->read_proc = proc_mf_dump_side;
250 ent->write_proc = proc_mf_change_side;
252 ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
256 ent->data = (void *)0;
257 ent->read_proc = proc_mf_dump_src;
258 ent->write_proc = proc_mf_change_src;
263 __initcall(mf_proc_init);