blob: f417d177eb100d172a3b250caafdd93a514c945c [file] [log] [blame]
Ilya Yanok7ac2fe22012-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 Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Ilya Yanok7ac2fe22012-09-18 00:22:50 +00009 */
10#include <common.h>
Nikita Kiryanov36afd452015-11-08 17:11:49 +020011#include <errno.h>
Ilya Yanok7ac2fe22012-09-18 00:22:50 +000012#include <spl.h>
13#include <net.h>
14
15DECLARE_GLOBAL_DATA_PTR;
16
Nikita Kiryanov36afd452015-11-08 17:11:49 +020017int spl_net_load_image(const char *device)
Ilya Yanok7ac2fe22012-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 Hershbergerd2eaec62015-03-22 17:09:06 -050025 rv = eth_initialize();
Ilya Yanok7ac2fe22012-09-18 00:22:50 +000026 if (rv == 0) {
27 printf("No Ethernet devices found\n");
Nikita Kiryanov36afd452015-11-08 17:11:49 +020028 return -ENODEV;
Ilya Yanok7ac2fe22012-09-18 00:22:50 +000029 }
30 if (device)
31 setenv("ethact", device);
Joe Hershbergerbc0571f2015-04-08 01:41:21 -050032 rv = net_loop(BOOTP);
Ilya Yanok7ac2fe22012-09-18 00:22:50 +000033 if (rv < 0) {
34 printf("Problem booting with BOOTP\n");
Nikita Kiryanov36afd452015-11-08 17:11:49 +020035 return rv;
Ilya Yanok7ac2fe22012-09-18 00:22:50 +000036 }
Simon Glass71316c12016-09-24 18:19:53 -060037 return spl_parse_image_header(&spl_image,
38 (struct image_header *)load_addr);
Ilya Yanok7ac2fe22012-09-18 00:22:50 +000039}