Add basic support for mini2440 board to barebox.
[barebox-mini2440.git] / commands / net.c
blob938463c7c4d08165ce812105a85e9a2537d874fb
1 /*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
6 * project.
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.
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.
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
24 /**
25 * @file
26 * @brief tftp, rarpboot, dhcp, nfs, cdp - Boot support
29 #include <common.h>
30 #include <command.h>
31 #include <environment.h>
32 #include <driver.h>
33 #include <net.h>
34 #include <fs.h>
35 #include <errno.h>
36 #include <libbb.h>
38 #ifdef CONFIG_NET_RARP
39 extern void RarpRequest(void);
41 static int do_rarpb(struct command *cmdtp, int argc, char *argv[])
43 int size;
45 if (NetLoopInit(RARP) < 0)
46 return 1;
48 NetOurIP = 0;
49 RarpRequest(); /* Basically same as BOOTP */
51 if ((size = NetLoop()) < 0)
52 return 1;
54 /* NetLoop ok, update environment */
55 netboot_update_env();
57 return 0;
60 BAREBOX_CMD_START(rarpboot)
61 .cmd = do_rarpb,
62 .usage = "boot image via network using rarp/tftp protocol",
63 BAREBOX_CMD_HELP("[loadAddress] [bootfilename]\n")
64 BAREBOX_CMD_END
65 #endif /* CONFIG_NET_RARP */
67 static int do_ethact(struct command *cmdtp, int argc, char *argv[])
69 struct eth_device *edev;
71 if (argc == 1) {
72 edev = eth_get_current();
73 if (edev)
74 printf("%s%d\n", edev->dev.name, edev->dev.id);
75 return 0;
78 if (argc != 2)
79 return COMMAND_ERROR_USAGE;
81 edev = eth_get_byname(argv[1]);
82 if (edev)
83 eth_set_current(edev);
84 else {
85 printf("no such net device: %s\n", argv[1]);
86 return 1;
89 return 0;
92 static const __maybe_unused char cmd_ethact_help[] =
93 "Usage: ethact [ethx]\n";
95 BAREBOX_CMD_START(ethact)
96 .cmd = do_ethact,
97 .usage = "set current ethernet device",
98 BAREBOX_CMD_HELP(cmd_ethact_help)
99 BAREBOX_CMD_END