From patchwork Fri Jan 20 08:43:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 644636 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp663456pvb; Fri, 20 Jan 2023 00:42:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXufxINchxM2Rr6u+pL7JkH8cydo9cBDExOb7whtVrNw+FWeJrV99lBhqNAcqiBi6qidvd9e X-Received: by 2002:a05:6808:190f:b0:35a:2c5d:466f with SMTP id bf15-20020a056808190f00b0035a2c5d466fmr21666681oib.43.1674204141582; Fri, 20 Jan 2023 00:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674204141; cv=none; d=google.com; s=arc-20160816; b=GTFYpgybHfh6bmCobJBlFY8CqTT8iscYKiM0/Civ1tD6WwP8AQi8j2OxMRYCtESiCt KdGR7wftJfGmYGYncy/ZmJmMuQYVQgA2ZtJavvtXL3IrgmrNcMngmDhYaafXcZjNJEnq 4IH7j7OrHstadqPSyWCW9wX5q3ygHuNYoCE6Gz5isCrmJjdM68eD41I/Wd3YuF25MxXJ Jx6aiC5hNgYmxwiJPGABafY9hLHhvhMSjPdV5WX//AInjGu7zwe1o1yU9hvQdiUHc3Y0 0u324KDicOUkHVP9/JFkMEs8EiWHs7aL2hEmJ4uaPFgWVPPkU7Xwnji+zy8vXsPB5l1V b0+Q== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9mNjcLPQEN6J7O2KGF8Go5ktmn5vKk+ZCoYeX6F9Uwc=; b=FXNPNlZhpJvMbLC2huxgMeVLQFfWAuj887F8h8dKXtja70ITlQyJtyvOaWm0UZVOxE unSduKOXVpd3wtL3/vI43fGVF2wqYN2XnSM0yYCgBy3b/SBB0rOMgTTYQ2FqckuxykNw W6XGRMuw95H2JB+VF8EJ4wO7raBU+2pm8ByZUyPKiMa0ZL/ou3iTYpQlG6J5yiY3fgls tulhJwcnFXtGeCmEzG0ZUBu2cpHtKPtZyTuZWawLIJ6FL1/tlaVfOIXMNdVYvKcDr2e/ ipHbN+0wkzcTpXAdQhcMlF5y384+Nk1LQHW4ZoTyAubnOf5Oz7IAjJ/vAFlIqO+Zw29r ChUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=szYVzm66; 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 w13-20020a056808140d00b003671d339356si13469946oiv.167.2023.01.20.00.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:42:21 -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=szYVzm66; 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 BC28A85668; Fri, 20 Jan 2023 09:41:56 +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="szYVzm66"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4A0C5856A9; Fri, 20 Jan 2023 09:41:46 +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-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 0F71085668 for ; Fri, 20 Jan 2023 09:41:41 +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=masahisa.kojima@linaro.org Received: by mail-pj1-x102b.google.com with SMTP id k10-20020a17090a590a00b0022ba875a1a4so1396011pji.3 for ; Fri, 20 Jan 2023 00:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=9mNjcLPQEN6J7O2KGF8Go5ktmn5vKk+ZCoYeX6F9Uwc=; b=szYVzm66ooQRE10VXQ+hthNyKSBDIbg6Ujt5mxYdsTEa3P3VKu/y3T9jop5rRJNjgh jWumasCkvV3xerBpj1nXcZWTJq0aHaLlTG29+vZQjS+2Xb/rM0hMSwx8SuXWeDaQ/xSs mvd6PNgsoJ6Aadi5tfp4tgRrOEls8V5x2vWZcZfELzaRqQ4UMTnapAI3gv7q7/NHfYj3 9jXbhJcd6t866/sRc5TNC09yd3nYZNzx5QDuWFfEVMdj1Bbg2wyB6R7p/DtS8UvDqZuB zv1KDzY4vDq2NYyzbd/cb+SnhWyPuDwAtoy6M7oXJP/WRCDvZ8mIHbUXcguutw+bJRbY u/kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9mNjcLPQEN6J7O2KGF8Go5ktmn5vKk+ZCoYeX6F9Uwc=; b=uTIqcQixaT7PD1Bxc7k9kDAlr6Ai/n9STcODNITwGv3hjdgVVXzH1/7/E4qXPNhStq VvYMRfTK3dv8gGS8blbIL1gOrsm1iNaJJkgKxZ164yy7lE+x5cD7snuPH3WFqNhsGJ7O +7HI1EV4kVHaoOus+wR4Mxp2ovkEVv8xhWh3lC6A6yc2T4ToZizfMG9RtJwOjFxKgAO8 zyS2oWk95hJBwgSxRpakNcX/gFBwh/Cx8DfBHHaSOml6uZs1h653sDIwX3EJnthRaoG0 QqsZinQHAZXJgVWLdVAhD3cf7LBzxfGpZ7+FxnjJL/Tyj19j4oNTqQ58Nxd/VS/ScUa3 HlWw== X-Gm-Message-State: AFqh2kpa4rF9MtBOI6tJahQLV70d46ZlDohv3VHV4pxsvvK3jRC9GTqh IszElMX2Isn++f3Yk4YPdyq50YcqLocWGQ7P X-Received: by 2002:a05:6a20:7d9c:b0:ad:2abb:5a5e with SMTP id v28-20020a056a207d9c00b000ad2abb5a5emr47669657pzj.61.1674204099153; Fri, 20 Jan 2023 00:41:39 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id m12-20020a634c4c000000b0047063eb4098sm21652195pgl.37.2023.01.20.00.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:41:38 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v4 1/4] eficonfig: refactor eficonfig_process_common function Date: Fri, 20 Jan 2023 17:43:55 +0900 Message-Id: <20230120084358.5919-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230120084358.5919-1-masahisa.kojima@linaro.org> References: <20230120084358.5919-1-masahisa.kojima@linaro.org> 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 Current change boot order implementation does not call eficonfig_process_common() and call own menu functions for display_statusline, item_data_print and item_choice. Change boot order functionality should call eficonfig_process_common() to improve maintenanceability. This commit is a preparation to remove the change boot order specific implementation. The menu functions (display_statusline, item_data_print and item_choice) are added as argument of eficonfig_process_common(). The menu description string displayed at the bottom of the menu is also added as argument. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- No update since v3 Changes in v3: - modify "reverse" local variable type to bool Changes in v2: - add const qualifier to eficonfig_menu_desc, change it to pointer cmd/eficonfig.c | 71 +++++++++++++++++++++++++++++++++---------- cmd/eficonfig_sbkey.c | 18 +++++++++-- include/efi_config.h | 13 +++++++- 3 files changed, 82 insertions(+), 20 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index d830e4af53..24d6bdb6bf 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -22,6 +22,8 @@ #include static struct efi_simple_text_input_protocol *cin; +const char *eficonfig_menu_desc = + " Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"; #define EFICONFIG_DESCRIPTION_MAX 32 #define EFICONFIG_OPTIONAL_DATA_MAX 64 @@ -134,10 +136,10 @@ void eficonfig_print_msg(char *msg) * * @data: pointer to the data associated with each menu entry */ -static void eficonfig_print_entry(void *data) +void eficonfig_print_entry(void *data) { struct eficonfig_entry *entry = data; - int reverse = (entry->efi_menu->active == entry->num); + bool reverse = (entry->efi_menu->active == entry->num); /* TODO: support scroll or page for many entries */ @@ -161,7 +163,7 @@ static void eficonfig_print_entry(void *data) * * @m: pointer to the menu structure */ -static void eficonfig_display_statusline(struct menu *m) +void eficonfig_display_statusline(struct menu *m) { struct eficonfig_entry *entry; @@ -171,10 +173,11 @@ static void eficonfig_display_statusline(struct menu *m) printf(ANSI_CURSOR_POSITION "\n%s\n" ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION - " Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit" + "%s" ANSI_CLEAR_LINE_TO_END ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, 1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 1, - entry->efi_menu->count + 6, 1, entry->efi_menu->count + 7, 1); + entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc, + entry->efi_menu->count + 7, 1); } /** @@ -183,7 +186,7 @@ static void eficonfig_display_statusline(struct menu *m) * @data: pointer to the efimenu structure * Return: key string to identify the selected entry */ -static char *eficonfig_choice_entry(void *data) +char *eficonfig_choice_entry(void *data) { struct cli_ch_state s_cch, *cch = &s_cch; struct list_head *pos, *n; @@ -361,9 +364,17 @@ out: * * @efi_menu: pointer to the efimenu structure * @menu_header: pointer to the menu header string + * @menu_desc: pointer to the menu description + * @display_statusline: function pointer to draw statusline + * @item_data_print: function pointer to draw the menu item + * @item_choice: function pointer to handle the key press * Return: status code */ -efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header) +efi_status_t eficonfig_process_common(struct efimenu *efi_menu, + char *menu_header, const char *menu_desc, + void (*display_statusline)(struct menu *), + void (*item_data_print)(void *), + char *(*item_choice)(void *)) { struct menu *menu; void *choice = NULL; @@ -382,10 +393,11 @@ efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_heade if (!efi_menu->menu_header) return EFI_OUT_OF_RESOURCES; } + if (menu_desc) + efi_menu->menu_desc = menu_desc; - menu = menu_create(NULL, 0, 1, eficonfig_display_statusline, - eficonfig_print_entry, eficonfig_choice_entry, - efi_menu); + menu = menu_create(NULL, 0, 1, display_statusline, item_data_print, + item_choice, efi_menu); if (!menu) return EFI_INVALID_PARAMETER; @@ -644,7 +656,12 @@ static efi_status_t eficonfig_select_volume(struct eficonfig_select_file_info *f if (ret != EFI_SUCCESS) goto out; - ret = eficonfig_process_common(efi_menu, " ** Select Volume **"); + ret = eficonfig_process_common(efi_menu, " ** Select Volume **", + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); + out: efi_free_pool(volume_handles); list_for_each_safe(pos, n, &efi_menu->list) { @@ -819,7 +836,11 @@ static efi_status_t eficonfig_show_file_selection(struct eficonfig_select_file_i if (ret != EFI_SUCCESS) goto err; - ret = eficonfig_process_common(efi_menu, " ** Select File **"); + ret = eficonfig_process_common(efi_menu, " ** Select File **", + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); err: EFI_CALL(f->close(f)); eficonfig_destroy(efi_menu); @@ -980,7 +1001,11 @@ efi_status_t eficonfig_process_show_file_option(void *data) if (!efi_menu) return EFI_OUT_OF_RESOURCES; - ret = eficonfig_process_common(efi_menu, " ** Update File **"); + ret = eficonfig_process_common(efi_menu, " ** Update File **", + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); if (ret != EFI_SUCCESS) /* User selects "Clear" or "Quit" */ ret = EFI_NOT_READY; @@ -1326,7 +1351,12 @@ static efi_status_t eficonfig_show_boot_option(struct eficonfig_boot_option *bo, if (ret != EFI_SUCCESS) goto out; - ret = eficonfig_process_common(efi_menu, header_str); + ret = eficonfig_process_common(efi_menu, header_str, + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); + out: eficonfig_destroy(efi_menu); @@ -1745,7 +1775,11 @@ static efi_status_t eficonfig_show_boot_selection(unsigned int *selected) if (ret != EFI_SUCCESS) goto out; - ret = eficonfig_process_common(efi_menu, " ** Select Boot Option **"); + ret = eficonfig_process_common(efi_menu, " ** Select Boot Option **", + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); out: list_for_each_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); @@ -2567,7 +2601,12 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a if (!efi_menu) return CMD_RET_FAILURE; - ret = eficonfig_process_common(efi_menu, " ** UEFI Maintenance Menu **"); + ret = eficonfig_process_common(efi_menu, + " ** UEFI Maintenance Menu **", + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); eficonfig_destroy(efi_menu); if (ret == EFI_ABORTED) diff --git a/cmd/eficonfig_sbkey.c b/cmd/eficonfig_sbkey.c index ed39aab081..caca27495e 100644 --- a/cmd/eficonfig_sbkey.c +++ b/cmd/eficonfig_sbkey.c @@ -410,7 +410,10 @@ static efi_status_t enumerate_and_show_signature_database(void *varname) goto out; snprintf(buf, sizeof(buf), " ** Show Signature Database (%ls) **", (u16 *)varname); - ret = eficonfig_process_common(efi_menu, buf); + ret = eficonfig_process_common(efi_menu, buf, eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); out: list_for_each_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); @@ -472,7 +475,11 @@ static efi_status_t eficonfig_process_set_secure_boot_key(void *data) efi_menu = eficonfig_create_fixed_menu(key_config_menu_items, ARRAY_SIZE(key_config_menu_items)); - ret = eficonfig_process_common(efi_menu, header_str); + ret = eficonfig_process_common(efi_menu, header_str, + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); eficonfig_destroy(efi_menu); if (ret == EFI_ABORTED) @@ -518,7 +525,12 @@ efi_status_t eficonfig_process_secure_boot_config(void *data) break; } - ret = eficonfig_process_common(efi_menu, header_str); + ret = eficonfig_process_common(efi_menu, header_str, + eficonfig_menu_desc, + eficonfig_display_statusline, + eficonfig_print_entry, + eficonfig_choice_entry); + eficonfig_destroy(efi_menu); if (ret == EFI_ABORTED) diff --git a/include/efi_config.h b/include/efi_config.h index fd69926343..cec5715f84 100644 --- a/include/efi_config.h +++ b/include/efi_config.h @@ -9,12 +9,14 @@ #define _EFI_CONFIG_H #include +#include #define EFICONFIG_ENTRY_NUM_MAX 99 #define EFICONFIG_VOLUME_PATH_MAX 512 #define EFICONFIG_FILE_PATH_MAX 512 #define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16)) +extern const char *eficonfig_menu_desc; typedef efi_status_t (*eficonfig_entry_func)(void *data); /** @@ -45,6 +47,7 @@ struct eficonfig_entry { * @active: active menu entry index * @count: total count of menu entry * @menu_header: menu header string + * @menu_desc: menu description string * @list: menu entry list structure */ struct efimenu { @@ -52,6 +55,7 @@ struct efimenu { int active; int count; char *menu_header; + const char *menu_desc; struct list_head list; }; @@ -86,9 +90,16 @@ struct eficonfig_select_file_info { }; void eficonfig_print_msg(char *msg); +void eficonfig_print_entry(void *data); +void eficonfig_display_statusline(struct menu *m); +char *eficonfig_choice_entry(void *data); void eficonfig_destroy(struct efimenu *efi_menu); efi_status_t eficonfig_process_quit(void *data); -efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_header); +efi_status_t eficonfig_process_common(struct efimenu *efi_menu, + char *menu_header, const char *menu_desc, + void (*display_statusline)(struct menu *), + void (*item_data_print)(void *), + char *(*item_choice)(void *)); efi_status_t eficonfig_process_select_file(void *data); efi_status_t eficonfig_get_unused_bootoption(u16 *buf, efi_uintn_t buf_size, u32 *index); From patchwork Fri Jan 20 08:43:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 644637 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp663504pvb; Fri, 20 Jan 2023 00:42:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXtoJXTLZ8244UrMhpuKChkFFFMq6ZoPZ95R9strqY5kv6rBU9QRoTrboOFhm1w+HXcbG86W X-Received: by 2002:a05:6871:4684:b0:150:c4e4:447e with SMTP id ni4-20020a056871468400b00150c4e4447emr7480345oab.12.1674204150579; Fri, 20 Jan 2023 00:42:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674204150; cv=none; d=google.com; s=arc-20160816; b=VMGgol1rsc4BLbTvlaghJ0i6axF3bF4qT6MDNLcxoEJRNzAO2P/CVxzU+RG0Op2oxD QSHMBjJltYtKZPt8IpAtPf1i8VmF5Rk6yDClEv2nSXHQhZYoKL0PSxX+gpPfPMf3lNqx kkqPaW8OOzqIePN+uE2/ybhCrO7QbUcxe6Rj9yEweK8YZQKsvco/rnGGpkcJY4K3ZtMm gY3Iz9tWY7C6H8swmXYP8KjDOgQ1BsvWdPAS4AOfJz1+0QgvFgJvpxyBP9ztSyJ11h2D VextqopOzad9olsPDT0lF9y5syMMkK/p26zCYBiV4Xbl1Ic2MjfcjjZ6FasCG5wcKLgu F3BQ== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1RqX0a8N8awDlTs42/q3pWd8wnVDw/Om3k7s9tMxUuQ=; b=RRwiv6cWCmSqnLDUzcgOWNtEhB0QVjx5GcjxCuJLixGyoLcicL6Lq48tjYfyHnHobV f5D5gW3d7TE9mztOHFea1bmOWFvFyju94SsBYc9/8dUcPn44tCoZJuyh03PpA89djm2W /67extUy2vqyalpjQQf3bKWi+ntJ2BbeTZHyZxxLoP8IshQM/tVFomNAC9zSr/sRGGcM ZyC35CY3MZ2tiO3Qt0D8HnnmFMc5jlqjksRxpa/BTlp+K3OLFFyfwD3M8b4bgEs6IDkU l55TwV64eMaqLaN19M8j6AwDQ6cpk1oaFSle7bAQbJhh7+is+RO4Ox1VzSSLXU1LFoQt KRLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pWNMF8CX; 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 v12-20020a056870b50c00b0014376a90153si38565163oap.70.2023.01.20.00.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:42:30 -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=pWNMF8CX; 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 CE6C9856C5; Fri, 20 Jan 2023 09:42:20 +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="pWNMF8CX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 18ABA856A1; Fri, 20 Jan 2023 09:41:50 +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-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 16E6A853D1 for ; Fri, 20 Jan 2023 09:41:43 +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=masahisa.kojima@linaro.org Received: by mail-pj1-x102a.google.com with SMTP id y3-20020a17090a390300b00229add7bb36so4224548pjb.4 for ; Fri, 20 Jan 2023 00:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=1RqX0a8N8awDlTs42/q3pWd8wnVDw/Om3k7s9tMxUuQ=; b=pWNMF8CXVHJnouY+yQBR2KsFviGbdPkNRa81si0GyV7xb2DpqocbKDaVwJFh1cZeGd cEDEam5YXj2OEj/NLMUZ8q9UjvRmlqUpoL3EDv6A5gZf8e9bLBOuNSMZ/vR1ckdlpfQH VueA9Gs9OK2bNpN4yf1bDYPcqO0TjbYuUP8fV7SNwfPpxXq8XcuKDyJgPWPMqB4OcAqS eMbzXr2xaq4Ewu6hvwStFBuLPGrPY33CYEFzfXL3C4VZQVAUUrPrj/YXCA/k3zq0gY8S beeSmWXaDJsJVfzfOvuRfVNRH71LRnqVcjaRHayPEiBvdwnxM26BkAxqlf6TeCC/WzOx WdTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1RqX0a8N8awDlTs42/q3pWd8wnVDw/Om3k7s9tMxUuQ=; b=w23e2GO7/c4txUjhgf9shzhz77sGo3MfeKA71WVp6VhZj2nNuYVb4I7CBp2+/C+20i 5Hvw3ANqTPOkN+miXr15S3trIP94LN1F4OpxcEjJ5P6/8hy5pL/2JYyNmapxsyZN1BR2 xrWeQt4Llui5PgtyKSi8VTC6OrkbPg0GrKJHBaPCXSTEaNT6ZCfwD3kGWWws214Y6SQa rrN0t+yUxqtldpq9ZCFazU6NWQTTC3XSfaCmC540JY2pWpTKUSyUQc1aPQUkUEwZOYr8 QS9oUDgde7gQ3giZ6qcX3HF5sUuOIuKU0XXD+pelyYkLHPIqa19ctEV7vvUEdNOBcnla UPmQ== X-Gm-Message-State: AFqh2krTiG+a1jw1jW++s73vSdLxnyTNR/VF4LHfAiUXdkeMBMc0O+vR ymd/GxxPqzuw2hqgc29JHliJozojkzVNCSYO X-Received: by 2002:a05:6a20:4fa9:b0:b8:3264:122b with SMTP id gh41-20020a056a204fa900b000b83264122bmr15008270pzb.15.1674204101208; Fri, 20 Jan 2023 00:41:41 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id m12-20020a634c4c000000b0047063eb4098sm21652195pgl.37.2023.01.20.00.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:41:40 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v4 2/4] eficonfig: refactor change boot order implementation Date: Fri, 20 Jan 2023 17:43:56 +0900 Message-Id: <20230120084358.5919-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230120084358.5919-1-masahisa.kojima@linaro.org> References: <20230120084358.5919-1-masahisa.kojima@linaro.org> 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 This commit removes the change boot order specific menu implementation. The change boot order implementation calls eficonfig_process_common() same as other menus. The change boot order menu requires own item_data_print and item_choice implementation, but display_statusline function can be a same function as other menus. Signed-off-by: Masahisa Kojima Acked-by: Ilias Apalodimas Reviewed-by: Ilias Apalodimas --- No update since v3 Changes in v3: - modify "reverse" local variable type to bool Changes in v2: - add comment when the user key press is not valid - add const qualifier to eficonfig_change_boot_order_desc cmd/eficonfig.c | 246 +++++++++++++++++++++++++++++------------------- 1 file changed, 151 insertions(+), 95 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 24d6bdb6bf..01bd1b05bc 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -25,6 +25,11 @@ static struct efi_simple_text_input_protocol *cin; const char *eficonfig_menu_desc = " Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"; +static const char *eficonfig_change_boot_order_desc = + " Press UP/DOWN to move, +/- to change orde\n" + " Press SPACE to activate or deactivate the entry\n" + " Select [Save] to complete, ESC/CTRL+C to quit"; + #define EFICONFIG_DESCRIPTION_MAX 32 #define EFICONFIG_OPTIONAL_DATA_MAX 64 @@ -106,6 +111,17 @@ struct eficonfig_boot_order_data { bool active; }; +/** + * struct eficonfig_save_boot_order_data - structure to be used to change boot order + * + * @efi_menu: pointer to efimenu structure + * @selected: flag to indicate user selects "Save" entry + */ +struct eficonfig_save_boot_order_data { + struct efimenu *efi_menu; + bool selected; +}; + /** * eficonfig_print_msg() - print message * @@ -174,10 +190,9 @@ void eficonfig_display_statusline(struct menu *m) "\n%s\n" ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION "%s" - ANSI_CLEAR_LINE_TO_END ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, + ANSI_CLEAR_LINE_TO_END, 1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 1, - entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc, - entry->efi_menu->count + 7, 1); + entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc); } /** @@ -1844,63 +1859,44 @@ out: } /** - * eficonfig_display_change_boot_order() - display the BootOrder list + * eficonfig_print_change_boot_order_entry() - print the boot option entry * - * @efi_menu: pointer to the efimenu structure - * Return: status code + * @data: pointer to the data associated with each menu entry */ -static void eficonfig_display_change_boot_order(struct efimenu *efi_menu) +static void eficonfig_print_change_boot_order_entry(void *data) { - bool reverse; - struct list_head *pos, *n; - struct eficonfig_entry *entry; - - printf(ANSI_CLEAR_CONSOLE ANSI_CURSOR_POSITION - "\n ** Change Boot Order **\n" - ANSI_CURSOR_POSITION - " Press UP/DOWN to move, +/- to change order" - ANSI_CURSOR_POSITION - " Press SPACE to activate or deactivate the entry" - ANSI_CURSOR_POSITION - " Select [Save] to complete, ESC/CTRL+C to quit" - ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, - 1, 1, efi_menu->count + 5, 1, efi_menu->count + 6, 1, - efi_menu->count + 7, 1, efi_menu->count + 8, 1); - - /* draw boot option list */ - list_for_each_safe(pos, n, &efi_menu->list) { - entry = list_entry(pos, struct eficonfig_entry, list); - reverse = (entry->num == efi_menu->active); + struct eficonfig_entry *entry = data; + bool reverse = (entry->efi_menu->active == entry->num); - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7); + printf(ANSI_CURSOR_POSITION, entry->num + 4, 7); - if (reverse) - puts(ANSI_COLOR_REVERSE); + if (reverse) + puts(ANSI_COLOR_REVERSE); - if (entry->num < efi_menu->count - 2) { - if (((struct eficonfig_boot_order_data *)entry->data)->active) - printf("[*] "); - else - printf("[ ] "); - } + if (entry->num < entry->efi_menu->count - 2) { + if (((struct eficonfig_boot_order_data *)entry->data)->active) + printf("[*] "); + else + printf("[ ] "); + } - printf("%s", entry->title); + printf("%s", entry->title); - if (reverse) - puts(ANSI_COLOR_RESET); - } + if (reverse) + puts(ANSI_COLOR_RESET); } /** - * eficonfig_choice_change_boot_order() - handle the BootOrder update + * eficonfig_choice_change_boot_order() - user key input handler * - * @efi_menu: pointer to the efimenu structure - * Return: status code + * @data: pointer to the menu entry + * Return: key string to identify the selected entry */ -static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) +char *eficonfig_choice_change_boot_order(void *data) { struct cli_ch_state s_cch, *cch = &s_cch; struct list_head *pos, *n; + struct efimenu *efi_menu = data; enum bootmenu_key key = BKEY_NONE; struct eficonfig_entry *entry, *tmp; @@ -1926,7 +1922,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) case BKEY_UP: if (efi_menu->active > 0) --efi_menu->active; - return EFI_NOT_READY; + return NULL; case BKEY_MINUS: if (efi_menu->active < efi_menu->count - 3) { list_for_each_safe(pos, n, &efi_menu->list) { @@ -1942,20 +1938,29 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) ++efi_menu->active; } - return EFI_NOT_READY; + return NULL; case BKEY_DOWN: if (efi_menu->active < efi_menu->count - 1) ++efi_menu->active; - return EFI_NOT_READY; + return NULL; case BKEY_SELECT: /* "Save" */ - if (efi_menu->active == efi_menu->count - 2) - return EFI_SUCCESS; - + if (efi_menu->active == efi_menu->count - 2) { + list_for_each_prev_safe(pos, n, &efi_menu->list) { + entry = list_entry(pos, struct eficonfig_entry, list); + if (entry->num == efi_menu->active) + break; + } + return entry->key; + } /* "Quit" */ - if (efi_menu->active == efi_menu->count - 1) - return EFI_ABORTED; - + if (efi_menu->active == efi_menu->count - 1) { + entry = list_last_entry(&efi_menu->list, + struct eficonfig_entry, + list); + return entry->key; + } + /* Pressed key is not valid, wait next key press */ break; case BKEY_SPACE: if (efi_menu->active < efi_menu->count - 2) { @@ -1965,20 +1970,84 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) struct eficonfig_boot_order_data *data = entry->data; data->active = !data->active; - return EFI_NOT_READY; + return NULL; } } } + /* Pressed key is not valid, wait next key press */ break; case BKEY_QUIT: - return EFI_ABORTED; + entry = list_last_entry(&efi_menu->list, + struct eficonfig_entry, list); + return entry->key; default: - /* Pressed key is not valid, no need to regenerate the menu */ + /* Pressed key is not valid, wait next key press */ break; } } } +/** + * eficonfig_process_save_boot_order() - callback function for "Save" entry + * + * @data: pointer to the data + * Return: status code + */ +static efi_status_t eficonfig_process_save_boot_order(void *data) +{ + u32 count = 0; + efi_status_t ret; + efi_uintn_t size; + struct list_head *pos, *n; + u16 *new_bootorder; + struct efimenu *efi_menu; + struct eficonfig_entry *entry; + struct eficonfig_save_boot_order_data *save_data = data; + + efi_menu = save_data->efi_menu; + + /* + * The change boot order menu always has "Save" and "Quit" entries. + * !(efi_menu->count - 2) means there is no user defined boot option. + */ + if (!(efi_menu->count - 2)) + return EFI_SUCCESS; + + new_bootorder = calloc(1, (efi_menu->count - 2) * sizeof(u16)); + if (!new_bootorder) { + ret = EFI_OUT_OF_RESOURCES; + goto out; + } + + /* create new BootOrder */ + count = 0; + list_for_each_safe(pos, n, &efi_menu->list) { + struct eficonfig_boot_order_data *data; + + entry = list_entry(pos, struct eficonfig_entry, list); + /* exit the loop when iteration reaches "Save" */ + if (!strncmp(entry->title, "Save", strlen("Save"))) + break; + + data = entry->data; + if (data->active) + new_bootorder[count++] = data->boot_index; + } + + size = count * sizeof(u16); + ret = efi_set_variable_int(u"BootOrder", &efi_global_variable_guid, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + size, new_bootorder, false); + + save_data->selected = true; +out: + free(new_bootorder); + + return ret; +} + /** * eficonfig_add_change_boot_order_entry() - add boot order entry * @@ -2054,6 +2123,7 @@ static efi_status_t eficonfig_create_change_boot_order_entry(struct efimenu *efi efi_status_t ret; u16 *var_name16 = NULL; efi_uintn_t size, buf_size; + struct eficonfig_save_boot_order_data *save_data; /* list the load option in the order of BootOrder variable */ for (i = 0; i < num; i++) { @@ -2104,7 +2174,17 @@ static efi_status_t eficonfig_create_change_boot_order_entry(struct efimenu *efi goto out; } - ret = eficonfig_append_menu_entry(efi_menu, title, NULL, NULL); + save_data = malloc(sizeof(struct eficonfig_save_boot_order_data)); + if (!save_data) { + ret = EFI_OUT_OF_RESOURCES; + goto out; + } + save_data->efi_menu = efi_menu; + save_data->selected = false; + + ret = eficonfig_append_menu_entry(efi_menu, title, + eficonfig_process_save_boot_order, + save_data); if (ret != EFI_SUCCESS) goto out; @@ -2127,7 +2207,6 @@ out: */ static efi_status_t eficonfig_process_change_boot_order(void *data) { - u32 count; u16 *bootorder; efi_status_t ret; efi_uintn_t num, size; @@ -2148,47 +2227,24 @@ static efi_status_t eficonfig_process_change_boot_order(void *data) goto out; while (1) { - eficonfig_display_change_boot_order(efi_menu); - - ret = eficonfig_choice_change_boot_order(efi_menu); - if (ret == EFI_SUCCESS) { - u16 *new_bootorder; - - new_bootorder = calloc(1, (efi_menu->count - 2) * sizeof(u16)); - if (!new_bootorder) { - ret = EFI_OUT_OF_RESOURCES; - goto out; - } - - /* create new BootOrder */ - count = 0; - list_for_each_safe(pos, n, &efi_menu->list) { - struct eficonfig_boot_order_data *data; - + ret = eficonfig_process_common(efi_menu, + " ** Change Boot Order **", + eficonfig_change_boot_order_desc, + eficonfig_display_statusline, + eficonfig_print_change_boot_order_entry, + eficonfig_choice_change_boot_order); + /* exit from the menu if user selects the "Save" entry. */ + if (ret == EFI_SUCCESS && efi_menu->active == (efi_menu->count - 2)) { + list_for_each_prev_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); - /* exit the loop when iteration reaches "Save" */ - if (!strncmp(entry->title, "Save", strlen("Save"))) + if (entry->num == efi_menu->active) break; - - data = entry->data; - if (data->active) - new_bootorder[count++] = data->boot_index; } - - size = count * sizeof(u16); - ret = efi_set_variable_int(u"BootOrder", &efi_global_variable_guid, - EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, - size, new_bootorder, false); - - free(new_bootorder); - goto out; - } else if (ret == EFI_NOT_READY) { - continue; - } else { - goto out; + if (((struct eficonfig_save_boot_order_data *)entry->data)->selected) + break; } + if (ret != EFI_SUCCESS) + break; } out: free(bootorder); From patchwork Fri Jan 20 08:43:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 644638 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp663571pvb; Fri, 20 Jan 2023 00:42:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXvV9VV3S3ezOLn0CV6XC+r6OrcD5flSVHMvOvBg26aL2LXLCM/bhSQXDurifOxfMXrB0Wj5 X-Received: by 2002:a05:6870:7909:b0:142:9258:b78d with SMTP id hg9-20020a056870790900b001429258b78dmr7076288oab.12.1674204163514; Fri, 20 Jan 2023 00:42:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674204163; cv=none; d=google.com; s=arc-20160816; b=ZWSMyF1QMHOJAWri9Tf33EVK+7bH9jOPSGvgK8J23HHv5PhJtgwRBEd/DvoPiiys04 E/ewroZ4ZixiEUgzoUg5l+6jNuWNIUhZLQRsQ/cT3B6MX2D6lptXzBhapnGY5WVxs81o 4LYUQXieImVoGkPI37XoN9nkq/gs3olv9RTBdYlmsBUgN1GWveZUMhHC8wf+Sm1rcdve gKFfxuST/IMlPsW5vcpSoTPYeDyEuvLl8BlHud9nedk+963Ojl4KUXkuY5ATbsQmwtuu jvQKQOSIBB6NNRIND/24VmLfi5MTuVA3jiVFkPQAh5Vv6MrmEfqYkIQRjncADTa8kh97 YRZA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=l9hoDhLbABLTWsvu3D6NPkwUy9Kh9cYkUj00ZgWRqis=; b=FtJm8sN1gxUWLJJSll0JSfNFf5COHqxgtGlizpZeiPZAVwg7h5inOW1qUQD9l2VcnA U7nst0zwGbmTcNp4KvoLw5oth+jrd/G5mxIPWNKErHavZXk1AnzjjjwpykveGbYQDQT/ yLeduIcw3G6UU2/iVKO5qMS4zQSgGVDHjTRwrmhU4pJ36ODa1sP8E+Xr1fXpt4VcT0o9 y+FSnJkM9m0jdfk/a37jM2mDRcZS/xgyS+J/IuRIagrY8XsDODORFdSKhJvBbbCBbH8o 7Nroap2Ze3oEcSMd3vUCMw/dRs1MBmpKDW94Nw6zghocBbghu5OgfYc8yMNuU7bwIu2+ qCeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hwnBgJ3g; 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 g1-20020a0568080dc100b00359fd80c73asi33967814oic.60.2023.01.20.00.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:42:43 -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=hwnBgJ3g; 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 210C0856D6; Fri, 20 Jan 2023 09:42: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=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="hwnBgJ3g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CAF2E853D1; Fri, 20 Jan 2023 09:41:51 +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-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) (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 2D0A08569D for ; Fri, 20 Jan 2023 09:41:44 +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=masahisa.kojima@linaro.org Received: by mail-pj1-x1036.google.com with SMTP id x2-20020a17090a46c200b002295ca9855aso8402221pjg.2 for ; Fri, 20 Jan 2023 00:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=l9hoDhLbABLTWsvu3D6NPkwUy9Kh9cYkUj00ZgWRqis=; b=hwnBgJ3gAjkPi4HP4JvdLjirjTKqk/dsMnZzLlzPEezJy6hnBRLGQ0gvsEPFWZDSDG K75nXqUrWdlEvNmHH9/GGemeizssOInnVgZnagf4cGMYJsJRzz34tnBuHHKh7bdFA1/3 DDbQn1vb1oqi4cw2hlHT9WZIBlW/p1B8s0q0jt0VXXxt895+wqYRCRVjJtYoMiRF3GzJ +87AhXljuQllDQrSQ1AHBG0j5ZFmxWf79Dx6m/VBM8l/JCOBeAqJtWdNEX15OJUmTiqo RtLOoTj+0eKgQsSk6x3LBjyjrjkAekuL3F8GEsQSaUTD5mylWyb94XkW3ez9CkyfQvwW cEww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l9hoDhLbABLTWsvu3D6NPkwUy9Kh9cYkUj00ZgWRqis=; b=lmj9UDWLxGHfU9WQm82P8HKbDcVW5JvaaQzaNnPvjPm+S/TmvRsHrQtvyTK1tJfvWU /NG7uGHkbiJxVeXCt3dLuGU5E5kMdTS9YiCyEPN6CcN3Uxx8WotoPqPeNyNmzzFAYcQb jd5Yby46nLE5Rz8FQypAFyoTMHHHxt3q8EpcUS1A4f1Dj9l6avnG/3pYTuZIhD0zldeR Rd4gQf+uy1PsaQNIXXLCwDTcsT6u2wf66MsaG8LmW6HLqaUsUzq7MD1EGCk6f2yZdQ/4 IIoB360AxmABVhyJnk87oEXbWAukYWxL5Vlyym+cmqyOdmbmhZtBZVwWzLkeBIabelgc 8xVw== X-Gm-Message-State: AFqh2kqE6H8pNqmu+FqB8iu1MkajSmkXxa5pAso0yqqs5Ja2nrRFUTs0 QOqqvlmruuJQdookGzHCSPbt3tbXP+Xbvrrx X-Received: by 2002:a05:6a20:d68b:b0:b8:5134:a36b with SMTP id it11-20020a056a20d68b00b000b85134a36bmr15348548pzb.21.1674204103359; Fri, 20 Jan 2023 00:41:43 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id m12-20020a634c4c000000b0047063eb4098sm21652195pgl.37.2023.01.20.00.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:41:42 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v4 3/4] eficonfig: add vertical scroll support Date: Fri, 20 Jan 2023 17:43:57 +0900 Message-Id: <20230120084358.5919-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230120084358.5919-1-masahisa.kojima@linaro.org> References: <20230120084358.5919-1-masahisa.kojima@linaro.org> 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 The current eficonfig menu does not support vertical scroll, so it can not display the menu entries greater than the console row size. This commit add the vertial scroll support. The console size is retrieved by SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode() service, then calculates the row size for menu entry by subtracting menu header and description row size from the console row size. "start" and "end" are added in the efimenu structure. "start" keeps the menu entry index at the top, "end" keeps the bottom menu entry index. item_data_print() menu function only draws the menu entry between "start" and "end". Signed-off-by: Masahisa Kojima --- No update since v3 Changes in v3: - modify "reverse" local variable type to bool Changes in v2: - add comment when the user key press is not valid - add const qualifier to eficonfig_change_boot_order_desc cmd/eficonfig.c | 79 ++++++++++++++++++++++++++++++++++++-------- include/efi_config.h | 4 +++ include/efi_loader.h | 1 + 3 files changed, 70 insertions(+), 14 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 01bd1b05bc..5692b332c7 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -30,8 +30,13 @@ static const char *eficonfig_change_boot_order_desc = " Press SPACE to activate or deactivate the entry\n" " Select [Save] to complete, ESC/CTRL+C to quit"; +static struct efi_simple_text_output_protocol *cout; +static int avail_row; + #define EFICONFIG_DESCRIPTION_MAX 32 #define EFICONFIG_OPTIONAL_DATA_MAX 64 +#define EFICONFIG_MENU_HEADER_ROW_NUM 3 +#define EFICONFIG_MENU_DESC_ROW_NUM 5 /** * struct eficonfig_filepath_info - structure to be used to store file path @@ -157,18 +162,16 @@ void eficonfig_print_entry(void *data) struct eficonfig_entry *entry = data; bool reverse = (entry->efi_menu->active == entry->num); - /* TODO: support scroll or page for many entries */ + if (entry->efi_menu->start > entry->num || entry->efi_menu->end < entry->num) + return; - /* - * Move cursor to line where the entry will be drawn (entry->num) - * First 3 lines(menu header) + 1 empty line - */ - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7); + printf(ANSI_CURSOR_POSITION, (entry->num - entry->efi_menu->start) + + EFICONFIG_MENU_HEADER_ROW_NUM + 1, 7); if (reverse) puts(ANSI_COLOR_REVERSE); - printf("%s", entry->title); + printf(ANSI_CLEAR_LINE "%s", entry->title); if (reverse) puts(ANSI_COLOR_RESET); @@ -191,8 +194,8 @@ void eficonfig_display_statusline(struct menu *m) ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION "%s" ANSI_CLEAR_LINE_TO_END, - 1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 1, - entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc); + 1, 1, entry->efi_menu->menu_header, avail_row + 4, 1, + avail_row + 5, 1, entry->efi_menu->menu_desc); } /** @@ -216,13 +219,23 @@ char *eficonfig_choice_entry(void *data) switch (key) { case BKEY_UP: - if (efi_menu->active > 0) + if (efi_menu->active > 0) { --efi_menu->active; + if (efi_menu->start > efi_menu->active) { + efi_menu->start--; + efi_menu->end--; + } + } /* no menu key selected, regenerate menu */ return NULL; case BKEY_DOWN: - if (efi_menu->active < efi_menu->count - 1) + if (efi_menu->active < efi_menu->count - 1) { ++efi_menu->active; + if (efi_menu->end < efi_menu->active) { + efi_menu->start++; + efi_menu->end++; + } + } /* no menu key selected, regenerate menu */ return NULL; case BKEY_SELECT: @@ -402,6 +415,8 @@ efi_status_t eficonfig_process_common(struct efimenu *efi_menu, efi_menu->delay = -1; efi_menu->active = 0; + efi_menu->start = 0; + efi_menu->end = avail_row - 1; if (menu_header) { efi_menu->menu_header = strdup(menu_header); @@ -1868,7 +1883,11 @@ static void eficonfig_print_change_boot_order_entry(void *data) struct eficonfig_entry *entry = data; bool reverse = (entry->efi_menu->active == entry->num); - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7); + if (entry->efi_menu->start > entry->num || entry->efi_menu->end < entry->num) + return; + + printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, + (entry->num - entry->efi_menu->start) + EFICONFIG_MENU_HEADER_ROW_NUM + 1, 7); if (reverse) puts(ANSI_COLOR_REVERSE); @@ -1920,8 +1939,13 @@ char *eficonfig_choice_change_boot_order(void *data) } fallthrough; case BKEY_UP: - if (efi_menu->active > 0) + if (efi_menu->active > 0) { --efi_menu->active; + if (efi_menu->start > efi_menu->active) { + efi_menu->start--; + efi_menu->end--; + } + } return NULL; case BKEY_MINUS: if (efi_menu->active < efi_menu->count - 3) { @@ -1937,11 +1961,20 @@ char *eficonfig_choice_change_boot_order(void *data) list_add(&entry->list, &tmp->list); ++efi_menu->active; + if (efi_menu->end < efi_menu->active) { + efi_menu->start++; + efi_menu->end++; + } } return NULL; case BKEY_DOWN: - if (efi_menu->active < efi_menu->count - 1) + if (efi_menu->active < efi_menu->count - 1) { ++efi_menu->active; + if (efi_menu->end < efi_menu->active) { + efi_menu->start++; + efi_menu->end++; + } + } return NULL; case BKEY_SELECT: /* "Save" */ @@ -2590,6 +2623,7 @@ static efi_status_t eficonfig_init(void) efi_status_t ret = EFI_SUCCESS; static bool init; struct efi_handler *handler; + unsigned long columns, rows; if (!init) { ret = efi_search_protocol(efi_root, &efi_guid_text_input_protocol, &handler); @@ -2600,6 +2634,23 @@ static efi_status_t eficonfig_init(void) EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (ret != EFI_SUCCESS) return ret; + ret = efi_search_protocol(efi_root, &efi_guid_text_output_protocol, &handler); + if (ret != EFI_SUCCESS) + return ret; + + ret = efi_protocol_open(handler, (void **)&cout, efi_root, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS) + return ret; + + cout->query_mode(cout, cout->mode->mode, &columns, &rows); + avail_row = rows - (EFICONFIG_MENU_HEADER_ROW_NUM + + EFICONFIG_MENU_DESC_ROW_NUM); + if (avail_row <= 0) { + eficonfig_print_msg("Console size is too small!"); + return EFI_INVALID_PARAMETER; + } + /* TODO: Should we check the minimum column size? */ } init = true; diff --git a/include/efi_config.h b/include/efi_config.h index cec5715f84..6a104e4b1d 100644 --- a/include/efi_config.h +++ b/include/efi_config.h @@ -49,6 +49,8 @@ struct eficonfig_entry { * @menu_header: menu header string * @menu_desc: menu description string * @list: menu entry list structure + * @start: top menu index to draw + * @end: bottom menu index to draw */ struct efimenu { int delay; @@ -57,6 +59,8 @@ struct efimenu { char *menu_header; const char *menu_desc; struct list_head list; + int start; + int end; }; /** diff --git a/include/efi_loader.h b/include/efi_loader.h index f9e427f090..4560b0d04c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -328,6 +328,7 @@ extern const efi_guid_t efi_esrt_guid; extern const efi_guid_t smbios_guid; /*GUID of console */ extern const efi_guid_t efi_guid_text_input_protocol; +extern const efi_guid_t efi_guid_text_output_protocol; extern char __efi_runtime_start[], __efi_runtime_stop[]; extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[]; From patchwork Fri Jan 20 08:43:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 644639 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp663616pvb; Fri, 20 Jan 2023 00:42:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXuD2zkT0D99C8XB6Cv1oN7cR2N0VxjKfhC1Lww1+TCd95GRzKGc03CIdH/wuukFpiUnqoMg X-Received: by 2002:a05:6871:450d:b0:15f:f55:282f with SMTP id nj13-20020a056871450d00b0015f0f55282fmr7304030oab.45.1674204176071; Fri, 20 Jan 2023 00:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674204176; cv=none; d=google.com; s=arc-20160816; b=kdmrQbs1lq4vSZyRNFc67Ov4Fi74JaDIG1/bhTp5RJaTNZ43a0OrCCOGmC+BGXmAky kCBhlQ7SSzXzDaWPcs1+uAc3dV2FlmIj2QV80Mn0MDH4uGWaTH3BmQPswMFZO9A5wVbn ul4letm2MVk8Lfo/Ik89OaewN/o5RsVvTFP7KeAE0iIqwugDCntioLLabor2Fsnfm2PH vCvihU11vs/BIBUy490nZmQI5qmzRI1GtK/h1gXcy0Tjw2oXsaM0fdcdDX2DCi9qomsT xTv2SzhlnPaouK3Lf48hoLas4x8UlpeHMhCcis/lrXQd9rXGUrx+P8rWzGFiqVQa9afI bawg== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=WoksOS9i8lSGnSOKcVlpHoI78JNRa2NTYeEPYMCFagc=; b=FXb0Vr4N1VzeuqplOvdK3GyGYZ2YEnda+z6A0sB4Rip3bAxZvPyf/jjjuXkZoplK2i d37COoquwvyEGEcwK7K3aENFvV+dP456Luu+hLrlTQVWDLywmQJzjpnA7wG5/rncTLjW kyu9O2kkrrvmnuSo9SH5Sj+EIpp3Pc7jhgPkXQg79Sti0J0lMDg2TTw36gVD0l4AMxEh ZzihRuSLTyE9U6MA6WHqDtnCVa0I/sPk+y2LOC5ptI3zwPS49JkDry3PTtgPWLfZtdSG QJ9tVOg0Y4FsQsOrDCFiCnFd4LVfWLmiI+sqLSctiFW8oevZLXQRCpCdhWYdFXawp1h3 SR3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TDDYVG96; 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 e23-20020a056870239700b0015edf025626si20444072oap.153.2023.01.20.00.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:42:56 -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=TDDYVG96; 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 ECCC6856DE; Fri, 20 Jan 2023 09:42:33 +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="TDDYVG96"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 814A6853D1; Fri, 20 Jan 2023 09:41:53 +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-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (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 CDCF885668 for ; Fri, 20 Jan 2023 09:41:47 +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=masahisa.kojima@linaro.org Received: by mail-pl1-x62d.google.com with SMTP id b17so4745237pld.7 for ; Fri, 20 Jan 2023 00:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=WoksOS9i8lSGnSOKcVlpHoI78JNRa2NTYeEPYMCFagc=; b=TDDYVG96W3tsf47Lik96PyoSoiU6YuvfKlOxAJjnviDv03+O5os9vyurTqpTktN0T8 yWmxv1oKKVv6SZeNb4UTlj7hIdZ0/T35DJxpZ9Z0fxKVsWBOyZBiENJaqxW42Ttgt5Ba RUcAjL0e9DUPUys1/6jZ0uK0r4pUbZ1iaLPQCse3N/NwqH3jCpnKF9nMDxcbx67WDBAb lubaK0LTemLXy1c9jDthLQgm35S4kLK7olH/o3X2BAXnwU+ZmlRLKAb/iV2lPOxVMpBQ lJUS8KcavMmOWHOKOQwNrCQ1qDiaTxgTfZSPviPSFvwgOJA6bU/Z6A4NWD+WqwdCmUXd rvLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WoksOS9i8lSGnSOKcVlpHoI78JNRa2NTYeEPYMCFagc=; b=md3jtWtJqK4e5GI7H8k2Tt78/YjBf8VzwImQz/8420xZEz2Y1NA3smKitnHzqynR01 T5t+Fan6/P9NnQq14JoNJw4DgJtk6pA5W140reNFZEO5uOEDl2EytBEfS1i7wRtad2sP aDdkQhAXhOF+iXsuTeBCrjEmbZSmeKJb9RHrMj3RfHdl4xXRXeOSs37EtCXLpujvBqs8 HOZ0tN44rdRWF3c/YD8+DIxlo99SOmUlsd9mFpBrJRoAwZhEv3DxBdRsWQj1ZMSXq8QU Rx0K1cP9yT4rnu+qk2LSpvzwawX7kgRLTkUFbnYGYmaFzrSbGk4eBWmFwfWCRBoe9aL/ 3YoA== X-Gm-Message-State: AFqh2koisuryrGN3Q12FMQndQZpiwzOPiCMNORZwVHY+bUiHAZ4TA/de mthp6Zmp86ISj1Jqg2telfBm6yPpscR3Qbkm X-Received: by 2002:a05:6a21:9998:b0:b8:2e75:c973 with SMTP id ve24-20020a056a21999800b000b82e75c973mr21531592pzb.49.1674204105491; Fri, 20 Jan 2023 00:41:45 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id m12-20020a634c4c000000b0047063eb4098sm21652195pgl.37.2023.01.20.00.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 00:41:45 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v4 4/4] eficonfig: increase the number of menu entries Date: Fri, 20 Jan 2023 17:43:58 +0900 Message-Id: <20230120084358.5919-5-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230120084358.5919-1-masahisa.kojima@linaro.org> References: <20230120084358.5919-1-masahisa.kojima@linaro.org> 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 Current eficonfig has the maximum number of menu entries and it is 99. If there are more EFI load options and files in the system, eficonfig can not handle it. This commit increases this maximum number of menu entries to INT_MAX. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- Newly created in v4 include/efi_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/efi_config.h b/include/efi_config.h index 6a104e4b1d..e5edbb5e09 100644 --- a/include/efi_config.h +++ b/include/efi_config.h @@ -11,7 +11,7 @@ #include #include -#define EFICONFIG_ENTRY_NUM_MAX 99 +#define EFICONFIG_ENTRY_NUM_MAX INT_MAX #define EFICONFIG_VOLUME_PATH_MAX 512 #define EFICONFIG_FILE_PATH_MAX 512 #define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16))