diff options
author | Simon Glass <sjg@chromium.org> | 2023-12-15 20:14:13 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-12-21 16:07:52 -0500 |
commit | a48336e5ea19ca0d32dfff1c4eaeececa8d2f570 (patch) | |
tree | f91a41bf86cfbfdb9163f55a024c9ce7946293ef | |
parent | c49216253d4357500a96b849bc3a02896093a9a9 (diff) | |
download | u-boot-a48336e5ea19ca0d32dfff1c4eaeececa8d2f570.zip u-boot-a48336e5ea19ca0d32dfff1c4eaeececa8d2f570.tar.gz u-boot-a48336e5ea19ca0d32dfff1c4eaeececa8d2f570.tar.bz2 |
bootm: Adjust arguments of boot_os_fn
Adjust boot_os_fn to use struct bootm_info instead of the separate
argc, argv and image parameters. Update the handlers accordingly. Few
of the functions make use of the arguments, so this improves code size
slightly.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
-rw-r--r-- | arch/arc/lib/bootm.c | 5 | ||||
-rw-r--r-- | arch/arm/lib/bootm.c | 6 | ||||
-rw-r--r-- | arch/m68k/lib/bootm.c | 5 | ||||
-rw-r--r-- | arch/microblaze/lib/bootm.c | 6 | ||||
-rw-r--r-- | arch/mips/lib/bootm.c | 6 | ||||
-rw-r--r-- | arch/nios2/lib/bootm.c | 10 | ||||
-rw-r--r-- | arch/powerpc/lib/bootm.c | 5 | ||||
-rw-r--r-- | arch/riscv/lib/bootm.c | 11 | ||||
-rw-r--r-- | arch/sandbox/lib/bootm.c | 5 | ||||
-rw-r--r-- | arch/sh/lib/bootm.c | 6 | ||||
-rw-r--r-- | arch/x86/lib/bootm.c | 6 | ||||
-rw-r--r-- | arch/xtensa/lib/bootm.c | 4 | ||||
-rw-r--r-- | boot/bootm.c | 11 | ||||
-rw-r--r-- | boot/bootm_os.c | 77 | ||||
-rw-r--r-- | include/bootm.h | 9 |
15 files changed, 100 insertions, 72 deletions
diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c index 44ec586..b143392 100644 --- a/arch/arc/lib/bootm.c +++ b/arch/arc/lib/bootm.c @@ -3,6 +3,7 @@ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. */ +#include <bootm.h> #include <bootstage.h> #include <env.h> #include <image.h> @@ -78,8 +79,10 @@ static void boot_jump_linux(struct bootm_headers *images, int flag) board_jump_and_run(kernel_entry, r0, 0, r2); } -int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + /* No need for those on ARC */ if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE)) return -1; diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index c562857..f30a483 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -12,6 +12,7 @@ */ #include <common.h> +#include <bootm.h> #include <bootstage.h> #include <command.h> #include <cpu_func.h> @@ -378,9 +379,10 @@ static void boot_jump_linux(struct bootm_headers *images, int flag) * DIFFERENCE: Instead of calling prep and go at the end * they are called if subcommand is equal 0. */ -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + /* No need for those on ARM */ if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) return -1; diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c index 79d8b34..f2d02e4 100644 --- a/arch/m68k/lib/bootm.c +++ b/arch/m68k/lib/bootm.c @@ -4,6 +4,7 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ +#include <bootm.h> #include <bootstage.h> #include <command.h> #include <env.h> @@ -34,9 +35,9 @@ void arch_lmb_reserve(struct lmb *lmb) arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 1024); } -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; int ret; struct bd_info *kbd; void (*kernel) (struct bd_info *, ulong, ulong, ulong, ulong); diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c index f3ec4b7..cbe9d85 100644 --- a/arch/microblaze/lib/bootm.c +++ b/arch/microblaze/lib/bootm.c @@ -7,6 +7,7 @@ * Yasushi SHOJI <yashi@atmark-techno.com> */ +#include <bootm.h> #include <bootstage.h> #include <command.h> #include <cpu_func.h> @@ -81,9 +82,10 @@ static void boot_prep_linux(struct bootm_headers *images) } } -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + images->cmdline_start = (ulong)env_get("bootargs"); /* cmdline init is the part of 'prep' and nothing to do for 'bdt' */ diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index f1cff69..286dbd5 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -4,6 +4,7 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ +#include <bootm.h> #include <bootstage.h> #include <env.h> #include <image.h> @@ -300,9 +301,10 @@ static void boot_jump_linux(struct bootm_headers *images) linux_extra); } -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + /* No need for those on MIPS */ if (flag & BOOTM_STATE_OS_BD_T) return -1; diff --git a/arch/nios2/lib/bootm.c b/arch/nios2/lib/bootm.c index 06c094d..657a17c 100644 --- a/arch/nios2/lib/bootm.c +++ b/arch/nios2/lib/bootm.c @@ -5,6 +5,7 @@ */ #include <common.h> +#include <bootm.h> #include <cpu_func.h> #include <env.h> #include <image.h> @@ -16,9 +17,9 @@ DECLARE_GLOBAL_DATA_PTR; #define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */ -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; void (*kernel)(int, int, int, char *) = (void *)images->ep; char *commandline = env_get("bootargs"); ulong initrd_start = images->rd_start; @@ -29,8 +30,9 @@ int do_bootm_linux(int flag, int argc, char *const argv[], if (images->ft_len) of_flat_tree = images->ft_addr; #endif - if (!of_flat_tree && argc > 1) - of_flat_tree = (char *)hextoul(argv[1], NULL); + /* TODO: Clean this up - the DT should already be set up */ + if (!of_flat_tree && bmi->argc > 1) + of_flat_tree = (char *)hextoul(bmi->argv[1], NULL); if (of_flat_tree) initrd_end = (ulong)of_flat_tree; diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c index 910121e..75c6bfd 100644 --- a/arch/powerpc/lib/bootm.c +++ b/arch/powerpc/lib/bootm.c @@ -8,6 +8,7 @@ #include <common.h> +#include <bootm.h> #include <bootstage.h> #include <cpu_func.h> #include <env.h> @@ -223,9 +224,9 @@ static int boot_body_linux(struct bootm_headers *images) return 0; } -noinline int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; int ret; if (flag & BOOTM_STATE_OS_CMDLINE) { diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index f9e1e18..13cbaab 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -7,6 +7,7 @@ */ #include <bootstage.h> +#include <bootm.h> #include <command.h> #include <dm.h> #include <fdt_support.h> @@ -105,9 +106,10 @@ static void boot_jump_linux(struct bootm_headers *images, int flag) } } -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + /* No need for those on RISC-V */ if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) return -1; @@ -127,10 +129,9 @@ int do_bootm_linux(int flag, int argc, char *const argv[], return 0; } -int do_bootm_vxworks(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_vxworks(int flag, struct bootm_info *bmi) { - return do_bootm_linux(flag, argc, argv, images); + return do_bootm_linux(flag, bmi); } static ulong get_sp(void) diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c index a748ba6..e56de90 100644 --- a/arch/sandbox/lib/bootm.c +++ b/arch/sandbox/lib/bootm.c @@ -5,6 +5,7 @@ */ #include <common.h> +#include <bootm.h> #include <bootstage.h> #include <image.h> #include <asm/io.h> @@ -64,8 +65,10 @@ static int boot_prep_linux(struct bootm_headers *images) return 0; } -int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + if (flag & BOOTM_STATE_OS_PREP) return boot_prep_linux(images); diff --git a/arch/sh/lib/bootm.c b/arch/sh/lib/bootm.c index b205e5e..05d586b 100644 --- a/arch/sh/lib/bootm.c +++ b/arch/sh/lib/bootm.c @@ -8,6 +8,7 @@ */ #include <common.h> +#include <bootm.h> #include <command.h> #include <env.h> #include <image.h> @@ -39,9 +40,10 @@ static unsigned long sh_check_cmd_arg(char *cmdline, char *key, int base) return val; } -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + /* Linux kernel load address */ void (*kernel) (void) = (void (*)(void))images->ep; /* empty_zero_page */ diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index 3196f9d..050c420 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -8,6 +8,7 @@ */ #include <common.h> +#include <bootm.h> #include <bootstage.h> #include <command.h> #include <efi.h> @@ -237,9 +238,10 @@ static int boot_jump_linux(struct bootm_headers *images) images->os.arch == IH_ARCH_X86_64); } -int do_bootm_linux(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + /* No need for those on x86 */ if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE) return -1; diff --git a/arch/xtensa/lib/bootm.c b/arch/xtensa/lib/bootm.c index fee3392..9780d46 100644 --- a/arch/xtensa/lib/bootm.c +++ b/arch/xtensa/lib/bootm.c @@ -5,6 +5,7 @@ */ #include <common.h> +#include <bootm.h> #include <bootstage.h> #include <command.h> #include <cpu_func.h> @@ -134,8 +135,9 @@ static struct bp_tag *setup_fdt_tag(struct bp_tag *params, void *fdt_start) * Boot Linux. */ -int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers *images) +int do_bootm_linux(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; struct bp_tag *params, *params_start; ulong initrd_start, initrd_end; char *commandline = env_get("bootargs"); diff --git a/boot/bootm.c b/boot/bootm.c index 8a0dba5..f1c45c3 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -6,6 +6,7 @@ #ifndef USE_HOSTCC #include <common.h> +#include <bootm.h> #include <bootstage.h> #include <cli.h> #include <command.h> @@ -1018,6 +1019,7 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], int states, struct bootm_headers *images, int boot_progress) { + struct bootm_info bmi; boot_os_fn *boot_fn; ulong iflag = 0; int ret = 0, need_boot_fn; @@ -1096,12 +1098,15 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, return 1; } + bmi.images = images; + bmi.argc = argc; + bmi.argv = argv; /* Call various other states that are not generally used */ if (!ret && (states & BOOTM_STATE_OS_CMDLINE)) - ret = boot_fn(BOOTM_STATE_OS_CMDLINE, argc, argv, images); + ret = boot_fn(BOOTM_STATE_OS_CMDLINE, &bmi); if (!ret && (states & BOOTM_STATE_OS_BD_T)) - ret = boot_fn(BOOTM_STATE_OS_BD_T, argc, argv, images); + ret = boot_fn(BOOTM_STATE_OS_BD_T, &bmi); if (!ret && (states & BOOTM_STATE_OS_PREP)) { ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX); if (ret) { @@ -1109,7 +1114,7 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, ret = CMD_RET_FAILURE; goto err; } - ret = boot_fn(BOOTM_STATE_OS_PREP, argc, argv, images); + ret = boot_fn(BOOTM_STATE_OS_PREP, &bmi); } #ifdef CONFIG_TRACE diff --git a/boot/bootm_os.c b/boot/bootm_os.c index b924221..4f547b1 100644 --- a/boot/bootm_os.c +++ b/boot/bootm_os.c @@ -23,9 +23,9 @@ DECLARE_GLOBAL_DATA_PTR; -static int do_bootm_standalone(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_standalone(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; int (*appl)(int, char *const[]); if (!env_get_autostart()) { @@ -33,7 +33,7 @@ static int do_bootm_standalone(int flag, int argc, char *const argv[], return 0; } appl = (int (*)(int, char * const []))images->ep; - appl(argc, argv); + appl(bmi->argc, bmi->argv); return 0; } @@ -64,9 +64,9 @@ static void __maybe_unused fit_unsupported_reset(const char *msg) } #ifdef CONFIG_BOOTM_NETBSD -static int do_bootm_netbsd(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_netbsd(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; void (*loader)(struct bd_info *bd, struct legacy_img_hdr *hdr, char *console, char *cmdline); struct legacy_img_hdr *os_hdr, *hdr; @@ -102,14 +102,14 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[], os_hdr = hdr; } - if (argc > 0) { + if (bmi->argc > 0) { ulong len; int i; - for (i = 0, len = 0; i < argc; i += 1) - len += strlen(argv[i]) + 1; + for (i = 0, len = 0; i < bmi->argc; i += 1) + len += strlen(bmi->argv[i]) + 1; cmdline = malloc(len); - copy_args(cmdline, argc, argv, ' '); + copy_args(cmdline, bmi->argc, bmi->argv, ' '); } else { cmdline = env_get("bootargs"); if (cmdline == NULL) @@ -137,9 +137,9 @@ static int do_bootm_netbsd(int flag, int argc, char *const argv[], #endif /* CONFIG_BOOTM_NETBSD*/ #ifdef CONFIG_BOOTM_RTEMS -static int do_bootm_rtems(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_rtems(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; void (*entry_point)(struct bd_info *); if (flag != BOOTM_STATE_OS_GO) @@ -170,9 +170,9 @@ static int do_bootm_rtems(int flag, int argc, char *const argv[], #endif /* CONFIG_BOOTM_RTEMS */ #if defined(CONFIG_BOOTM_OSE) -static int do_bootm_ose(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_ose(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; void (*entry_point)(void); if (flag != BOOTM_STATE_OS_GO) @@ -203,9 +203,9 @@ static int do_bootm_ose(int flag, int argc, char *const argv[], #endif /* CONFIG_BOOTM_OSE */ #if defined(CONFIG_BOOTM_PLAN9) -static int do_bootm_plan9(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_plan9(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; void (*entry_point)(void); char *s; @@ -224,8 +224,8 @@ static int do_bootm_plan9(int flag, int argc, char *const argv[], if (s != NULL) { char *confaddr = (char *)hextoul(s, NULL); - if (argc > 0) { - copy_args(confaddr, argc, argv, '\n'); + if (bmi->argc) { + copy_args(confaddr, bmi->argc, bmi->argv, '\n'); } else { s = env_get("bootargs"); if (s != NULL) @@ -311,9 +311,10 @@ static void do_bootvx_fdt(struct bootm_headers *images) puts("## vxWorks terminated\n"); } -static int do_bootm_vxworks_legacy(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_vxworks_legacy(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; + if (flag != BOOTM_STATE_OS_GO) return 0; @@ -322,8 +323,7 @@ static int do_bootm_vxworks_legacy(int flag, int argc, char *const argv[], return 1; } -int do_bootm_vxworks(int flag, int argc, char *const argv[], - struct bootm_headers *images) +int do_bootm_vxworks(int flag, struct bootm_info *bmi) { char *bootargs; int pos; @@ -348,19 +348,19 @@ int do_bootm_vxworks(int flag, int argc, char *const argv[], if (std_dtb) { if (flag & BOOTM_STATE_OS_PREP) printf(" Using standard DTB\n"); - return do_bootm_linux(flag, argc, argv, images); + return do_bootm_linux(flag, bmi); } else { if (flag & BOOTM_STATE_OS_PREP) printf(" !!! WARNING !!! Using legacy DTB\n"); - return do_bootm_vxworks_legacy(flag, argc, argv, images); + return do_bootm_vxworks_legacy(flag, bmi); } } #endif #if defined(CONFIG_CMD_ELF) -static int do_bootm_qnxelf(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_qnxelf(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; char *local_args[2]; char str[16]; int dcache; @@ -376,7 +376,7 @@ static int do_bootm_qnxelf(int flag, int argc, char *const argv[], #endif sprintf(str, "%lx", images->ep); /* write entry-point into string */ - local_args[0] = argv[0]; + local_args[0] = bmi->argv[0]; local_args[1] = str; /* and provide it via the arguments */ /* @@ -396,9 +396,9 @@ static int do_bootm_qnxelf(int flag, int argc, char *const argv[], #endif #ifdef CONFIG_INTEGRITY -static int do_bootm_integrity(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_integrity(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; void (*entry_point)(void); if (flag != BOOTM_STATE_OS_GO) @@ -429,9 +429,9 @@ static int do_bootm_integrity(int flag, int argc, char *const argv[], #endif #ifdef CONFIG_BOOTM_OPENRTOS -static int do_bootm_openrtos(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_openrtos(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; void (*entry_point)(void); if (flag != BOOTM_STATE_OS_GO) @@ -455,9 +455,9 @@ static int do_bootm_openrtos(int flag, int argc, char *const argv[], #endif #ifdef CONFIG_BOOTM_OPTEE -static int do_bootm_tee(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_tee(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; int ret; /* Validate OPTEE header */ @@ -468,14 +468,14 @@ static int do_bootm_tee(int flag, int argc, char *const argv[], return ret; /* From here we can run the regular linux boot path */ - return do_bootm_linux(flag, argc, argv, images); + return do_bootm_linux(flag, bmi); } #endif #ifdef CONFIG_BOOTM_EFI -static int do_bootm_efi(int flag, int argc, char *const argv[], - struct bootm_headers *images) +static int do_bootm_efi(int flag, struct bootm_info *bmi) { + struct bootm_headers *images = bmi->images; efi_status_t efi_ret; void *image_buf; @@ -569,9 +569,14 @@ __weak void board_preboot_os(void) int boot_selected_os(int argc, char *const argv[], int state, struct bootm_headers *images, boot_os_fn *boot_fn) { + struct bootm_info bmi; arch_preboot_os(); board_preboot_os(); - boot_fn(state, argc, argv, images); + + bmi.argc = argc; + bmi.argv = argv; + bmi.images = images; + boot_fn(state, &bmi); /* Stand-alone may return when 'autostart' is 'no' */ if (images->os.type == IH_TYPE_STANDALONE || diff --git a/include/bootm.h b/include/bootm.h index a6d5d5c..85c560d 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -39,16 +39,11 @@ struct bootm_info { * - disabled interrupts. * * @flag: Flags indicating what to do (BOOTM_STATE_...) - * @argc: Number of arguments. Note that the arguments are shifted down - * so that 0 is the first argument not processed by U-Boot, and - * argc is adjusted accordingly. This avoids confusion as to how - * many arguments are available for the OS. - * @images: Pointers to os/initrd/fdt + * bmi: Bootm information * Return: 1 on error. On success the OS boots so this function does * not return. */ -typedef int boot_os_fn(int flag, int argc, char *const argv[], - struct bootm_headers *images); +typedef int boot_os_fn(int flag, struct bootm_info *bmi); extern boot_os_fn do_bootm_linux; extern boot_os_fn do_bootm_vxworks; |