From patchwork Tue Jan 15 02:54:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155600 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4383597jaa; Mon, 14 Jan 2019 18:55:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN5i9goNd5mj+uzs2m1Gr4mQuB4I/5+1WiMC0I3ibd2RJN/7YR4r+Q66ob0Gvu32a0cvWBu+ X-Received: by 2002:a50:ca86:: with SMTP id x6mr1521054edh.287.1547520929616; Mon, 14 Jan 2019 18:55:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547520929; cv=none; d=google.com; s=arc-20160816; b=JKBr5fO7IgM/1xHI8gRJnRVc5MbuPCpVZ93jsfJuP6yRqCBZgwGFvC5imVOr0eyi/B F/fcB9efVzbx5r7GMN/VXQhmpE5UF1XQBCrCwsVnfBsFViMtHCgRjDzBBnD2zjzsAj/n 05ozBxQ5doLs3r/0pVv/gTgebJZzm4ByV2bNaoN3pnK8ENQ8SPrfCae07qMe4YXWe39/ VotwJW0FYLyCEm++fZUEYknc7lzNv/n7wQCkpbvZtcAx8jDScV6yC1njT+UbJiEzCrm4 9TyHvru5vF05sPuPFSM+XBjthm299Vvmj7eBzLoksWLI2mtiY3PzO4Wvb93NY0yHuTGH uVOg== 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=zaPnT/UgeOTsEN7R3D/8iatQ+s0T+br63n7TSGzAH7o=; b=JMdXIV7xVb4QL9hhxii8H/EwS16oHIs5Irqd/Lfl4lRqjKF+yw8JsTaQOkA1P54SRE L7XwMJpjb5ujtP4Q5OKJIJpY7qK4MP8WPklhKGD2AFe2bR+PF6hCmR7AxcdHW89Vd/S3 ySw9LbYg1n7wXkMIvUGFQd2+x6LJ7tLaPCF49CQKW/CW2ZCqiWVYGgBhd/R42NcXmi0y dJ0ik+EQc7onh66MXNH/9mtFeKF/uA3VDr7OwxDhxuA6Lo7xDBvktsZAom9S8qKNybBk UzHbKjDzuDysevBAo0vMCBMfFPZFSyFNiCx1U8DUv5CYUOfEnIvOHBZhHPrCmK3XJteJ q2QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=J0NXnSV2; 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 h4si11300eda.166.2019.01.14.18.55.29; Mon, 14 Jan 2019 18:55:29 -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=J0NXnSV2; 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 21331C21D65; Tue, 15 Jan 2019 02:55:02 +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_H2, 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 41A47C21FBD; Tue, 15 Jan 2019 02:54:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CFBD1C21FC7; Tue, 15 Jan 2019 02:54:38 +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 40841C22005 for ; Tue, 15 Jan 2019 02:54:38 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id q145so486283ybq.9 for ; Mon, 14 Jan 2019 18:54:38 -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=WMjtXav7CB+xiDee0XiwMp4b+bfeGqowvGW1B38iFFw=; b=J0NXnSV2nLmWvBfEx6Tnr12ub2azUSPiPmgNQyClO4BoOHtYyPH1Go/0DKHVjFVDkj YvE8ZhuXLeztl6n02iiT/NQlORuZfKzpkTfxBTLXbwAM1KMcwmsDtTKpVqUlR4wmyREP jZ1WepXTTxTS3ojk1w0GAZUljHDfMSIMlRaeY= 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=WMjtXav7CB+xiDee0XiwMp4b+bfeGqowvGW1B38iFFw=; b=KoAbkVGuDUJRC3FEaYFZ8Ij2mXT1f75tRyzJMP7zL2Kfuecc0uxekXLBXSyxzcZxto ekpH6RDceo/ObswHfumlAhvmwRh5zMI2zx8ia5GQ/y6vSnUTfCAmvcXpANpPiEmNuaia +nMP5oeUUUon0LeKFt6nH3VplpT4Uvw1/8bh1j4deu12Xhlj/hWZbzFzeeVjR2Pmc/K/ a9eMEEPyeCHpfOSlOQXy0SSO9f+BksR4xkIwte99j+R21q/Aj7e0DSE3N/xQjNn5DCdl DUQmBsQtEb7J74T0jfs8RAQ3GGDxlc7Q0Sz48auC1pUC2zoDZnBD8PM+1jy1ywcwMvYX U2mw== X-Gm-Message-State: AJcUukdhKnJuJP293S3TZnl9o68VAUnpumiVYNFye6tr+kUFw+eOQR9C DpwJeVQ3bSvSED/0invRkz/eDg== X-Received: by 2002:a25:dacc:: with SMTP id n195mr1266085ybf.287.1547520876954; Mon, 14 Jan 2019 18:54:36 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id v9sm840987ywh.2.2019.01.14.18.54.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:36 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:33 +0900 Message-Id: <20190115025437.11966-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025437.11966-1-takahiro.akashi@linaro.org> References: <20190115025437.11966-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 1/5] efi_loader: bootmgr: support BootNext and BootCurrent variable behavior 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" See UEFI v2.7, section 3.1.2 for details of the specification. With my efitool command, you can try as the following: => efi boot add 1 SHELL ... => efi boot add 2 HELLO ... => efi boot order 1 2 => efi bootmgr (starting SHELL ...) => efi boot next 2 => efi bootmgr (starting HELLO ...) => efi dumpvar BootCurrent: {boot,run}(blob) 00000000: 02 00 .. BootOrder: {boot,run}(blob) 00000000: 01 00 02 00 .... Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_bootmgr.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a095df3f540b..6c5303736dc6 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -145,11 +145,21 @@ static void *try_load_entry(uint16_t n, struct efi_device_path **device_path, efi_deserialize_load_option(&lo, load_option); if (lo.attributes & LOAD_OPTION_ACTIVE) { + u32 attributes; efi_status_t ret; debug("%s: trying to load \"%ls\" from %pD\n", __func__, lo.label, lo.file_path); + attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + size = sizeof(n); + ret = rs->set_variable(L"BootCurrent", + (efi_guid_t *)&efi_global_variable_guid, + attributes, size, &n); + if (ret != EFI_SUCCESS) + goto error; + ret = efi_load_image_from_path(lo.file_path, &image); if (ret != EFI_SUCCESS) @@ -173,16 +183,38 @@ error: void *efi_bootmgr_load(struct efi_device_path **device_path, struct efi_device_path **file_path) { - uint16_t *bootorder; + u16 bootnext, *bootorder; efi_uintn_t size; void *image = NULL; int i, num; + efi_status_t ret; __efi_entry_check(); bs = systab.boottime; rs = systab.runtime; + /* get BootNext */ + size = sizeof(bootnext); + ret = rs->get_variable(L"BootNext", + (efi_guid_t *)&efi_global_variable_guid, + NULL, &size, &bootnext); + if (!bootnext) + goto run_list; + + /* delete BootNext */ + ret = rs->set_variable(L"BootNext", + (efi_guid_t *)&efi_global_variable_guid, + 0, 0, &bootnext); + if (ret != EFI_SUCCESS) + goto error; + + image = try_load_entry(bootnext, device_path, file_path); + if (image) + goto error; + +run_list: + /* BootOrder */ bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size); if (!bootorder) goto error; From patchwork Tue Jan 15 02:54:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155602 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4384759jaa; Mon, 14 Jan 2019 18:57:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5mJfsTg0OmZkyWlM6HjzqAfdEt/A3weePsId3vHjARpdHb/tiYgOqutmPTZG/81r1VGKkc X-Received: by 2002:a50:f098:: with SMTP id v24mr1631036edl.78.1547521027919; Mon, 14 Jan 2019 18:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521027; cv=none; d=google.com; s=arc-20160816; b=LtPKetzHnCMsJ6EfPYt8ylEi19gaDJkdKMKJkivrUTsGmVUeghRIojQo9/v77dmeS2 xNtwgvEhqnajOjFSV0tfMWo3Btm8T5LNERnju5QzOHsD14jysR+mmyHE1nwmuAMbQRb5 61shYIcgFnVdvBMNm4tqpYAYu6MEenE7upX2RY+9sjUl3Jwx8MLHVHEtOKECEZE9U6PQ 7KaUq7o/932Uly8n7sRW4Otr2DGzSKnV8asT4NBbfYw7bEpsqu3skb5tDZbmpt/hk2Rm a7ARnphqecPxEZwOSWlEhItgnSck7x4jrpqP0m49I7ua4BOJPNjkVa/EwMzMGBNXvHu+ eiqQ== 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=DH18k20lmo8ZgwNMpXaeN//aY/CTSXckRubaKOvl2Ck=; b=l1cRCE5KgySz5d5onXmVsgCXZEoKxnHnncCKgJhT68y/5CWDpuSAMJJ/+MhMN+G7PC 23Huz6MNAIyq7gnPP2eCnk//obum5tOc2dh5XY7iKLcPOGcr0L0lGR+njmGZhLDjhC9k SU37Yq3T/O0izMFjU8jwK0yxCa74ToqA/OMHga4lJcQORVJSVTiWCQk/Pq+Y3BN7xcbE M+R0z2sAUYy0AW2raV92O9g3SR8p4Z0S6dGFqi/XxEUoBbEli0OjD+qCtADv1behClJ5 SYHHAfEh1h9mtk2ebfynAPRxxD92MGzwhPzZTOVOZZ2sspQ4Ql577lTFxvvyHazjpnRg sMTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B5CGUK5Z; 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 v3-v6si2979937eji.60.2019.01.14.18.57.07; Mon, 14 Jan 2019 18:57:07 -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=B5CGUK5Z; 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 750A0C21D83; Tue, 15 Jan 2019 02:55:21 +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_H2, 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 0CFDBC2201B; Tue, 15 Jan 2019 02:54:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DAD97C21DFA; Tue, 15 Jan 2019 02:54:41 +0000 (UTC) Received: from mail-yb1-f196.google.com (mail-yb1-f196.google.com [209.85.219.196]) by lists.denx.de (Postfix) with ESMTPS id 3286CC21FEC for ; Tue, 15 Jan 2019 02:54:41 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id j10so488964ybj.8 for ; Mon, 14 Jan 2019 18:54:41 -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=5iUS6AFXp88aTCdpbWjC63MtSviEpXMCIXRUWW+FVvw=; b=B5CGUK5ZtYseIWEUCGx83HEd3PVJ65fNY1UBri1D/2OafvB6SUmU4tzfwPPV+iyHRu zQb2DMHvZejFUQsQ4w4Sc8GpjqXZJ4ev2YQg6CkgBn2crwnX7Axufr+w+dej1XxCLne/ z+Uxa0zOPRT/HIFzHBK+w7jmrOyKLZXbeGfU4= 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=5iUS6AFXp88aTCdpbWjC63MtSviEpXMCIXRUWW+FVvw=; b=tSCWZwk4BAhCRc1mPC15SKbTbSuqYUvL4ojQzlxsw5n5wFbIAkGickjT8eLaolpC6J Wq53bB/PixF16DW2z5yxcOlhf57MmD9rPDrZ+Z+M9zlDZU8NpPF/eGlMN4eaMCTPhjFM y93c8qTfIyuOKDIWKHrt5lRYaX7WzQ71tIj7aAdrNO82wyrACzDbkBcuC4pZlJxQryZk 72+mhGrTEPIua3AW4eXoSFGxJIeyuEQTz4wmwPLpCXTvkO8xJAfLsRs/DYAZjhYl+rr/ hFGhop7zodkEKzqFKL4rqfO0Df+arpDxy1HZPD2dlL8HicFMaAAK7zJIUeSxM9XjTXoG mPNA== X-Gm-Message-State: AJcUukdv+DlMd6UTx+sQIpqw1lONLMZAdtHCyByry5rqsQPvADWuOWgH s6EpjsQZBuwk3LjKJtsgr1Uf5A== X-Received: by 2002:a25:9749:: with SMTP id h9mr1211279ybo.219.1547520880157; Mon, 14 Jan 2019 18:54:40 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id q24sm779819ywa.95.2019.01.14.18.54.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:39 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:34 +0900 Message-Id: <20190115025437.11966-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025437.11966-1-takahiro.akashi@linaro.org> References: <20190115025437.11966-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 2/5] efi_loader: bootmgr: allow for running a given load option 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" With an extra argument, efi_bootmgr_load() can now load an efi binary based on a "BootXXXX" variable specified. Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 3 ++- include/efi_loader.h | 5 ++++- lib/efi_loader/efi_bootmgr.c | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7012d72ab50d..76171ab679c3 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -452,7 +452,8 @@ static int do_bootefi_bootmgr_exec(void) void *addr; efi_status_t r; - addr = efi_bootmgr_load(&device_path, &file_path); + addr = efi_bootmgr_load(EFI_BOOTMGR_DEFAULT_ORDER, + &device_path, &file_path); if (!addr) return 1; diff --git a/include/efi_loader.h b/include/efi_loader.h index dd68cfce5c65..3077a1e9d58b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -549,9 +549,12 @@ struct efi_load_option { u8 *optional_data; }; +#define EFI_BOOTMGR_DEFAULT_ORDER (-1) + void efi_deserialize_load_option(struct efi_load_option *lo, u8 *data); unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **data); -void *efi_bootmgr_load(struct efi_device_path **device_path, +void *efi_bootmgr_load(int boot_id, + struct efi_device_path **device_path, struct efi_device_path **file_path); #else /* CONFIG_IS_ENABLED(EFI_LOADER) */ diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 6c5303736dc6..7ce51de4dfb0 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -180,7 +180,8 @@ error: * available load-options, finding and returning the first one that can * be loaded successfully. */ -void *efi_bootmgr_load(struct efi_device_path **device_path, +void *efi_bootmgr_load(int boot_id, + struct efi_device_path **device_path, struct efi_device_path **file_path) { u16 bootnext, *bootorder; @@ -194,6 +195,12 @@ void *efi_bootmgr_load(struct efi_device_path **device_path, bs = systab.boottime; rs = systab.runtime; + /* specified boot option */ + if (boot_id != -1) { + image = try_load_entry(boot_id, device_path, file_path); + goto error; + } + /* get BootNext */ size = sizeof(bootnext); ret = rs->get_variable(L"BootNext", From patchwork Tue Jan 15 02:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155608 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4387149jaa; Mon, 14 Jan 2019 19:00:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN6sj3TrZgzhnksxT99AvzVsSMG7nWwjZ1BJQoiAajlnBdd+S0cAEJ0CWafPZ3qzv7vQODKH X-Received: by 2002:a17:906:6d59:: with SMTP id a25-v6mr1468375ejt.54.1547521230900; Mon, 14 Jan 2019 19:00:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521230; cv=none; d=google.com; s=arc-20160816; b=MxHISuazcVZUqr1YhZjko0vXLu5mjC3PsX3MdpvkSBnrs1J7Xl2JLKbCfQkkfx8P6W spJ8hJ/QKUcGXcjuB5WAEKAs3IdUwSA/Xa8UUmLURTfWYZFXA3bfkfkLwYskDVIGhW8U xZFQBQARRARSpHCy5ZBYtqq5yACBGQrVc1CE4o3OJvRISpx/Fco7yAyHWdN8JUf22ZYf Gn+w84Ggq7PtQAIAj0fhrSkzIlRcGGM66KEEWdfhE3arMzRmIsY5ItYIVS57yxqc2U9B NS1PovIVrAtNkABWB8kI6QSvklhHqP/GI+n29LTqXzGONWWbfIcB1KsYzkSxSjPyS1KQ frrw== 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=Sj5GK2tyMUjQ/UHTwDDcsQmG5kA5AR17ShWNve0P6rQ=; b=zLq+wqcCv2k3xWLL+As++SgPV5uTha/SGixKCwdej0nBBD2GDPyLa5L232pCJm4Y5j w+PvTeUfCcByGQOq6c9YdVGzOo8IP7bK5XwF7X9mLqRZm5st+3VVYh0rFi2xoppbwNdH P47xiR8dca4mNrssamBA/Hs/b1L+4tKAr6ipFHQtLWOPcKHxffhyUweBnNpn+H1bWE6s BitNJC1eb08d3brcjqm+MD4oR1yl0CsbIG/iMmU73fgLqLSsTrlaoWMBUY7tIOr6I715 xom9eqh5KOpLS6Htmcd7EKXv5m6GtnJEAkZXvKY3Hy+y29wkUPeGO0PKw5iWqY77KzV1 I+/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YSi0eUnJ; 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 k22si3304023edd.408.2019.01.14.19.00.30; Mon, 14 Jan 2019 19:00: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=YSi0eUnJ; 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 84830C21FE2; Tue, 15 Jan 2019 02:55:54 +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 D53C0C22005; Tue, 15 Jan 2019 02:55:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 79796C222D3; Tue, 15 Jan 2019 02:54:48 +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 62CF9C21F88 for ; Tue, 15 Jan 2019 02:54:44 +0000 (UTC) Received: by mail-yw1-f67.google.com with SMTP id d190so510025ywb.5 for ; Mon, 14 Jan 2019 18:54:44 -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=Psc4+NKvUhkn/AOE6o2bg1AHk+i0ed6a/jH7VGguJRg=; b=YSi0eUnJhnHFwmer/Xi1+6oTnkRMob1G2Z+medGEPP6HotBdY/1vrvhGCJUttDxWu0 M1YnOxQp+z+ojoU2XsNx8ugKC1p4zwi5WEpRcUJgmy1SarNUr2Mz7xNZn2VLmbicM7+l VKQhUgfzJhqYb9CBM6f55zdqXe1AanNw2HfRI= 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=Psc4+NKvUhkn/AOE6o2bg1AHk+i0ed6a/jH7VGguJRg=; b=fT7NfpF2cz1fZrN9AOdRSEhkufTx5d5idbZkM16rNys23r3I41+tCeLUI2c1h4iK85 qzCMlj4ybRXN2bDvJ/QBF/l7lbbEDkamqBAuELrFwtn3Cu9tVmBAQ19j1NK1BTodSudI qumGvEIg2iKKPGKVW8uE2kcAyuGsJDal1jEBv5VSyub3Vf7i0cNIqyNCcHPQH218dKpl 0KNaICifsvW61VruIULrFgLL+tIgYouvtbMk05GRceOCjvPsuhRXOkRJu1aiIuBxYRhr BHyZZ6KnVTzdH18Jt4iOJJWZsj36MjOGa0mfJ33gQtG3OGe3PCLAZS0ACzG9nzzwahYT KahQ== X-Gm-Message-State: AJcUukdrUdP8HSxLNlgMlsJumrnFGX6rBEbzbcmwHRQTE1hkHhq4X5mZ KeyZBM+OBofPtL7wiGttxprUhQ== X-Received: by 2002:a81:2891:: with SMTP id o139mr1297139ywo.100.1547520883371; Mon, 14 Jan 2019 18:54:43 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id d3sm1285976ywh.58.2019.01.14.18.54.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:42 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:35 +0900 Message-Id: <20190115025437.11966-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025437.11966-1-takahiro.akashi@linaro.org> References: <20190115025437.11966-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 3/5] cmd: bootefi: carve out fdt parameter handling 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" The current way how command parameters, particularly "fdt addr," are handled makes it a bit complicated to add a subcommand-specific parameter. So just refactor the code and extract efi_handle_fdt(). This commit is a preparatory change for enhancing bootmgr sub-command. Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 76171ab679c3..3be01b49b589 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -279,6 +279,31 @@ static void bootefi_run_finish(struct efi_loaded_image_obj *image_obj, efi_delete_handle(&image_obj->header); } +static int efi_handle_fdt(char *fdt_opt) +{ + unsigned long fdt_addr; + efi_status_t r; + + if (fdt_opt) { + fdt_addr = simple_strtoul(fdt_opt, NULL, 16); + if (!fdt_addr && *fdt_opt != '0') + return CMD_RET_USAGE; + + /* Install device tree */ + r = efi_install_fdt(fdt_addr); + if (r != EFI_SUCCESS) { + printf("ERROR: failed to install device tree\n"); + return CMD_RET_FAILURE; + } + } else { + /* Remove device tree. EFI_NOT_FOUND can be ignored here */ + efi_install_configuration_table(&efi_guid_fdt, NULL); + printf("WARNING: booting without device tree\n"); + } + + return CMD_RET_SUCCESS; +} + /** * do_bootefi_exec() - execute EFI binary * @@ -474,7 +499,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned long addr; char *saddr; efi_status_t r; - unsigned long fdt_addr; /* Allow unaligned memory access */ allow_unaligned(); @@ -490,21 +514,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; - if (argc > 2) { - fdt_addr = simple_strtoul(argv[2], NULL, 16); - if (!fdt_addr && *argv[2] != '0') - return CMD_RET_USAGE; - /* Install device tree */ - r = efi_install_fdt(fdt_addr); - if (r != EFI_SUCCESS) { - printf("ERROR: failed to install device tree\n"); - return CMD_RET_FAILURE; - } - } else { - /* Remove device tree. EFI_NOT_FOUND can be ignored here */ - efi_install_configuration_table(&efi_guid_fdt, NULL); - printf("WARNING: booting without device tree\n"); - } #ifdef CONFIG_CMD_BOOTEFI_HELLO if (!strcmp(argv[1], "hello")) { ulong size = __efi_helloworld_end - __efi_helloworld_begin; @@ -522,6 +531,9 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct efi_loaded_image_obj *image_obj; struct efi_loaded_image *loaded_image_info; + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) + return CMD_RET_FAILURE; + if (bootefi_test_prepare(&image_obj, &loaded_image_info, "\\selftest", (uintptr_t)&efi_selftest, "efi_selftest")) @@ -534,6 +546,9 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else #endif if (!strcmp(argv[1], "bootmgr")) { + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) + return CMD_RET_FAILURE; + return do_bootefi_bootmgr_exec(); } else { saddr = argv[1]; @@ -543,6 +558,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!addr && *saddr != '0') return CMD_RET_USAGE; + if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) + return CMD_RET_FAILURE; } printf("## Starting EFI application at %08lx ...\n", addr); From patchwork Tue Jan 15 02:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155601 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4384082jaa; Mon, 14 Jan 2019 18:56:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN77fQggxwBm9AkhDvqgtwnUgyLcsYFiSc+E3oMownvHTJPWHcE8Uo6PgkEvfhp5yTX2m93q X-Received: by 2002:a50:b0a4:: with SMTP id j33mr1484199edd.267.1547520973050; Mon, 14 Jan 2019 18:56:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547520973; cv=none; d=google.com; s=arc-20160816; b=PvkaDPzqv7ZDBDYPlVyoAbOTR8MvLZo/rvQnyiYJ9jw+a05AE1VWJ8opKEHNgUu2e+ m5VF9liPDPQ8O4eJYSCd7t7CEluXFVm2aFczp9c1FHMw0kZIzEqi8xhI6g1GURD6T5kC V4xrY3Z5D9qvHi3szdD3X30mreExduZzqo2dr0bBwXO8uhI1K2lIyR/cAbRHTT+K43hd rovXk5jbW/Usyg4EKKekYfMaMcrdsjJWLNDgc3t9iUEPemME/QIAXcB6ldAl8lGguJ3X okEibUc3NkOGRLR96LDHVGvYXo5Kdzhwde0jM2aE/xBYimB6A0HsIgo6+i7pcW4ghuf1 FjJg== 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=9zYMLxS7Fdcso1zLn2iHKovAn0NbmyecfedMeky1RDg=; b=V7/LKyrZldyVzf+QwlbW8SUZ8mT8CP6MMqNj4pE7j8K5QXFgL6iRy3Vr0U5C3UIBps VTuJ6frcFaN2ywl4Zr6QAIjN4JWae1gr3AGbV1lfHd9In6YI4+/XvzhcEFzVsA+rCpYf SntHpEz9OV6Fw/Ro5dT5fwdcF0TxRViMB4PSxC2XmJnEE5102hwqSBVbsqyr5hRC8heZ a+x5OtVsWt2L9R/SqiMk2tj3LQXhgeR73PTM1+1TnOEZoPUNoya4rruJLfHx8pKdgARY nuXXtsiMNeh3MZWi9Ti480FHtrOfm+jpAhaE8eGSwFIRWNR9SfsEywuzMB7LkGC4V7LF g/Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fUygd3xq; 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 u23si5611142edo.113.2019.01.14.18.56.12; Mon, 14 Jan 2019 18:56: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=fUygd3xq; 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 A2FBCC21F17; Tue, 15 Jan 2019 02:55:37 +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_H2, 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 E173EC2204C; Tue, 15 Jan 2019 02:55:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C4F59C21F88; Tue, 15 Jan 2019 02:54:51 +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 94934C2214B for ; Tue, 15 Jan 2019 02:54:47 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id 2so501649ybw.4 for ; Mon, 14 Jan 2019 18:54:47 -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=BK+n1M5VyKZVxMJg2AvLpZXnr3paTYK4PauaqJk5rGw=; b=fUygd3xq8DjesWpmkTdOG7kOM0F2JCpz1XYM84Al+xVZYhZyUyvSjPsscq1+0ucoaI ZNU8omIVa+dElw2QiIN7AYuWx8G88wv9l4bTgzkmKxf6wMV3m/R7sOof9UlkB2U//OBx 7+y/8c9dHkihe4TTRqj/EbSHr8tLMmyiqvqW8= 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=BK+n1M5VyKZVxMJg2AvLpZXnr3paTYK4PauaqJk5rGw=; b=We1GFbQOIlHHbFvnZHD11RcPlF2N3Dg876Mok6jHBP8EksBtsg5vI0Xk2tzvbdyFfW WZ0OE5bZD4rFahxnKaxnKHXFPCd6ZmYI1Qob6+E/8QxqxTdEQMjlf72HevWwaqxP5COj U13IhE7Oahhm32hn7u/GpcGftWTEc2BzNZB6Vd9vW/4lLMTwIevz33enJYutY3OVMx4Y F0vYT37GEuRZYTWkvtqpsBo3MDAzUH7zArd/xPyShx6/skNEWuNQXw/L3uSyLDjepYGN u38vSiTrOZnJmgjX3miLdl/W05TBUS8jO6oMAJ+w3ar6XVmY5l68VgTumWUdSI/JX8Gt CCug== X-Gm-Message-State: AJcUukejgSBOFU8dF8PI6cCWQ/e1VmwmPz/C4fqUlXt9EQdP/GjaqlNi Grx230MHKuRbwCMC8WYalvLssQ== X-Received: by 2002:a25:57c6:: with SMTP id l189mr1257300ybb.130.1547520886556; Mon, 14 Jan 2019 18:54:46 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id y16sm719166ywg.35.2019.01.14.18.54.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:46 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:36 +0900 Message-Id: <20190115025437.11966-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025437.11966-1-takahiro.akashi@linaro.org> References: <20190115025437.11966-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 4/5] cmd: bootefi: run an EFI application of a specific load option 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" With this patch applied, we will be able to selectively execute an EFI application by specifying a load option, say "1" for Boot0001, "2" for Boot0002 and so on. => bootefi bootmgr 1, or bootefi bootmgr - 1 Please note that BootXXXX need not be included in "BootOrder". Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3be01b49b589..241fd0f987ab 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -471,16 +471,15 @@ static efi_status_t bootefi_test_prepare #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ -static int do_bootefi_bootmgr_exec(void) +static int do_bootefi_bootmgr_exec(int boot_id) { struct efi_device_path *device_path, *file_path; void *addr; efi_status_t r; - addr = efi_bootmgr_load(EFI_BOOTMGR_DEFAULT_ORDER, - &device_path, &file_path); + addr = efi_bootmgr_load(boot_id, &device_path, &file_path); if (!addr) - return 1; + return CMD_RET_FAILURE; printf("## Starting EFI application at %p ...\n", addr); r = do_bootefi_exec(addr, device_path, file_path); @@ -488,9 +487,9 @@ static int do_bootefi_bootmgr_exec(void) r & ~EFI_ERROR_MASK); if (r != EFI_SUCCESS) - return 1; + return CMD_RET_FAILURE; - return 0; + return CMD_RET_SUCCESS; } /* Interpreter command to boot an arbitrary EFI image from memory */ @@ -546,10 +545,28 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else #endif if (!strcmp(argv[1], "bootmgr")) { - if (efi_handle_fdt(argc > 2 ? argv[2] : NULL)) - return CMD_RET_FAILURE; + char *fdtstr, *endp; + int boot_id = EFI_BOOTMGR_DEFAULT_ORDER; + + if (argc > 2) { + fdtstr = argv[2]; + /* Special address "-" means no device tree */ + if (fdtstr[0] == '-') + fdtstr = NULL; + + r = efi_handle_fdt(fdtstr); + if (r) + return CMD_RET_FAILURE; + } + + if (argc > 3) { + boot_id = (int)simple_strtoul(argv[3], &endp, 0); + if ((argv[3] + strlen(argv[3]) != endp) || + boot_id > 0xffff) + return CMD_RET_USAGE; + } - return do_bootefi_bootmgr_exec(); + return do_bootefi_bootmgr_exec(boot_id); } else { saddr = argv[1]; @@ -590,7 +607,7 @@ static char bootefi_help_text[] = " Use environment variable efi_selftest to select a single test.\n" " Use 'setenv efi_selftest list' to enumerate all tests.\n" #endif - "bootefi bootmgr [fdt addr]\n" + "bootefi bootmgr [|'-' []]\n" " - load and boot EFI payload based on BootOrder/BootXXXX variables.\n" "\n" " If specified, the device tree located at gets\n" @@ -598,7 +615,7 @@ static char bootefi_help_text[] = #endif U_BOOT_CMD( - bootefi, 3, 0, do_bootefi, + bootefi, 5, 0, do_bootefi, "Boots an EFI payload from memory", bootefi_help_text ); From patchwork Tue Jan 15 02:54:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 155604 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4385635jaa; Mon, 14 Jan 2019 18:58:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN68NVzS0RvX1jtAuR77XEcmDbOEROyziktaPUwvlRr5gylWylGpb4YcZVK9qxKknfg0A/3Z X-Received: by 2002:a17:906:6c9:: with SMTP id v9-v6mr1426548ejb.203.1547521107477; Mon, 14 Jan 2019 18:58:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547521107; cv=none; d=google.com; s=arc-20160816; b=ammIvqh99Zz+vegGY8HVhLcULEIBJ9UfJOLrL9hMMsryYfXxfQxFjDAMQAWfWMfJbf f5zobM2U4fX7rg0kEy9v+IWCU/ioSRcfH4BmMuFyb9q9Bx1PZI0nWh5AAlrR6m5cnE4U w5eMgDXYd7jy4FSXTQ2RngNoK+u2fEn0Oeb5Cejz3A8uBgWu9Vs4qIKv+GqU476jVb8s FGnrAm0Px/IOSciwfrOxl1unbw5KcqzynXhRrMCl23SJCN6SvYkRjvwOBBGcv4Luk4cL KVQb9PdnNcNat/CrKT0oFsR6SHOhXEbRxug9WdMuzTj4a60e8ZbbEL0nbXDX2IzT5fKC syyQ== 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=1GBkO8GeNyiLvWqg3I7AUF+ohddQNg75FPoqFz4+0zA=; b=lAov8YWInJR+7uF1A2xLXTVn5IM1ZeE2TV32ztRMDQ/Ad4QWCOoNPE3v/3mBA0Tta1 7H/HYGvpJ0ZU6y34KcEqmyapx+qQSHTMu3nVsGmhOVvwrF84nzrnReBTJfioRJwIq5Wq 1jaqtIkcOC1vRomUFqkj1Of/qe1YrcS8dw/Z9P8jQjOU8uTOo5z1HIfzJIZ+CF1DVmjU Li5Lx7o6Zyd66IrZrErcfKwGhccBguGi3HEdKEKqQ+TWl9/38AQrdAhCrekhjTgvyNLm +gl5bl5h68aKv9OOkjqPbT2e3g+w+K9ja7kuHruDHuNzWhC3Z7RAXHFwLABoHtVnsF7f k9pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="a2/ZboNu"; 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 h11si655001edw.441.2019.01.14.18.58.27; Mon, 14 Jan 2019 18:58:27 -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="a2/ZboNu"; 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 216BFC21FBF; Tue, 15 Jan 2019 02:56:12 +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_H2, 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 F027EC21F1D; Tue, 15 Jan 2019 02:55:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AFFFCC21FCD; Tue, 15 Jan 2019 02:54:54 +0000 (UTC) Received: from mail-yb1-f196.google.com (mail-yb1-f196.google.com [209.85.219.196]) by lists.denx.de (Postfix) with ESMTPS id D8D4BC21FF8 for ; Tue, 15 Jan 2019 02:54:50 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id t16so482682ybk.10 for ; Mon, 14 Jan 2019 18:54:50 -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=Rhon+GzxhdTNEKSMVmVxmmCG9oYuqPgybpgeh0Kbnk4=; b=a2/ZboNuocFvZB1bkSbq1L9KSpYHGGbIp3W3GqTnHp3Ow5IMvHLkBo+qdfV4WxHVWp 8hiXC4s2ArXOrro2LmS7uuo3BDXYadOyABh2LsOcrnzIrra8kb9O/d2zkAVYEQGYSrtm BVHIvsnXbtr3CUc7/ZNmSmNC25NDXyvsYLgBQ= 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=Rhon+GzxhdTNEKSMVmVxmmCG9oYuqPgybpgeh0Kbnk4=; b=JGLxQ9TFsb5KQCp7xS7233eaLR9DM+lrEBVIpeVDuJGEc1EMzBHPB3kzE8EulP/PAn IGeGtxrdLFllz0v1Y4VFDo9usiMX+AxiR/aYbPfPqlF0Wt5CyqioOxJEoTaPYtjVSwlM 2SM9j7CY4O1Y+MWc3bYBWyrk6xBtTls+7KM9lLiijEv+u7lbcK6mj2rJTQhsc+U597UB 2S+nGhk0l6kY0nEIX4zZqVLLomRxIs9behRXOz+XTgXIfmUfi2DGXxyQRMCKEXtV4hAP ELvackuM3+wKc4hxiYCZhVbehcPfSz5Yc0bCLgE3RfvPW+8TlGdPpOdT5a+jhkQuuB2s a7Xw== X-Gm-Message-State: AJcUukeVbKwK3q8IyWQerWg6FtSljNIzFW+nbv9GVNrFt30ehEqWFqvW JWhEEQztpAVmiHNnJmtUdRbfNqipEik= X-Received: by 2002:a5b:902:: with SMTP id a2mr1196421ybq.445.1547520889845; Mon, 14 Jan 2019 18:54:49 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id e124sm741929ywf.17.2019.01.14.18.54.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 18:54:49 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 15 Jan 2019 11:54:37 +0900 Message-Id: <20190115025437.11966-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190115025437.11966-1-takahiro.akashi@linaro.org> References: <20190115025437.11966-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 5/5] cmd: run: add "-e" option to run an EFI application 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" "run -e" allows for executing EFI application with a specific "BootXXXX" variable. If no "BootXXXX" is specified or "BootOrder" is specified, it tries to run an EFI application specified in the order of "bootOrder." Signed-off-by: AKASHI Takahiro --- cmd/bootefi.c | 31 +++++++++++++++++++++++++++++++ cmd/nvedit.c | 9 ++++++++- common/cli.c | 10 ++++++++++ include/command.h | 3 +++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 241fd0f987ab..ebe149dffa1f 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -492,6 +492,37 @@ static int do_bootefi_bootmgr_exec(int boot_id) return CMD_RET_SUCCESS; } +/* Called by "run" command */ +int do_bootefi_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int boot_id = -1; + char *endp; + + if (argc > 2) + return CMD_RET_USAGE; + + if (argc == 2) { + if (!strcmp(argv[1], "BootOrder")) { + boot_id = -1; + } else if (!strncmp(argv[2], "Boot", 4)) { + boot_id = (int)simple_strtoul(&argv[2][4], &endp, 0); + if ((argv[2] + strlen(argv[2]) != endp) || + boot_id > 0xffff) + return CMD_RET_USAGE; + } else { + return CMD_RET_USAGE; + } + } + + if (efi_init_obj_list()) + return CMD_RET_FAILURE; + + if (efi_handle_fdt(NULL)) + return CMD_RET_FAILURE; + + return do_bootefi_bootmgr_exec(boot_id); +} + /* Interpreter command to boot an arbitrary EFI image from memory */ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { diff --git a/cmd/nvedit.c b/cmd/nvedit.c index de16c72c23f2..ce746bbf1b3e 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -1344,7 +1344,14 @@ U_BOOT_CMD_COMPLETE( run, CONFIG_SYS_MAXARGS, 1, do_run, "run commands in an environment variable", "var [...]\n" - " - run the commands in the environment variable(s) 'var'", + " - run the commands in the environment variable(s) 'var'" +#if defined(CONFIG_CMD_BOOTEFI) + "\n" + "run -e [BootXXXX]\n" + " - load and run UEFI app based on 'BootXXXX' UEFI variable", +#else + , +#endif var_complete ); #endif diff --git a/common/cli.c b/common/cli.c index 51b8d5f85cbb..fbb09d5049a4 100644 --- a/common/cli.c +++ b/common/cli.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -125,6 +126,15 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; +#ifdef CONFIG_CMD_BOOTEFI + if (!strcmp(argv[1], "-e")) { + argc--; + argv++; + + return do_bootefi_run(cmdtp, flag, argc, argv); + } +#endif + for (i = 1; i < argc; ++i) { char *arg; diff --git a/include/command.h b/include/command.h index 200c7a5e9f4e..feddef300ccc 100644 --- a/include/command.h +++ b/include/command.h @@ -48,6 +48,9 @@ typedef struct cmd_tbl_s cmd_tbl_t; #if defined(CONFIG_CMD_RUN) extern int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); #endif +#if defined(CONFIG_CMD_BOOTEFI) +extern int do_bootefi_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +#endif /* common/command.c */ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int