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
= spl_get_load_buffer(-sizeof(*header
), sizeof(*header
));
21 if (part_get_info(block_dev
, partition
, &part_info
)) {
22 printf("spl: no partition table found\n");
26 ext4fs_set_blk_dev(block_dev
, &part_info
);
28 err
= ext4fs_mount(0);
30 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
31 printf("%s: ext4fs mount err - %d\n", __func__
, err
);
36 err
= ext4fs_open(filename
, &filelen
);
38 puts("spl: ext4fs_open failed\n");
41 err
= ext4fs_read((char *)header
, 0, sizeof(struct image_header
), &actlen
);
43 puts("spl: ext4fs_read failed\n");
47 err
= spl_parse_image_header(spl_image
, header
);
49 puts("spl: ext: failed to parse image header\n");
53 err
= ext4fs_read((char *)spl_image
->load_addr
, 0, filelen
, &actlen
);
56 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
58 printf("%s: error reading image %s, err - %d\n",
59 __func__
, filename
, err
);
65 #ifdef CONFIG_SPL_OS_BOOT
66 int spl_load_image_ext_os(struct spl_image_info
*spl_image
,
67 struct blk_desc
*block_dev
, int partition
)
70 __maybe_unused loff_t filelen
, actlen
;
71 disk_partition_t part_info
= {};
72 __maybe_unused
char *file
;
74 if (part_get_info(block_dev
, partition
, &part_info
)) {
75 printf("spl: no partition table found\n");
79 ext4fs_set_blk_dev(block_dev
, &part_info
);
81 err
= ext4fs_mount(0);
83 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
84 printf("%s: ext4fs mount err - %d\n", __func__
, err
);
88 #if defined(CONFIG_SPL_ENV_SUPPORT)
89 file
= env_get("falcon_args_file");
91 err
= ext4fs_open(file
, &filelen
);
93 puts("spl: ext4fs_open failed\n");
96 err
= ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR
, 0, filelen
, &actlen
);
98 printf("spl: error reading image %s, err - %d, falling back to default\n",
102 file
= env_get("falcon_image_file");
104 err
= spl_load_image_ext(spl_image
, block_dev
,
107 puts("spl: falling back to default\n");
113 puts("spl: falcon_image_file not set in environment, falling back to default\n");
116 puts("spl: falcon_args_file not set in environment, falling back to default\n");
122 err
= ext4fs_open(CONFIG_SPL_FS_LOAD_ARGS_NAME
, &filelen
);
124 puts("spl: ext4fs_open failed\n");
126 err
= ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR
, 0, filelen
, &actlen
);
128 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
129 printf("%s: error reading image %s, err - %d\n",
130 __func__
, CONFIG_SPL_FS_LOAD_ARGS_NAME
, err
);
135 return spl_load_image_ext(spl_image
, block_dev
, partition
,
136 CONFIG_SPL_FS_LOAD_KERNEL_NAME
);
139 int spl_load_image_ext_os(struct spl_image_info
*spl_image
,
140 struct blk_desc
*block_dev
, int partition
)