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();
56 /* proc function to write EEPROM after changing int entry */
57 int proc_dolasatint(struct ctl_table *table, int write,
58 void *buffer, size_t *lenp, loff_t *ppos)
62 r = proc_dointvec(table, write, buffer, lenp, ppos);
66 lasat_write_eeprom_info();
74 /* proc function to read/write RealTime Clock */
75 int proc_dolasatrtc(struct ctl_table *table, int write,
76 void *buffer, size_t *lenp, loff_t *ppos)
82 read_persistent_clock(&ts);
84 /* check for time < 0 and set to 0 */
88 r = proc_dointvec(table, write, buffer, lenp, ppos);
93 rtc_mips_set_mmss(rtctmp);
100 int proc_lasat_ip(struct ctl_table *table, int write,
101 void *buffer, size_t *lenp, loff_t *ppos)
108 if (!table->data || !table->maxlen || !*lenp ||
117 while (len < *lenp) {
118 if (get_user(c, p++))
120 if (c == 0 || c == '\n')
124 if (len >= sizeof(ipbuf)-1)
125 len = sizeof(ipbuf) - 1;
126 if (copy_from_user(ipbuf, buffer, len))
130 /* Now see if we can convert it to a valid IP */
132 *(unsigned int *)(table->data) = ip;
133 lasat_write_eeprom_info();
135 ip = *(unsigned int *)(table->data);
136 sprintf(ipbuf, "%d.%d.%d.%d",
145 if (copy_to_user(buffer, ipbuf, len))
148 if (put_user('\n', ((char *) buffer) + len))
160 int proc_lasat_prid(struct ctl_table *table, int write,
161 void *buffer, size_t *lenp, loff_t *ppos)
165 r = proc_dointvec(table, write, buffer, lenp, ppos);
169 lasat_board_info.li_eeprom_info.prid =
170 lasat_board_info.li_prid;
171 lasat_write_eeprom_info();
172 lasat_init_board_info();
177 extern int lasat_boot_to_service;
179 static struct ctl_table lasat_table[] = {
181 .procname = "cpu-hz",
182 .data = &lasat_board_info.li_cpu_hz,
183 .maxlen = sizeof(int),
185 .proc_handler = proc_dointvec,
188 .procname = "bus-hz",
189 .data = &lasat_board_info.li_bus_hz,
190 .maxlen = sizeof(int),
192 .proc_handler = proc_dointvec,
196 .data = &lasat_board_info.li_bmid,
197 .maxlen = sizeof(int),
199 .proc_handler = proc_dointvec,
203 .data = &lasat_board_info.li_prid,
204 .maxlen = sizeof(int),
206 .proc_handler = proc_lasat_prid,
210 .procname = "ipaddr",
211 .data = &lasat_board_info.li_eeprom_info.ipaddr,
212 .maxlen = sizeof(int),
214 .proc_handler = proc_lasat_ip,
217 .procname = "netmask",
218 .data = &lasat_board_info.li_eeprom_info.netmask,
219 .maxlen = sizeof(int),
221 .proc_handler = proc_lasat_ip,
225 .procname = "passwd_hash",
226 .data = &lasat_board_info.li_eeprom_info.passwd_hash,
228 sizeof(lasat_board_info.li_eeprom_info.passwd_hash),
230 .proc_handler = proc_dolasatstring,
233 .procname = "boot-service",
234 .data = &lasat_boot_to_service,
235 .maxlen = sizeof(int),
237 .proc_handler = proc_dointvec,
243 .maxlen = sizeof(int),
245 .proc_handler = proc_dolasatrtc,
249 .procname = "namestr",
250 .data = &lasat_board_info.li_namestr,
251 .maxlen = sizeof(lasat_board_info.li_namestr),
253 .proc_handler = proc_dostring,
256 .procname = "typestr",
257 .data = &lasat_board_info.li_typestr,
258 .maxlen = sizeof(lasat_board_info.li_typestr),
260 .proc_handler = proc_dostring,
265 static struct ctl_table lasat_root_table[] = {
274 static int __init lasat_register_sysctl(void)
276 struct ctl_table_header *lasat_table_header;
279 register_sysctl_table(lasat_root_table);
280 if (!lasat_table_header) {
281 printk(KERN_ERR "Unable to register LASAT sysctl\n");
288 __initcall(lasat_register_sysctl);