2 * Thomas Horsten <thh@lasat.com>
3 * Copyright (C) 2000 LASAT Networks A/S.
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 * Routines specific to the LASAT boards
20 #include <linux/types.h>
21 #include <asm/lasat/lasat.h>
23 #include <linux/module.h>
24 #include <linux/sysctl.h>
25 #include <linux/stddef.h>
26 #include <linux/init.h>
28 #include <linux/ctype.h>
29 #include <linux/string.h>
30 #include <linux/net.h>
31 #include <linux/inet.h>
32 #include <linux/uaccess.h>
41 /* And the same for proc */
42 int proc_dolasatstring(struct ctl_table *table, int write,
43 void *buffer, size_t *lenp, loff_t *ppos)
47 r = proc_dostring(table, write, buffer, lenp, ppos);
51 lasat_write_eeprom_info();
59 /* proc function to read/write RealTime Clock */
60 int proc_dolasatrtc(struct ctl_table *table, int write,
61 void *buffer, size_t *lenp, loff_t *ppos)
67 read_persistent_clock64(&ts);
69 /* check for time < 0 and set to 0 */
73 r = proc_dointvec(table, write, buffer, lenp, ppos);
78 rtc_mips_set_mmss(rtctmp);
85 int proc_lasat_ip(struct ctl_table *table, int write,
86 void *buffer, size_t *lenp, loff_t *ppos)
93 if (!table->data || !table->maxlen || !*lenp ||
102 while (len < *lenp) {
103 if (get_user(c, p++))
105 if (c == 0 || c == '\n')
109 if (len >= sizeof(ipbuf)-1)
110 len = sizeof(ipbuf) - 1;
111 if (copy_from_user(ipbuf, buffer, len))
115 /* Now see if we can convert it to a valid IP */
117 *(unsigned int *)(table->data) = ip;
118 lasat_write_eeprom_info();
120 ip = *(unsigned int *)(table->data);
121 sprintf(ipbuf, "%d.%d.%d.%d",
130 if (copy_to_user(buffer, ipbuf, len))
133 if (put_user('\n', ((char *) buffer) + len))
145 int proc_lasat_prid(struct ctl_table *table, int write,
146 void *buffer, size_t *lenp, loff_t *ppos)
150 r = proc_dointvec(table, write, buffer, lenp, ppos);
154 lasat_board_info.li_eeprom_info.prid =
155 lasat_board_info.li_prid;
156 lasat_write_eeprom_info();
157 lasat_init_board_info();
162 extern int lasat_boot_to_service;
164 static struct ctl_table lasat_table[] = {
166 .procname = "cpu-hz",
167 .data = &lasat_board_info.li_cpu_hz,
168 .maxlen = sizeof(int),
170 .proc_handler = proc_dointvec,
173 .procname = "bus-hz",
174 .data = &lasat_board_info.li_bus_hz,
175 .maxlen = sizeof(int),
177 .proc_handler = proc_dointvec,
181 .data = &lasat_board_info.li_bmid,
182 .maxlen = sizeof(int),
184 .proc_handler = proc_dointvec,
188 .data = &lasat_board_info.li_prid,
189 .maxlen = sizeof(int),
191 .proc_handler = proc_lasat_prid,
195 .procname = "ipaddr",
196 .data = &lasat_board_info.li_eeprom_info.ipaddr,
197 .maxlen = sizeof(int),
199 .proc_handler = proc_lasat_ip,
202 .procname = "netmask",
203 .data = &lasat_board_info.li_eeprom_info.netmask,
204 .maxlen = sizeof(int),
206 .proc_handler = proc_lasat_ip,
210 .procname = "passwd_hash",
211 .data = &lasat_board_info.li_eeprom_info.passwd_hash,
213 sizeof(lasat_board_info.li_eeprom_info.passwd_hash),
215 .proc_handler = proc_dolasatstring,
218 .procname = "boot-service",
219 .data = &lasat_boot_to_service,
220 .maxlen = sizeof(int),
222 .proc_handler = proc_dointvec,
228 .maxlen = sizeof(int),
230 .proc_handler = proc_dolasatrtc,
234 .procname = "namestr",
235 .data = &lasat_board_info.li_namestr,
236 .maxlen = sizeof(lasat_board_info.li_namestr),
238 .proc_handler = proc_dostring,
241 .procname = "typestr",
242 .data = &lasat_board_info.li_typestr,
243 .maxlen = sizeof(lasat_board_info.li_typestr),
245 .proc_handler = proc_dostring,
250 static struct ctl_table lasat_root_table[] = {
259 static int __init lasat_register_sysctl(void)
261 struct ctl_table_header *lasat_table_header;
264 register_sysctl_table(lasat_root_table);
265 if (!lasat_table_header) {
266 printk(KERN_ERR "Unable to register LASAT sysctl\n");
273 __initcall(lasat_register_sysctl);