2 * SPDX-License-Identifier: GPL-2.0+
7 #include <asm/u-boot.h>
11 #ifdef CONFIG_SPL_EXT_SUPPORT
12 int spl_load_image_ext(block_dev_desc_t
*block_dev
,
17 struct image_header
*header
;
18 loff_t filelen
, actlen
;
19 disk_partition_t part_info
= {};
21 header
= (struct image_header
*)(CONFIG_SYS_TEXT_BASE
-
22 sizeof(struct image_header
));
24 if (get_partition_info(block_dev
,
25 partition
, &part_info
)) {
26 printf("spl: no partition table found\n");
30 ext4fs_set_blk_dev(block_dev
, &part_info
);
32 err
= ext4fs_mount(0);
34 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
35 printf("%s: ext4fs mount err - %d\n", __func__
, err
);
40 err
= ext4fs_open(filename
, &filelen
);
42 puts("spl: ext4fs_open failed\n");
45 err
= ext4fs_read((char *)header
, sizeof(struct image_header
), &actlen
);
47 puts("spl: ext4fs_read failed\n");
51 spl_parse_image_header(header
);
53 err
= ext4fs_read((char *)spl_image
.load_addr
, 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(block_dev_desc_t
*block_dev
, int partition
)
69 __maybe_unused loff_t filelen
, actlen
;
70 disk_partition_t part_info
= {};
71 __maybe_unused
char *file
;
73 if (get_partition_info(block_dev
,
74 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
);
89 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
90 file
= getenv("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
, filelen
, &actlen
);
99 printf("spl: error reading image %s, err - %d, falling back to default\n",
103 file
= getenv("falcon_image_file");
105 err
= spl_load_image_ext(block_dev
, partition
, file
);
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
, 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(block_dev
, partition
,
136 CONFIG_SPL_FS_LOAD_KERNEL_NAME
);