1 // SPDX-License-Identifier: GPL-2.0+
5 #include <asm/u-boot.h>
10 int spl_load_image_ext(struct spl_image_info *spl_image,
11 struct blk_desc *block_dev, int partition,
15 struct image_header *header;
16 loff_t filelen, actlen;
17 disk_partition_t part_info = {};
19 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
20 sizeof(struct image_header));
22 if (part_get_info(block_dev, partition, &part_info)) {
23 printf("spl: no partition table found\n");
27 ext4fs_set_blk_dev(block_dev, &part_info);
29 err = ext4fs_mount(0);
31 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
32 printf("%s: ext4fs mount err - %d\n", __func__, err);
37 err = ext4fs_open(filename, &filelen);
39 puts("spl: ext4fs_open failed\n");
42 err = ext4fs_read((char *)header, 0, sizeof(struct image_header), &actlen);
44 puts("spl: ext4fs_read failed\n");
48 err = spl_parse_image_header(spl_image, header);
50 puts("spl: ext: failed to parse image header\n");
54 err = ext4fs_read((char *)spl_image->load_addr, 0, 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(struct spl_image_info *spl_image,
68 struct blk_desc *block_dev, int partition)
71 __maybe_unused loff_t filelen, actlen;
72 disk_partition_t part_info = {};
73 __maybe_unused char *file;
75 if (part_get_info(block_dev, 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);
89 #if defined(CONFIG_SPL_ENV_SUPPORT)
90 file = env_get("falcon_args_file");
92 err = ext4fs_open(file, &filelen);
94 puts("spl: ext4fs_open failed\n");
97 err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen);
99 printf("spl: error reading image %s, err - %d, falling back to default\n",
103 file = env_get("falcon_image_file");
105 err = spl_load_image_ext(spl_image, block_dev,
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, 0, 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(spl_image, block_dev, partition,
137 CONFIG_SPL_FS_LOAD_KERNEL_NAME);
140 int spl_load_image_ext_os(struct spl_image_info *spl_image,
141 struct blk_desc *block_dev, int partition)