blob: 184902cde5764b151ddab88cea4dd62384023ae9 [file] [log] [blame]
wdenkb00ec162003-06-19 23:40:20 +00001/*
2 * (C) Copyright 2003
3 * Murray Jensen, CSIRO-MIT, <Murray.Jensen@csiro.au>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkb00ec162003-06-19 23:40:20 +00006 */
7
8#include <common.h>
9
wdenkb00ec162003-06-19 23:40:20 +000010int
11hymod_get_serno (const char *prompt)
12{
13 for (;;) {
14 int n, serno;
15 char *p;
16
17#ifdef CONFIG_BOOT_RETRY_TIME
18 reset_cmd_timeout ();
19#endif
20
21 n = readline (prompt);
22
23 if (n < 0)
24 return (n);
25
26 if (n == 0)
27 continue;
28
29 serno = (int) simple_strtol (console_buffer, &p, 10);
30
31 if (p > console_buffer && *p == '\0' && serno > 0)
32 return (serno);
33
34 printf ("Invalid number (%s) - please re-enter\n",
35 console_buffer);
36 }
37}
38
39int
40hymod_get_ethaddr (void)
41{
42 for (;;) {
43 int n;
44
45#ifdef CONFIG_BOOT_RETRY_TIME
46 reset_cmd_timeout ();
47#endif
48
49 n = readline ("Enter board ethernet address: ");
50
51 if (n < 0)
52 return (n);
53
54 if (n == 0)
55 continue;
56
57 if (n == 17) {
58 int i;
59 char *p, *q;
wdenkb00ec162003-06-19 23:40:20 +000060
61 /* see if it looks like an ethernet address */
62
63 p = console_buffer;
64
65 for (i = 0; i < 6; i++) {
66 char term = (i == 5 ? '\0' : ':');
67
Wolfgang Denk6f1cf052011-11-05 05:13:10 +000068 (void)simple_strtol (p, &q, 16);
wdenkb00ec162003-06-19 23:40:20 +000069
70 if ((q - p) != 2 || *q++ != term)
71 break;
72
73 p = q;
74 }
75
76 if (i == 6) {
77 /* it looks ok - set it */
78 printf ("Setting ethernet addr to %s\n",
79 console_buffer);
80
81 setenv ("ethaddr", console_buffer);
82
83 puts ("Remember to do a 'saveenv' to "
84 "make it permanent\n");
85
86 return (0);
87 }
88 }
89
90 printf ("Invalid ethernet addr (%s) - please re-enter\n",
91 console_buffer);
92 }
93}