From patchwork Tue Dec 18 05:05:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154067 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3282733ljp; Mon, 17 Dec 2018 21:08:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/WDzRXMRPNQCPGRcvEuWiWXffMg8AqhmEkxVzxz645+WpubPd6F3pFqoIAoLmZrrjej0yPz X-Received: by 2002:a17:906:1c5b:: with SMTP id l27-v6mr12233948ejg.118.1545109719903; Mon, 17 Dec 2018 21:08:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109719; cv=none; d=google.com; s=arc-20160816; b=gqznqyNZ54f56Mfb852xF3BXbl5O/eNZzTnoMGCjfS+W66ARIJw0PSZLdgdT79BIjW kk1sDeRqVQIDN+YhfbWZO1iQeUA1nC5TulBn0xzj4sW2eLjpUHH0DKmI7PHxRBYAtD8l 5MBy5X7mthqYp/KP/2zcFt4Ir06ktMw4SGBYxwofIywvOJs8reWACBAjiZCFCbP+g5KD JvXkmzbHkltzu8hr37O/glqS+l2XS9B5MOFrYxY0rfD4nDdVHiABOd4K95JQdrCOCsLY fRwilzmxHcZVeah8PgCO7/26msoQWn1XowwHB0UHmLzFejuPNTMUdVi/tK2Yc052h8R6 ehOg== 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=HDJbhPaUMchOrGIIxpP3qYvLG8LxNplfY1pvo2vlB8Y=; b=hOgSJ9arweHlwRGsClotSNeRApG37NA9T83+K5+2VmWy0lC5gqAgePWtjSMsvdxoQs Y86wR04i30Ggy0IM8i2DT8SmluCZyEneebKgBALUujDjAWOiShuXlejAxIHqyDIZ0rIt QH59EQE1mfTd/VZot19N8YK/WFTtsBcE2LePBiemzlK1VMK9f2Xgt9dnmfth+ZNLEISv 79W4Ti6IsaHlJXqfiNFdPrTHnSBZVTBh3RrzbvAuiIIA7tU2E9Z9B3yWYYIiOWWonfFg DAYYCJmnLwqvFHOUXB9AQx6UG7KI60cdt8xk8bKpjDL5EImzK0QFbtvjxkjpDtk3SwPo w+8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N9+fF2TY; 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 e6si385849edb.139.2018.12.17.21.08.39; Mon, 17 Dec 2018 21:08:39 -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=N9+fF2TY; 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 854E7C21ECC; Tue, 18 Dec 2018 05:02:53 +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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 D37CBC21FBA; Tue, 18 Dec 2018 05:02:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AA423C2203B; Tue, 18 Dec 2018 05:01:56 +0000 (UTC) Received: from mail-yw1-f67.google.com (mail-yw1-f67.google.com [209.85.161.67]) by lists.denx.de (Postfix) with ESMTPS id D64EDC21FCE for ; Tue, 18 Dec 2018 05:01:55 +0000 (UTC) Received: by mail-yw1-f67.google.com with SMTP id n21so5134016ywd.10 for ; Mon, 17 Dec 2018 21:01:55 -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=6MsyvSPXIJKJdTm/ejOafZgOUP0Nf80mFYdTnvgebp0=; b=N9+fF2TYZc44dYEsm0IP7RabMj/fpOJnqscKnQB64VjxvnBmZDezGQioheLgGblL9U hiMZsMmXNkvkJV0SNGGj1j6JgefLINTnf+Yx+dGErDDH/VmlaWgjkFdbkZ+D/Pgl7T99 DW5H7MTBuvdDGN1Gffr17UPcuYVjXwAaXtTCw= 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=6MsyvSPXIJKJdTm/ejOafZgOUP0Nf80mFYdTnvgebp0=; b=nbA2KB1s2yPkhtty+xefMOX7te7NelGW+z5gj9H9y4dFC5ymRpbXyXe23VrBgMaZGk lXre49kXFX00aQJ409oMKuMw1w5Q6f59/aHOnN1KX4qQlrflk63jXfSXW550sjOCnOdB n2K/nVb5Tub8x6yDWbWmL6JaXqluzgh1Dvrfe0oennsxeAzCsDgr6wzWPqmihds6AFCO V1IhxSyqkWvZePQGLKbkBf3u4Rlpla/5fzqpT5+uyoOFJ7xNTAI1zLaNeQdqXyatpi1i E+fe7b86Y6YVu+GobRwCkkF8SDLq2xn5XZvu+lSKsbaxJq0DS4hi+H5Ub9quMSGjo9iy w3yQ== X-Gm-Message-State: AA+aEWY2mdLjcH6tU5uko7+z0+7Tgd6QIO4pQgMnQq6K7bW6n1Atd81D qEXcu0BvvuLgV1RMw35D8tMlFA== X-Received: by 2002:a81:5485:: with SMTP id i127mr16690967ywb.160.1545109314850; Mon, 17 Dec 2018 21:01:54 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j137sm6921438ywj.57.2018.12.17.21.01.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 21:01:54 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:05:05 +0900 Message-Id: <20181218050510.20308-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050510.20308-1-takahiro.akashi@linaro.org> References: <20181218050510.20308-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 3/8] cmd: efishell: 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 Driver Name Image Path ============================================ (unknown) +(not found) guid: 18a031ab-b443-4d1a-a5c0-0c09261e9f71 Currently, no useful information can be printed. Signed-off-by: AKASHI Takahiro --- cmd/efishell.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/cmd/efishell.c b/cmd/efishell.c index 929b6343b1b2..ed8de9e0355d 100644 --- a/cmd/efishell.c +++ b/cmd/efishell.c @@ -343,6 +343,95 @@ static int do_efi_show_devices(int argc, char * const argv[]) return CMD_RET_SUCCESS; } +static int efi_get_driver_handle_info(efi_handle_t handle, u16 **name, + u16 **devname, u16 **filename) +{ + struct efi_driver_binding_protocol *binding; + struct efi_loaded_image *image; + efi_status_t ret; + + ret = bs->open_protocol(handle, &efi_guid_driver_binding_protocol, + (void **)&binding, NULL, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS) + return -1; + + ret = bs->open_protocol(binding->image_handle, &efi_guid_loaded_image, + (void **)&image, NULL /* FIXME */, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS) + goto e_out; + + /* + * TODO: + * handle image->device_handle, + * use append_device_path() + */ + *devname = NULL; + *filename = efi_dp_str(image->file_path); + + return 0; + +e_out: + *devname = NULL; + *filename = NULL; + + return 0; +} + +static int do_efi_show_drivers(int argc, char * const argv[]) +{ + efi_handle_t *handles = NULL, *handle; + efi_uintn_t size = 0; + u16 *drvname, *devname, *filename; + 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("Driver Name Image Path\n"); + printf("============================================\n"); + handle = handles; + for (i = 0; i < size / sizeof(*handle); i++) { + if (!efi_get_driver_handle_info(*handle, &drvname, &devname, + &filename)) { + printf("%-16s%ls+%ls\n", + "(unknown)", devname, filename); + efi_free_pool(devname); + efi_free_pool(filename); + + /* TODO: no other info */ + struct efi_object *efiobj; + struct list_head *lhandle; + struct efi_handler *protocol; + + efiobj = efi_search_obj(*handle); + list_for_each(lhandle, &efiobj->protocols) { + protocol = list_entry(lhandle, + struct efi_handler, link); + printf(" guid: %pUl\n", protocol->guid); + } + } + handle++; + } + + return CMD_RET_SUCCESS; +} + static int do_efi_boot_add(int argc, char * const argv[]) { int id; @@ -726,6 +815,8 @@ static int do_efishell(cmd_tbl_t *cmdtp, int flag, return do_efi_set_var(argc, argv); else if (!strcmp(command, "devices")) return do_efi_show_devices(argc, argv); + else if (!strcmp(command, "drivers")) + return do_efi_show_drivers(argc, argv); else return CMD_RET_USAGE; } @@ -749,7 +840,9 @@ static char efishell_help_text[] = " - set/delete uefi variable's value\n" " may be \"=\"...\"\", \"=0x...\" (set) or \"=\" (delete)\n" "efishell devices\n" - " - show uefi devices\n"; + " - show uefi devices\n" + "efishell drivers\n" + " - show uefi drivers\n"; #endif U_BOOT_CMD(