blob: 63aa13c4a977e2fa20952e07725fa8a9c0a6a6c7 [file] [log] [blame]
wdenk6dd652f2003-06-19 23:40:20 +00001/*
2 * (C) Copyright 2003
3 * Murray Jensen, CSIRO-MIT, <Murray.Jensen@csiro.au>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25
26/* imports from common/main.c */
27extern char console_buffer[CFG_CBSIZE];
28
29int
30hymod_get_serno (const char *prompt)
31{
32 for (;;) {
33 int n, serno;
34 char *p;
35
36#ifdef CONFIG_BOOT_RETRY_TIME
37 reset_cmd_timeout ();
38#endif
39
40 n = readline (prompt);
41
42 if (n < 0)
43 return (n);
44
45 if (n == 0)
46 continue;
47
48 serno = (int) simple_strtol (console_buffer, &p, 10);
49
50 if (p > console_buffer && *p == '\0' && serno > 0)
51 return (serno);
52
53 printf ("Invalid number (%s) - please re-enter\n",
54 console_buffer);
55 }
56}
57
58int
59hymod_get_ethaddr (void)
60{
61 for (;;) {
62 int n;
63
64#ifdef CONFIG_BOOT_RETRY_TIME
65 reset_cmd_timeout ();
66#endif
67
68 n = readline ("Enter board ethernet address: ");
69
70 if (n < 0)
71 return (n);
72
73 if (n == 0)
74 continue;
75
76 if (n == 17) {
77 int i;
78 char *p, *q;
79 uchar ea[6];
80
81 /* see if it looks like an ethernet address */
82
83 p = console_buffer;
84
85 for (i = 0; i < 6; i++) {
86 char term = (i == 5 ? '\0' : ':');
87
88 ea[i] = simple_strtol (p, &q, 16);
89
90 if ((q - p) != 2 || *q++ != term)
91 break;
92
93 p = q;
94 }
95
96 if (i == 6) {
97 /* it looks ok - set it */
98 printf ("Setting ethernet addr to %s\n",
99 console_buffer);
100
101 setenv ("ethaddr", console_buffer);
102
103 puts ("Remember to do a 'saveenv' to "
104 "make it permanent\n");
105
106 return (0);
107 }
108 }
109
110 printf ("Invalid ethernet addr (%s) - please re-enter\n",
111 console_buffer);
112 }
113}