Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 9 | */ |
| 10 | #include <common.h> |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 11 | #include <errno.h> |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 12 | #include <spl.h> |
| 13 | #include <net.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
Simon Glass | c0b6c9b | 2016-09-24 18:19:57 -0600 | [diff] [blame^] | 17 | int spl_net_load_image(struct spl_boot_device *bootdev) |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 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); |
Joe Hershberger | 3dbe17e | 2015-03-22 17:09:06 -0500 | [diff] [blame] | 25 | rv = eth_initialize(); |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 26 | if (rv == 0) { |
| 27 | printf("No Ethernet devices found\n"); |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 28 | return -ENODEV; |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 29 | } |
Simon Glass | c0b6c9b | 2016-09-24 18:19:57 -0600 | [diff] [blame^] | 30 | if (bootdev->boot_device_name) |
| 31 | setenv("ethact", bootdev->boot_device_name); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 32 | rv = net_loop(BOOTP); |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 33 | if (rv < 0) { |
| 34 | printf("Problem booting with BOOTP\n"); |
Nikita Kiryanov | 33eefe4 | 2015-11-08 17:11:49 +0200 | [diff] [blame] | 35 | return rv; |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 36 | } |
Simon Glass | 6b2e4db | 2016-09-24 18:19:53 -0600 | [diff] [blame] | 37 | return spl_parse_image_header(&spl_image, |
| 38 | (struct image_header *)load_addr); |
Ilya Yanok | f7a2c55 | 2012-09-18 00:22:50 +0000 | [diff] [blame] | 39 | } |