From patchwork Mon Jan 21 07:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 156170 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp6089120jaa; Sun, 20 Jan 2019 23:53:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN4FQgfEp7DbGFTfT4Ah7gc1Y1xue1Q9j7NJd45/I1i0DcYIRbXmhrwxm2cDqfSOK1NXrwFi X-Received: by 2002:a50:f5f4:: with SMTP id x49mr26437588edm.26.1548057210323; Sun, 20 Jan 2019 23:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057210; cv=none; d=google.com; s=arc-20160816; b=aFDo/l8/ZKQiqgqAuHOFPkBwdBh148pIgAAKjYmzwKlcRt2OiMbJvdd8gH5Jn7c46x 2XAwmHjL6NVEkKeB+XBvMhvvyKv4wqaIuMF74ez/pWflFLAl5rZLrhg3K8RGqAvXs1VO 6FdGmm7KhokJBlPXcErFc2+HFxHdr9ZFPc/4QegvOS3TFBWw/sN4rrh/vlQ6YiWXpMtl PGEvFIaA4afRfSdYA6J4OC5firY+iqjsqpLLGU9KwOXmf2EKCwf66Et8hbO3+01Laneg lBlOuxXaGyELuCpNNnD/Ulxy1GZqjZpetdnvikSTIMQuYT9phkI1jIC7WNBKM6zd6GxF T5/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature; bh=KkE7uNaeIWdYvgCtHMRe9+gbUGOx+tNBPC9f21aNwz4=; b=c4k6t57tKHNI4AwylMecUZFOHdhzAyrtA1n7bkAdOiYYK58YEcmQ+Z8+aSBcspmxSf bC15En9Frpjlz8nUqGNZ2zQUxSlKvR20nzaQ39tdnv6zq8UZ+B4Ok9cn3bco079JEZq3 a4h/cggHw0vAaD1HK3qts3witaD70Xlcwa0rWqXAzZ+tPxX3LBUaLV9EztsMhHYJq6xR J4koSndohVK1xVdWnkggXJfSYkTISTae5s2jwqUhDKoRWgoNtLF3+KKvRmKUH0+3muQA 5gg+y+O6wZ7ubt3H3AtTamSdLHViIg/pmig4ZKggmU3ml7plmRlboJ3JMJWhey6czqrh hVwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IrNkkJZ0; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id gz8-v6si209198ejb.64.2019.01.20.23.53.30; Sun, 20 Jan 2019 23:53:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IrNkkJZ0; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id D6F02C21E30; Mon, 21 Jan 2019 07:51:16 +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=RCVD_IN_DNSWL_NONE, 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 451AEC21E4F; Mon, 21 Jan 2019 07:49:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E1B04C21E6A; Mon, 21 Jan 2019 07:49:36 +0000 (UTC) Received: from mail-yb1-f193.google.com (mail-yb1-f193.google.com [209.85.219.193]) by lists.denx.de (Postfix) with ESMTPS id 92DCCC21E5B for ; Mon, 21 Jan 2019 07:49:31 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id 2so6814598ybw.4 for ; Sun, 20 Jan 2019 23:49:31 -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=mnPR0yGaVZkhSCjxMJHaQ9wUUznjLizLE87vBTcuJWk=; b=IrNkkJZ0z7xtHFAQdu3bqaAaaGH+ll88WqhJX3A4hkjr38XC9JZE3AvXhbunKAoVW/ KbKk57P7vREX/FCn2B0sZv+xTnvlLUxg2ynlVMqoA2wo/k5afa7rPbpvaGdMesUi+2wG LKzrhlbPDqwdMcBfhLBybNPWZuSYJuJrQ74e4= 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=mnPR0yGaVZkhSCjxMJHaQ9wUUznjLizLE87vBTcuJWk=; b=djhTQ813b/gODLb6nYAdrZwd/M2gEgHd7bancOMnq1X2G30bu37dAzN1N5qF62gVm7 7DuwpllTIhn5RCoFF7yc06Oe2zq1rZ8SSunnOAY2z0jakZ7o8Lv+Ac8ZWQsIz/bKQRZG Rq/CzyT7nIdpZFbTaToM/TaIerj1+WxSDEEgP7rE0s0i1ipGQhEBnEFdbWcIqwHsR6D9 jX1OVsTHrx9d/K9bwxLIvRGWJg8WQVHdRCQH9e/JidXFTzrjdFdHri/FLXlGFPdKykry jgS00R6xKk0elcA+IZSVWaia89Mp3BbinMi0xFA6eMF3TcakDn2GZ3Fpq+r1p3JU3ZJK 4ctQ== X-Gm-Message-State: AJcUukdPRWUdTUF2+4Jzh5+J9tTBo+AI+c5yv8vnNAytrnWSWnbvbKhz vwy1K3fYB3Oz7TjGDXv96/7jMA== X-Received: by 2002:a5b:b41:: with SMTP id b1mr15722031ybr.225.1548056970259; Sun, 20 Jan 2019 23:49:30 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 141sm4852255yws.47.2019.01.20.23.49.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 23:49:29 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Mon, 21 Jan 2019 16:49:20 +0900 Message-Id: <20190121074923.29959-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190121074923.29959-1-takahiro.akashi@linaro.org> References: <20190121074923.29959-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 4/7] cmd: efidebug: add dh 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" "dh" command prints all the uefi handles used in the system. => efi dh 7ef3bfa0: Device Path, Device Path To Text, Device Path Utilities, Unicode Collation 2 7ef31d30: Driver Binding 7ef31da0: Simple Text Output 7ef31e10: Simple Text Input, Simple Text Input Ex 7ef3cca0: Block IO, Device Path 7ef3d070: Block IO, Device Path 7ef3d1b0: Block IO, Device Path, Simple File System 7ef3d3e0: Block IO, Device Path, Simple File System Signed-off-by: AKASHI Takahiro --- cmd/efidebug.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 739b7880459d..34794398c0c2 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -470,6 +470,120 @@ static int do_efi_show_drivers(cmd_tbl_t *cmdtp, int flag, return CMD_RET_SUCCESS; } +static const struct { + const char *text; + const efi_guid_t guid; +} guid_list[] = { + { + "Device Path", + DEVICE_PATH_GUID, + }, + { + "Device Path To Text", + EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, + }, + { + "Device Path Utilities", + EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID, + }, + { + "Unicode Collation 2", + EFI_UNICODE_COLLATION_PROTOCOL2_GUID, + }, + { + "Driver Binding", + EFI_DRIVER_BINDING_PROTOCOL_GUID, + }, + { + "Simple Text Input", + EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, + }, + { + "Simple Text Input Ex", + EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID, + }, + { + "Simple Text Output", + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, + }, + { + "Block IO", + BLOCK_IO_GUID, + }, + { + "Simple File System", + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, + }, + { + "Loaded Image", + LOADED_IMAGE_PROTOCOL_GUID, + }, + { + "GOP", + EFI_GOP_GUID, + }, +}; + +static const char *get_guid_text(const efi_guid_t *guid) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(guid_list); i++) + if (!guidcmp(&guid_list[i].guid, guid)) + break; + + if (i != ARRAY_SIZE(guid_list)) + return guid_list[i].text; + else + return NULL; +} + +static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + efi_handle_t *handles; + efi_guid_t **guid; + efi_uintn_t count; + const char *guid_text; + int num, i, j; + efi_status_t ret; + + handles = NULL; + num = 0; + if (efi_get_handles_by_proto(NULL, &handles, &num)) + return CMD_RET_FAILURE; + + if (!num) + return CMD_RET_SUCCESS; + + for (i = 0; i < num; i++) { + printf("%16p:", handles[i]); + ret = BS->protocols_per_handle(handles[i], &guid, &count); + if (ret || !count) { + putc('\n'); + continue; + } + + for (j = 0; j < count; j++) { + if (j) + printf(", "); + else + putc(' '); + + guid_text = get_guid_text(guid[j]); + if (guid_text) + puts(guid_text); + else + printf("%pUl", guid[j]); + } + putc('\n'); + } + + free(handles); + + return CMD_RET_SUCCESS; +} + static int do_efi_boot_add(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -867,6 +981,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = { "", ""), 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, + "", ""), }; /* Interpreter command to configure UEFI environment */ @@ -921,7 +1037,9 @@ static char efidebug_help_text[] = "efidebug devices\n" " - show uefi devices\n" "efidebug drivers\n" - " - show uefi drivers\n"; + " - show uefi drivers\n" + "efidebug dh\n" + " - show uefi handles\n"; #endif U_BOOT_CMD(