[U-Boot] [RFC v2 05/11] cmd: bootefi: merge efi_install_fdt() and efi_process_fdt()

AKASHI Takahiro takahiro.akashi at linaro.org
Thu Mar 28 01:31:26 UTC 2019


On Wed, Mar 27, 2019 at 07:33:49AM +0100, Heinrich Schuchardt wrote:
> On 3/27/19 5:40 AM, AKASHI Takahiro wrote:
> > This is a preparatory patch for reworking do_bootefi() in later patch.
> > For simplicity, merge two functions.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
> > ---
> >  cmd/bootefi.c | 67 +++++++++++++++++++++------------------------------
> >  1 file changed, 28 insertions(+), 39 deletions(-)
> >
> > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > index aba8b203d419..ce0db07f8633 100644
> > --- a/cmd/bootefi.c
> > +++ b/cmd/bootefi.c
> > @@ -165,41 +165,8 @@ static void efi_carve_out_dt_rsv(void *fdt)
> >  	}
> >  }
> >
> > -static efi_status_t efi_install_fdt(ulong fdt_addr)
> > -{
> > -	bootm_headers_t img = { 0 };
> > -	efi_status_t ret;
> > -	void *fdt;
> > -
> > -	fdt = map_sysmem(fdt_addr, 0);
> > -	if (fdt_check_header(fdt)) {
> > -		printf("ERROR: invalid device tree\n");
> > -		return EFI_INVALID_PARAMETER;
> > -	}
> > -
> > -	/* Create memory reservation as indicated by the device tree */
> > -	efi_carve_out_dt_rsv(fdt);
> > -
> > -	/* Prepare fdt for payload */
> > -	ret = copy_fdt(&fdt);
> > -	if (ret)
> > -		return ret;
> > -
> > -	if (image_setup_libfdt(&img, fdt, 0, NULL)) {
> > -		printf("ERROR: failed to process device tree\n");
> > -		return EFI_LOAD_ERROR;
> > -	}
> > -
> > -	/* Link to it in the efi tables */
> > -	ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
> > -	if (ret != EFI_SUCCESS)
> > -		return EFI_OUT_OF_RESOURCES;
> > -
> > -	return ret;
> > -}
> > -
> >  /**
> > - * efi_process_fdt() - process fdt passed by a command argument
> > + * efi_install_fdt() - install fdt passed by a command argument
> >   * @fdt_opt:	pointer to argument
> >   * Return:	CMD_RET_SUCCESS on success,
> >  		CMD_RET_USAGE or CMD_RET_FAILURE otherwise
> > @@ -207,21 +174,43 @@ static efi_status_t efi_install_fdt(ulong fdt_addr)
> >   * If specified, fdt will be installed as configuration table,
> >   * otherwise no fdt will be passed.
> >   */
> > -static efi_status_t efi_process_fdt(const char *fdt_opt)
> > +static efi_status_t efi_install_fdt(const char *fdt_opt)
> >  {
> >  	unsigned long fdt_addr;
> > +	void *fdt;
> > +	bootm_headers_t img = { 0 };
> >  	efi_status_t ret;
> >
> >  	if (fdt_opt) {
> > +		/* Install device tree */
> >  		fdt_addr = simple_strtoul(fdt_opt, NULL, 16);
> >  		if (!fdt_addr && *fdt_opt != '0')
> >  			return EFI_INVALID_PARAMETER;
> >
> > -		/* Install device tree */
> > -		ret = efi_install_fdt(fdt_addr);
> > +		fdt = map_sysmem(fdt_addr, 0);
> > +		if (fdt_check_header(fdt)) {
> > +			printf("ERROR: invalid device tree\n");
> > +			return EFI_INVALID_PARAMETER;
> > +		}
> > +
> > +		/* Create memory reservation as indicated by the device tree */
> > +		efi_carve_out_dt_rsv(fdt);
> > +
> > +		/* Prepare fdt for payload */
> > +		ret = copy_fdt(&fdt);
> > +		if (ret)
> > +			return ret;
> > +
> > +		if (image_setup_libfdt(&img, fdt, 0, NULL)) {
> > +			printf("ERROR: failed to process device tree\n");
> > +			return EFI_LOAD_ERROR;
> > +		}
> > +
> > +		/* Link to it in the efi tables */
> > +		ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
> >  		if (ret != EFI_SUCCESS) {
> >  			printf("ERROR: failed to install device tree\n");
> > -			return ret;
> > +			return EFI_OUT_OF_RESOURCES;
> >  		}
> >  	} else {
> >  		/* Remove device tree. EFI_NOT_FOUND can be ignored here */
> > @@ -441,7 +430,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> >  	if (argc < 2)
> >  		return CMD_RET_USAGE;
> >
> > -	r = fdt_process_fdt(argc > 2 ? argv[2] : NULL);
> > +	r = fdt_install_fdt(argc > 2 ? argv[2] : NULL);
> >  	if (r != EFI_SUCCESS)
> >  		return r;
> 
> We want to return CMD_RET_* from do_bootefi() and not EFI_*.

Right, will fix.

-Takahiro Akashi

> Best regards
> 
> Heinrich
> 
> >
> >
> 


More information about the U-Boot mailing list