From patchwork Mon Nov 5 09:06:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 150159 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2358039ljp; Mon, 5 Nov 2018 01:11:04 -0800 (PST) X-Google-Smtp-Source: AJdET5dGoXVCGN3Qmj2WPE6I6r/9KY5Outgfi7FAuYquRSavroniwgzMJvzwAC+TGUopAlzRhpKr X-Received: by 2002:a17:906:2989:: with SMTP id x9-v6mr1371513eje.156.1541409064690; Mon, 05 Nov 2018 01:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541409064; cv=none; d=google.com; s=arc-20160816; b=cyguRQ9kPkL2Xe1NQjwiSUoBWN1mQJjN7hLcUlzBdT+ppGxx3xi1bw+kCTO2ELXOLI YPynhOAVA71RfNs3/CYDI/L3QnKgcwrk585C8ry2HEBdItPvUEsUZ7L5NPBhY5fyf5aT /VBmE01gpeOjV7w2S0RXrfmJTR6yVLBugTE8tqtNaCi8pKkpyKHyQzOQCnTHEMgnmskx TcmnvU6/kSFlRtJGMgQxeqF0xGc5l8Ui36O+cXXSGDfB/v4ZaXGlZfWArO09LZfaWDeC A9Kxb+Jxc+lhHkyg/3H03+x0RfpUfUKMhmpA2POW5wtoHWp9sXgQrHisPgYmkdh8S4QZ U+eQ== 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=iTuvQ2/z/3wJKGCdP+O20q4ksPhJT+XM4yplHvqDuAY=; b=tUfSkauT4MXkiQJaIJTENPQq0LtywsMQUTGWTVDuFGosa4wncxfYGvepQkOvlcAVJe EeskstWTrQRj1hsuVN+/lXmvsAczDELfk8D1DWr1T/O9YTr94ogqYowfF3c0h0LEgAtg +T4SIubfdprtskXY9JwdVxDsXSt4ajvnhYY1Hrohk2OLjvQljxps/b1ESBYZ/kubCo30 87QHoq8S/O5Kaxi+TOkH1dYnDaTmlRKDcq5ZUDE0LUl4+NrYQ2ewsDts6xfmRNi2aXUA SPiKa6uI/JBNXcCTOZA00fLuoK8pENRYJF5OKP+4MrS5pOmgGauie6w5rU8rEzCTvMoN fcXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kdbK0QtF; 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 j16-v6si491060ede.53.2018.11.05.01.11.04; Mon, 05 Nov 2018 01:11:04 -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=kdbK0QtF; 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 54189C22454; Mon, 5 Nov 2018 09:07:25 +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=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 71D39C221FD; Mon, 5 Nov 2018 09:06:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EAD59C221F2; Mon, 5 Nov 2018 09:05:22 +0000 (UTC) Received: from mail-yw1-f65.google.com (mail-yw1-f65.google.com [209.85.161.65]) by lists.denx.de (Postfix) with ESMTPS id F2ACAC221F7 for ; Mon, 5 Nov 2018 09:05:16 +0000 (UTC) Received: by mail-yw1-f65.google.com with SMTP id k6-v6so3335445ywa.11 for ; Mon, 05 Nov 2018 01:05:16 -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=JZmANuSgRuN3oc7F6I0XYwhDdUW8krKEoA+3OpJqtOQ=; b=kdbK0QtF9nA56zRowwlzI85NhDTBm6ab20N+s1P89NTY2U0M7UQ5o0AoNQwB/OaoX4 m6mEZkehl9P3y2QxqG4bS/j5s5HbnvaocObW/cnshifvDALhuOmA5LWB5MnbdVSzg42d iMeHl0xx793tlzn6b6tHK6p2iH4YZ2YlUJ6OM= 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=JZmANuSgRuN3oc7F6I0XYwhDdUW8krKEoA+3OpJqtOQ=; b=peWqPUbSs00we5KX6tZ3IIOl9iIV5jMh9GbP1yppg6Is1bv6rOjuSFdsfVqe+qb6eJ eioK0l73SFY0fqp0tbsz8A4l+dOarpqJ/YnTF+CDQEuoqmCigx3pbUzF3HFdvEwjD7tU hPWPPvpvRFontHsRnyipnVuQpPh2XAawt2ae8cQSbfGcM+HQp32wCgM88mmbTRQvFn4W ql3+ACa2x/RLPuCjTZ+PTcpz9zxiwRGOzwCh4ef7NQaK0OWzOb2pC+roJOpQZHSzlhb8 pye7QZGjslY3lMDH5oh7KEsBTjelcuT6jlR4iyvuTdDaUJN2+89kMyQ5AMeTQ9dLkuU5 NOjA== X-Gm-Message-State: AGRZ1gJajxeOZPzL57zIppyte/q5l7RR5fCxx0wW+72lCqPFkMeSVQLw O39vfvXh4lco1T8W3dBoAt6GXg== X-Received: by 2002:a81:e4d:: with SMTP id 74-v6mr20221645ywo.162.1541408715822; Mon, 05 Nov 2018 01:05:15 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id a189-v6sm10806380ywf.49.2018.11.05.01.05.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 01:05:15 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de Date: Mon, 5 Nov 2018 18:06:50 +0900 Message-Id: <20181105090653.7409-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181105090653.7409-1-takahiro.akashi@linaro.org> References: <20181105090653.7409-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: xypron.glpk@gmx.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 11/14] 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 | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3aedf5a09f93..7580008f691b 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -509,13 +509,13 @@ exit: return ret; } -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(&device_path, &file_path); + addr = efi_bootmgr_load(boot_id, &device_path, &file_path); if (!addr) return 1; @@ -595,8 +595,20 @@ 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(boot_id); } else { @@ -639,7 +651,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" @@ -647,7 +659,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 );