blob: ae71d26f0a61e730d88f6c0e93fc1358a6c5ec5a [file] [log] [blame]
Ilya Yanokf7a2c552012-09-18 00:22:50 +00001/*
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 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Ilya Yanokf7a2c552012-09-18 00:22:50 +00009 */
10#include <common.h>
Nikita Kiryanov33eefe42015-11-08 17:11:49 +020011#include <errno.h>
Ilya Yanokf7a2c552012-09-18 00:22:50 +000012#include <spl.h>
13#include <net.h>
14
15DECLARE_GLOBAL_DATA_PTR;
16
Nikita Kiryanov33eefe42015-11-08 17:11:49 +020017int spl_net_load_image(const char *device)
Ilya Yanokf7a2c552012-09-18 00:22:50 +000018{
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);
Joe Hershberger3dbe17e2015-03-22 17:09:06 -050025 rv = eth_initialize();
Ilya Yanokf7a2c552012-09-18 00:22:50 +000026 if (rv == 0) {
27 printf("No Ethernet devices found\n");
Nikita Kiryanov33eefe42015-11-08 17:11:49 +020028 return -ENODEV;
Ilya Yanokf7a2c552012-09-18 00:22:50 +000029 }
30 if (device)
31 setenv("ethact", device);
Joe Hershbergerc80b41b02015-04-08 01:41:21 -050032 rv = net_loop(BOOTP);
Ilya Yanokf7a2c552012-09-18 00:22:50 +000033 if (rv < 0) {
34 printf("Problem booting with BOOTP\n");
Nikita Kiryanov33eefe42015-11-08 17:11:49 +020035 return rv;
Ilya Yanokf7a2c552012-09-18 00:22:50 +000036 }
Marek Vasut02266e22016-04-29 00:44:54 +020037 return spl_parse_image_header((struct image_header *)load_addr);
Ilya Yanokf7a2c552012-09-18 00:22:50 +000038}