From patchwork Mon Jan 21 07:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 156168 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp6088321jaa; Sun, 20 Jan 2019 23:52:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN7R5qHV9LMl+OY/Ak5Cg75iVfzPht4swl3mNOkcwI/HVNL60t4hQ+rR00iij9IwRYbSU9oN X-Received: by 2002:a50:a9e5:: with SMTP id n92mr25613400edc.63.1548057133775; Sun, 20 Jan 2019 23:52:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057133; cv=none; d=google.com; s=arc-20160816; b=BLSRl5MGpLrxOaWPOGPQpolKNJwi6K0sgVFqp4Eog/dzbXkQqEjGyejppyr59NktvD UfXrHyWdLBrMk6xTLiWYxz0qYkl0BkhG9DtnJo0YVnLfUG3MXAf24wAxrF1h0hivcAhD bNNoHTLFy3Pqb/kIufG8Inng9YgdsKLja6UyyiGAylUBZPIt3KPb8SyC/cTmL1mUUsZ6 8BerTl/Z67Ky5LUFtqZzfOyEYIF6ZeA5b9o8OHmOetS2tP2OvjUtYRMSgoSLBNBf3jTj t/V5YU/j6xHRaDLaxqpyIsWARdh11je5/wIVYPbI0CBbyl1DE/mLp9sogZLhnf8hOPQ5 9OZA== 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=pM5oKca3FPiLL8UDGzsO/gjElwsZXS4DNtHvPlhZk1c=; b=gJpRf36iRnq9rAWnn7dMqCBjVuT/zdDmBgggntVn2K6uCdvW7PpJNQ0P5p+UIXIEPX TFv5OtemRF3mZxLkazBtWApYnMNRDM1g1IXF4R1yTDbzP4yyjwV+NQoOQNH8sl6hyryQ 3c9IzRJqVTlVrKulT/earoNCYnx4t24ij6Xt84RUWVWsC3Ez8LnsSFNoXwCkUfd1sUE7 7pC0JL4U5qm/31ygcWq6Ray5DZUcWj7c4GxTnL/hUrVu8stNMYIHjLK6+7MtLpGpTncS byf0Rez8jFdgiUvUdJ5xp+S/Px6RKTg4tMIseCL9BdDpSegh2PL5o5nc/mG7DMSCygy6 g7XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HUdKnpaj; 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 z16-v6si9422450eju.332.2019.01.20.23.52.13; Sun, 20 Jan 2019 23:52:13 -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=HUdKnpaj; 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 609CEC21E8A; Mon, 21 Jan 2019 07:50:58 +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_BLOCKED, 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 C90E4C21E9F; Mon, 21 Jan 2019 07:49:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8EAB7C21E6A; Mon, 21 Jan 2019 07:49:32 +0000 (UTC) Received: from mail-yw1-f66.google.com (mail-yw1-f66.google.com [209.85.161.66]) by lists.denx.de (Postfix) with ESMTPS id 66EEBC21E18 for ; Mon, 21 Jan 2019 07:49:27 +0000 (UTC) Received: by mail-yw1-f66.google.com with SMTP id h193so7701148ywc.4 for ; Sun, 20 Jan 2019 23:49:27 -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=KmwFEkAebPj/EoZvFZmjdWgydBFiGVoRtXnzaXR41/U=; b=HUdKnpajKHJX16JNzUpbnCi2GI1sOZKVSyd/Hdqkr/DOENIqWhePj6j2PxqLtcrruK p5fzkFUnJdkLa6/NbF9sqyKdIV+KJMm/Citn6QEAsFncgoqQxsQv0xrScUX88epwtmYZ GmLaWNRafgD0OcJZuXj8UIN2vi/UioS3+Zn9o= 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=KmwFEkAebPj/EoZvFZmjdWgydBFiGVoRtXnzaXR41/U=; b=nG7LFR0IPqE2IYpQ7qCVx8/HkLX26K/RhXLZtMWXOlwhWUZjj7/v6SdM9JsEUlVtNr 30D4AOKPRGy+mRU3m/wwlbqHrfvYIsXHpmJ21unLrRwcNyMT0B8KbXqg67D7nBkvcjhT We9+dHuYqlJRxQ0hRFmHghBtZIi8S54IvT2Bur9kDBGRg7ZkqjLWO0Vz9DlWjQ2dMKvy JqyGZQ+L35ccafhfs8O+5hyqP0ChBTPh5o5KDECET4tNvjUJFyNTRpn0Y91Sj1VaDs4w 03v39eKn8jyQGyIH/2uJ/PQKHSDMMDWuTbUgCWtMxMlhBU+eVUI3z00E0metPneFPUTd EJeg== X-Gm-Message-State: AJcUukfQcTuLDfk1WytpiCmUATD81KIBhj++QPJfHmpkMTPrVKSfpS0O emFyerMbsOJqGZAg8YJHSOZ8RA== X-Received: by 2002:a81:3607:: with SMTP id d7mr27258191ywa.427.1548056966375; Sun, 20 Jan 2019 23:49:26 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id v9sm5174736ywh.2.2019.01.20.23.49.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 23:49:26 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Mon, 21 Jan 2019 16:49:19 +0900 Message-Id: <20190121074923.29959-4-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 3/7] cmd: efidebug: add drivers 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" "drivers" command prints all the uefi drivers on the system. => efi drivers D r v Driver Name Image Path ================ ==================== ========== 7ef31d30 Signed-off-by: AKASHI Takahiro --- cmd/efidebug.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 0c7b51364753..739b7880459d 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include #define BS systab.boottime @@ -394,6 +396,80 @@ static int do_efi_show_devices(cmd_tbl_t *cmdtp, int flag, return CMD_RET_SUCCESS; } +static int efi_get_driver_handle_info(efi_handle_t handle, u16 **driver_name, + u16 **image_path) +{ + struct efi_handler *handler; + struct efi_loaded_image *image; + efi_status_t ret; + + /* + * driver name + * TODO: support EFI_COMPONENT_NAME2_PROTOCOL + */ + *driver_name = NULL; + + /* image name */ + ret = efi_search_protocol(handle, &efi_guid_loaded_image, &handler); + if (ret != EFI_SUCCESS) { + *image_path = NULL; + return 0; + } + + image = handler->protocol_interface; + *image_path = efi_dp_str(image->file_path); + + return 0; +} + +static int do_efi_show_drivers(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + efi_handle_t *handles = NULL, *handle; + efi_uintn_t size = 0; + u16 *driver_name, *image_path_text; + efi_status_t ret; + int i; + + ret = BS->locate_handle(BY_PROTOCOL, &efi_guid_driver_binding_protocol, + NULL, &size, NULL); + if (ret == EFI_BUFFER_TOO_SMALL) { + handles = calloc(1, size); + if (!handles) + return CMD_RET_FAILURE; + + ret = BS->locate_handle(BY_PROTOCOL, + &efi_guid_driver_binding_protocol, + NULL, &size, handles); + } + if (ret != EFI_SUCCESS) { + free(handles); + return CMD_RET_FAILURE; + } + + printf("D\n"); + printf("r\n"); + printf("v Driver Name Image Path\n"); + printf("================ ==================== ==========\n"); + handle = handles; + for (i = 0; i < size / sizeof(*handle); i++) { + if (!efi_get_driver_handle_info(*handle, &driver_name, + &image_path_text)) { + if (image_path_text) + printf("%16p %-20ls %ls\n", + *handle, driver_name, image_path_text); + else + printf("%16p %-20ls \n", + *handle, driver_name); + efi_free_pool(driver_name); + efi_free_pool(image_path_text); + } + handle++; + } + + return CMD_RET_SUCCESS; +} + static int do_efi_boot_add(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -789,6 +865,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = { U_BOOT_CMD_MKENT(setvar, CONFIG_SYS_MAXARGS, 1, do_efi_set_var, "", ""), 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, + "", ""), }; /* Interpreter command to configure UEFI environment */ @@ -841,7 +919,9 @@ static char efidebug_help_text[] = " - set/delete uefi variable's value\n" " may be \"=\"...\"\", \"=0x...\", \"=H...\", (set) or \"=\" (delete)\n" "efidebug devices\n" - " - show uefi devices\n"; + " - show uefi devices\n" + "efidebug drivers\n" + " - show uefi drivers\n"; #endif U_BOOT_CMD(