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/sysctl.h>
24 #include <linux/stddef.h>
25 #include <linux/init.h>
27 #include <linux/ctype.h>
28 #include <linux/string.h>
29 #include <linux/net.h>
30 #include <linux/inet.h>
31 #include <linux/uaccess.h>
40 /* And the same for proc */
41 int proc_dolasatstring(struct ctl_table *table, int write,
42 void *buffer, size_t *lenp, loff_t *ppos)
46 r = proc_dostring(table, write, buffer, lenp, ppos);
50 lasat_write_eeprom_info();
58 /* proc function to read/write RealTime Clock */
59 int proc_dolasatrtc(struct ctl_table *table, int write,
60 void *buffer, size_t *lenp, loff_t *ppos)
66 read_persistent_clock64(&ts);
68 /* check for time < 0 and set to 0 */
72 r = proc_dointvec(table, write, buffer, lenp, ppos);
78 * Due to the RTC hardware limitation, we can not actually
79 * use the full 64-bit range here.
84 update_persistent_clock64(ts);
92 int proc_lasat_ip(struct ctl_table *table, int write,
93 void *buffer, size_t *lenp, loff_t *ppos)
100 if (!table->data || !table->maxlen || !*lenp ||
109 while (len < *lenp) {
110 if (get_user(c, p++))
112 if (c == 0 || c == '\n')
116 if (len >= sizeof(ipbuf)-1)
117 len = sizeof(ipbuf) - 1;
118 if (copy_from_user(ipbuf, buffer, len))
122 /* Now see if we can convert it to a valid IP */
124 *(unsigned int *)(table->data) = ip;
125 lasat_write_eeprom_info();
127 ip = *(unsigned int *)(table->data);
128 sprintf(ipbuf, "%d.%d.%d.%d",
137 if (copy_to_user(buffer, ipbuf, len))
140 if (put_user('\n', ((char *) buffer) + len))
152 int proc_lasat_prid(struct ctl_table *table, int write,
153 void *buffer, size_t *lenp, loff_t *ppos)
157 r = proc_dointvec(table, write, buffer, lenp, ppos);
161 lasat_board_info.li_eeprom_info.prid =
162 lasat_board_info.li_prid;
163 lasat_write_eeprom_info();
164 lasat_init_board_info();
169 extern int lasat_boot_to_service;
171 static struct ctl_table lasat_table[] = {
173 .procname = "cpu-hz",
174 .data = &lasat_board_info.li_cpu_hz,
175 .maxlen = sizeof(int),
177 .proc_handler = proc_dointvec,
180 .procname = "bus-hz",
181 .data = &lasat_board_info.li_bus_hz,
182 .maxlen = sizeof(int),
184 .proc_handler = proc_dointvec,
188 .data = &lasat_board_info.li_bmid,
189 .maxlen = sizeof(int),
191 .proc_handler = proc_dointvec,
195 .data = &lasat_board_info.li_prid,
196 .maxlen = sizeof(int),
198 .proc_handler = proc_lasat_prid,
202 .procname = "ipaddr",
203 .data = &lasat_board_info.li_eeprom_info.ipaddr,
204 .maxlen = sizeof(int),
206 .proc_handler = proc_lasat_ip,
209 .procname = "netmask",
210 .data = &lasat_board_info.li_eeprom_info.netmask,
211 .maxlen = sizeof(int),
213 .proc_handler = proc_lasat_ip,
217 .procname = "passwd_hash",
218 .data = &lasat_board_info.li_eeprom_info.passwd_hash,
220 sizeof(lasat_board_info.li_eeprom_info.passwd_hash),
222 .proc_handler = proc_dolasatstring,
225 .procname = "boot-service",
226 .data = &lasat_boot_to_service,
227 .maxlen = sizeof(int),
229 .proc_handler = proc_dointvec,
235 .maxlen = sizeof(int),
237 .proc_handler = proc_dolasatrtc,
241 .procname = "namestr",
242 .data = &lasat_board_info.li_namestr,
243 .maxlen = sizeof(lasat_board_info.li_namestr),
245 .proc_handler = proc_dostring,
248 .procname = "typestr",
249 .data = &lasat_board_info.li_typestr,
250 .maxlen = sizeof(lasat_board_info.li_typestr),
252 .proc_handler = proc_dostring,
257 static struct ctl_table lasat_root_table[] = {
266 static int __init lasat_register_sysctl(void)
268 struct ctl_table_header *lasat_table_header;
271 register_sysctl_table(lasat_root_table);
272 if (!lasat_table_header) {
273 printk(KERN_ERR "Unable to register LASAT sysctl\n");
280 arch_initcall(lasat_register_sysctl);