2 * SPDX-License-Identifier: GPL-2.0+
7 #include <asm/u-boot.h>
12 #ifdef CONFIG_SPL_EXT_SUPPORT
13 int spl_load_image_ext(block_dev_desc_t *block_dev,
18 struct image_header *header;
19 loff_t filelen, actlen;
20 disk_partition_t part_info = {};
22 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
23 sizeof(struct image_header));
25 if (get_partition_info(block_dev,
26 partition, &part_info)) {
27 printf("spl: no partition table found\n");
31 ext4fs_set_blk_dev(block_dev, &part_info);
33 err = ext4fs_mount(0);
35 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
36 printf("%s: ext4fs mount err - %d\n", __func__, err);
41 err = ext4fs_open(filename, &filelen);
43 puts("spl: ext4fs_open failed\n");
46 err = ext4fs_read((char *)header, sizeof(struct image_header), &actlen);
48 puts("spl: ext4fs_read failed\n");
52 spl_parse_image_header(header);
54 err = ext4fs_read((char *)spl_image.load_addr, filelen, &actlen);
57 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
59 printf("%s: error reading image %s, err - %d\n",
60 __func__, filename, err);
66 #ifdef CONFIG_SPL_OS_BOOT
67 int spl_load_image_ext_os(block_dev_desc_t *block_dev, int partition)
70 __maybe_unused loff_t filelen, actlen;
71 disk_partition_t part_info = {};
72 __maybe_unused char *file;
74 if (get_partition_info(block_dev,
75 partition, &part_info)) {
76 printf("spl: no partition table found\n");
80 ext4fs_set_blk_dev(block_dev, &part_info);
82 err = ext4fs_mount(0);
84 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
85 printf("%s: ext4fs mount err - %d\n", __func__, err);
90 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
91 file = getenv("falcon_args_file");
93 err = ext4fs_open(file, &filelen);
95 puts("spl: ext4fs_open failed\n");
98 err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, filelen, &actlen);
100 printf("spl: error reading image %s, err - %d, falling back to default\n",
104 file = getenv("falcon_image_file");
106 err = spl_load_image_ext(block_dev, partition, file);
108 puts("spl: falling back to default\n");
114 puts("spl: falcon_image_file not set in environment, falling back to default\n");
117 puts("spl: falcon_args_file not set in environment, falling back to default\n");
123 err = ext4fs_open(CONFIG_SPL_FS_LOAD_ARGS_NAME, &filelen);
125 puts("spl: ext4fs_open failed\n");
127 err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, filelen, &actlen);
129 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
130 printf("%s: error reading image %s, err - %d\n",
131 __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
136 return spl_load_image_ext(block_dev, partition,
137 CONFIG_SPL_FS_LOAD_KERNEL_NAME);
140 int spl_load_image_ext_os(block_dev_desc_t *block_dev, int partition)