2019-09-16 03:09:31 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright 2019 NXP
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <image.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2019-09-16 03:09:31 +00:00
|
|
|
#include <linux/libfdt.h>
|
|
|
|
#include <spl.h>
|
2021-08-07 08:00:39 +00:00
|
|
|
#include <asm/mach-imx/image.h>
|
2019-09-16 03:09:31 +00:00
|
|
|
#include <asm/arch/sys_proto.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
/* Caller need ensure the offset and size to align with page size */
|
|
|
|
ulong spl_romapi_raw_seekable_read(u32 offset, u32 size, void *buf)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
debug("%s 0x%x, size 0x%x\n", __func__, offset, size);
|
|
|
|
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_download_image(buf, offset, size);
|
2021-08-07 08:00:39 +00:00
|
|
|
|
|
|
|
if (ret == ROM_API_OKAY)
|
|
|
|
return size;
|
|
|
|
|
|
|
|
printf("%s Failure when load 0x%x, size 0x%x\n", __func__, offset, size);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ulong __weak spl_romapi_get_uboot_base(u32 image_offset, u32 rom_bt_dev)
|
|
|
|
{
|
2022-03-09 16:09:45 +00:00
|
|
|
return image_offset +
|
|
|
|
(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000);
|
2021-08-07 08:00:39 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 03:09:31 +00:00
|
|
|
static int is_boot_from_stream_device(u32 boot)
|
|
|
|
{
|
|
|
|
u32 interface;
|
|
|
|
|
|
|
|
interface = boot >> 16;
|
|
|
|
if (interface >= BT_DEV_TYPE_USB)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (interface == BT_DEV_TYPE_MMC && (boot & 1))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ulong spl_romapi_read_seekable(struct spl_load_info *load,
|
|
|
|
ulong sector, ulong count,
|
|
|
|
void *buf)
|
|
|
|
{
|
|
|
|
u32 pagesize = *(u32 *)load->priv;
|
|
|
|
ulong byte = count * pagesize;
|
|
|
|
u32 offset;
|
|
|
|
|
|
|
|
offset = sector * pagesize;
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
return spl_romapi_raw_seekable_read(offset, byte, buf) / pagesize;
|
2019-09-16 03:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
|
|
|
|
struct spl_boot_device *bootdev,
|
|
|
|
u32 rom_bt_dev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
u32 offset;
|
|
|
|
u32 pagesize, size;
|
2022-09-07 02:26:52 +00:00
|
|
|
struct legacy_img_hdr *header;
|
2019-09-16 03:09:31 +00:00
|
|
|
u32 image_offset;
|
|
|
|
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset);
|
2023-07-02 01:03:51 +00:00
|
|
|
if (ret != ROM_API_OKAY)
|
|
|
|
goto err;
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2023-07-02 01:03:51 +00:00
|
|
|
ret = rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize);
|
|
|
|
if (ret != ROM_API_OKAY)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
ret = rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset);
|
|
|
|
if (ret != ROM_API_OKAY)
|
|
|
|
goto err;
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2022-09-07 02:26:52 +00:00
|
|
|
header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
|
|
|
printf("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n",
|
|
|
|
image_offset, pagesize, offset);
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
offset = spl_romapi_get_uboot_base(image_offset, rom_bt_dev);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2022-09-07 02:26:52 +00:00
|
|
|
size = ALIGN(sizeof(struct legacy_img_hdr), pagesize);
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_download_image((u8 *)header, offset, size);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
|
|
|
if (ret != ROM_API_OKAY) {
|
|
|
|
printf("ROMAPI: download failure offset 0x%x size 0x%x\n",
|
|
|
|
offset, size);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && image_get_magic(header) == FDT_MAGIC) {
|
2019-09-16 03:09:31 +00:00
|
|
|
struct spl_load_info load;
|
|
|
|
|
|
|
|
memset(&load, 0, sizeof(load));
|
|
|
|
load.bl_len = pagesize;
|
|
|
|
load.read = spl_romapi_read_seekable;
|
|
|
|
load.priv = &pagesize;
|
2021-08-07 08:00:39 +00:00
|
|
|
return spl_load_simple_fit(spl_image, &load, offset / pagesize, header);
|
|
|
|
} else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
|
|
|
|
struct spl_load_info load;
|
|
|
|
|
|
|
|
memset(&load, 0, sizeof(load));
|
|
|
|
load.bl_len = pagesize;
|
|
|
|
load.read = spl_romapi_read_seekable;
|
|
|
|
load.priv = &pagesize;
|
|
|
|
|
|
|
|
ret = spl_load_imx_container(spl_image, &load, offset / pagesize);
|
2019-09-16 03:09:31 +00:00
|
|
|
} else {
|
|
|
|
/* TODO */
|
|
|
|
puts("Can't support legacy image\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2023-07-02 01:03:51 +00:00
|
|
|
|
|
|
|
err:
|
|
|
|
puts("ROMAPI: Failure query boot infor pagesize/offset\n");
|
|
|
|
return -1;
|
2019-09-16 03:09:31 +00:00
|
|
|
}
|
|
|
|
|
imx: spl_imx_romapi: avoid tricky use of spl_load_simple_fit() to get full FIT size
Currently, spl_imx_romapi uses a somewhat tricky workaround for the
fact that a FIT image with external data doesn't directly allow one to
know the full size of the file: It does a dummy spl_load_simple_fit(),
having the ->read callback remember the largest offset requested, and
then does a last call to rom_api_download_image() to fetch the
remaining part of the full FIT image.
We can avoid that by just keeping track of how much we have downloaded
already, and if the ->read() requests something outside the current
valid buffer, fetch up to the end of the current request.
The current method also suffers from not working when CONFIG_IMX_HAB
is enabled: While in that case u-boot.itb is not built with external
data, so the fdt header does contain the full size of the dtb
structure. However, it does not account for the extra CONFIG_CSF_SIZE
added by board_spl_fit_size_align(). And also, the data it hands out
during the first dummy spl_load_simple_fit() is of course garbage, and
wouldn't pass the verification.
So we really need to call spl_load_simple_fit() only once, let that
figure out just how big the FIT image is (including whatever data, CSF
or "ordinary" external data, has been tacked on beyond the fdt
structure), and always provide valid data from the ->read callback.
This only affects the CONFIG_SPL_LOAD_FIT case - I don't have any
hardware or experience with the CONFIG_SPL_LOAD_IMX_CONTAINER case, so
I leave that alone for now.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Fabio Estevam <festevam@denx.de>
2023-09-19 13:49:31 +00:00
|
|
|
struct stream_state {
|
|
|
|
u8 *base;
|
|
|
|
u8 *end;
|
|
|
|
u32 pagesize;
|
|
|
|
};
|
|
|
|
|
|
|
|
static ulong spl_romapi_read_stream(struct spl_load_info *load, ulong sector,
|
|
|
|
ulong count, void *buf)
|
|
|
|
{
|
|
|
|
struct stream_state *ss = load->priv;
|
|
|
|
u8 *end = (u8*)(sector + count);
|
|
|
|
u32 bytes;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (end > ss->end) {
|
|
|
|
bytes = end - ss->end;
|
|
|
|
bytes += ss->pagesize - 1;
|
|
|
|
bytes /= ss->pagesize;
|
|
|
|
bytes *= ss->pagesize;
|
|
|
|
|
|
|
|
debug("downloading another 0x%x bytes\n", bytes);
|
|
|
|
ret = rom_api_download_image(ss->end, 0, bytes);
|
|
|
|
|
|
|
|
if (ret != ROM_API_OKAY) {
|
|
|
|
printf("Failure download %d\n", bytes);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ss->end = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(buf, (void *)(sector), count);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2019-09-16 03:09:31 +00:00
|
|
|
static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
|
|
|
|
ulong count, void *buf)
|
|
|
|
{
|
|
|
|
memcpy(buf, (void *)(sector), count);
|
|
|
|
|
|
|
|
if (load->priv) {
|
|
|
|
ulong *p = (ulong *)load->priv;
|
|
|
|
ulong total = sector + count;
|
|
|
|
|
|
|
|
if (total > *p)
|
|
|
|
*p = total;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ulong get_fit_image_size(void *fit)
|
|
|
|
{
|
|
|
|
struct spl_image_info spl_image;
|
|
|
|
struct spl_load_info spl_load_info;
|
|
|
|
ulong last = (ulong)fit;
|
|
|
|
|
|
|
|
memset(&spl_load_info, 0, sizeof(spl_load_info));
|
|
|
|
spl_load_info.bl_len = 1;
|
|
|
|
spl_load_info.read = spl_ram_load_read;
|
|
|
|
spl_load_info.priv = &last;
|
|
|
|
|
|
|
|
spl_load_simple_fit(&spl_image, &spl_load_info,
|
|
|
|
(uintptr_t)fit, fit);
|
|
|
|
|
|
|
|
return last - (ulong)fit;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
static u8 *search_fit_header(u8 *p, int size)
|
2019-09-16 03:09:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i += 4)
|
|
|
|
if (genimg_get_format(p + i) == IMAGE_FORMAT_FIT)
|
|
|
|
return p + i;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
static u8 *search_container_header(u8 *p, int size)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
u8 *hdr;
|
|
|
|
|
|
|
|
for (i = 0; i < size; i += 4) {
|
|
|
|
hdr = p + i;
|
|
|
|
if (*(hdr + 3) == 0x87 && *hdr == 0 && (*(hdr + 1) != 0 || *(hdr + 2) != 0))
|
|
|
|
return p + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 *search_img_header(u8 *p, int size)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
|
|
|
|
return search_fit_header(p, size);
|
|
|
|
else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER))
|
|
|
|
return search_container_header(p, size);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 img_header_size(void)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
|
|
|
|
return sizeof(struct fdt_header);
|
|
|
|
else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER))
|
|
|
|
return sizeof(struct container_hdr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int img_info_size(void *img_hdr)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SPL_LOAD_FIT
|
|
|
|
return fit_get_size(img_hdr);
|
|
|
|
#elif defined CONFIG_SPL_LOAD_IMX_CONTAINER
|
|
|
|
struct container_hdr *container = img_hdr;
|
|
|
|
|
|
|
|
return (container->length_lsb + (container->length_msb << 8));
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int img_total_size(void *img_hdr)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
|
|
|
|
return get_fit_image_size(img_hdr);
|
|
|
|
} else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) {
|
|
|
|
int total = get_container_size((ulong)img_hdr, NULL);
|
|
|
|
|
|
|
|
if (total < 0) {
|
|
|
|
printf("invalid container image\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-09-16 03:09:31 +00:00
|
|
|
static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,
|
|
|
|
struct spl_boot_device *bootdev)
|
|
|
|
{
|
|
|
|
struct spl_load_info load;
|
|
|
|
u32 pagesize, pg;
|
|
|
|
int ret;
|
|
|
|
int i = 0;
|
|
|
|
u8 *p = (u8 *)CONFIG_SPL_IMX_ROMAPI_LOADADDR;
|
2021-08-07 08:00:39 +00:00
|
|
|
u8 *phdr = NULL;
|
2019-09-16 03:09:31 +00:00
|
|
|
int imagesize;
|
|
|
|
int total;
|
|
|
|
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
|
|
|
if (ret != ROM_API_OKAY)
|
|
|
|
puts("failure at query_boot_info\n");
|
|
|
|
|
|
|
|
pg = pagesize;
|
|
|
|
if (pg < 1024)
|
|
|
|
pg = 1024;
|
|
|
|
|
|
|
|
for (i = 0; i < 640; i++) {
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_download_image(p, 0, pg);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
|
|
|
if (ret != ROM_API_OKAY) {
|
|
|
|
puts("Steam(USB) download failure\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
phdr = search_img_header(p, pg);
|
2019-09-16 03:09:31 +00:00
|
|
|
p += pg;
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
if (phdr)
|
2019-09-16 03:09:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
if (!phdr) {
|
|
|
|
puts("Can't found uboot image in 640K range\n");
|
2019-09-16 03:09:31 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
if (p - phdr < img_header_size()) {
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_download_image(p, 0, pg);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
|
|
|
if (ret != ROM_API_OKAY) {
|
|
|
|
puts("Steam(USB) download failure\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
p += pg;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
imagesize = img_info_size(phdr);
|
2022-07-20 07:27:55 +00:00
|
|
|
printf("Find img info 0x%p, size %d\n", phdr, imagesize);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
if (p - phdr < imagesize) {
|
|
|
|
imagesize -= p - phdr;
|
2019-09-16 03:09:31 +00:00
|
|
|
/*need pagesize hear after ROM fix USB problme*/
|
|
|
|
imagesize += pg - 1;
|
|
|
|
imagesize /= pg;
|
|
|
|
imagesize *= pg;
|
|
|
|
|
|
|
|
printf("Need continue download %d\n", imagesize);
|
|
|
|
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_download_image(p, 0, imagesize);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
|
|
|
p += imagesize;
|
|
|
|
|
|
|
|
if (ret != ROM_API_OKAY) {
|
|
|
|
printf("Failure download %d\n", imagesize);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
imx: spl_imx_romapi: avoid tricky use of spl_load_simple_fit() to get full FIT size
Currently, spl_imx_romapi uses a somewhat tricky workaround for the
fact that a FIT image with external data doesn't directly allow one to
know the full size of the file: It does a dummy spl_load_simple_fit(),
having the ->read callback remember the largest offset requested, and
then does a last call to rom_api_download_image() to fetch the
remaining part of the full FIT image.
We can avoid that by just keeping track of how much we have downloaded
already, and if the ->read() requests something outside the current
valid buffer, fetch up to the end of the current request.
The current method also suffers from not working when CONFIG_IMX_HAB
is enabled: While in that case u-boot.itb is not built with external
data, so the fdt header does contain the full size of the dtb
structure. However, it does not account for the extra CONFIG_CSF_SIZE
added by board_spl_fit_size_align(). And also, the data it hands out
during the first dummy spl_load_simple_fit() is of course garbage, and
wouldn't pass the verification.
So we really need to call spl_load_simple_fit() only once, let that
figure out just how big the FIT image is (including whatever data, CSF
or "ordinary" external data, has been tacked on beyond the fdt
structure), and always provide valid data from the ->read callback.
This only affects the CONFIG_SPL_LOAD_FIT case - I don't have any
hardware or experience with the CONFIG_SPL_LOAD_IMX_CONTAINER case, so
I leave that alone for now.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Fabio Estevam <festevam@denx.de>
2023-09-19 13:49:31 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
|
|
|
|
struct stream_state ss;
|
|
|
|
|
|
|
|
ss.base = phdr;
|
|
|
|
ss.end = p;
|
|
|
|
ss.pagesize = pagesize;
|
|
|
|
|
|
|
|
memset(&load, 0, sizeof(load));
|
|
|
|
load.bl_len = 1;
|
|
|
|
load.read = spl_romapi_read_stream;
|
|
|
|
load.priv = &ss;
|
|
|
|
|
|
|
|
return spl_load_simple_fit(spl_image, &load, (ulong)phdr, phdr);
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
total = img_total_size(phdr);
|
2019-09-16 03:09:31 +00:00
|
|
|
total += 3;
|
|
|
|
total &= ~0x3;
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
imagesize = total - (p - phdr);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
|
|
|
imagesize += pagesize - 1;
|
|
|
|
imagesize /= pagesize;
|
|
|
|
imagesize *= pagesize;
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
printf("Download %d, Total size %d\n", imagesize, total);
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_download_image(p, 0, imagesize);
|
2019-09-16 03:09:31 +00:00
|
|
|
if (ret != ROM_API_OKAY)
|
|
|
|
printf("ROM download failure %d\n", imagesize);
|
|
|
|
|
|
|
|
memset(&load, 0, sizeof(load));
|
|
|
|
load.bl_len = 1;
|
|
|
|
load.read = spl_ram_load_read;
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
|
|
|
|
return spl_load_simple_fit(spl_image, &load, (ulong)phdr, phdr);
|
|
|
|
else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER))
|
|
|
|
return spl_load_imx_container(spl_image, &load, (ulong)phdr);
|
|
|
|
|
|
|
|
return -1;
|
2019-09-16 03:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int board_return_to_bootrom(struct spl_image_info *spl_image,
|
|
|
|
struct spl_boot_device *bootdev)
|
|
|
|
{
|
|
|
|
int ret;
|
2023-02-03 10:21:47 +00:00
|
|
|
u32 boot, bstage;
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2022-06-20 08:53:20 +00:00
|
|
|
ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot);
|
2023-07-02 01:03:51 +00:00
|
|
|
if (ret != ROM_API_OKAY)
|
|
|
|
goto err;
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2023-07-02 01:03:51 +00:00
|
|
|
ret = rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage);
|
|
|
|
if (ret != ROM_API_OKAY)
|
|
|
|
goto err;
|
2019-09-16 03:09:31 +00:00
|
|
|
|
2023-02-03 10:21:47 +00:00
|
|
|
printf("Boot Stage: ");
|
|
|
|
|
|
|
|
switch (bstage) {
|
|
|
|
case BT_STAGE_PRIMARY:
|
|
|
|
printf("Primary boot\n");
|
|
|
|
break;
|
|
|
|
case BT_STAGE_SECONDARY:
|
|
|
|
printf("Secondary boot\n");
|
|
|
|
break;
|
|
|
|
case BT_STAGE_RECOVERY:
|
|
|
|
printf("Recovery boot\n");
|
|
|
|
break;
|
|
|
|
case BT_STAGE_USB:
|
|
|
|
printf("USB boot\n");
|
|
|
|
break;
|
|
|
|
default:
|
2023-04-28 04:08:08 +00:00
|
|
|
printf("Unknown (0x%x)\n", bstage);
|
2023-02-03 10:21:47 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 03:09:31 +00:00
|
|
|
if (is_boot_from_stream_device(boot))
|
|
|
|
return spl_romapi_load_image_stream(spl_image, bootdev);
|
|
|
|
|
|
|
|
return spl_romapi_load_image_seekable(spl_image, bootdev, boot);
|
2023-07-02 01:03:51 +00:00
|
|
|
err:
|
|
|
|
puts("ROMAPI: failure at query_boot_info\n");
|
|
|
|
return -1;
|
2019-09-16 03:09:31 +00:00
|
|
|
}
|