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(struct blk_desc
*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 (part_get_info(block_dev
, 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 err
= spl_parse_image_header(header
);
53 puts("spl: ext4fs_read failed\n");
57 err
= ext4fs_read((char *)spl_image
.load_addr
, filelen
, &actlen
);
60 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
62 printf("%s: error reading image %s, err - %d\n",
63 __func__
, filename
, err
);
69 #ifdef CONFIG_SPL_OS_BOOT
70 int spl_load_image_ext_os(struct blk_desc
*block_dev
, int partition
)
73 __maybe_unused loff_t filelen
, actlen
;
74 disk_partition_t part_info
= {};
75 __maybe_unused
char *file
;
77 if (part_get_info(block_dev
, partition
, &part_info
)) {
78 printf("spl: no partition table found\n");
82 ext4fs_set_blk_dev(block_dev
, &part_info
);
84 err
= ext4fs_mount(0);
86 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
87 printf("%s: ext4fs mount err - %d\n", __func__
, err
);
92 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
93 file
= getenv("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
, filelen
, &actlen
);
102 printf("spl: error reading image %s, err - %d, falling back to default\n",
106 file
= getenv("falcon_image_file");
108 err
= spl_load_image_ext(block_dev
, partition
, file
);
110 puts("spl: falling back to default\n");
116 puts("spl: falcon_image_file not set in environment, falling back to default\n");
119 puts("spl: falcon_args_file not set in environment, falling back to default\n");
125 err
= ext4fs_open(CONFIG_SPL_FS_LOAD_ARGS_NAME
, &filelen
);
127 puts("spl: ext4fs_open failed\n");
129 err
= ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR
, filelen
, &actlen
);
131 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
132 printf("%s: error reading image %s, err - %d\n",
133 __func__
, CONFIG_SPL_FS_LOAD_ARGS_NAME
, err
);
138 return spl_load_image_ext(block_dev
, partition
,
139 CONFIG_SPL_FS_LOAD_KERNEL_NAME
);
142 int spl_load_image_ext_os(struct blk_desc
*block_dev
, int partition
)