From patchwork Fri Feb 22 08:10:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1046632 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="I4g1Iwzg"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 445PCp1z1Cz9s9y for ; Fri, 22 Feb 2019 19:10:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D4C25C21E38; Fri, 22 Feb 2019 08:10:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 96F04C21F1A; Fri, 22 Feb 2019 08:09:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9405DC21F2F; Fri, 22 Feb 2019 08:09:12 +0000 (UTC) Received: from mail-yw1-f65.google.com (mail-yw1-f65.google.com [209.85.161.65]) by lists.denx.de (Postfix) with ESMTPS id C8D64C21F1A for ; Fri, 22 Feb 2019 08:09:08 +0000 (UTC) Received: by mail-yw1-f65.google.com with SMTP id s204so525328ywg.2 for ; Fri, 22 Feb 2019 00:09:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PtWZ9ye66WLUprYkXWfkdxbWbNY6d7AXNk6SyuWhU48=; b=I4g1IwzgYGlB2nHyBsf6yg6Whg5WrF0tkEqlVubI++STibvGK/AlPJmZyvIE8L/WaU 3V2f4YIdWqw6KND+RBaEZUY/IPR3uwi6lMyuYzO3ejoLGsRlKDTXeCq+zK3gmk4OS+4B dE3xmyAWDgXXVO/rgJAMYvU95B5nH6/TL/xtYhbWCL7eg8jz6bMd57dNNrO73CCNE6yV MEJijIL5fRnK/lWm31pDtYhZNNh5EVl4l7IOlbdwPKkrrTZIJOmZyD452EX2lAcflomb 8d5zghfKVMK5UnzwgahQlaDDPiXkGd8HrTkEWnzrbvBnpFundeziQPVnof/cR/9mxSln stPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PtWZ9ye66WLUprYkXWfkdxbWbNY6d7AXNk6SyuWhU48=; b=O3Wh1nzLlT9hx/RLGms07E6zKhLHo76VoOcwnwpGZxdJdwiJZsLYL6+h3vmnfWprWL sKFBJiSavGYVg5QT93cuCHPJ9e6Re67y2fCQQIlsnR4aqZAUHiH4m8ZqMNmUDVT0s1+d Bv1OW0B3OPjk36rRaJ39OujizfgZi60FrhDR+X6UdWdT66kx12fKAacaKdEDMy4CdsoG lgkc1stTigGOaZAHEbtkx0ikDO51Rf06tc9nbVSMNnTaIyKDPOYCa7GOt04tDixxTOny YM8gvTlvbJffJ89UtVpaoPWwv4w+pMX24Wof0HAHsT5mPimSxU5Kq8fPCm8FNYTYuG1W 0yVg== X-Gm-Message-State: AHQUAubUJnDYQGOMcoXL7W35IgjKbGTunueblJ3N6jtADitLhT5WWGbE umlvud/RSIPvtEymj6qLllv09g== X-Google-Smtp-Source: AHgI3IaNCXHBUQUtO1WafoP68HkQMrVrRt9QLf+Yu9g8Z6yKwulev5RYqVrhD3OgOV3VsAemNQzW4Q== X-Received: by 2002:a81:5d87:: with SMTP id r129mr2150962ywb.347.1550822947772; Fri, 22 Feb 2019 00:09:07 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id c124sm250175ywd.73.2019.02.22.00.09.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 00:09:07 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Fri, 22 Feb 2019 17:10:10 +0900 Message-Id: <20190222081014.2117-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222081014.2117-1-takahiro.akashi@linaro.org> References: <20190222081014.2117-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v8 4/8] cmd: efidebug: add devices command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" "devices" command prints all the uefi variables on the system. => efi devices Scanning disk ahci_scsi.id0lun0... Scanning disk ahci_scsi.id1lun0... Found 4 disks Device Device Path ================ ==================== 000000007ef07ea0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b) 000000007ef00c10 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(0,0) 000000007ef00dd0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0) 000000007ef07be0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(1,MBR,0x086246ba,0x800,0x40000) 000000007ef07510 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(2,MBR,0x086246ba,0x40800,0x3f800) Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- cmd/efidebug.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index ef3a66e393f0..794e96890024 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -15,6 +15,80 @@ #include #include +#define BS systab.boottime + +/** + * efi_get_device_handle_info() - get information of UEFI device + * + * @handle: Handle of UEFI device + * @dev_path_text: Pointer to text of device path + * Return: 0 on success, -1 on failure + * + * Currently return a formatted text of device path. + */ +static int efi_get_device_handle_info(efi_handle_t handle, u16 **dev_path_text) +{ + struct efi_device_path *dp; + efi_status_t ret; + + ret = EFI_CALL(BS->open_protocol(handle, &efi_guid_device_path, + (void **)&dp, NULL /* FIXME */, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL)); + if (ret == EFI_SUCCESS) { + *dev_path_text = efi_dp_str(dp); + return 0; + } else { + return -1; + } +} + +#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(cmd_tbl_t *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(BS->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++) { + if (!efi_get_device_handle_info(handles[i], &dev_path_text)) { + printf("%p %ls\n", handles[i], dev_path_text); + efi_free_pool(dev_path_text); + } + } + + EFI_CALL(BS->free_pool(handles)); + + return CMD_RET_SUCCESS; +} + /** * do_efi_boot_add() - set UEFI load option * @@ -510,6 +584,8 @@ static int do_efi_boot_opt(cmd_tbl_t *cmdtp, int flag, static cmd_tbl_t cmd_efidebug_sub[] = { U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""), + U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices, + "", ""), }; /** @@ -568,7 +644,9 @@ static char efidebug_help_text[] = " - set UEFI BootNext variable\n" "efidebug boot order [ [ [ [...]]]]\n" " - set/show UEFI boot order\n" - "\n"; + "\n" + "efidebug devices\n" + " - show uefi devices\n"; #endif U_BOOT_CMD(