1
2
3
4
5
6
7#include <common.h>
8#include <spl.h>
9
10static int spl_nor_load_image(struct spl_image_info *spl_image,
11 struct spl_boot_device *bootdev)
12{
13 int ret;
14
15
16
17
18 spl_image->flags |= SPL_COPY_PAYLOAD_ONLY;
19
20#ifdef CONFIG_SPL_OS_BOOT
21 if (!spl_start_uboot()) {
22 const struct image_header *header;
23
24
25
26
27
28 header = (const struct image_header *)CONFIG_SYS_OS_BASE;
29
30 if (image_get_os(header) == IH_OS_LINUX) {
31
32
33 ret = spl_parse_image_header(spl_image, header);
34 if (ret)
35 return ret;
36
37 memcpy((void *)spl_image->load_addr,
38 (void *)(CONFIG_SYS_OS_BASE +
39 sizeof(struct image_header)),
40 spl_image->size);
41
42 spl_image->arg = (void *)CONFIG_SYS_FDT_BASE;
43
44 return 0;
45 } else {
46 puts("The Expected Linux image was not found.\n"
47 "Please check your NOR configuration.\n"
48 "Trying to start u-boot now...\n");
49 }
50 }
51#endif
52
53
54
55
56
57 ret = spl_parse_image_header(spl_image,
58 (const struct image_header *)CONFIG_SYS_UBOOT_BASE);
59 if (ret)
60 return ret;
61
62 memcpy((void *)(unsigned long)spl_image->load_addr,
63 (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
64 spl_image->size);
65
66 return 0;
67}
68SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image);
69