1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25
26int
27hymod_get_serno (const char *prompt)
28{
29 for (;;) {
30 int n, serno;
31 char *p;
32
33#ifdef CONFIG_BOOT_RETRY_TIME
34 reset_cmd_timeout ();
35#endif
36
37 n = readline (prompt);
38
39 if (n < 0)
40 return (n);
41
42 if (n == 0)
43 continue;
44
45 serno = (int) simple_strtol (console_buffer, &p, 10);
46
47 if (p > console_buffer && *p == '\0' && serno > 0)
48 return (serno);
49
50 printf ("Invalid number (%s) - please re-enter\n",
51 console_buffer);
52 }
53}
54
55int
56hymod_get_ethaddr (void)
57{
58 for (;;) {
59 int n;
60
61#ifdef CONFIG_BOOT_RETRY_TIME
62 reset_cmd_timeout ();
63#endif
64
65 n = readline ("Enter board ethernet address: ");
66
67 if (n < 0)
68 return (n);
69
70 if (n == 0)
71 continue;
72
73 if (n == 17) {
74 int i;
75 char *p, *q;
76
77
78
79 p = console_buffer;
80
81 for (i = 0; i < 6; i++) {
82 char term = (i == 5 ? '\0' : ':');
83
84 (void)simple_strtol (p, &q, 16);
85
86 if ((q - p) != 2 || *q++ != term)
87 break;
88
89 p = q;
90 }
91
92 if (i == 6) {
93
94 printf ("Setting ethernet addr to %s\n",
95 console_buffer);
96
97 setenv ("ethaddr", console_buffer);
98
99 puts ("Remember to do a 'saveenv' to "
100 "make it permanent\n");
101
102 return (0);
103 }
104 }
105
106 printf ("Invalid ethernet addr (%s) - please re-enter\n",
107 console_buffer);
108 }
109}
110