From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13A26C433F5 for ; Wed, 5 Oct 2022 00:23:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 46B9F84C59; Wed, 5 Oct 2022 02:23:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XoPu7Xw0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D59584D5B; Wed, 5 Oct 2022 02:23:40 +0200 (CEST) Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AAEF184BFD for ; Wed, 5 Oct 2022 02:23:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x435.google.com with SMTP id y136so14508002pfb.3 for ; Tue, 04 Oct 2022 17:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=iZv36xTD/CuTH3krXX6GwRenNAwq2H6416nVs7veGaU=; b=XoPu7Xw0/vdpNH2cfhC8Yh5K0Da5XD6h5bm+saWJcE+4hUqaBgEmYdoVk1jiDQ6KGa i6S2Uql48ZXutcuWrojND1qsb8M64SdS44FjgnFUJrkwcoxDF2bTdZyhMnlEtQ/yXTVJ keyemCeyJ0KZfZMHS39s27ZjIY57sU8EzmM6pRbVI2OYt6DxwNCTZ6tzmqU1uSRx+lmi 4YcgffmoY8yYkavFV8I88b81V6oidX7fitSggrtLgVAsUpERmRJ3TCNkG+NQHNYbYASQ Wv7o6RJkhpKACTfA1yaGlNzsuYcTST2HXv+ahAuebzqxvpEYrOOkeA0ABfTy0d1X1iB5 AgFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iZv36xTD/CuTH3krXX6GwRenNAwq2H6416nVs7veGaU=; b=ww9SlaXRZLOEOTBS5N/F3sDL9ejfACxEbK3q5l2AOhhVhOhr8MedxrxAY4YSyYgmaR 9ltppugkJtfmlCodV/OWdrGO7gQTFVZZiNtgEqZTJEW8vkJpb9EGt4+qDlxpb8IB2cTK fXsPZYuh4vkB3qwGTzEUYhUeLX2+XLCSteOsk6I1NNTy81nDWowvxE1kQ7jgffAgKfiM cV+9b78Tpwoh0CVYG4aerIgTBw4jNPa94CGm5mzMgnpoJGDRndygKAPJU2zMm7vwA758 ck8i3qneKXCGWdvtkiiWss5KToEMQOm30arSluNyMtpoPqOT3d4XyH8DFnXfU+iQLT/x sk2Q== X-Gm-Message-State: ACrzQf2ByS7wI/4pFFhrbARwgbxpwQVd9egopbgYlBS0GdWWWB3EZWH1 PYWub6VvnfOB8e4wpx8ypzsFYw== X-Google-Smtp-Source: AMsMyM4sCH2b6I4R52dsYJyqN4AzNPIYqzqd121MTw4tsouyvHiojgX33g4TFBjMpPMXMDObr0HKBg== X-Received: by 2002:a65:498b:0:b0:412:8e4:2842 with SMTP id r11-20020a65498b000000b0041208e42842mr25283644pgs.71.1664929414725; Tue, 04 Oct 2022 17:23:34 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:39e7:db31:fd97:9c8d]) by smtp.gmail.com with ESMTPSA id q13-20020a170902dacd00b0017825ab5320sm9541887plx.251.2022.10.04.17.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 17:23:33 -0700 (PDT) Date: Wed, 5 Oct 2022 09:23:30 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: Ilias Apalodimas , u-boot@lists.denx.de Subject: Re: [PATCH 1/1] cmd: simplify command efidebug Message-ID: <20221005002330.GA34350@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , Ilias Apalodimas , u-boot@lists.denx.de References: <20221004134032.128142-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221004134032.128142-1-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Heinrich, On Tue, Oct 04, 2022 at 03:40:32PM +0200, Heinrich Schuchardt wrote: > Currently we have subcommands 'efidebug dh' which shows protocols per > handle and 'efidebug devices' which shows the device path. None shows which > U-Boot device matches the handle. If you know how a device path display format is constructed, you can identify it. For instance, /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -> efi_root /VenHw(bbe4e671-5773-4ea1-9aab-3a7dbf40c482,00) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -> host 0 /HD(1,GPT,7e5c17c5-3f5f-49d0-ae96-511b21d7f273,0x800,0x3f7df) ^ -> partition 1 > Change 'efidebug dh' to show the device path and the U-Boot device if any > is associated with the handle. There is a good reason for two separate subcommands. While "dh" shows all the handles which currently exist on the system, "devices" shows only ones with device path protocol. The number of handles can possibly be huge (try "dh" on EDK2). For those who are interested in what devices are connected at some point, "devices" subcommand is still useful. The problem is not "devices" subcommand itself, but the display format of device path. UEFI spec says, in "10.6 EFI Device Path Display Format Overview", "This section describes the recommended conversion between an EFI Device ^^^^^^^^^^^ Path Protocol and text." So if there is more readable/understandable format, we may want to use it for U-Boot UEFI (at least, as an alternate option of format). Say, /VenHw(root)/VenHw(host, 0)/HD(1,GPT,....) I believe that it is simple and unambiguous. > Remove 'efidebug devices'. So please don't remove "devices". Instead, I recommend that the same change be applied to this subcommand, displaying both formats at "devices". -Takahiro Akashi > Old output of 'efidebug dh': > > Handle Protocols > ================ ==================== > 000000001b22e690 Device Path, Block IO > 000000001b22e800 Device Path, Block IO, system, Simple File System > > New output of 'efidebug dh': > > 000000001b22e690 (host0) > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/VenHw(bbe4e671-5773-4ea1-9aab-3a7dbf40c482,00) > Block IO > > 000000001b22e800 (host0:1) > /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/VenHw(bbe4e671-5773-4ea1-9aab-3a7dbf40c482,00)/HD(1,GPT,7e5c17c5-3f5f-49d0-ae96-511b21d7f273,0x800,0x3f7df) > Block IO > system > Simple File System > > Signed-off-by: Heinrich Schuchardt > --- > cmd/efidebug.c | 102 ++++++++----------------------------------------- > 1 file changed, 15 insertions(+), 87 deletions(-) > > diff --git a/cmd/efidebug.c b/cmd/efidebug.c > index 84e6ff5565..76a6b4d8eb 100644 > --- a/cmd/efidebug.c > +++ b/cmd/efidebug.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -344,79 +345,11 @@ static int do_efi_capsule(struct cmd_tbl *cmdtp, int flag, > } > #endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ > > -/** > - * efi_get_device_path_text() - get device path text > - * > - * Return the text representation of the device path of a handle. > - * > - * @handle: handle of UEFI device > - * Return: > - * Pointer to the device path text or NULL. > - * The caller is responsible for calling FreePool(). > - */ > -static u16 *efi_get_device_path_text(efi_handle_t handle) > -{ > - struct efi_handler *handler; > - efi_status_t ret; > - > - ret = efi_search_protocol(handle, &efi_guid_device_path, &handler); > - if (ret == EFI_SUCCESS && handler->protocol_interface) { > - struct efi_device_path *dp = handler->protocol_interface; > - > - return efi_dp_str(dp); > - } else { > - return NULL; > - } > -} > - > #define EFI_HANDLE_WIDTH ((int)sizeof(efi_handle_t) * 2) > > static const char spc[] = " "; > static const char sep[] = "================"; > > -/** > - * do_efi_show_devices() - show UEFI devices > - * > - * @cmdtp: Command table > - * @flag: Command flag > - * @argc: Number of arguments > - * @argv: Argument array > - * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure > - * > - * Implement efidebug "devices" sub-command. > - * Show all UEFI devices and their information. > - */ > -static int do_efi_show_devices(struct cmd_tbl *cmdtp, int flag, > - int argc, char *const argv[]) > -{ > - efi_handle_t *handles; > - efi_uintn_t num, i; > - u16 *dev_path_text; > - efi_status_t ret; > - > - ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL, > - &num, &handles)); > - if (ret != EFI_SUCCESS) > - return CMD_RET_FAILURE; > - > - if (!num) > - return CMD_RET_SUCCESS; > - > - printf("Device%.*s Device Path\n", EFI_HANDLE_WIDTH - 6, spc); > - printf("%.*s ====================\n", EFI_HANDLE_WIDTH, sep); > - for (i = 0; i < num; i++) { > - dev_path_text = efi_get_device_path_text(handles[i]); > - if (dev_path_text) { > - printf("%p %ls\n", handles[i], dev_path_text); > - efi_free_pool(dev_path_text); > - } > - } > - > - efi_free_pool(handles); > - > - return CMD_RET_SUCCESS; > -} > - > /** > * efi_get_driver_handle_info() - get information of UEFI driver > * > @@ -535,26 +468,25 @@ static int do_efi_show_handles(struct cmd_tbl *cmdtp, int flag, > if (!num) > return CMD_RET_SUCCESS; > > - printf("Handle%.*s Protocols\n", EFI_HANDLE_WIDTH - 6, spc); > - printf("%.*s ====================\n", EFI_HANDLE_WIDTH, sep); > for (i = 0; i < num; i++) { > - printf("%p", handles[i]); > + struct efi_handler *handler; > + > + printf("\n%p", handles[i]); > + if (handles[i]->dev) > + printf(" (%s)", handles[i]->dev->name); > + printf("\n"); > + /* Print device path */ > + ret = efi_search_protocol(handles[i], &efi_guid_device_path, > + &handler); > + if (ret == EFI_SUCCESS) > + printf(" %pD\n", handler->protocol_interface); > ret = EFI_CALL(BS->protocols_per_handle(handles[i], &guid, > &count)); > - if (ret || !count) { > - putc('\n'); > - continue; > - } > - > + /* Print other protocols */ > for (j = 0; j < count; j++) { > - if (j) > - printf(", "); > - else > - putc(' '); > - > - printf("%pUs", guid[j]); > + if (guidcmp(guid[j], &efi_guid_device_path)) > + printf(" %pUs\n", guid[j]); > } > - putc('\n'); > } > > efi_free_pool(handles); > @@ -1539,8 +1471,6 @@ static struct cmd_tbl cmd_efidebug_sub[] = { > U_BOOT_CMD_MKENT(capsule, CONFIG_SYS_MAXARGS, 1, do_efi_capsule, > "", ""), > #endif > - U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices, > - "", ""), > U_BOOT_CMD_MKENT(drivers, CONFIG_SYS_MAXARGS, 1, do_efi_show_drivers, > "", ""), > U_BOOT_CMD_MKENT(dh, CONFIG_SYS_MAXARGS, 1, do_efi_show_handles, > @@ -1630,8 +1560,6 @@ static char efidebug_help_text[] = > #endif > "\n" > #endif > - "efidebug devices\n" > - " - show UEFI devices\n" > "efidebug drivers\n" > " - show UEFI drivers\n" > "efidebug dh\n" > -- > 2.37.2 >