All of lore.kernel.org
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH 2/3 v5] cmd: efi: ESRT table debug print
Date: Wed, 3 Mar 2021 09:01:51 +0900	[thread overview]
Message-ID: <20210303000151.GB10164@laputa> (raw)
In-Reply-To: <20210302121354.23009-3-jose.marinho@arm.com>

On Tue, Mar 02, 2021 at 12:13:53PM +0000, Jose Marinho wrote:
> This commit enables the ESRT printing from the u-boot shell by invoking:
> - efidebug capsule esrt
> 
> Signed-off-by: Jose Marinho <jose.marinho@arm.com>
> 
> CC: Heinrich Schuchardt	<xypron.glpk@gmx.de>
> CC: Sughosh Ganu <sughosh.ganu@linaro.org>
> CC: AKASHI Takahiro <takahiro.akashi@linaro.org>
> CC: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> CC: Andre Przywara <andre.przywara@arm.com>
> CC: Alexander Graf <agraf@csgraf.de>
> CC: nd at arm.com
> 
> ---
>  cmd/efidebug.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> index a7dace2f80..5a9ff2bd9a 100644
> --- a/cmd/efidebug.c
> +++ b/cmd/efidebug.c
> @@ -129,6 +129,61 @@ static int do_efi_capsule_show(struct cmd_tbl *cmdtp, int flag,
>  	return CMD_RET_SUCCESS;
>  }
>  
> +#ifdef CONFIG_EFI_ESRT
> +/**
> + * do_efi_capsule_esrt() - manage UEFI capsules
> + *
> + * @cmdtp:	Command table
> + * @flag:	Command flag
> + * @argc:	Number of arguments
> + * @argv:	Argument array
> + * Return:	CMD_RET_SUCCESS on success,
> + *		CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
> + *
> + * Implement efidebug "capsule esrt" sub-command.
> + * The prints the current ESRT table.
> + *
> + *     efidebug capsule esrt

Strictly speaking, ESRT does not always require capsules
to be used as "23.4.2 ESRT and Firmware Management Protocol" says.

> + */
> +static int do_efi_capsule_esrt(struct cmd_tbl *cmdtp, int flag,
> +			       int argc, char * const argv[])
> +{
> +	struct efi_system_resource_table *esrt = NULL;
> +
> +	if (argc != 1)
> +		return CMD_RET_USAGE;
> +
> +	for (int idx = 0; idx < systab.nr_tables; idx++)
> +		if (!guidcmp(&efi_esrt_guid, &systab.tables[idx].guid))
> +			esrt = (struct efi_system_resource_table *)systab.tables[idx].table;
> +
> +	if (!esrt)
> +		return CMD_RET_FAILURE;

Is this really a failure?
Even so, it would be nice to print a verbose message here.

> +
> +	printf("========================================\n");
> +	printf("ESRT: fw_resource_count=%d\n", esrt->fw_resource_count);
> +	printf("ESRT: fw_resource_count_max=%d\n", esrt->fw_resource_count_max);
> +	printf("ESRT: fw_resource_version=%lld\n", esrt->fw_resource_version);
> +
> +	for (int idx = 0; idx < esrt->fw_resource_count; idx++) {
> +		printf("[entry %d]==============================\n", idx);
> +		printf("ESRT: fw_class=%pUL\n", &esrt->entries[idx].fw_class);

More symbolic expression would be friendly.

> +		printf("ESRT: fw_type=%d\n", esrt->entries[idx].fw_type);
> +		printf("ESRT: fw_version=%d\n", esrt->entries[idx].fw_version);
> +		printf("ESRT: lowest_supported_fw_version=%d\n",
> +		       esrt->entries[idx].lowest_supported_fw_version);
> +		printf("ESRT: capsule_flags=%d\n",
> +		       esrt->entries[idx].capsule_flags);
> +		printf("ESRT: last_attempt_version=%d\n",
> +		       esrt->entries[idx].last_attempt_version);
> +		printf("ESRT: last_attempt_status=%d\n",
> +		       esrt->entries[idx].last_attempt_status);

ditto.

> +	}
> +	printf("========================================\n");
> +
> +	return CMD_RET_SUCCESS;
> +}
> +#endif /*  CONFIG_EFI_ESRT */
>  /**
>   * do_efi_capsule_res() - show a capsule update result
>   *
> @@ -221,6 +276,10 @@ static struct cmd_tbl cmd_efidebug_capsule_sub[] = {
>  			 "", ""),
>  	U_BOOT_CMD_MKENT(show, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_show,
>  			 "", ""),
> +#ifdef CONFIG_EFI_ESRT
> +	U_BOOT_CMD_MKENT(esrt, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_esrt,
> +			 "", ""),
> +#endif
>  	U_BOOT_CMD_MKENT(disk-update, 0, 0, do_efi_capsule_on_disk_update,
>  			 "", ""),
>  	U_BOOT_CMD_MKENT(result, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_res,
> @@ -256,6 +315,7 @@ static int do_efi_capsule(struct cmd_tbl *cmdtp, int flag,
>  
>  	return cp->cmd(cmdtp, flag, argc, argv);
>  }
> +
>  #endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */
>  
>  /**
> @@ -1580,6 +1640,10 @@ static char efidebug_help_text[] =
>  	"  - show capsule information\n"
>  	"efidebug capsule result [<capsule result var>]\n"
>  	"  - show a capsule update result\n"
> +#ifdef CONFIG_EFI_ESRT
> +	"efidebug capsule esrt\n"
> +	"  - print the ESRT\n"
> +#endif
>  	"\n"
>  #endif
>  	"efidebug devices\n"
> -- 
> 2.17.1
> 

  reply	other threads:[~2021-03-03  0:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-02 12:13 [PATCH 0/3 v5] Add ESRT and test ESRT creation Jose Marinho
2021-03-02 12:13 ` [PATCH 1/3 v5] efi: Add ESRT to the EFI system table Jose Marinho
2021-03-02 12:13 ` [PATCH 2/3 v5] cmd: efi: ESRT table debug print Jose Marinho
2021-03-03  0:01   ` AKASHI Takahiro [this message]
2021-03-02 12:13 ` [PATCH 3/3 v5] efi: ESRT creation tests Jose Marinho
2021-03-02 18:30   ` Heinrich Schuchardt
2021-03-02 23:48     ` AKASHI Takahiro
2021-03-03  9:34       ` Jose Marinho
2021-03-02 17:26 ` [PATCH RESEND 1/3 v5] efi: Add ESRT to the EFI system table Jose Marinho
2021-03-02 18:11   ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210303000151.GB10164@laputa \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.