boot: Add missing code for bootz_run()

The bootz method is special in that it uses its own implementation of
several of the bootm states.

The existing do_bootz() function calls bootz_run() but first does a few
other things. These are missing in the direct call to bootz_run(). I
probably missed this because bootz_start() sets up its own
struct bootm_info so I assumed it was independent. While the struct
itself is independent, changes to the images member (which is a pointer)
persist.

Move the required code into bootz_run()

This change was manually tested on an rpi2 with postmarketOS added,
using standard boot and also the 'bootz' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 47eda7e80e ("boot: pxe: Use bootm_...() functions where possible")
Reported-by: Svyatoslav Ryhel <clamor95@gmail.com>
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895
This commit is contained in:
Simon Glass
2025-04-09 09:57:21 -06:00
parent 5841e78ed6
commit 4a03fbc8bb
2 changed files with 36 additions and 62 deletions

View File

@@ -1185,6 +1185,39 @@ int bootm_run(struct bootm_info *bmi)
int bootz_run(struct bootm_info *bmi)
{
struct bootm_headers *images = bmi->images;
ulong zi_start, zi_end;
int ret;
ret = bootm_run_states(bmi, BOOTM_STATE_START);
if (ret)
return ret;
images->ep = bmi->addr_img ? hextoul(bmi->addr_img, NULL) :
image_load_addr;
ret = bootz_setup(images->ep, &zi_start, &zi_end);
if (ret)
return ret;
lmb_reserve(images->ep, zi_end - zi_start);
/*
* Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
* have a header that provide this informaiton.
*/
if (bootm_find_images(images->ep, bmi->conf_ramdisk, bmi->conf_fdt,
images->ep, zi_end - zi_start))
return -EINVAL;
/*
* We are doing the BOOTM_STATE_LOADOS state ourselves, so must
* disable interrupts ourselves
*/
bootm_disable_interrupts();
images->os.os = IH_OS_LINUX;
return boot_run(bmi, "bootz", 0);
}

View File

@@ -20,56 +20,6 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
return -1;
}
/*
* zImage booting support
*/
static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[], struct bootm_headers *images)
{
ulong zi_start, zi_end;
struct bootm_info bmi;
int ret;
bootm_init(&bmi);
if (argc)
bmi.addr_img = argv[0];
if (argc > 1)
bmi.conf_ramdisk = argv[1];
if (argc > 2)
bmi.conf_fdt = argv[2];
/* do not set up argc and argv[] since nothing uses them */
ret = bootm_run_states(&bmi, BOOTM_STATE_START);
/* Setup Linux kernel zImage entry point */
if (!argc) {
images->ep = image_load_addr;
debug("* kernel: default image load address = 0x%08lx\n",
image_load_addr);
} else {
images->ep = hextoul(argv[0], NULL);
debug("* kernel: cmdline image address = 0x%08lx\n",
images->ep);
}
ret = bootz_setup(images->ep, &zi_start, &zi_end);
if (ret != 0)
return 1;
lmb_reserve(images->ep, zi_end - zi_start);
/*
* Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
* have a header that provide this informaiton.
*/
if (bootm_find_images(image_load_addr, cmd_arg1(argc, argv),
cmd_arg2(argc, argv), images->ep,
zi_end - zi_start))
return 1;
return 0;
}
int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct bootm_info bmi;
@@ -78,17 +28,6 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
/* Consume 'bootz' */
argc--; argv++;
if (bootz_start(cmdtp, flag, argc, argv, &images))
return 1;
/*
* We are doing the BOOTM_STATE_LOADOS state ourselves, so must
* disable interrupts ourselves
*/
bootm_disable_interrupts();
images.os.os = IH_OS_LINUX;
bootm_init(&bmi);
if (argc)
bmi.addr_img = argv[0];
@@ -99,8 +38,10 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
bmi.cmd_name = "bootz";
ret = bootz_run(&bmi);
if (ret)
return CMD_RET_FAILURE;
return ret;
return 0;
}
U_BOOT_LONGHELP(bootz,