From patchwork Tue Dec 18 05:02:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154057 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3279266ljp; Mon, 17 Dec 2018 21:03:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1sej/b69cZQIm/nCYA+ww15vpE09rv8C2yfbWRWBQQ0HF57CIuj/TWHgaioeotpf1s3nI X-Received: by 2002:a50:a726:: with SMTP id h35mr15219074edc.192.1545109409267; Mon, 17 Dec 2018 21:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109409; cv=none; d=google.com; s=arc-20160816; b=c8/KuXFBCo1HL8Rtkmql/mdJNpgH/arsvoZj2CZ2Z7/nGoud3xVPYAJU1Y/9e6x/t1 mIk0Akn4PbEbKftAZAGf7EIskIMVWOAz+ZSN49BlJrFmimef34J9UdfFs+iEiqTXKG1x hin4rlyl/sxidiG6E0POgceNpQr26TDevD5ZRy4uz62+3aMrKpLlt+pZyqtLi3BiexVx gUex+CytnkwV8aJDQPzp74OkXJVJJTJF/7BI9nmWwtQBZ6I5ZFneigIVDDNFmhB43ibb QuTJqSWDVOF36N3klxMWizQkiOFhzUTMPdHMXK7ZJC96EmlzJY2Gt7j6aUUPCubg7xvR M5KA== 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=Ntjm+Knn8OSQZGp1Fbp7qEaaSTzHqGoDY0FSH/IFTcA=; b=C7ZybFG9TUqLyDlmPK062uHzDWpgO48iMYT4P0Cl4YopLwBI2vCgxqm9wgd+BMlN/t yZpvNWtt/Eo3Y4bK/xo2FyGkE6XhAC503BYCN/29FbVY7tJbNHFj8jYv2rB/IxzJoDuo 5BtFVmTPW6Wy9CNhGr5aFzSqO5XduBVrt1/IOG1j3Fx/8BaaanpkryMye0J6dzdxNMcx A5W3GceyQTLPRUbJwRDfT1ciPxjT/8jUUUjAAkEcf/WbyubVJ3bOlkDVY1dO2Di/LMz5 qmlk5JKmacXAdB5r9neP97+DNQm/SURG4iZ/GajJxTljU7ad14sbxca7Fbmr+KCNpuRl H8Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="cBX/gMNa"; 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 u19-v6si4970808ejm.190.2018.12.17.21.03.29; Mon, 17 Dec 2018 21:03: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="cBX/gMNa"; 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 C0D9DC21F68; Tue, 18 Dec 2018 05:00:34 +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 55E7EC21F79; Tue, 18 Dec 2018 05:00:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 47BFFC2207B; Tue, 18 Dec 2018 04:59:40 +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 F3335C21FAC for ; Tue, 18 Dec 2018 04:59:34 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id e124so5991020ybb.8 for ; Mon, 17 Dec 2018 20:59:34 -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=mn2VI8IXVGHLcm/1gZI+cQjDOH0ghEQ3cWP5xJ4AnZA=; b=cBX/gMNa3wHE2LS9I8yC0f7XMm/mInW2gksaNhr3/nhMMaueAkRmpP5Tqyg61kUy9r 4PfXtbUnrpqYcaoLR1K9S/tJpSLrpFxp8CNVuxy6rADYeUWBEnIECT7SjPSnMaZxQvk/ 65jr3YhhMxCgcxPG275hdbfdfRAwtxK8JHVcc= 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=mn2VI8IXVGHLcm/1gZI+cQjDOH0ghEQ3cWP5xJ4AnZA=; b=CeT79ZayEiCYBk9lYIM2Qh2zzUuP7TmL0IYheSTlUWmsbZfsaz6pPRqO/v76hQSoZP 8DkfTfIGBm5nzdXuYfdE+dybQhMeZ2zYymWObaZyZaNPQkPygAvNX3t8jwoCgh+45e9W AKTTxN2jouW6TEWninrw62vQnecYgbSj+1oy3pExWGpatGLinWRdA2+wt9b4WtWjP9O0 wJt331A7JnJIl1xyCPg9MugtdUjHA+clat/ppHS2k8B2rYezAyWl65fk5n7tfWX/DMKG /s4qqIGjNvlZMoay3S3bEYMb2qU8JvNNtwUvQB8r1lpj8k7yR6uKXVg0SBb+remC+2m9 V7Mw== X-Gm-Message-State: AA+aEWZGGIK3GgoIJPKJrpoEWqSzVeea2ctGgVjwZ69VmqY6XmIBrhD8 bxzUm9cTl6JlPvipuAMY3w2Ydw== X-Received: by 2002:a25:9c86:: with SMTP id y6mr15716255ybo.216.1545109173814; Mon, 17 Dec 2018 20:59:33 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id w2sm4616951ywe.62.2018.12.17.20.59.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:59:33 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:53 +0900 Message-Id: <20181218050257.20142-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050257.20142-1-takahiro.akashi@linaro.org> References: <20181218050257.20142-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 efishell command[1], 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 setvar BootNext =H0200 => efi bootmgr (starting HELLO ...) => efi dumpvar BootCurrent: {boot,run}(blob) 00000000: 02 00 .. BootOrder: {boot,run}(blob) 00000000: 01 00 02 00 .... Using "run -e" would be more human-friendly, though. [1] https://lists.denx.de/pipermail/u-boot/2018-November/346450.html Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_bootmgr.c | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a095df3f540b..a54ae28343ce 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,41 @@ error: void *efi_bootmgr_load(struct efi_device_path **device_path, struct efi_device_path **file_path) { - uint16_t *bootorder; + u16 bootnext, *bootorder; + u32 attributes; efi_uintn_t size; void *image = NULL; int i, num; + efi_status_t ret; __efi_entry_check(); bs = systab.boottime; rs = systab.runtime; + /* 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; + + attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + size = 0; + ret = rs->set_variable(L"BootNext", + (efi_guid_t *)&efi_global_variable_guid, + attributes, size, &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 Dec 18 05:02:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154058 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3279331ljp; Mon, 17 Dec 2018 21:03:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/W6BTbEBmoJG7llALvH3exNW295POBt2mvN+FLlkYoDQ3NQpNotyQhR7gyQSNNuU4MELAPq X-Received: by 2002:a50:a2e5:: with SMTP id 92mr15387602edm.169.1545109412671; Mon, 17 Dec 2018 21:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109412; cv=none; d=google.com; s=arc-20160816; b=zeZfrrOD4opyh90Q9GU2jjjOS1ciaCFHJHX97QXH28pE21uVZnY+oc4SCyVFjUBsh6 Nr3fj5zRra6HPCVbsZxCIqDE2oOEStA8f94zO6cASMyQHEX1W/eYFM4jvKo8q7gsWsfX 4mVV2LzZh+bwlKq7cbHjkl5ITzetPt+iHTJJUes8PFEEDQI2h00hkz0WHm8Xjp3wwQ6H uwgaTpmbwxInGW7K/AqdBmo4YSXs3zPsepd4+URCMptmKyBtdBBlSpd2UOEXCy4VSeGz RBj6U8V9LCH+OLNZgF9k736esdKssyGBxQ0YknYcrGy84lM+bLMsLQfynCAjEH705mnG B0xQ== 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=S183cCR6kh9GC0iwI93tn8VdHe6FFfSBTo5AZ9w+Z+g=; b=uszwGMAeqf4w6CIguR6WjH/9r3PbbzwPDnhYOoTPulEwGEIuUjl18RatKlkUVVCeqj uOFoS0FrV4RX0YLEL/2n7/RrkNIYbEN60pudkKMt6hFJU2xNujXlmxMWT41VvpYG8Lse ZPQKZa9xmhOB/1XhOWWns1oBDUe6ITh9nMw9e8JKhZXnVrVNhb02FuNwLE6ggzEuJ8FD ALpqfg5tYP7GftxG/ubARAcT5hZyGj7Y646/QDUwAJr5GF2QPaXMFm9KrXsBPgrwbZ8W ppQJYZPgRgJw7xVldzijCra915WGiT8alGF9QgT1GG/FBdD7Bbm0wuEVHTCZmuRK6EPu CyuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dqcZinfz; 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 l19-v6si2118851ejp.77.2018.12.17.21.03.32; Mon, 17 Dec 2018 21:03:32 -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=dqcZinfz; 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 5068EC21FC2; Tue, 18 Dec 2018 05:01:28 +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 5757AC21EBE; Tue, 18 Dec 2018 05:00:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1AEF1C21E89; Tue, 18 Dec 2018 04:59:42 +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 31988C22033 for ; Tue, 18 Dec 2018 04:59:38 +0000 (UTC) Received: by mail-yb1-f196.google.com with SMTP id c67so6027298ybf.0 for ; Mon, 17 Dec 2018 20:59: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=XfdP5/2N9Uf+K6ylGDnd2ScBCIbYNHqyXjeSfDq385A=; b=dqcZinfz3Kp3Jua0QW1eHAOVbbiCwsAHk8zB/2rbKlti1fHxp2lqunsWMWaLzF+oZx M1x3OeLXE9oXImTjABXKmKaBHrhFEscUm4z2olNSSATCUV54QBW/HxvxyYqokhwWEACY 7gaaaayhOiwFQCmvHJjuZE1IcvFg6I8oJobr0= 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=XfdP5/2N9Uf+K6ylGDnd2ScBCIbYNHqyXjeSfDq385A=; b=l0E0FydBL0FxrxKhHmdrIKLbrurdz5TLuA5D0OuTSt/2M5QjQLzO7VjaFaVg7gMqfS rMqRdSC2GIAxRuH6JP+Es6s4j1bCK4zOnry6jmKTea/nv4TjXfmQgWiynEPTDWaIYW27 gRX+7GYZBgsB1CcqATYo1/wYfXoT7FAhda3OXqw1hx8lrUlJZWcI2XRgblHCIHwpMovR nu2YB8jHIhf4uhPHGlxJh2Yv43UHt2IorocV9EPsRXdmaedJh5LNnwGe0gw42uVmXigB Qy4TtNPn9+Bw2/XYjlxn5pTmOjLx0HCQ91NENz3pliTvHxM4wJwfklODQolAu3COlxBD 4KGg== X-Gm-Message-State: AA+aEWa05/XvvWYGoIN08jIPAU9xvzr3XMrjc6nCGEfmtI9/E92nG0ZS XitPVJWRou1nJfMQuB9j5y2FAg== X-Received: by 2002:a25:2c04:: with SMTP id s4mr355202ybs.245.1545109177117; Mon, 17 Dec 2018 20:59:37 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id p11sm4485428ywm.60.2018.12.17.20.59.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:59:36 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:54 +0900 Message-Id: <20181218050257.20142-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050257.20142-1-takahiro.akashi@linaro.org> References: <20181218050257.20142-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 | 2 +- include/efi_loader.h | 3 ++- lib/efi_loader/efi_bootmgr.c | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7012d72ab50d..3ebae1cdad08 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -452,7 +452,7 @@ 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(-1, &device_path, &file_path); if (!addr) return 1; diff --git a/include/efi_loader.h b/include/efi_loader.h index dd68cfce5c65..5a6321122c9c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -551,7 +551,8 @@ struct efi_load_option { 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 a54ae28343ce..db391147fb2d 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; @@ -195,6 +196,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; + } + /* BootNext */ size = sizeof(bootnext); ret = rs->get_variable(L"BootNext", From patchwork Tue Dec 18 05:02:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154059 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3279908ljp; Mon, 17 Dec 2018 21:04:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xm6C4K6U19SSUI934AyQHqhM6vlbI17WI0scan6ceX9jQcOOSYII01GDZ6EBbxKcd/+LVb X-Received: by 2002:a50:97f3:: with SMTP id f48mr14913732edb.271.1545109463584; Mon, 17 Dec 2018 21:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109463; cv=none; d=google.com; s=arc-20160816; b=dijEZ7vs4ZWJ3rPgkfyw5Gk92s/q9Jp47DurBmHyMGnwuRcqNFS1O5aNEFxSDLTI5M 1hz4VhYqGX4cG8J/SDP0JP0/murkoA3JHV+yS0a/tv44q0gfmeoRii9WgqUmoi7xfC8b 8c0qWJsKSbbxAU09l604rG4q9cT3K4keWzTAuvQvYS+UpxaUhQT3ra7Ns7QbVjhEMXwx GBD/BHgfCJ/mNXZXPTB+vkGtgPBMRcEmB97Q2g1KXUeEZ4rDT9rI8YQCMlL9b5R//nDf COSnDKwJVyA3UAuCPkTv+/zfxMTYRMj+IdKPcbN2bm4UkqCGzsQQ/HOOXAMrp5xOSBa1 o+sw== 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=KFCbuS/bOLBYdhZ1ZmOFp63SUpScCm86pduG++cZ6G8=; b=JUvG5GSPF+Ifrsh9dxEMkvnv82Wos+vsOfKY67btQPR7zx9b17GwrJ1tzWh6SrBv2t KhwtCQoA1QrTdGotJFICOzLSihgq6A2/7BWI3K0jVkoM3C4tv+BhNcGWB4TIMjczLg1P eqnIVhfWIh2kS45SJ8ZAQeZMaj3ydIDP3jQMEeaVKFX5NM/Rqrq2aLShdEdIq54+ZPq2 DpCeT/m4lHEhB63kEvf4rYnDzHmdcVfr/FQNUzuI1NWr4sNsN2vvXLyPTzgjm7ncOp8I +TdL6nFtO3HTf0PEmYKUD/IsnyzpVcnhuUxcGXLINTReXOUnCSm/w1FKBHwpCJlqvcDH y7gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FdEOPF+r; 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 u22-v6si2432997ejb.233.2018.12.17.21.04.23; Mon, 17 Dec 2018 21:04:23 -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=FdEOPF+r; 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 2C666C22074; Tue, 18 Dec 2018 05:01:11 +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 6699AC22090; Tue, 18 Dec 2018 05:00:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A19EAC2204E; Tue, 18 Dec 2018 04:59:46 +0000 (UTC) Received: from mail-yb1-f194.google.com (mail-yb1-f194.google.com [209.85.219.194]) by lists.denx.de (Postfix) with ESMTPS id 6C09BC2206B for ; Tue, 18 Dec 2018 04:59:42 +0000 (UTC) Received: by mail-yb1-f194.google.com with SMTP id r11so5998920ybp.12 for ; Mon, 17 Dec 2018 20:59:42 -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=wN/J4dhVCAUCNnMUqguKi19oitOOcid/1TmJNC3Iw9o=; b=FdEOPF+rHqI7EkDvN/cz+KPApZrWnNpWa7ksqG0UC4cpKq3ieeu38dpoD+k/+33XvI eqr062QDuqx+bkVVbVF2lZkB37QsdeJMtf0qESpCHahMPAuUhRQbwOeG4oLc30Y6freP x/XTnkbuR2iV8PQEIlu3L3lZprW9XW7pOY9gE= 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=wN/J4dhVCAUCNnMUqguKi19oitOOcid/1TmJNC3Iw9o=; b=bvnarTSj4c2cibarnN9H02jkOLIVOfzEdSx1XrYS7dtPSLfV9Jqz5DZBlOlnBh2wJ/ K9LqmKoK/eSXZ42xO7n2BqxLSTtuAgBqHVIOkbOv/DdiO6qGd72QtMmsZmUdrfaKNzAq N2slx3d8EzcApfoySBpXgMVVcXssEbbtzGNJil0/ux17RiJFLXDDIg8NWDfG9hHTDoBK PtkcaHt9RN4H4s+n3YF8whU8V8TaCYLNquNYAvDWd0JV9uLDjruWjl3a3dTyjONrpgTP AM648uFfAjz/sIfMQqqD/O0mTu90u/KaOdlQ0ZUlBgWCLwxd8/oY4GDgX9goyjm7IqDs HaCA== X-Gm-Message-State: AA+aEWbxdomhkOXiABVNH+g8xNxl/0fHVZG8l0DdUwNIud7/Pn2tDA1/ 6cUcA5Ez/6UICeRcxU1LSS1bXQ== X-Received: by 2002:a25:52c1:: with SMTP id g184mr15953632ybb.289.1545109181383; Mon, 17 Dec 2018 20:59:41 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id d204sm4468129ywa.68.2018.12.17.20.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:59:40 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:55 +0900 Message-Id: <20181218050257.20142-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050257.20142-1-takahiro.akashi@linaro.org> References: <20181218050257.20142-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 Revert "fixup! fixup! cmd: bootefi: carve out fdt parameter handling" This reverts commit abc315426e37bdfb96a48d23c1fc96399b68baa5. --- cmd/bootefi.c | 49 +++++++++++++++++++++++++++++++++---------------- cmd/bootefi.h | 3 +++ 2 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 cmd/bootefi.h diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3ebae1cdad08..796ca6ee69ec 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); } +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 * @@ -473,7 +498,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(); @@ -489,21 +513,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; @@ -521,6 +530,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")) @@ -533,6 +545,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]; @@ -542,6 +557,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); diff --git a/cmd/bootefi.h b/cmd/bootefi.h new file mode 100644 index 000000000000..4e11ab1211cb --- /dev/null +++ b/cmd/bootefi.h @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +int efi_handle_fdt(char *fdt_opt); From patchwork Tue Dec 18 05:02:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154054 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3276824ljp; Mon, 17 Dec 2018 21:00:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/W7BmuShwjPSf7bFhy67O4cyh1EqtfAh6kt8ZqD9M6XFSY29kDT1PAhS5e/COC5cV4cgpaA X-Received: by 2002:a50:d94a:: with SMTP id u10mr15021265edj.214.1545109236139; Mon, 17 Dec 2018 21:00:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109236; cv=none; d=google.com; s=arc-20160816; b=S46hxU7qVyet632rixGw1SI8OWwuFYlW6Z+WU9c/umQG/MJDHGZIVBresQh14bh21+ 9qQNQbWKfaIhgz1rox5szBMZ8QL3S5fM3fVkUprwZWfwSZ4nbPLFRpgkkrjpRHqClAem gOpU/aXFJfWJFUL3F3zTghbQobzMjXMtU40Aa3+pngXMc2tcZ3CgWvXxMPEBdBAUbVpY 6wRldtUaO5RubkQ6TQAUB0A+FSPAI3zziH9olEmMnJ8Li3PVTvKX0f6Zs/yf/nXhsg+z ADskdk4egMAnxmQ69i0hc91PS5DSPRegNMGFseD3noSz5s6YC8A1HUDQfGZ2DTcgKUHv uy5g== 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=NtCZ1iKleF216GC1DP28viTiRV7Xh6a9u7HQtH9a0k4=; b=ur9jcAt//aO9uM4fVqyDmQjnpFZc5mhy6lgXhS/ABJ1uKM30SkUap8WAPPxviY1/RR zOrXS5jFyx/FYOr8RCBM1hIGagiM8zPKmyzqpGSfJWZKX/ymJimniNAbfYXCxtUKJ2Nn jNZROb8J8jr4ok/CWttAhnX7VX9jYhZ/H+jVsmPpeDTN0siwBcsok5GIci0dXpTIjAQf D/nb630uPqSMB52E0tW2ojB7finIt8P3oJKrPCqF5KGW8eebIYNeTR3EWk4gtAlx4TK7 Hy1iLWrAZ1ZQJR04H85VFvEIpeqqFXgXtefGyhXWvyFssai7QrvT8l+xvUUfEMXQjqNi o6Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FQk5tCl0; 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 x28si92391edm.388.2018.12.17.21.00.35; Mon, 17 Dec 2018 21:00:36 -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=FQk5tCl0; 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 B13B2C21F69; Tue, 18 Dec 2018 05:00: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_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 EFB61C2207C; Tue, 18 Dec 2018 05:00:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3B1A3C21F79; Tue, 18 Dec 2018 04:59:46 +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 B65F3C22018 for ; Tue, 18 Dec 2018 04:59:45 +0000 (UTC) Received: by mail-yw1-f67.google.com with SMTP id n21so5132385ywd.10 for ; Mon, 17 Dec 2018 20:59:45 -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=ii6PV6GSsUlkcoQ/gUiPoKvRBPgajnWaDVaVvqpiorQ=; b=FQk5tCl07FkeAMmQ2nzNE9tBAGawtJUEyQZ4/5XHT1GDQg/6jDwbnL8P0BhUCthCOr ZK4fWufICzcFlpBhQW3YtRaH9qqoL2THSxX+dMe1DNlckGkSDBiF/HRwttjBJq1f3+Ws 86tDOIZml16oWc1HEFId/868rALFYcrTn5weg= 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=ii6PV6GSsUlkcoQ/gUiPoKvRBPgajnWaDVaVvqpiorQ=; b=GHqosFeNyiTcVuEVRenbQoYeNlTU4FpTYFPWtovuytfjjtJBr8dAlScliWMgXTAXtY R0NMexBMAhf8/m7mm+9bZ+yQB9UO2Yv5SCYFVZj99/AonN2D226T1PKHI/JPLMVDLBaq xLyhO9wWVG2YiutouAVZGf1bFeJ/qOfilYz+O7UaCvff9wWEtrGzUFJQg/S0yoEsKSLa hu0456c2XLhXEDNw0mTWWwc7k4OgOeEMo2UcOEBOeHzebvUug1K8E+NuUTMwLCVOG3SV /glWuqyMXI/Z3UIguELkDKV/rh7yxeb0Pw9J0wUKm6Qubffm5VLo755Wvx64JCHcSMFr YReg== X-Gm-Message-State: AA+aEWYgVWkf75o9NELfvDfzn4xswUc0knM0uA1QPGKjzTf3+mF3VL4w 8GnuVxwCZlE0kWbfdDAf7qxJ2g== X-Received: by 2002:a81:5191:: with SMTP id f139mr16169200ywb.132.1545109184689; Mon, 17 Dec 2018 20:59:44 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z2sm3728183ywe.32.2018.12.17.20.59.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:59:44 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:56 +0900 Message-Id: <20181218050257.20142-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050257.20142-1-takahiro.akashi@linaro.org> References: <20181218050257.20142-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 796ca6ee69ec..2fc52e3056d2 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -471,13 +471,13 @@ 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(-1, &device_path, &file_path); + addr = efi_bootmgr_load(boot_id, &device_path, &file_path); if (!addr) return 1; @@ -545,10 +545,22 @@ 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 *endp; + int boot_id = -1; + + if (argc > 2) + if (efi_handle_fdt((argv[2][0] == '-') ? + NULL : argv[2])) + 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]; @@ -589,7 +601,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" @@ -597,7 +609,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 Dec 18 05:02:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154056 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3278529ljp; Mon, 17 Dec 2018 21:02:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/VrVJEJNBUqJ62Z09c13E7m57gj57Q1dnqLotnXV5UvOjvZxVCzi2H7EMAFdQDkJ51xluOY X-Received: by 2002:a17:906:4684:: with SMTP id a4-v6mr12405144ejr.24.1545109353884; Mon, 17 Dec 2018 21:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109353; cv=none; d=google.com; s=arc-20160816; b=X4YdpgRN/VH+UeVb2H2hjNoB1xmeDl0tsp67tymOYZRbz9+1u9GU2WuHzvug4rHQ20 w6FnRXZMi80IkA0XxOv8x749C3DpjBCEvBwtNPPcMBexaeQixNw9/uTJch0407bc1nXy fpv//0c9n+k7aavZR1iqiMcI7MMcIIRq/vreKP/vjN4FYBi4hA+PpHfLoHjAXKHckHmH kHwzeYd/ulNnFE2dKAQsAIXKA+2QV2yHP0mGzwZ41O7lLbEqHB0TFumPyGDT3Y870TEV JDIG4/ok8bqH2It6vYWvL1FvmvRdX1x6mo/40aBtuPhlug1mFs6+7sqkmQOOH8dQ5cxH 2CEw== 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=xRK6U0hJEZ6G8xememW4yzQ+RhrjKcJcni2/6pXUD3k=; b=rYz4PFu8TBj95i6tzH0HI2H20jFnttGwZdTs4bnocDkPiP1VfrkWAiZRLnGaCEmG/d iIJwlBPbSEz8cAMr/4SnkxVkJHNj8u99BfZmj00/yNfHppCEmRVJLkBCfCELOMrtHiNe WUQ4CUxWNFLFeE81fRJWsv7yda95d+x3f77wPQzxaCF4DUI3pYCo5R/cmJdWOU9NBZmB MqWwj7wNjsBZmNA4fO8KPOxXRvjEZbVv1f+a8wliFaMD04qASWnE1mxzBmMEC18LKsRa mQQIlWjvJnWSURBORehOigC8rVRqB4J91RKudNQfP9z5V0+QOVV495yVZGhs+u6mZeYm 1PNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WZvyuMpr; 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 n7-v6si3112404ejr.283.2018.12.17.21.02.33; Mon, 17 Dec 2018 21:02:33 -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=WZvyuMpr; 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 76773C21ECC; Tue, 18 Dec 2018 05:00: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_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 576F7C220AF; Tue, 18 Dec 2018 05:00:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 94E95C21FA3; Tue, 18 Dec 2018 04:59:49 +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 EF553C21FB9 for ; Tue, 18 Dec 2018 04:59:48 +0000 (UTC) Received: by mail-yw1-f66.google.com with SMTP id g75so6187241ywb.1 for ; Mon, 17 Dec 2018 20:59:48 -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=0CgRnx09H1XwU9KniHuUr0FlCy9bxtQYmCtRCCn+dK0=; b=WZvyuMpryha56mbdQC2bwY2B9b9Axx1/2z7SffaGM8eU+fITRNQmtDmG+nnVgGe+9F 45MRpI5ZrPCFF9Zh1JnAnb+O15zMrfgEzmrLLhv6RAQTpMIcIIGYkhYc1cdlaxjHkfBo 3TGjCIfSxu0bltBEHjtVi8yquG0+TANHupg7w= 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=0CgRnx09H1XwU9KniHuUr0FlCy9bxtQYmCtRCCn+dK0=; b=rtyajQLk+tAgn7RvyQzocBTMu6vXrkoZgFhcy9uJjiWpqv2Wizaz3MWliIx7aqoGFT psuwIFsy3cfvJ+DAqY4S/CZrk/MTkEon9rY+exqqYE8U6tvaniNvf8fQ0RZdsSROMUV1 SNgF0ryBDnx518E/F/Wr2kpmpPy3olBAXiIVtD4QApSdVQS5dYBRcwaikPMWIYvcC9/K xYGkD9f4pGwqnW4EMRnnFFMfitJn53hcdOYVyvtUOACNQiYLLYtp0u3n6f3D85rpQKCm VSeN/RZ8w73c8/BITFsqQk7bawxY09DhSMYLw8V45dAZE+7J1wg+l/W+i2bFnwf9ZKIS O5Yg== X-Gm-Message-State: AA+aEWaMsSk8FHhgpr6JMX157akR4TI5CygFa+gwJWbuMMddDawRZL8M /hZHQbcSY4ZxycnolOxZxCZJPQ== X-Received: by 2002:a81:3009:: with SMTP id w9mr16459225yww.28.1545109187943; Mon, 17 Dec 2018 20:59:47 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id n16sm5082676ywn.31.2018.12.17.20.59.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 20:59:47 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:02:57 +0900 Message-Id: <20181218050257.20142-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181218050257.20142-1-takahiro.akashi@linaro.org> References: <20181218050257.20142-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 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 | 2 +- cmd/nvedit.c | 5 +++++ common/cli.c | 31 +++++++++++++++++++++++++++++++ include/command.h | 3 +++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 2fc52e3056d2..8122793d11c5 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -471,7 +471,7 @@ static efi_status_t bootefi_test_prepare #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ -static int do_bootefi_bootmgr_exec(int boot_id) +int do_bootefi_bootmgr_exec(int boot_id) { struct efi_device_path *device_path, *file_path; void *addr; diff --git a/cmd/nvedit.c b/cmd/nvedit.c index de16c72c23f2..c0facabfc4fe 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -1343,8 +1343,13 @@ U_BOOT_CMD( U_BOOT_CMD_COMPLETE( run, CONFIG_SYS_MAXARGS, 1, do_run, "run commands in an environment variable", +#if defined(CONFIG_CMD_BOOTEFI) + "var -e [BootXXXX]\n" + " - load and run UEFI app based on 'BootXXXX' UEFI variable", +#else "var [...]\n" " - run the commands in the environment variable(s) 'var'", +#endif var_complete ); #endif diff --git a/common/cli.c b/common/cli.c index 51b8d5f85cbb..013dd2e51936 100644 --- a/common/cli.c +++ b/common/cli.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include "../cmd/bootefi.h" DECLARE_GLOBAL_DATA_PTR; @@ -125,6 +127,35 @@ 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")) { + int boot_id = -1; + char *endp; + + if (argc == 3) { + if (!strcmp(argv[2], "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); + } +#endif + for (i = 1; i < argc; ++i) { char *arg; diff --git a/include/command.h b/include/command.h index 200c7a5e9f4e..9b7b876585d9 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) +int do_bootefi_bootmgr_exec(int boot_id); +#endif /* common/command.c */ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int