Complete decoupling of bootm logic from commands
Subsystems (13)
v3 cover Complete decoupling of bootm logic from commands
This series continues refactoring the bootm code to allow it to be used with CONFIG_COMMAND disabled. The OS-handling code is refactored and a new bootm_run() function is created to run through the bootm stages. This completes the work.
A booti_go() function is created also, in case it proves useful, but at last for now standard boot does not use this.
This is cmdd (part d of CMDLINE refactoring)
It depends on dm/bootstda-working
which depends on dm/cmdc-working
Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info
- Rename addr_fit to addr_img in struct bootm_info
- Enable CONFIG_MEASURED_BOOT always and rely on CONFIG_MEASURED_BOOT
- Rename addr_fit to addr_img in struct bootm_info
- Add new boot_run() function
Changes in v2:
- Add new patch to enable more bootm OS methods in sandbox
- Split addition of struct bootm_info to its own patch
- Split changing of boot_os_fn parameters to a separate patch
- Split out adding the rest of struct bootm_info fields to separate patch
- Split out patch to move do_bootm_states() comment to header
- Split out booti removal of #ifdef
- Split out bootz removal of #ifdef
- Adjust patch to focus just on dropping the do_bootm_states() arguments
- Split do_bootm_states() rename to a separate patch
- Rework series to allow OS access to cmdline arguments for bootm
Simon Glass (22):
mips: Add a reset_cpu() function
m68k: Add a reset_cpu() function
ppc: Add a reset_cpu() function
nios2: Add a reset_cpu() function
riscv: Add a reset_cpu() function
bootm: Adjust how the board is reset
sandbox: bootm: Enable more bootm OS methods
bootm: Create a struct for argument information
bootm: Adjust arguments of boot_os_fn
bootm: Add more fields to bootm_info
bootm: Move do_bootm_states() comment to header file
booti: Avoid use of #ifdef
bootz: Avoid use of #ifdef
bootm: Drop arguments from do_bootm_states()
bootm: Rename do_bootm_states() to bootm_run_states()
bootm: Tidy up boot_selected_os()
bootm: Create a function to run through the bootm states
stm32: Use local vars in stm32prog for initrd and fdt
bootm: Create a function to run through the bootz states
stm32: Use bootm_run() and bootz_run()
bootm: Create a function to run through the booti states
bootm: Create a new boot_run() function to handle booting
arch/arc/lib/bootm.c | 5 +- arch/arm/lib/bootm.c | 6 +- .../cmd_stm32prog/cmd_stm32prog.c | 33 ++-- arch/m68k/lib/bootm.c | 5 +- arch/m68k/lib/traps.c | 7 + arch/microblaze/lib/bootm.c | 6 +- arch/mips/cpu/cpu.c | 8 +- arch/mips/lib/bootm.c | 8 +- arch/nios2/cpu/cpu.c | 8 +- arch/nios2/lib/bootm.c | 10 +- arch/powerpc/lib/bootm.c | 5 +- arch/powerpc/lib/traps.c | 10 ++ arch/riscv/cpu/cpu.c | 13 ++ arch/riscv/lib/bootm.c | 11 +- arch/riscv/lib/reset.c | 7 +- arch/sandbox/cpu/cpu.c | 8 + arch/sandbox/lib/bootm.c | 5 +- arch/sh/lib/bootm.c | 6 +- arch/x86/lib/bootm.c | 6 +- arch/xtensa/lib/bootm.c | 4 +- boot/bootm.c | 119 ++++++++------- boot/bootm_os.c | 78 +++++----- cmd/booti.c | 55 ++++--- cmd/bootm.c | 43 ++++-- cmd/bootz.c | 35 +++-- configs/sandbox_defconfig | 3 +- include/bootm.h | 142 ++++++++++++++++-- 27 files changed, 444 insertions(+), 202 deletions(-)
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 1/22 mips: Add a reset_cpu() function
The current do_reset() is called from a command context. Add a function which can be used from anywhere, as is done on ARM.
---
(no changes since v1)
arch/mips/cpu/cpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/mips/cpu/cpu.c +7 -1
@@ -4,6 +4,7 @@* Wolfgang Denk, DENX Software Engineering, <[email protected]> */ +#include <cpu_func.h> #include <command.h> #include <init.h> #include <linux/compiler.h>
@@ -20,9 +21,14 @@ void __weak _machine_restart(void)/* NOP */ ; } -int do_reset (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +void reset_cpu (void ) {_machine_restart (); +} + +int do_reset (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +{ +reset_cpu ();return 0 ; }
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 2/22 m68k: Add a reset_cpu() function
In reply to Simon GlassThe current do_reset() is called from a command context. Add a function which can be used from anywhere, as is done on ARM.
Since there are lots of reset functions, this one actually just calls do_reset(). Future refactoring could correct this.
---
(no changes since v1)
arch/m68k/lib/traps.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/m68k/lib/traps.c +7 -0
@@ -7,6 +7,7 @@* Wolfgang Denk, DENX Software Engineering, [email protected]. */ +#include <cpu_func.h> #include <init.h> #include <watchdog.h> #include <command.h>
@@ -65,3 +66,9 @@ int arch_initr_trap(void)return 0 ; } + +void reset_cpu (void ) +{ +/* TODO: Refactor all the do_reset calls to be reset_cpu() instead */ +do_reset (NULL ,0 ,0 ,NULL ); +}
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 3/22 ppc: Add a reset_cpu() function
In reply to Simon GlassThe current do_reset() is called from a command context. Add a function which can be used from anywhere, as is done on ARM.
This is only needed if CONFIG_SYSRESET is disabled.
Since there are lots of reset functions, this one actually just calls do_reset(). Future refactoring could correct this.
---
(no changes since v1)
arch/powerpc/lib/traps.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/powerpc/lib/traps.c +10 -0
@@ -4,6 +4,8 @@* Wolfgang Denk, DENX Software Engineering, [email protected]. */ +#include <command.h> +#include <cpu_func.h> #include <init.h> #include <asm/global_data.h>
@@ -17,3 +19,11 @@ int arch_initr_trap(void)return 0 ; } + +#ifndef CONFIG_SYSRESET +void reset_cpu (void ) +{ +/* TODO: Refactor all the do_reset calls to be reset_cpu() instead */ +do_reset (NULL ,0 ,0 ,NULL ); +} +#endif
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 4/22 nios2: Add a reset_cpu() function
In reply to Simon GlassThe current do_reset() is called from a command context. Add a function which can be used from anywhere, as is done on ARM.
---
(no changes since v1)
arch/nios2/cpu/cpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/nios2/cpu/cpu.c +7 -1
@@ -35,11 +35,17 @@ int checkboard(void) }#endif -int do_reset (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +void reset_cpu (void ) {disable_interrupts ();/* indirect call to go beyond 256MB limitation of toolchain */ nios2_callr (gd->arch.reset_addr); +} + +int do_reset (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +{ +reset_cpu (); +return 0 ; }
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 5/22 riscv: Add a reset_cpu() function
In reply to Simon GlassThe current do_reset() is called from a command context. Add a function which can be used from anywhere, as is done on ARM. Adjust do_reset() to call it.
Note that reset_cpu() is normally provided by SYSRESET so make this declaration conditional on that being disabled.
---
(no changes since v1)
arch/riscv/cpu/cpu.c | 13 +++++++++++++ arch/riscv/lib/reset.c | 7 ++----- 2 files changed, 15 insertions(+), 5 deletions(-)
arch/riscv/cpu/cpu.c +13 -0
@@ -3,10 +3,13 @@* Copyright (C) 2018, Bin Meng <[email protected]> */ +#include <command.h> #include <cpu.h> +#include <cpu_func.h> #include <dm.h> #include <dm/lists.h> #include <event.h> +#include <hang.h> #include <init.h> #include <log.h> #include <asm/encoding.h>
@@ -162,3 +165,13 @@ int arch_early_init_r(void)__weak void harts_early_init (void ) { } + +#if !CONFIG_IS_ENABLED (SYSRESET ) +void reset_cpu (void ) +{ +printf ("resetting ...\n" ); + +printf ("reset not supported yet\n" ); +hang (); +} +#endif
arch/riscv/lib/reset.c +2 -5
@@ -4,14 +4,11 @@*/ #include <command.h> -#include <hang.h> +#include <cpu_func.h> int do_reset (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { -printf ("resetting ...\n" ); - -printf ("reset not supported yet\n" ); -hang (); +reset_cpu ();return 0 ; }
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 6/22 bootm: Adjust how the board is reset
In reply to Simon GlassUse reset_cpu() to reset the board, copying the logic from the 'reset' command. This makes more sense than directly calling the do_reset() function with the arguments passsed to the bootm command.
---
(no changes since v1)
boot/bootm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
boot/bootm.c +5 -3
@@ -1140,10 +1140,12 @@ err:if (iflag)enable_interrupts (); -if (ret ==BOOTM_ERR_UNIMPLEMENTED ) +if (ret ==BOOTM_ERR_UNIMPLEMENTED ) {bootstage_error (BOOTSTAGE_ID_DECOMP_UNIMPL ); -else if (ret ==BOOTM_ERR_RESET ) -do_reset (cmdtp, flag, argc, argv); + }else if (ret ==BOOTM_ERR_RESET ) { +printf ("Resetting the board...\n" ); +reset_cpu (); + }return ret; }
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 7/22 sandbox: bootm: Enable more bootm OS methods
In reply to Simon GlassIt is useful for sandbox to build as much code as possible. Enable support for booting various other operating systems. Add the missing cache functions.
These operating systems do not actually boot on sandbox, of course.
---
(no changes since v2)
Changes in v2:
- Add new patch to enable more bootm OS methods in sandbox
arch/sandbox/cpu/cpu.c | 8 ++++++++ configs/sandbox_defconfig | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-)
arch/sandbox/cpu/cpu.c +8 -0
@@ -286,6 +286,14 @@ void sandbox_set_enable_pci_map(int enable) enable_pci_map = enable; } +void dcache_enable (void ) +{ +} + +void dcache_disable (void ) +{ +} +int dcache_status (void ) {return 1 ;
configs/sandbox_defconfig +2 -1
@@ -44,10 +44,11 @@ CONFIG_CMD_CPU=y CONFIG_CMD_LICENSE=y CONFIG_CMD_BOOTM_PRE_LOAD=y CONFIG_CMD_BOOTZ=y +CONFIG_BOOTM_OPENRTOS=y +CONFIG_BOOTM_OSE=y CONFIG_CMD_BOOTEFI_HELLO=y CONFIG_CMD_BOOTMENU=y CONFIG_CMD_ABOOTIMG=y -# CONFIG_CMD_ELF is not set CONFIG_CMD_ASKENV=y CONFIG_CMD_GREPENV=y CONFIG_CMD_ERASEENV=y
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 8/22 bootm: Create a struct for argument information
In reply to Simon GlassSome OS functions require the arguments to the 'bootm' command. This is inconvenient for two reasons.
Firstly, there may not be any actual command, if CMDLINE is not enabled and programmatic boot is being used.
Secondly, most functions don't require the arguments, so it is inefficient to pass them when not needed. For example it increases code size.
Create a new struct which holds the arguments, which can be used if needed.
Add the images pointer as well, since this is commonly needed.
---
(no changes since v2)
Changes in v2:
- Split addition of struct bootm_info to its own patch
include/bootm.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
include/bootm.h +15 -1
@@ -16,6 +16,20 @@ struct cmd_tbl;#define BOOTM_ERR_OVERLAP (-2)#define BOOTM_ERR_UNIMPLEMENTED (-3) +/** +* struct bootm_info() - information used when processing images to boot +* +* @images: images information +* @argc: Number of arguments to the command (excluding the actual command). +* This is 0 if there are no arguments +* @argv: NULL-terminated list of arguments, or NULL if there are no arguments +*/ +struct bootm_info { +struct bootm_headers *images; +int argc; +char *const *argv; +}; +/* * Continue booting an OS image; caller already has: * - copied image header to global variable `header'
@@ -39,7 +53,7 @@ typedef int boot_os_fn(int flag, int argc, char *const argv[],extern boot_os_fn do_bootm_linux;extern boot_os_fn do_bootm_vxworks; -int do_bootelf (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_bootelf (struct cmd_tbl *cmdtp,int fglag,int argc,char *const argv[]);boot_os_fn *bootm_os_get_boot_func (int os);
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 9/22 bootm: Adjust arguments of boot_os_fn
In reply to Simon GlassAdjust 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.
---
(no changes since v2)
Changes in v2:
- Split changing of boot_os_fn parameters to a separate patch
arch/arc/lib/bootm.c | 5 ++- arch/arm/lib/bootm.c | 6 ++- arch/m68k/lib/bootm.c | 5 ++- arch/microblaze/lib/bootm.c | 6 ++- arch/mips/lib/bootm.c | 6 ++- arch/nios2/lib/bootm.c | 10 +++-- arch/powerpc/lib/bootm.c | 5 ++- arch/riscv/lib/bootm.c | 11 +++--- arch/sandbox/lib/bootm.c | 5 ++- arch/sh/lib/bootm.c | 6 ++- arch/x86/lib/bootm.c | 6 ++- arch/xtensa/lib/bootm.c | 4 +- boot/bootm.c | 11 ++++-- boot/bootm_os.c | 77 ++++++++++++++++++++----------------- include/bootm.h | 9 +---- 15 files changed, 100 insertions(+), 72 deletions(-)
arch/arc/lib/bootm.c +4 -1
@@ -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 ;
arch/arm/lib/bootm.c +4 -2
@@ -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 ;
arch/m68k/lib/bootm.c +3 -2
@@ -4,6 +4,7 @@* Wolfgang Denk, DENX Software Engineering, [email protected]. */ +#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 );
arch/microblaze/lib/bootm.c +4 -2
@@ -7,6 +7,7 @@* Yasushi SHOJI <[email protected]> */ +#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' */
arch/mips/lib/bootm.c +4 -2
@@ -4,6 +4,7 @@* Wolfgang Denk, DENX Software Engineering, [email protected]. */ +#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 ;
arch/nios2/lib/bootm.c +6 -4
@@ -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;
arch/powerpc/lib/bootm.c +3 -2
@@ -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 ) {
arch/riscv/lib/bootm.c +6 -5
@@ -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 )
arch/sandbox/lib/bootm.c +4 -1
@@ -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);
arch/sh/lib/bootm.c +4 -2
@@ -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 */
arch/x86/lib/bootm.c +4 -2
@@ -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 ;
arch/xtensa/lib/bootm.c +3 -1
@@ -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" );
boot/bootm.c +8 -3
@@ -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
boot/bootm_os.c +41 -36
208 lines not on this page · raw message
include/bootm.h +2 -7
@@ -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;
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 10/22 bootm: Add more fields to bootm_info
In reply to Simon GlassAdd fields for the three bootm parameters and other things needed for booting. Also add a helper to set up the struct correctly.
---
Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info
Changes in v2:
- Split out adding the rest of struct bootm_info fields to separate patch
boot/bootm.c | 8 ++++++++ include/bootm.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
boot/bootm.c +8 -0
@@ -1192,6 +1192,14 @@ int bootm_boot_start(ulong addr, const char *cmdline)return ret; } +void bootm_init (struct bootm_info *bmi) +{ +memset (bmi,'\0' ,sizeof (struct bootm_info )); + bmi->boot_progress = true; +if (IS_ENABLED (CONFIG_CMD_BOOTM )) + bmi->images = &images; +} +/** * switch_to_non_secure_mode() - switch to non-secure mode *
include/bootm.h +35 -0
@@ -19,17 +19,52 @@ struct cmd_tbl;/** * struct bootm_info() - information used when processing images to boot * +* These mirror the first three arguments of the bootm command. They are +* designed to handle any type of image, but typically it is a FIT. +* +* @addr_img: Address of image to bootm, as passed to +* genimg_get_kernel_addr_fit() for processing: +* +* NULL: Usees default load address, i.e. image_load_addr +* <addr>: Uses hex address +* +* For FIT: +* "[<addr>]#<conf>": Uses address (or image_load_addr) and also specifies +* the FIT configuration to use +* "[<addr>]:<subimage>": Uses address (or image_load_addr) and also +* specifies the subimage name containing the OS +* +* @conf_ramdisk: Address (or with FIT, the name) of the ramdisk image, as +* passed to boot_get_ramdisk() for processing, or NULL for none +* @conf_fdt: Address (or with FIT, the name) of the FDT image, as passed to +* boot_get_fdt() for processing, or NULL for none +* @boot_progress: true to show boot progress * @images: images information +* @cmd_name: command which invoked this operation, e.g. "bootm" * @argc: Number of arguments to the command (excluding the actual command). * This is 0 if there are no arguments * @argv: NULL-terminated list of arguments, or NULL if there are no arguments */ struct bootm_info { +const char *addr_img; +const char *conf_ramdisk; +const char *conf_fdt; +bool boot_progress;struct bootm_headers *images; +const char *cmd_name;int argc;char *const *argv; }; +/** +* bootm_init() - Set up a bootm_info struct with useful defaults +* +* Set up the struct with default values for all members: +* @boot_progress is set to true and @images is set to the global images +* variable. Everything else is set to NULL except @argc which is 0 +*/ +void bootm_init (struct bootm_info *bmi); +/* * Continue booting an OS image; caller already has: * - copied image header to global variable `header'
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 10/22] bootm: Add more fields to bootm_info
Quoted 4 lines · Simon Glass
Add fields for the three bootm parameters and other things needed for booting. Also add a helper to set up the struct correctly.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH v3 11/22 bootm: Move do_bootm_states() comment to header file
In reply to Simon GlassThis is an exported function, so move the function comment to the bootm.h header file.
---
(no changes since v2)
Changes in v2:
- Split out patch to move do_bootm_states() comment to header
boot/bootm.c | 25 ------------------------- include/bootm.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-)
boot/bootm.c +0 -25
@@ -990,31 +990,6 @@ unmap_image:return ret; } -/** -* Execute selected states of the bootm command. -* -* Note the arguments to this state must be the first argument, Any 'bootm' -* or sub-command arguments must have already been taken. -* -* Note that if states contains more than one flag it MUST contain -* BOOTM_STATE_START, since this handles and consumes the command line args. -* -* Also note that aside from boot_os_fn functions and bootm_load_os no other -* functions we store the return value of in 'ret' may use a negative return -* value, without special handling. -* -* @param cmdtp Pointer to bootm command table entry -* @param flag Command flags (CMD_FLAG_...) -* @param argc Number of subcommand arguments (0 = no arguments) -* @param argv Arguments -* @param states Mask containing states to run (BOOTM_STATE_...) -* @param images Image header information -* @param boot_progress 1 to show boot progress, 0 to not do this -* Return: 0 if ok, something else on error. Some errors will cause this -* function to perform a reboot! If states contains BOOTM_STATE_OS_GO -* then the intent is to boot an OS, so this function will not return -* unless the image type is standalone. -*/ int do_bootm_states (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[],int states,struct bootm_headers *images,int boot_progress)
include/bootm.h +25 -0
@@ -131,6 +131,31 @@ int bootm_find_images(ulong img_addr, const char *conf_ramdisk,*/ int bootm_measure (struct bootm_headers *images); +/** +* Execute selected states of the bootm command. +* +* Note the arguments to this state must be the first argument, Any 'bootm' +* or sub-command arguments must have already been taken. +* +* Note that if states contains more than one flag it MUST contain +* BOOTM_STATE_START, since this handles and consumes the command line args. +* +* Also note that aside from boot_os_fn functions and bootm_load_os no other +* functions we store the return value of in 'ret' may use a negative return +* value, without special handling. +* +* @param cmdtp Pointer to bootm command table entry +* @param flag Command flags (CMD_FLAG_...) +* @param argc Number of subcommand arguments (0 = no arguments) +* @param argv Arguments +* @param states Mask containing states to run (BOOTM_STATE_...) +* @param images Image header information +* @param boot_progress 1 to show boot progress, 0 to not do this +* Return: 0 if ok, something else on error. Some errors will cause this +* function to perform a reboot! If states contains BOOTM_STATE_OS_GO +* then the intent is to boot an OS, so this function will not return +* unless the image type is standalone. +*/ int do_bootm_states (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[],int states,struct bootm_headers *images,int boot_progress);
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 12/22 booti: Avoid use of #ifdef
In reply to Simon GlassUse the compiler to get the set of states, instead of the preprocessor.
---
(no changes since v2)
Changes in v2:
- Split out booti removal of #ifdef
cmd/booti.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
cmd/booti.c +11 -13
@@ -105,6 +105,7 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,int do_booti (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { +int states;int ret;/* Consume 'booti' */
@@ -120,19 +121,16 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])bootm_disable_interrupts (); images.os.os =IH_OS_LINUX ; -#ifdef CONFIG_RISCV_SMODE - images.os.arch =IH_ARCH_RISCV ; -#elif CONFIG_ARM64 - images.os.arch =IH_ARCH_ARM64 ; -#endif - ret =do_bootm_states (cmdtp, flag, argc, argv, -#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH -BOOTM_STATE_RAMDISK | -#endif -BOOTM_STATE_MEASURE | -BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | -BOOTM_STATE_OS_GO , - &images,1 ); +if (IS_ENABLED (CONFIG_RISCV_SMODE )) + images.os.arch =IH_ARCH_RISCV ; +else if (IS_ENABLED (CONFIG_ARM64 )) + images.os.arch =IH_ARCH_ARM64 ; + + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; +if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) + states |=BOOTM_STATE_RAMDISK ; + ret =do_bootm_states (cmdtp, flag, argc, argv, states, &images,1 );return ret; }
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 13/22 bootz: Avoid use of #ifdef
In reply to Simon GlassUse the compiler to get the set of states, instead of the preprocessor.
---
(no changes since v2)
Changes in v2:
- Split out bootz removal of #ifdef
cmd/bootz.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
cmd/bootz.c +8 -9
@@ -64,7 +64,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,int do_bootz (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { -int ret; +int states, ret;/* Consume 'bootz' */ argc--; argv++;
@@ -79,14 +79,13 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])bootm_disable_interrupts (); images.os.os =IH_OS_LINUX ; - ret =do_bootm_states (cmdtp, flag, argc, argv, -#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH -BOOTM_STATE_RAMDISK | -#endif -BOOTM_STATE_MEASURE | -BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | -BOOTM_STATE_OS_GO , - &images,1 ); + + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; +if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) + states |=BOOTM_STATE_RAMDISK ; + + ret =do_bootm_states (cmdtp, flag, argc, argv, states, &images,1 );return ret; }
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 14/22 bootm: Drop arguments from do_bootm_states()
In reply to Simon GlassUse the bootm_info struct to hold the information required by bootm.
Now that none of the functions called from do_bootm_states() needs an argv[] list, change the arguments of do_bootm_states() as well. Take care to use the same value for boot_progress even though it is a little inconsistent.
For booti make sure it only uses argv[] and argc at the top of the function, so we can eventually refactor to remove these parameters.
With bootm, some OSes need access to the arguments provided to the command, so set these up in the bootm_info struct, for bootm only.
---
Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info
Changes in v2:
- Adjust patch to focus just on dropping the do_bootm_states() arguments
boot/bootm.c | 52 ++++++++++++++++++++----------------------------- cmd/booti.c | 33 ++++++++++++++++++++----------- cmd/bootm.c | 33 +++++++++++++++++++++++++++++-- cmd/bootz.c | 27 +++++++++++++++++++++---- include/bootm.h | 25 ++++++++---------------- 5 files changed, 105 insertions(+), 65 deletions(-)
boot/bootm.c +21 -31
@@ -990,11 +990,9 @@ unmap_image:return ret; } -int do_bootm_states (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],int states,struct bootm_headers *images, -int boot_progress) +int do_bootm_states (struct bootm_info *bmi,int states) { -struct bootm_info bmi; +struct bootm_headers *images = bmi->images;boot_os_fn *boot_fn;ulong iflag =0 ;int ret =0 , need_boot_fn;
@@ -1009,17 +1007,18 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc, ret =bootm_start ();if (!ret && (states &BOOTM_STATE_PRE_LOAD )) - ret =bootm_pre_load (argv[0 ]); + ret =bootm_pre_load (bmi->addr_img);if (!ret && (states &BOOTM_STATE_FINDOS )) - ret =bootm_find_os (cmdtp->name, argv[0 ]); + ret =bootm_find_os (bmi->cmd_name, bmi->addr_img);if (!ret && (states &BOOTM_STATE_FINDOTHER )) {ulong img_addr; - img_addr = argc ?hextoul (argv[0 ],NULL ) : image_load_addr; - ret =bootm_find_other (img_addr,cmd_arg1 (argc, argv), -cmd_arg2 (argc, argv)); + img_addr = bmi->addr_img ?hextoul (bmi->addr_img,NULL ) + : image_load_addr; + ret =bootm_find_other (img_addr, bmi->conf_ramdisk, + bmi->conf_fdt); } if (IS_ENABLED(CONFIG_MEASURED_BOOT) && !ret &&
@@ -1073,15 +1072,11 @@ 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 , &bmi); + ret =boot_fn (BOOTM_STATE_OS_CMDLINE , bmi);if (!ret && (states &BOOTM_STATE_OS_BD_T )) - ret =boot_fn (BOOTM_STATE_OS_BD_T , &bmi); + 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) {
@@ -1089,7 +1084,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 , &bmi); + ret =boot_fn (BOOTM_STATE_OS_PREP , bmi); }#ifdef CONFIG_TRACE
@@ -1097,10 +1092,10 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,if (!ret && (states &BOOTM_STATE_OS_FAKE_GO )) {char *cmd_list =env_get ("fakegocmd" ); - ret =boot_selected_os (argc, argv,BOOTM_STATE_OS_FAKE_GO , - images, boot_fn); + ret =boot_selected_os (bmi->argc, bmi->argv, +BOOTM_STATE_OS_FAKE_GO , images, boot_fn);if (!ret && cmd_list) - ret =run_command_list (cmd_list,-1 , flag); + ret =run_command_list (cmd_list,-1 ,0 ); }#endif
@@ -1112,8 +1107,8 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,/* Now run the OS! We hope this doesn't return */ if (!ret && (states &BOOTM_STATE_OS_GO )) - ret =boot_selected_os (argc, argv,BOOTM_STATE_OS_GO , - images, boot_fn); + ret =boot_selected_os (bmi->argc, bmi->argv,BOOTM_STATE_OS_GO , + images, boot_fn);/* Deal with any fallout */ err:
@@ -1132,19 +1127,11 @@ err:int bootm_boot_start (ulong addr,const char *cmdline) { -static struct cmd_tbl cmd = {"bootm" };char addr_str[30 ]; -char *argv[] = {addr_str,NULL }; +struct bootm_info bmi;int states;int ret; -/* -* TODO([email protected]): This uses the command-line interface, but -* should not. To clean this up, the various bootm states need to be -* passed an info structure instead of cmdline flags. Then this can -* set up the required info and move through the states without needing -* the command line. -*/ states =BOOTM_STATE_START |BOOTM_STATE_FINDOS |BOOTM_STATE_PRE_LOAD |BOOTM_STATE_FINDOTHER |BOOTM_STATE_LOADOS | BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
@@ -1162,7 +1149,10 @@ int bootm_boot_start(ulong addr, const char *cmdline)printf ("Failed to set cmdline\n" );return ret; } - ret =do_bootm_states (&cmd,0 ,1 , argv, states, &images,1 ); +bootm_init (&bmi); + bmi.addr_img = addr_str; + bmi.cmd_name ="bootm" ; + ret =do_bootm_states (&bmi, states);return ret; }
cmd/booti.c +22 -11
@@ -20,9 +20,9 @@ DECLARE_GLOBAL_DATA_PTR;/* * Image booting support */ -static int booti_start (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],struct bootm_headers *images) +static int booti_start (struct bootm_info *bmi) { +struct bootm_headers *images = bmi->images;int ret;ulong ld;ulong relocated_addr;
@@ -34,16 +34,15 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,unsigned long decomp_len;int ctype; - ret =do_bootm_states (cmdtp, flag, argc, argv,BOOTM_STATE_START , - images,1 ); + ret =do_bootm_states (bmi,BOOTM_STATE_START );/* Setup Linux kernel Image entry point */ -if (!argc) { +if (!bmi->addr_img) { ld = image_load_addr;debug ("* kernel: default image load address = 0x%08lx\n" , image_load_addr); }else { - ld =hextoul (argv[0 ],NULL ); + ld =hextoul (bmi->addr_img,NULL );debug ("* kernel: cmdline image address = 0x%08lx\n" , ld); }
@@ -95,9 +94,8 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,* 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), relocated_addr, - image_size)) +if (bootm_find_images (image_load_addr, bmi->conf_ramdisk, bmi->conf_fdt, + relocated_addr, image_size))return 1 ;return 0 ;
@@ -105,13 +103,25 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,int do_booti (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { +struct bootm_info bmi;int states;int ret;/* Consume 'booti' */ argc--; argv++; -if (booti_start (cmdtp, flag, argc, argv, &images)) +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 ]; + bmi.boot_progress = true; + bmi.cmd_name ="booti" ; +/* do not set up argc and argv[] since nothing uses them */ + +if (booti_start (&bmi))return 1 ;/*
@@ -130,7 +140,8 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ;if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; - ret =do_bootm_states (cmdtp, flag, argc, argv, states, &images,1 ); + + ret =do_bootm_states (&bmi, states);return ret; }
cmd/bootm.c +31 -2
@@ -76,6 +76,7 @@ static ulong bootm_get_addr(int argc, char *const argv[])static int do_bootm_subcommand (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { +struct bootm_info bmi;int ret =0 ;long state;struct cmd_tbl *c;
@@ -103,7 +104,21 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc,return CMD_RET_USAGE ; } - ret =do_bootm_states (cmdtp, flag, argc, argv, state, &images,0 ); +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 ]; + bmi.cmd_name ="bootm" ; + bmi.boot_progress = false; + +/* set up argc and argv[] since some OSes use them */ + bmi.argc = argc; + bmi.argv = argv; + + ret =do_bootm_states (&bmi, state);#if defined(CONFIG_CMD_BOOTM_PRE_LOAD )if (!ret && (state &BOOTM_STATE_PRE_LOAD ))
@@ -120,6 +135,7 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc,int do_bootm (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { +struct bootm_info bmi;int states;int ret;
@@ -151,7 +167,20 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) states |=BOOTM_STATE_MEASURE ;if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) states |=BOOTM_STATE_OS_CMDLINE ; - ret =do_bootm_states (cmdtp, flag, argc, argv, states, &images,1 ); + +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 ]; + +/* set up argc and argv[] since some OSes use them */ + bmi.argc = argc; + bmi.argv = argv; + + ret =do_bootm_states (&bmi, states);return ret ?CMD_RET_FAILURE :0 ; }
cmd/bootz.c +23 -4
@@ -27,11 +27,20 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)static int bootz_start (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[],struct bootm_headers *images) { -int ret;ulong zi_start, zi_end; +struct bootm_info bmi; +int ret; - ret =do_bootm_states (cmdtp, flag, argc, argv,BOOTM_STATE_START , - images,1 ); +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 =do_bootm_states (&bmi,BOOTM_STATE_START );/* Setup Linux kernel zImage entry point */ if (!argc) {
@@ -64,6 +73,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,int do_bootz (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { +struct bootm_info bmi;int states, ret;/* Consume 'bootz' */
@@ -80,12 +90,21 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) images.os.os =IH_OS_LINUX ; +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 ]; + bmi.cmd_name ="bootz" ; + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ;if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; - ret =do_bootm_states (cmdtp, flag, argc, argv, states, &images,1 ); + ret =do_bootm_states (&bmi, states);return ret; }
include/bootm.h +8 -17
@@ -132,33 +132,24 @@ int bootm_find_images(ulong img_addr, const char *conf_ramdisk,int bootm_measure (struct bootm_headers *images);/** -* Execute selected states of the bootm command. -* -* Note the arguments to this state must be the first argument, Any 'bootm' -* or sub-command arguments must have already been taken. +* do_bootm_states() - Execute selected states of the bootm command. * * Note that if states contains more than one flag it MUST contain -* BOOTM_STATE_START, since this handles and consumes the command line args. +* BOOTM_STATE_START, since this handles the addr_fit, conf_ramdisk and conf_fit +* members of @bmi * -* Also note that aside from boot_os_fn functions and bootm_load_os no other -* functions we store the return value of in 'ret' may use a negative return +* Also note that aside from boot_os_fn functions and bootm_load_os, no other +* functions store the return value of in 'ret' may use a negative return * value, without special handling. * -* @param cmdtp Pointer to bootm command table entry -* @param flag Command flags (CMD_FLAG_...) -* @param argc Number of subcommand arguments (0 = no arguments) -* @param argv Arguments -* @param states Mask containing states to run (BOOTM_STATE_...) -* @param images Image header information -* @param boot_progress 1 to show boot progress, 0 to not do this +* @bmi: bootm information +* @states Mask containing states to run (BOOTM_STATE_...) * Return: 0 if ok, something else on error. Some errors will cause this * function to perform a reboot! If states contains BOOTM_STATE_OS_GO * then the intent is to boot an OS, so this function will not return * unless the image type is standalone. */ -int do_bootm_states (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[],int states,struct bootm_headers *images, -int boot_progress); +int do_bootm_states (struct bootm_info *bmi,int states);void arch_preboot_os (void );
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 15/22 bootm: Rename do_bootm_states() to bootm_run_states()
In reply to Simon GlassRename the function to bootm_run_states() to better indicate ts purpose. The 'do_' prefix is used to indicate a command processor, which this is now not.
---
(no changes since v2)
Changes in v2:
- Split do_bootm_states() rename to a separate patch
arch/mips/lib/bootm.c | 2 +- boot/bootm.c | 4 ++-- cmd/booti.c | 4 ++-- cmd/bootm.c | 4 ++-- cmd/bootz.c | 4 ++-- include/bootm.h | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-)
arch/mips/lib/bootm.c +1 -1
@@ -217,7 +217,7 @@ static int boot_reloc_fdt(struct bootm_headers *images) {/* * In case of legacy uImage's, relocation of FDT is already done -* by do_bootm_states() and should not repeated in 'bootm prep'. +* by bootm_run_states() and should not repeated in 'bootm prep'. */ if (images->state &BOOTM_STATE_FDT ) {debug ("## FDT already relocated\n" );
boot/bootm.c +2 -2
@@ -990,7 +990,7 @@ unmap_image:return ret; } -int do_bootm_states (struct bootm_info *bmi,int states) +int bootm_run_states (struct bootm_info *bmi,int states) {struct bootm_headers *images = bmi->images;boot_os_fn *boot_fn;
@@ -1152,7 +1152,7 @@ int bootm_boot_start(ulong addr, const char *cmdline)bootm_init (&bmi); bmi.addr_img = addr_str; bmi.cmd_name ="bootm" ; - ret =do_bootm_states (&bmi, states); + ret =bootm_run_states (&bmi, states);return ret; }
cmd/booti.c +2 -2
@@ -34,7 +34,7 @@ static int booti_start(struct bootm_info *bmi)unsigned long decomp_len;int ctype; - ret =do_bootm_states (bmi,BOOTM_STATE_START ); + ret =bootm_run_states (bmi,BOOTM_STATE_START );/* Setup Linux kernel Image entry point */ if (!bmi->addr_img) {
@@ -141,7 +141,7 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; - ret =do_bootm_states (&bmi, states); + ret =bootm_run_states (&bmi, states);return ret; }
cmd/bootm.c +2 -2
@@ -118,7 +118,7 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, bmi.argc = argc; bmi.argv = argv; - ret =do_bootm_states (&bmi, state); + ret =bootm_run_states (&bmi, state);#if defined(CONFIG_CMD_BOOTM_PRE_LOAD )if (!ret && (state &BOOTM_STATE_PRE_LOAD ))
@@ -180,7 +180,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bmi.argc = argc; bmi.argv = argv; - ret =do_bootm_states (&bmi, states); + ret =bootm_run_states (&bmi, states);return ret ?CMD_RET_FAILURE :0 ; }
cmd/bootz.c +2 -2
@@ -40,7 +40,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc, bmi.conf_fdt = argv[2 ];/* do not set up argc and argv[] since nothing uses them */ - ret =do_bootm_states (&bmi,BOOTM_STATE_START ); + ret =bootm_run_states (&bmi,BOOTM_STATE_START );/* Setup Linux kernel zImage entry point */ if (!argc) {
@@ -104,7 +104,7 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; - ret =do_bootm_states (&bmi, states); + ret =bootm_run_states (&bmi, states);return ret; }
include/bootm.h +2 -2
@@ -132,7 +132,7 @@ int bootm_find_images(ulong img_addr, const char *conf_ramdisk,int bootm_measure (struct bootm_headers *images);/** -* do_bootm_states() - Execute selected states of the bootm command. +* bootm_run_states() - Execute selected states of the bootm command. * * Note that if states contains more than one flag it MUST contain * BOOTM_STATE_START, since this handles the addr_fit, conf_ramdisk and conf_fit
@@ -149,7 +149,7 @@ int bootm_measure(struct bootm_headers *images);* then the intent is to boot an OS, so this function will not return * unless the image type is standalone. */ -int do_bootm_states (struct bootm_info *bmi,int states); +int bootm_run_states (struct bootm_info *bmi,int states);void arch_preboot_os (void );
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 16/22 bootm: Tidy up boot_selected_os()
In reply to Simon GlassUse struct bootm_info with this function, to avoiding needing to create a new one.
---
(no changes since v1)
boot/bootm.c | 6 ++---- boot/bootm_os.c | 11 +++-------- include/bootm.h | 3 +-- 3 files changed, 6 insertions(+), 14 deletions(-)
boot/bootm.c +2 -4
@@ -1092,8 +1092,7 @@ int bootm_run_states(struct bootm_info *bmi, int states)if (!ret && (states &BOOTM_STATE_OS_FAKE_GO )) {char *cmd_list =env_get ("fakegocmd" ); - ret =boot_selected_os (bmi->argc, bmi->argv, -BOOTM_STATE_OS_FAKE_GO , images, boot_fn); + ret =boot_selected_os (BOOTM_STATE_OS_FAKE_GO , bmi, boot_fn);if (!ret && cmd_list) ret =run_command_list (cmd_list,-1 ,0 ); }
@@ -1107,8 +1106,7 @@ int bootm_run_states(struct bootm_info *bmi, int states)/* Now run the OS! We hope this doesn't return */ if (!ret && (states &BOOTM_STATE_OS_GO )) - ret =boot_selected_os (bmi->argc, bmi->argv,BOOTM_STATE_OS_GO , - images, boot_fn); + ret =boot_selected_os (BOOTM_STATE_OS_GO , bmi, boot_fn);/* Deal with any fallout */ err:
boot/bootm_os.c +3 -8
@@ -566,20 +566,15 @@ __weak void board_preboot_os(void)/* please define board specific board_preboot_os() */ } -int boot_selected_os (int argc,char *const argv[],int state, -struct bootm_headers *images,boot_os_fn *boot_fn) +int boot_selected_os (int state,struct bootm_info *bmi,boot_os_fn *boot_fn) { -struct bootm_info bmi;arch_preboot_os ();board_preboot_os (); - bmi.argc = argc; - bmi.argv = argv; - bmi.images = images; -boot_fn (state, &bmi); +boot_fn (state, bmi);/* Stand-alone may return when 'autostart' is 'no' */ -if (images->os.type ==IH_TYPE_STANDALONE || +if (bmi->images->os.type ==IH_TYPE_STANDALONE ||IS_ENABLED (CONFIG_SANDBOX ) || state ==BOOTM_STATE_OS_FAKE_GO )/* We expect to return */ return 0 ;
include/bootm.h +1 -2
@@ -91,8 +91,7 @@ boot_os_fn *bootm_os_get_boot_func(int os);int bootm_host_load_images (const void *fit,int cfg_noffset);#endif -int boot_selected_os (int argc,char *const argv[],int state, -struct bootm_headers *images,boot_os_fn *boot_fn); +int boot_selected_os (int state,struct bootm_info *bmi,boot_os_fn *boot_fn);ulong bootm_disable_interrupts (void );
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 17/22 bootm: Create a function to run through the bootm states
In reply to Simon GlassIn quite a few places, the bootm command is used to handle a boot. We want these to be done without needing CONFIG_CMDLINE, so add a new bootm_run() function to handle this.
---
Changes in v3:
- Enable CONFIG_MEASURED_BOOT always and rely on CONFIG_MEASURED_BOOT
boot/bootm.c | 17 +++++++++++++++++ cmd/bootm.c | 14 +------------- include/bootm.h | 13 +++++++++++++ 3 files changed, 31 insertions(+), 13 deletions(-)
boot/bootm.c +17 -0
@@ -1123,6 +1123,23 @@ err:return ret; } +int bootm_run (struct bootm_info *bmi) +{ +int states; + + bmi->cmd_name ="bootm" ; + states =BOOTM_STATE_START |BOOTM_STATE_FINDOS |BOOTM_STATE_PRE_LOAD | +BOOTM_STATE_FINDOTHER |BOOTM_STATE_LOADOS | +BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | +BOOTM_STATE_OS_GO |BOOTM_STATE_MEASURE ; +if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) + states |=BOOTM_STATE_RAMDISK ; +if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) + states |=BOOTM_STATE_OS_CMDLINE ; + +return bootm_run_states (bmi, states); +} +int bootm_boot_start (ulong addr,const char *cmdline) {char addr_str[30 ];
cmd/bootm.c +1 -13
@@ -136,7 +136,6 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc,int do_bootm (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct bootm_info bmi; -int states;int ret;/* determine if we have a sub command */
@@ -157,17 +156,6 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])return do_bootm_subcommand (cmdtp, flag, argc, argv); } - states =BOOTM_STATE_START |BOOTM_STATE_FINDOS |BOOTM_STATE_PRE_LOAD | -BOOTM_STATE_FINDOTHER |BOOTM_STATE_LOADOS | -BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | -BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; -if (IS_ENABLED (CONFIG_MEASURED_BOOT )) - states |=BOOTM_STATE_MEASURE ; -if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) - states |=BOOTM_STATE_OS_CMDLINE ; -bootm_init (&bmi);if (argc) bmi.addr_img = argv[0 ];
@@ -180,7 +168,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bmi.argc = argc; bmi.argv = argv; - ret =bootm_run_states (&bmi, states); + ret =bootm_run (&bmi);return ret ?CMD_RET_FAILURE :0 ; }
include/bootm.h +13 -0
@@ -150,6 +150,19 @@ int bootm_measure(struct bootm_headers *images);*/ int bootm_run_states (struct bootm_info *bmi,int states); +/** +* bootm_run() - Run the entire bootm process +* +* This runs through the bootm process from start to finish, using the default +* set of states. +* +* This uses bootm_run_states(). +* +* @bmi: bootm information +* Return: 0 if ok, something else on error +*/ +int bootm_run (struct bootm_info *bmi); +void arch_preboot_os (void );/*
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 17/22] bootm: Create a function to run through the bootm states
Quoted 5 lines · Simon Glass
In quite a few places, the bootm command is used to handle a boot. We want these to be done without needing
CONFIG_CMDLINE, so add a newbootm_run()function to handle this.Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH v3 18/22 stm32: Use local vars in stm32prog for initrd and fdt
In reply to Simon GlassRather than assigning to the bootm_argv[] array multiple times, use local variables for the two things that can change and assign them at the end.
This makes it easier to drop the array eventually.
Tidu up an overly short line while we are here.
---
(no changes since v1)
.../cmd_stm32prog/cmd_stm32prog.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +14 -9
@@ -124,30 +124,35 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,char boot_addr_start[20 ];char dtb_addr[20 ];char initrd_addr[40 ]; +char *fdt_arg, *initrd_arg;char *bootm_argv[5 ] = { -"bootm" , boot_addr_start,"-" , dtb_addr,NULL +"bootm" , boot_addr_start, };const void *uimage = (void *)data->uimage;const void *dtb = (void *)data->dtb;const void *initrd = (void *)data->initrd; + fdt_arg = dtb_addr;if (!dtb) - bootm_argv[3 ] =env_get ("fdtcontroladdr" ); + fdt_arg =env_get ("fdtcontroladdr" );else -snprintf (dtb_addr,sizeof (dtb_addr) -1 , -"0x%p" , dtb); +snprintf (dtb_addr,sizeof (dtb_addr) -1 ,"0x%p" , dtb);snprintf (boot_addr_start,sizeof (boot_addr_start) -1 ,"0x%p" , uimage); + initrd_arg ="-" ;if (initrd) { -snprintf (initrd_addr,sizeof (initrd_addr) -1 ,"0x%p:0x%zx" , - initrd, data->initrd_size); - bootm_argv[2 ] = initrd_addr; +snprintf (initrd_addr,sizeof (initrd_addr) -1 , +"0x%p:0x%zx" , initrd, data->initrd_size); + initrd_arg = initrd_addr; } -printf ("Booting kernel at %s %s %s...\n\n\n" , - boot_addr_start, bootm_argv[2 ], bootm_argv[3 ]); +printf ("Booting kernel at %s %s %s...\n\n\n" , boot_addr_start, + initrd_arg, fdt_arg); + bootm_argv[2 ] = initrd_arg; + bootm_argv[3 ] = fdt_arg; +/* Try bootm for legacy and FIT format image */ if (genimg_get_format (uimage) !=IMAGE_FORMAT_INVALID )do_bootm (cmdtp,0 ,4 , bootm_argv);
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 19/22 bootm: Create a function to run through the bootz states
In reply to Simon GlassIn a few places, the bootz command is used to handle a boot. We want these to be done without needing CONFIG_CMDLINE, so add a new bootz_run() function to handle this.
---
(no changes since v1)
boot/bootm.c | 13 +++++++++++++ cmd/bootz.c | 9 ++------- include/bootm.h | 13 +++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-)
boot/bootm.c +13 -0
@@ -1140,6 +1140,19 @@ int bootm_run(struct bootm_info *bmi)return bootm_run_states (bmi, states); } +int bootz_run (struct bootm_info *bmi) +{ +int states; + + bmi->cmd_name ="bootz" ; + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; +if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) + states |=BOOTM_STATE_RAMDISK ; + +return bootm_run_states (bmi, states); +} +int bootm_boot_start (ulong addr,const char *cmdline) {char addr_str[30 ];
cmd/bootz.c +2 -7
@@ -74,7 +74,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,int do_bootz (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct bootm_info bmi; -int states, ret; +int ret;/* Consume 'bootz' */ argc--; argv++;
@@ -99,12 +99,7 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bmi.conf_fdt = argv[2 ]; bmi.cmd_name ="bootz" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; - - ret =bootm_run_states (&bmi, states); + ret =bootz_run (&bmi);return ret; }
include/bootm.h +13 -0
@@ -163,6 +163,19 @@ int bootm_run_states(struct bootm_info *bmi, int states);*/ int bootm_run (struct bootm_info *bmi); +/** +* bootz_run() - Run the entire bootz process +* +* This runs through the bootz process from start to finish, using the default +* set of states. +* +* This uses bootm_run_states(). +* +* @bmi: bootm information +* Return: 0 if ok, something else on error +*/ +int bootz_run (struct bootm_info *bmi); +void arch_preboot_os (void );/*
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 19/22] bootm: Create a function to run through the bootz states
Quoted 5 lines · Simon Glass
In a few places, the bootz command is used to handle a boot. We want these to be done without needing
CONFIG_CMDLINE, so add a newbootz_run()function to handle this.Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH v3 20/22 stm32: Use bootm_run() and bootz_run()
In reply to Simon GlassUse the new bootm/z_run() functions to avoid having to create an argument list for the stm32prog code.
---
Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info
.../cmd_stm32prog/cmd_stm32prog.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +11 -9
@@ -4,6 +4,7 @@*/ #include <common.h> +#include <bootm.h> #include <command.h> #include <dfu.h> #include <image.h>
@@ -125,12 +126,10 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,char dtb_addr[20 ];char initrd_addr[40 ];char *fdt_arg, *initrd_arg; -char *bootm_argv[5 ] = { -"bootm" , boot_addr_start, - };const void *uimage = (void *)data->uimage;const void *dtb = (void *)data->dtb;const void *initrd = (void *)data->initrd; +struct bootm_info bmi; fdt_arg = dtb_addr;if (!dtb)
@@ -141,7 +140,7 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,snprintf (boot_addr_start,sizeof (boot_addr_start) -1 ,"0x%p" , uimage); - initrd_arg ="-" ; + initrd_arg =NULL ;if (initrd) {snprintf (initrd_addr,sizeof (initrd_addr) -1 ,"0x%p:0x%zx" , initrd, data->initrd_size);
@@ -149,15 +148,18 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, }printf ("Booting kernel at %s %s %s...\n\n\n" , boot_addr_start, - initrd_arg, fdt_arg); - bootm_argv[2 ] = initrd_arg; - bootm_argv[3 ] = fdt_arg; + initrd_arg ?:"-" , fdt_arg); + +bootm_init (&bmi); + bmi.addr_img = boot_addr_start; + bmi.conf_ramdisk = initrd_arg; + bmi.conf_fdt = fdt_arg;/* Try bootm for legacy and FIT format image */ if (genimg_get_format (uimage) !=IMAGE_FORMAT_INVALID ) -do_bootm (cmdtp,0 ,4 , bootm_argv); +bootm_run (&bmi);else if (IS_ENABLED (CONFIG_CMD_BOOTZ )) -do_bootz (cmdtp,0 ,4 , bootm_argv); +bootz_run (&bmi); }if (data->script)cmd_source_script (data->script,NULL ,NULL );
Signature · 1 line
2.43.0.472.g3155946c3a-goog
PATCH v3 21/22 bootm: Create a function to run through the booti states
In reply to Simon GlassIn a few places, the booti command is used to handle a boot. We want these to be done without needing CONFIG_CMDLINE, so add a new booti_run() function to handle this.
So far this is not used.
---
(no changes since v2)
Changes in v2:
- Rework series to allow OS access to cmdline arguments for bootm
boot/bootm.c | 13 +++++++++++++ include/bootm.h | 13 +++++++++++++ 2 files changed, 26 insertions(+)
boot/bootm.c +13 -0
@@ -1153,6 +1153,19 @@ int bootz_run(struct bootm_info *bmi)return bootm_run_states (bmi, states); } +int booti_run (struct bootm_info *bmi) +{ +int states; + + bmi->cmd_name ="booti" ; + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; +if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) + states |=BOOTM_STATE_RAMDISK ; + +return bootm_run_states (bmi, states); +} +int bootm_boot_start (ulong addr,const char *cmdline) {char addr_str[30 ];
include/bootm.h +13 -0
@@ -176,6 +176,19 @@ int bootm_run(struct bootm_info *bmi);*/ int bootz_run (struct bootm_info *bmi); +/** +* booti_run() - Run the entire booti process +* +* This runs through the booti process from start to finish, using the default +* set of states. +* +* This uses bootm_run_states(). +* +* @bmi: bootm information +* Return: 0 if ok, something else on error +*/ +int booti_run (struct bootm_info *bmi); +void arch_preboot_os (void );/*
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 21/22] bootm: Create a function to run through the booti states
Quoted 7 lines · Simon Glass
In a few places, the booti command is used to handle a boot. We want these to be done without needing
CONFIG_CMDLINE, so add a newbooti_run()function to handle this.So far this is not used.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH v3 22/22 bootm: Create a new boot_run() function to handle booting
In reply to Simon GlassCreate a common function used by the three existing bootz/i/m_run() functions, to reduce duplicated code.
---
Changes in v3:
- Add new boot_run() function
boot/bootm.c | 40 ++++++++++++++-------------------------- include/bootm.h | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 26 deletions(-)
boot/bootm.c +14 -26
@@ -1123,47 +1123,35 @@ err:return ret; } -int bootm_run (struct bootm_info *bmi) +int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states) {int states; - bmi->cmd_name ="bootm" ; - states =BOOTM_STATE_START |BOOTM_STATE_FINDOS |BOOTM_STATE_PRE_LOAD | -BOOTM_STATE_FINDOTHER |BOOTM_STATE_LOADOS | -BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | -BOOTM_STATE_OS_GO |BOOTM_STATE_MEASURE ; + bmi->cmd_name = cmd; + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ;if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; -if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) - states |=BOOTM_STATE_OS_CMDLINE ; + states |= extra_states;return bootm_run_states (bmi, states); } -int bootz_run (struct bootm_info *bmi) +int bootm_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="bootz" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; +return boot_run (bmi,"bootm" ,BOOTM_STATE_START |BOOTM_STATE_FINDOS | +BOOTM_STATE_PRE_LOAD |BOOTM_STATE_FINDOTHER | +BOOTM_STATE_LOADOS ); +} -return bootm_run_states (bmi, states); +int bootz_run (struct bootm_info *bmi) +{ +return boot_run (bmi,"bootz" ,0 ); }int booti_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="booti" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; - -return bootm_run_states (bmi, states); +return boot_run (bmi,"booti" ,0 ); }int bootm_boot_start (ulong addr,const char *cmdline)
include/bootm.h +18 -0
@@ -150,6 +150,24 @@ int bootm_measure(struct bootm_headers *images);*/ int bootm_run_states (struct bootm_info *bmi,int states); +/** +* boot_run() - Run the entire bootm/booti/bootz process +* +* This runs through the boot process from start to finish, with a base set of +* states, along with the extra ones supplied. +* +* This uses bootm_run_states(). +* +* Note that it is normally easier to use bootm_run(), etc. since they handle +* the extra states correctly. +* +* @bmi: bootm information +* @cmd: command being run, NULL if none +* @extra_states: Mask of extra states to use for the boot +* Return: 0 if ok, something else on error +*/ +int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states); +/** * bootm_run() - Run the entire bootm process *
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Re: [PATCH v3 22/22] bootm: Create a new boot_run() function to handle booting
Quoted 99 lines · Simon Glass
Create a common function used by the three existing bootz/i/m_run() functions, to reduce duplicated code.
Signed-off-by Simon Glass <[email protected]>Suggested-by Tom Rini <[email protected]>---
Changes in v3:
- Add newboot_run()functionboot/bootm.c | 40 ++++++++++++++-------------------------- include/bootm.h | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 26 deletions(-)boot/bootm.c +14
-26@@ -1123,47 +1123,35 @@ err:return ret; } -int bootm_run (struct bootm_info *bmi) +int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states) {int states; - bmi->cmd_name ="bootm" ; - states =BOOTM_STATE_START |BOOTM_STATE_FINDOS |BOOTM_STATE_PRE_LOAD | -BOOTM_STATE_FINDOTHER |BOOTM_STATE_LOADOS | -BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | -BOOTM_STATE_OS_GO |BOOTM_STATE_MEASURE ; + bmi->cmd_name = cmd; + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ;if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; -if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) - states |=BOOTM_STATE_OS_CMDLINE ; + states |= extra_states;return bootm_run_states (bmi, states); } -int bootz_run (struct bootm_info *bmi) +int bootm_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="bootz" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; +return boot_run (bmi,"bootm" ,BOOTM_STATE_START |BOOTM_STATE_FINDOS | +BOOTM_STATE_PRE_LOAD |BOOTM_STATE_FINDOTHER | +BOOTM_STATE_LOADOS ); +} -return bootm_run_states (bmi, states); +int bootz_run (struct bootm_info *bmi) +{ +return boot_run (bmi,"bootz" ,0 ); }int booti_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="booti" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; - -return bootm_run_states (bmi, states); +return boot_run (bmi,"booti" ,0 ); }int bootm_boot_start (ulong addr,const char *cmdline)include/bootm.h +11
-0@@ -150,6 +150,24 @@ int bootm_measure(struct bootm_headers *images);*/ int bootm_run_states (struct bootm_info *bmi,int states); +/** +* boot_run() - Run the entire bootm/booti/bootz process +* +* This runs through the boot process from start to finish, with a base set of +* states, along with the extra ones supplied. +* +* This uses bootm_run_states(). +* +* Note that it is normally easier to use bootm_run(), etc. since they handle +* the extra states correctly. +*
include/bootm.h int bootm_measure(struct bootm_headers *images); · line 173
Quoted 10 lines
include/bootm.h +7
-0+* @bmi: bootm information +* @cmd: command being run, NULL if none +* @extra_states: Mask of extra states to use for the boot +* Return: 0 if ok, something else on error +*/ +int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states); +/** * bootm_run() - Run the entire bootm process *
Overall good, thanks. My question is, should we mark the others as static, or is this new helper static and not to be called externally?
Signature · 1 line
Tom
Re: [PATCH v3 22/22] bootm: Create a new boot_run() function to handle booting
Hi Tom,
Quoted 106 lines · Tom Rini
Quoted 104 lines · Simon Glass
Create a common function used by the three existing bootz/i/m_run() functions, to reduce duplicated code.
Signed-off-by Simon Glass <[email protected]>Suggested-by Tom Rini <[email protected]>---
Changes in v3:
- Add newboot_run()functionboot/bootm.c | 40 ++++++++++++++-------------------------- include/bootm.h | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 26 deletions(-)boot/bootm.c +14
-26@@ -1123,47 +1123,35 @@ err:return ret; } -int bootm_run (struct bootm_info *bmi) +int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states) {int states; - bmi->cmd_name ="bootm" ; - states =BOOTM_STATE_START |BOOTM_STATE_FINDOS |BOOTM_STATE_PRE_LOAD | -BOOTM_STATE_FINDOTHER |BOOTM_STATE_LOADOS | -BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | -BOOTM_STATE_OS_GO |BOOTM_STATE_MEASURE ; + bmi->cmd_name = cmd; + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ;if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; -if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) - states |=BOOTM_STATE_OS_CMDLINE ; + states |= extra_states;return bootm_run_states (bmi, states); } -int bootz_run (struct bootm_info *bmi) +int bootm_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="bootz" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; +return boot_run (bmi,"bootm" ,BOOTM_STATE_START |BOOTM_STATE_FINDOS | +BOOTM_STATE_PRE_LOAD |BOOTM_STATE_FINDOTHER | +BOOTM_STATE_LOADOS ); +} -return bootm_run_states (bmi, states); +int bootz_run (struct bootm_info *bmi) +{ +return boot_run (bmi,"bootz" ,0 ); }int booti_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="booti" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; - -return bootm_run_states (bmi, states); +return boot_run (bmi,"booti" ,0 ); }int bootm_boot_start (ulong addr,const char *cmdline)include/bootm.h +16
-0@@ -150,6 +150,24 @@ int bootm_measure(struct bootm_headers *images);*/ int bootm_run_states (struct bootm_info *bmi,int states); +/** +* boot_run() - Run the entire bootm/booti/bootz process +* +* This runs through the boot process from start to finish, with a base set of +* states, along with the extra ones supplied. +* +* This uses bootm_run_states(). +* +* Note that it is normally easier to use bootm_run(), etc. since they handle +* the extra states correctly. +* +* @bmi: bootm information +* @cmd: command being run, NULL if none +* @extra_states: Mask of extra states to use for the boot +* Return: 0 if ok, something else on error +*/
Quoted 8 lines
include/bootm.h int bootm_measure(struct bootm_headers *images); · line 173
Quoted 5 lines
include/bootm.h +2
-0+int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states); +/** * bootm_run() - Run the entire bootm process * Overall good, thanks. My question is, should we mark the others as static, or is this new helper static and not to be called externally?
The others are used externally.
For bootm_run() I toyed with the idea of it being static, but then wondered if we might use that programmatically instead of the bootz/i/m(_run) versions. It is quite nice that the differences are now pretty minor between them.
I don't mind either way, though.
Regards,
Simon
Tom Rini
Reviewed-byRe: [PATCH v3 22/22] bootm: Create a new boot_run() function to handle booting
Quoted 118 lines · Simon Glass
Hi Tom,
Quoted 106 lines · Tom Rini
Quoted 104 lines · Simon Glass
Create a common function used by the three existing bootz/i/m_run() functions, to reduce duplicated code.
Signed-off-by Simon Glass <[email protected]>Suggested-by Tom Rini <[email protected]>---
Changes in v3:
- Add newboot_run()functionboot/bootm.c | 40 ++++++++++++++-------------------------- include/bootm.h | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 26 deletions(-)boot/bootm.c +14
-26@@ -1123,47 +1123,35 @@ err:return ret; } -int bootm_run (struct bootm_info *bmi) +int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states) {int states; - bmi->cmd_name ="bootm" ; - states =BOOTM_STATE_START |BOOTM_STATE_FINDOS |BOOTM_STATE_PRE_LOAD | -BOOTM_STATE_FINDOTHER |BOOTM_STATE_LOADOS | -BOOTM_STATE_OS_PREP |BOOTM_STATE_OS_FAKE_GO | -BOOTM_STATE_OS_GO |BOOTM_STATE_MEASURE ; + bmi->cmd_name = cmd; + states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | +BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ;if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) states |=BOOTM_STATE_RAMDISK ; -if (IS_ENABLED (CONFIG_PPC ) ||IS_ENABLED (CONFIG_MIPS )) - states |=BOOTM_STATE_OS_CMDLINE ; + states |= extra_states;return bootm_run_states (bmi, states); } -int bootz_run (struct bootm_info *bmi) +int bootm_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="bootz" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; +return boot_run (bmi,"bootm" ,BOOTM_STATE_START |BOOTM_STATE_FINDOS | +BOOTM_STATE_PRE_LOAD |BOOTM_STATE_FINDOTHER | +BOOTM_STATE_LOADOS ); +} -return bootm_run_states (bmi, states); +int bootz_run (struct bootm_info *bmi) +{ +return boot_run (bmi,"bootz" ,0 ); }int booti_run (struct bootm_info *bmi) { -int states; - - bmi->cmd_name ="booti" ; - states =BOOTM_STATE_MEASURE |BOOTM_STATE_OS_PREP | -BOOTM_STATE_OS_FAKE_GO |BOOTM_STATE_OS_GO ; -if (IS_ENABLED (CONFIG_SYS_BOOT_RAMDISK_HIGH )) - states |=BOOTM_STATE_RAMDISK ; - -return bootm_run_states (bmi, states); +return boot_run (bmi,"booti" ,0 ); }int bootm_boot_start (ulong addr,const char *cmdline)include/bootm.h +16
-0@@ -150,6 +150,24 @@ int bootm_measure(struct bootm_headers *images);*/ int bootm_run_states (struct bootm_info *bmi,int states); +/** +* boot_run() - Run the entire bootm/booti/bootz process +* +* This runs through the boot process from start to finish, with a base set of +* states, along with the extra ones supplied. +* +* This uses bootm_run_states(). +* +* Note that it is normally easier to use bootm_run(), etc. since they handle +* the extra states correctly. +* +* @bmi: bootm information +* @cmd: command being run, NULL if none +* @extra_states: Mask of extra states to use for the boot +* Return: 0 if ok, something else on error +*/ Quoted 8 lines
include/bootm.h int bootm_measure(struct bootm_headers *images); · line 173
Quoted 5 lines
include/bootm.h +2
-0+int boot_run (struct bootm_info *bmi,const char *cmd,int extra_states); +/** * bootm_run() - Run the entire bootm process * Overall good, thanks. My question is, should we mark the others as static, or is this new helper static and not to be called externally?
Quoted 8 lines
The others are used externally.
For
bootm_run()I toyed with the idea of it being static, but then wondered if we might use that programmatically instead of the bootz/i/m(_run) versions. It is quite nice that the differences are now pretty minor between them.I don't mind either way, though.
OK, lets put it on the TODO list for once the CMDLINE=n case is fully flushed out and code otherwise cleaned up and organized, it'll perhaps be clearer then if the answer is old functions, new function or neither function.
Signature · 1 line
Tom
Quoted 9 lines · Simon Glass
This series continues refactoring the bootm code to allow it to be used with
CONFIG_COMMANDdisabled. The OS-handling code is refactored and a newbootm_run()function is created to run through the bootm stages. This completes the work.A
booti_go()function is created also, in case it proves useful, but at last for now standard boot does not use this.[...]
Applied to u-boot/next, thanks!
Signature · 1 line
Tom