[PATCH 12/16] x86: zboot: Allow setting a separate setup base address

Wolfgang Wallner wolfgang.wallner at br-automation.com
Thu Aug 13 13:22:49 CEST 2020


Hi Simon,

-----"Simon Glass" <sjg at chromium.org> schrieb: -----
> Betreff: [PATCH 12/16] x86: zboot: Allow setting a separate setup base address
> 
> At present the setup block is always obtained from the image
> automatically. In some cases it can be useful to use a setup block
> obtained elsewhere, e.g. if the image has already been unpacked. Add an
> argument to support this and update the logic to use it if provided.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
>  arch/x86/lib/zimage.c | 28 ++++++++++++++++++++++------
>  1 file changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
> index 4a0a69c8f7c..b64d0196f2d 100644
> --- a/arch/x86/lib/zimage.c
> +++ b/arch/x86/lib/zimage.c
> @@ -366,6 +366,11 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
>  		state.initrd_addr = simple_strtoul(argv[3], NULL, 16);
>  	if (argc >= 5)
>  		state.initrd_size = simple_strtoul(argv[4], NULL, 16);
> +	if (argc >= 6) {
> +		state.base_ptr = (void *)simple_strtoul(argv[5], NULL, 16);
> +		state.load_address = state.bzimage_addr;
> +		state.bzimage_addr = 0;

Nit: I found it rather confusing to understand what is going in the case when
this parameter is used compared to the 'normal' operation. Maybe you could add
comments here or in do_zboot_load() when the parameter is used?

> +	}
>  
>  	return 0;
>  }
> @@ -375,11 +380,20 @@ static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc,
>  {
>  	struct boot_params *base_ptr;
>  
> -	base_ptr = load_zimage((void *)state.bzimage_addr, state.bzimage_size,
> -			       &state.load_address);
> -	if (!base_ptr) {
> -		puts("## Kernel loading failed ...\n");
> -		return CMD_RET_FAILURE;
> +	if (state.base_ptr) {
> +		struct boot_params *from = (struct boot_params *)state.base_ptr;
> +
> +		base_ptr = (struct boot_params *)DEFAULT_SETUP_BASE;
> +		printf("Building boot_params at 0x%8.8lx\n", (ulong)base_ptr);
> +		memset(base_ptr, '\0', sizeof(*base_ptr));
> +		base_ptr->hdr = from->hdr;
> +	} else {
> +		base_ptr = load_zimage((void *)state.bzimage_addr, state.bzimage_size,
> +				       &state.load_address);
> +		if (!base_ptr) {
> +			puts("## Kernel loading failed ...\n");
> +			return CMD_RET_FAILURE;
> +		}
>  	}
>  	state.base_ptr = base_ptr;
>  	if (env_set_hex("zbootbase", (ulong)base_ptr) ||
> @@ -486,7 +500,7 @@ int do_zboot_parent(struct cmd_tbl *cmdtp, int flag, int argc,
>  
>  U_BOOT_CMDREP_COMPLETE(
>  	zboot, 8, do_zboot_parent, "Boot bzImage",
> -	"[addr] [size] [initrd addr] [initrd size]\n"
> +	"[addr] [size] [initrd addr] [initrd size] [setup]\n"
>  	"      addr -        The optional starting address of the bzimage.\n"
>  	"                    If not set it defaults to the environment\n"
>  	"                    variable \"fileaddr\".\n"
> @@ -494,6 +508,8 @@ U_BOOT_CMDREP_COMPLETE(
>  	"                    zero.\n"
>  	"      initrd addr - The address of the initrd image to use, if any.\n"
>  	"      initrd size - The size of the initrd image to use, if any.\n"
> +	"      setup -       The address of the kernel setup region, if this\n"
> +	"                    is not at addr\n"
>  	"\n"
>  	"Sub-commands to do part of the zboot sequence:\n"
>  	"\tstart [addr [arg ...]] - specify arguments\n"
> -- 
> 2.28.0.163.g6104cc2f0b6-goog

Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>


More information about the U-Boot mailing list