1 // SPDX-License-Identifier: GPL-2.0+
7 #include <asm/u-boot.h>
12 int spl_load_image_ext(struct spl_image_info *spl_image,
13 struct spl_boot_device *bootdev,
14 struct blk_desc *block_dev, int partition,
18 struct image_header *header;
19 loff_t filelen, actlen;
20 struct disk_partition part_info = {};
22 header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
24 if (part_get_info(block_dev, partition, &part_info)) {
25 printf("spl: no partition table found\n");
29 ext4fs_set_blk_dev(block_dev, &part_info);
31 err = ext4fs_mount(0);
33 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
34 printf("%s: ext4fs mount err - %d\n", __func__, err);
39 err = ext4fs_open(filename, &filelen);
41 puts("spl: ext4fs_open failed\n");
44 err = ext4fs_read((char *)header, 0, sizeof(struct image_header), &actlen);
46 puts("spl: ext4fs_read failed\n");
50 err = spl_parse_image_header(spl_image, bootdev, header);
52 puts("spl: ext: failed to parse image header\n");
56 err = ext4fs_read((char *)spl_image->load_addr, 0, filelen, &actlen);
59 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
61 printf("%s: error reading image %s, err - %d\n",
62 __func__, filename, err);
68 #if CONFIG_IS_ENABLED(OS_BOOT)
69 int spl_load_image_ext_os(struct spl_image_info *spl_image,
70 struct spl_boot_device *bootdev,
71 struct blk_desc *block_dev, int partition)
74 __maybe_unused loff_t filelen, actlen;
75 struct disk_partition part_info = {};
76 __maybe_unused char *file;
78 if (part_get_info(block_dev, partition, &part_info)) {
79 printf("spl: no partition table found\n");
83 ext4fs_set_blk_dev(block_dev, &part_info);
85 err = ext4fs_mount(0);
87 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
88 printf("%s: ext4fs mount err - %d\n", __func__, err);
92 #if defined(CONFIG_SPL_ENV_SUPPORT)
93 file = env_get("falcon_args_file");
95 err = ext4fs_open(file, &filelen);
97 puts("spl: ext4fs_open failed\n");
100 err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen);
102 printf("spl: error reading image %s, err - %d, falling back to default\n",
106 file = env_get("falcon_image_file");
108 err = spl_load_image_ext(spl_image, bootdev, block_dev,
111 puts("spl: falling back to default\n");
117 puts("spl: falcon_image_file not set in environment, falling back to default\n");
120 puts("spl: falcon_args_file not set in environment, falling back to default\n");
126 err = ext4fs_open(CONFIG_SPL_FS_LOAD_ARGS_NAME, &filelen);
128 puts("spl: ext4fs_open failed\n");
130 err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen);
132 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
133 printf("%s: error reading image %s, err - %d\n",
134 __func__, CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
139 return spl_load_image_ext(spl_image, bootdev, block_dev, partition,
140 CONFIG_SPL_FS_LOAD_KERNEL_NAME);
143 int spl_load_image_ext_os(struct spl_image_info *spl_image,
144 struct spl_boot_device *bootdev,
145 struct blk_desc *block_dev, int partition)