blob: 730f88e0d602e21b552a7f8170095f3d88f322f8 [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
Simon Glassc0b6c9b2016-09-24 18:19:57 -060017int spl_net_load_image(struct spl_boot_device *bootdev)
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 }
Simon Glassc0b6c9b2016-09-24 18:19:57 -060030 if (bootdev->boot_device_name)
31 setenv("ethact", bootdev->boot_device_name);
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 }
Simon Glass6b2e4db2016-09-24 18:19:53 -060037 return spl_parse_image_header(&spl_image,
38 (struct image_header *)load_addr);
Ilya Yanokf7a2c552012-09-18 00:22:50 +000039}