xref: /openbmc/u-boot/common/spl/spl_net.c (revision ee7bb5be)
1 /*
2  * (C) Copyright 2000-2004
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * (C) Copyright 2012
6  * Ilya Yanok <ilya.yanok@gmail.com>
7  *
8  * SPDX-License-Identifier:	GPL-2.0+
9  */
10 #include <common.h>
11 #include <errno.h>
12 #include <spl.h>
13 #include <net.h>
14 
15 DECLARE_GLOBAL_DATA_PTR;
16 
17 int spl_net_load_image(const char *device)
18 {
19 	int rv;
20 
21 	env_init();
22 	env_relocate();
23 	setenv("autoload", "yes");
24 	load_addr = CONFIG_SYS_TEXT_BASE - sizeof(struct image_header);
25 	rv = eth_initialize();
26 	if (rv == 0) {
27 		printf("No Ethernet devices found\n");
28 		return -ENODEV;
29 	}
30 	if (device)
31 		setenv("ethact", device);
32 	rv = net_loop(BOOTP);
33 	if (rv < 0) {
34 		printf("Problem booting with BOOTP\n");
35 		return rv;
36 	}
37 	return spl_parse_image_header((struct image_header *)load_addr);
38 }
39