From patchwork Wed Mar 1 14:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 657800 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp3525431wrb; Wed, 1 Mar 2023 06:44:41 -0800 (PST) X-Google-Smtp-Source: AK7set+G5N5O+oy9j439tDDt5nUPUiJ0bOPgasVN+g7ZZxXOJsOAA84HqaaohdJwVeKFC1l4WbZA X-Received: by 2002:a54:4510:0:b0:384:3f45:1f20 with SMTP id l16-20020a544510000000b003843f451f20mr3351871oil.51.1677681881519; Wed, 01 Mar 2023 06:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677681881; cv=none; d=google.com; s=arc-20160816; b=gRYkTl5BelBwXka/7+LYmERrHvhIZxyzwJ1M5lj86txcNCKSvgmZXFjadlMX0CGtQE TEoyeKX+jTa5f9tgJBC6KBx1/Brw/qDH+f53nJ6I3Y1wOrm6NlqqIENrvl/tRZ8gq5kG HdRI7ZSMXSCOLzyS+3PxjnUUONeMAzqlGqtw0l5pzabwU/5RFVd9ZyI4/9aj6KCnAPw4 RMe+DYLWyuEI4z6PLp3n6GG9ubSC4KU3zaO3wkOXLe5LTJ98C6loc+TP+OkVvMtKeiys ZhSfNgRbmihrV65quGRF1q6Sxi8aca9mJjZtm3TZa5Iumawoq7XPm0SMCHbsdjF6egpl LAeg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=7Ys9wdXg4gFBHDpqgBzqPiCKg96wymbaaCPSeoqBgSU=; b=P0GyEkXv7KxoWi8vQ0aHqcjCPJ8M2c+J/er/rb50a6aYoEz528sCPcb8ANUS6Izbqa 2kRazrwW18LVj87+TaoFJ0xeqzpY2ZGM1quWi1MvzlL01dfIIBHvWz4wtvLDDzPtcOQ4 Rb+Co6Dnu6NwNwRsVZachb3yYTr9gkp4j3rMgEwUEYIDC61c6tTkc4GDSwchRBqm83zC kvi8irh5cl7LMiDJ0ZXsW6KxBtUZgX5PuP71czEHf7VRUalcuk6N3fF317S958vgwj1S flIF3PcuToWfcFXbMuaNOfAW3ADSOMbjbjFpKeRfw0NIQZixjF2hdLR8kdaV7idrc9/x PhPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fpuyhOBK; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id i8-20020a056808030800b00383e1c09dbfsi13599827oie.142.2023.03.01.06.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 06:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fpuyhOBK; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 11CF385B21; Wed, 1 Mar 2023 15:44:37 +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="fpuyhOBK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C78AC85B34; Wed, 1 Mar 2023 15:44:34 +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-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) (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 0712485911 for ; Wed, 1 Mar 2023 15:44:32 +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=ilias.apalodimas@linaro.org Received: by mail-ed1-x52b.google.com with SMTP id s26so54603064edw.11 for ; Wed, 01 Mar 2023 06:44:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7Ys9wdXg4gFBHDpqgBzqPiCKg96wymbaaCPSeoqBgSU=; b=fpuyhOBKXnqFV4cuG/Com7CgPBh6+/2rZCnEL8oM7xknr5mRAkk7SyXanwysCc6WHr u3/ioi0kUesBDp1db6dtzEsYGBy5NS/OWlR5U/cguIIwjettQpBHvkkRrlU8SAG0vo1g dfCr/yIJ6tMIT5VVkJpbE6QEPSZSg50HkmRN3ZgdNUHcOQQXGlvJaY/wwnniuo1Iyzr/ uItKPiBq9/hsWDC7UAvUe3d2OJQGorofBA0ERkW7pWRP9TvEQn+iD0dI7MOYmQp0YcHV rydYBEUiP7/9iquQMLKmywGrZniR8Gbpip6CL9jtJlnff04cZDNU0VfE7AI1Ou3hq/Ix P2qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7Ys9wdXg4gFBHDpqgBzqPiCKg96wymbaaCPSeoqBgSU=; b=eWDmDjwfUjKj0q7u0VdzwdnIJD8Lph73B17JPLb1sJ+lXbdvP+VhfdlmfmzIwLuvTq alh57utFG9V1yJJe2P0i8WuAgzuOhMYmh+IKL1KM/RMki1fDiceUScXeeWNR+iXrLg+b Eg/t6zuW5yWLwl17srd/nAJWIovaS7FUIgFJPdllDKXvHizrgN1jaOKld0C9/eSSu+Z0 LC89IeriLjIfQOCTWH6MF6GVnZH904FZnx1T/xz54Qf+f2n8jkb5bNpHc7GNePxC2CrY NW4hVBN8hj/wmUu2axJDpJw92bBfEISGbCeKepx3QK3l12KjBkjxHJah4de3gy5E3gYz RbwQ== X-Gm-Message-State: AO0yUKW+Mt/uQs+klH6fNFAvFcQ0G87HDw3kabunbEBAp5n71ITXY29U xP9hAk2F2qAtkDqzfKg6VbR9xoAr9KvvwabW X-Received: by 2002:a17:907:d046:b0:8f3:8bfd:a8e with SMTP id vb6-20020a170907d04600b008f38bfd0a8emr7127761ejc.26.1677681871533; Wed, 01 Mar 2023 06:44:31 -0800 (PST) Received: from localhost.localdomain ([2a02:85f:fc09:d5bf:515c:3f68:fa64:bd]) by smtp.gmail.com with ESMTPSA id x16-20020a170906441000b008d09b900614sm5771863ejo.80.2023.03.01.06.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 06:44:31 -0800 (PST) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: masahisa.kojima@linaro.org, Ilias Apalodimas , Heinrich Schuchardt Subject: [RFC PATCH 1/1] eficonfig: Add a 'scan-only' mode in eficonfig Date: Wed, 1 Mar 2023 16:44:22 +0200 Message-Id: <20230301144422.1825389-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean eficonfig will automatically scan and add Boot#### variables on launch. It will also perform automatic management of the automatically added variables (e.g it might decide to delete a boot option if the DP disappears). This functionality is useful outside the context of eficonfig as well. So let's add a -a flag to eficonfig that will only perform the automatic variable management and exit. That would allow users to define a bootcmd along the lines of 'eficonfig -a && bootefi bootmgr', that matches the ยง3.5.1.1 'Removable Media Boot Behavior' behaviour described in the EFI spec. Open questions: - Is this ok to add on eficonfig? Similar functionality is described in the EFI spec as part of the efibootmgr - Having the functionality on the command gives us the flexibility to run the run the command when needed. Alternatively we could move it to the efibootmgr and hide it behing a Kconfig option Signed-off-by: Ilias Apalodimas --- cmd/eficonfig.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) -- 2.39.2 diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 720f52b48b8c..9b6631816997 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -2693,10 +2693,18 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a { efi_status_t ret; struct efimenu *efi_menu; + bool exit_on_scan = false; - if (argc > 1) + if (argc > 2) return CMD_RET_USAGE; + if (argc > 1) { + if (!strcmp(argv[1], "-a")) + exit_on_scan = true; + else + return CMD_RET_FAILURE; + } + ret = efi_init_obj_list(); if (ret != EFI_SUCCESS) { log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", @@ -2713,6 +2721,9 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND) return ret; + if (exit_on_scan) + return EFI_SUCCESS; + while (1) { efi_menu = eficonfig_create_fixed_menu(maintenance_menu_items, ARRAY_SIZE(maintenance_menu_items)); @@ -2734,8 +2745,14 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a return CMD_RET_SUCCESS; } +static char eficonfig_help_text[] = + " - UEFI menu to configure UEFI variables\n" + "\n" + "eficonfig - Spawn the configuration menu\n" + " -a Scan, configure Boot#### variables and exit\n"; + U_BOOT_CMD( - eficonfig, 1, 0, do_eficonfig, + eficonfig, 2, 0, do_eficonfig, "provide menu-driven UEFI variable maintenance interface", - "" + eficonfig_help_text );