From patchwork Tue Nov 9 01:32:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 518031 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp1053025iml; Mon, 8 Nov 2021 17:33:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwplpwJnG+b7OlyQRqrZ0t2zsjC0CQrnorZOBvDwF4N6cBYZrslUJo33fBzCyxFsU9Sh3y2 X-Received: by 2002:a17:906:4fc5:: with SMTP id i5mr4729905ejw.475.1636421635757; Mon, 08 Nov 2021 17:33:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636421635; cv=none; d=google.com; s=arc-20160816; b=tJjZK3DYSn1yemXrpTtzPWoWsuhuT5KsvMdi1rxJA6cMil7x1UWlsDrJ0R9YJ1M5WY ++/qOaywSYmT1eZCgtAP09cTtOCYZ80/Po/Eg8WOkAp4N9TtxMTMIDOAFOPkH7tu6NlC byo+gYN0i0crgseQ8v8CvDggd+I8XaJZYl+I5WE9a+wjADKn88wcGFJy5D92Y0bCOBih 7m7wHKrCMQ0Nm+DlKTTevnUXcnemj/l8AcNokWBxKsG/6ytc7hsrgjAZOk3gqXUtcVIF xqKsF9k27oWAYkt8/2jdnVqIYlrxre3WB1y4oBR15TzWrIGEypyQO/z3GgvSOS7mXZUx aVhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VTV++eOpBNzq43eetG78sqEJvDdgV6wIwIKieQLUhy4=; b=HyP+Zqo1uTriun0UVCs8P2xYCvIpVnx+hiWGAo5Qqd9xVXoqLROMcYuxUBoaVkxoGB YhiQ+tfurZRzzEOi+zyCkaJ2Woyniyw4WIAbicwJ3zx8RDJY6x+zAcMbhMnADi7Lgw+C 4ECXVXHwsr4HfOsulH3aIqi15zU6PjFplTVFq2VytxpIHMP1ssNK6aGPj0hxsLm8phU7 OkRtH6WuDKqDYZafawiebsOJKK+DWZpiDZJSWQDXr8g+DpUR2p51j0Leq52Xse9YBVqO 3dr+8IUV4r0BeYdZdkzRwocEv+DjkKgwlYl+NZyn493/xZvJJTTYlwUTKyLGrJn60mp4 fBSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P8PSXjSV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id z10si16368329ejr.293.2021.11.08.17.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 17:33:55 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P8PSXjSV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6326B838FC; Tue, 9 Nov 2021 02:33:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="P8PSXjSV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8B304838E9; Tue, 9 Nov 2021 02:33:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 29CAD83883 for ; Tue, 9 Nov 2021 02:33:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42d.google.com with SMTP id c4so6068101pfj.2 for ; Mon, 08 Nov 2021 17:33:28 -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=VTV++eOpBNzq43eetG78sqEJvDdgV6wIwIKieQLUhy4=; b=P8PSXjSVHENvVvk7lfyfVHia2/Wbs36PfV0bebRRiGDKe0/dN5dULEHyzY7xXhBIOG NSqGM5J3RVsXWLx4IA3ZS/G9wIArYouJW/ITVV30R+pKJbZc9rhqBzgoahKecbYIR1RU WAs7t90t26aJAcOomu5bBBdU4dB2YM9Ok+CLEAY6p2MJPfmapIQoa+DfFDMs/Bkl3H6y OLxrVoYWyjYAFztWIM+tI6E4YMfDYP+Q/cLzV4e1qCYdqTi7DzzqUOA06DQCQ9E3rnza yHVoumuZs2UVochhI30PCy92WcL/WyOU4Ku/NnWELjxJY3eVOnFuiRQ++yNDn94KxaPQ 8h8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VTV++eOpBNzq43eetG78sqEJvDdgV6wIwIKieQLUhy4=; b=XhK7dwgFxOCzr2VdP1uGoPfZZbqWPN4cd3WmB6gS2mge3IH5/VtMHZgO0PhYcT81Ks t+wkzXe19rofsJXyQtx+D9Wyle8mX3vZGFgbceSbl9edJU1Dw89wuoSWu8UDhrL4LTam vxJcUEyTqt2rRkzob9tfMkjTtpqyf7rKu4Ug7ATS7UTisYcp0YoeII34dvaOZK0LLGLC 6+8wfzk7y7WXNTSKXQHqtsoGwp+3GmFGXMNnT713/pr9jrKadQ1yhOvEFwgVy+KN1Ryp 7tMSacCeCAjZ+pgOm1UfA58eDzI0wHi0/MzSnfLrHHCVCHmDhtqHZ6iHxuDWC7AnHrkI o47A== X-Gm-Message-State: AOAM5311RuEmy1iAC0N5xYgActu8Y43fr4IEZ0J3oBdY1YoWxpnjCsde BYm8leaFbnA639wagrVI0WslGw== X-Received: by 2002:a63:3c4c:: with SMTP id i12mr2966711pgn.447.1636421606494; Mon, 08 Nov 2021 17:33:26 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:e857:cfcb:a6ed:9a8]) by smtp.gmail.com with ESMTPSA id v10sm4946589pfg.162.2021.11.08.17.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 17:33:26 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: sjg@chromium.org, ilias.apalodimas@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 3/3] cmd: efidebug: handle booting from removable media Date: Tue, 9 Nov 2021 10:32:33 +0900 Message-Id: <20211109013233.72902-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211109013233.72902-1-takahiro.akashi@linaro.org> References: <20211109013233.72902-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Support for booting from removable media is now added to UEFI boot manager. Here we should modify efidebug command in order to define a proper "BootXXXX" variable. With this patch applied, you will be able to specify the boot order, usb and scsi: => efidebug -b 1 SCSI scsi 0:1 => efidebug boot dump Boot0001: attributes: A-- (0x00000001) label: SCSI file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(0,0)/ HD(1,GPT,0ed48d12-1b4c-4e08-b3ee-decf20428036,0x800,0xa000) data: 00000000: 00 00 => efideubg -b 2 USB usb 0:1 => efidebug boot order 2 1 => bootefi bootmgr Signed-off-by: AKASHI Takahiro --- cmd/efidebug.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index a977ca9c72f5..aaf269cdf47d 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -933,6 +933,29 @@ out: return initrd_dp; } +/** + * count_arguments - count the number of arguments + * @argc: Total number of arguments + * @argv: Argument array + * Return: Number of arguments + * + * Count the number of arguments for a given option, "-?" + * Specifically if the first argument is not "-?", return 0; + */ +static int count_arguments(int argc, char *const argv[]) +{ + int i; + + if (argv[0][0] != '-') + return 0; + + for (i = 1; i < argc; i++) + if (argv[i][0] == '-') + break; + + return i; +} + /** * do_efi_boot_add() - set UEFI load option * @@ -945,7 +968,7 @@ out: * * Implement efidebug "boot add" sub-command. Create or change UEFI load option. * - * efidebug boot add -b