From patchwork Tue Jan 24 06:56:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 646023 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp40355pvb; Mon, 23 Jan 2023 22:54:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvcxp9wvWxXaVU71/XUNm1dh9Nah4MsiqH4jVug1sDonJBGnIhS74yn703yRpPDVjSNStuA X-Received: by 2002:a9d:172:0:b0:684:a1e5:4f with SMTP id 105-20020a9d0172000000b00684a1e5004fmr13125020otu.18.1674543274940; Mon, 23 Jan 2023 22:54:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674543274; cv=none; d=google.com; s=arc-20160816; b=povc6LqzwX56VtdUbW+ZE4hhgndbuXtG4dY8ZRaRh8B1NH9vQtDXns/gn7HFHXJl2k JIWbxnIvkY3PfO15g159hp8wpITb/ucP8tXSv5sggfHmtd1CzVuxRrplBnfV62YCh4H1 e3A/n2H+x1uOEiaJyxvw/HcCeaOespt8007J6iN9db+EvFY3s/Q2OSd3sqWZbMqGmyRr GY3rH2IxK3YLnto4yjGSUY/sH6uweN3UteMO8MzOVE+SA0bg+zi09MWf+HsYUncHn0yX 7qyE8kEpjSURCvnh9t/JVblWQzzJTQb6xzZVi8MdgISREQ6pCwuNvhqDHe0rbcdw6mud mZvQ== 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=x+AEeICnIQPDn8k9grX8QL6C7P7/7fxMn/Ig2851HC4=; b=ec6EXvQIixa+MYdAB96E1eHpnXXGkNcvmO0k3LCBRVrhZqiBKHkLtNW6qVsbsCsGNG DlRzIgpA+CeoEWQ9+BKhbVeCTcknp6ynyLdCOmDxsG0CW+FnhYt5jduaAkN/K7ODK0NM FOGxW2oH/0IgSYHmVbJRrVT68QrJ1d9+k55HB6Rs15wE+Dnm1avuxwMtvxSr7qk5gLGo czbMBx3bAUAM48nxULmWkG/ur0f0BIb1c/n3O7ZRkyTdsL4HYjvc2hhqWBnHstW2whMM DDuI8M4QW6IfuRK2dwunhXpzKv5Q2L4pLfBASy683a7fDvy3weGFRTqADDAtCdKe9z8B hA7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H3aBDEcj; 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 a8-20020a9d74c8000000b00665c202901fsi1535742otl.93.2023.01.23.22.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:54:34 -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=H3aBDEcj; 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 09B24855FD; Tue, 24 Jan 2023 07:53: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="H3aBDEcj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35DA2855EB; Tue, 24 Jan 2023 07:53:48 +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-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (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 BD9BB85282 for ; Tue, 24 Jan 2023 07:53: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-pl1-x631.google.com with SMTP id jl3so13827243plb.8 for ; Mon, 23 Jan 2023 22:53: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=x+AEeICnIQPDn8k9grX8QL6C7P7/7fxMn/Ig2851HC4=; b=H3aBDEcjg7kHwPpjTb3NeWPxyIVQMSClW7s/QRZA560eV5AjWCFvfyTvoAqG2An9zV Mzyp+vr23stUSLb5nWoqS35K0bnZqace424yZcmGkTCpMZo1Vs+G1gOoA13F8LviEIvD M+diEQ6NVgrW0l8NDCYCAeMhTSqK4AzFcaSUKx/rtp5QoEsV/Zmyx0rpCF/FFxEvAD5E h83U6X0mGQ+mPE0elkQfIE3rLfFQAeXJx3c2AuOP2Oz8cFvSl9mjko567SW+wYTh0d2F q2gvLUSwWuVnBN9eAGqdVfA+l/x9M/OVV9wAmtpPMVO8mwc66KYGwZsBHdosqYlirMFu IL3w== 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=x+AEeICnIQPDn8k9grX8QL6C7P7/7fxMn/Ig2851HC4=; b=Cs28+fw6RxIZYrf5ybcyJBDhAL2/RqydtrWAcNfUMGYoIO6rnNG35s+H0ZGZaD8IOR iNaaEOxqqPqc3es88cY82HO43B/R4DziVEmPh/KLCRulg6dNk3702RroRa/GlaApb/KV YvzOA5+fHXsrYj1AB1wsZwSwkkeZNwUayssIn+xCcqFiLSukkODtbWP/sKLlLFg3WDAf AnQgruUF7LvmpcB8cp8KotfZiiXUzT3K06hxQYnndSWTIgxv0/IJqmkL8ecGVJa0hfyM TubY+T4HBjXYehem6uA5FfL3YsFcNCK9WI5HzrmqQlw4nMymieaYGOZ7qba67obX042x 6IDg== X-Gm-Message-State: AO0yUKWOFTmGetPCOCjHurW3UCxaL9Sw7spKRik0xRuUYZJ4I94XgCzR j0I6YWWfXZrlIlB4LBMqkRltFrJxyD66rWnS X-Received: by 2002:a17:90b:4a8e:b0:22b:f035:c09c with SMTP id lp14-20020a17090b4a8e00b0022bf035c09cmr961644pjb.4.1674543222873; Mon, 23 Jan 2023 22:53:42 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id q102-20020a17090a1b6f00b002293b1aa2b6sm1254873pjq.30.2023.01.23.22.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:53:42 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v5 1/4] eficonfig: refactor eficonfig_process_common function Date: Tue, 24 Jan 2023 15:56:13 +0900 Message-Id: <20230124065616.25559-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230124065616.25559-1-masahisa.kojima@linaro.org> References: <20230124065616.25559-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 Tue Jan 24 06:56:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 646026 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp40547pvb; Mon, 23 Jan 2023 22:55:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXuzR0YvzfvkXtwq6JcudOXAgCkvf0vMP7J8qugItYEp3WtTRlvSFXK5j3TVPyYk9kFKhLcD X-Received: by 2002:a05:6870:b6a3:b0:157:cc21:2076 with SMTP id cy35-20020a056870b6a300b00157cc212076mr15840384oab.22.1674543311416; Mon, 23 Jan 2023 22:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674543311; cv=none; d=google.com; s=arc-20160816; b=iUm+wFo9azv8gwH7Ua8i24vZTieFC1M0INY5IXT+cs3hnR1d+e10w+hYvEPOWPKKts l7TL+r6I+/KqSbMCYjq5i3UhBv83in089Mgc6zHx5a2Q1OEDgwxLxxri/4L3hF8ziz8n iXYcsZzbHqkWVcktw4jMZuNKFuGmDUFdLOrnOvZDQOiNcDUyKkJZPSkzgMhPdNqEq7MF r8XzgyBFkpS9NP9ZXAkAsnc5unAN8Rfj0UE29uDbNCfNuF7jF9SAGiOnvXdZECydJAJc JgeYIrJaQSsQYojsa3OVpgjIpc7SYQWWpRWKk12LfLQ245e/snWi+oaUVWuaeoXK8rFF y1zg== 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=rt40tX0jh4gaE4w/8bPobA5HpqR67Xk1Vb0RH26MFk0=; b=qKf3F/m05muNWnPdunuj/1XPCqPGoxzv0snebYVG6JCUxihh/xEylbYOcfb2Ko0k0I 6YDGNbK2Sob3NLK3X/mdfRlVnUbzXRjq+PYsbmfjZT5JKmS7CSPbuNCXGhJVOlXgsPST Z2cMqD5CzoQGk83SE8POUt/ZN3LA3l05rF9JDj01krSVjhyXZeg1KB3gLEERr540VHnz WU/O11bbChTxcA0VVoIes9kbC5tCEW5Yo6zVQ0DcWzC08Xg8YpYMj3DpjPVuIT51i2Qq jPTkezkEzjjQ8m6ldug0Exmpxpc9h7h/Vjs89XU8cYbl2HqZHqXTspTEFl2jC7pQcc/Y pGVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1IciS+w; 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 g1-20020a056870ea0100b0014307f88104si1119503oap.166.2023.01.23.22.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:55:11 -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=H1IciS+w; 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 2FB60855B7; Tue, 24 Jan 2023 07:54:36 +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="H1IciS+w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B2CFD8529D; Tue, 24 Jan 2023 07:54:25 +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-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) (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 1BDF8855B7 for ; Tue, 24 Jan 2023 07:53: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-pj1-x1031.google.com with SMTP id z9-20020a17090a468900b00226b6e7aeeaso13177080pjf.1 for ; Mon, 23 Jan 2023 22:53: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=rt40tX0jh4gaE4w/8bPobA5HpqR67Xk1Vb0RH26MFk0=; b=H1IciS+wGAjQEiGMUKP1XXA3SXgNk4ypWTUpkMU74sBo7R3ODl20X6uqpW88/6wHh8 rjED/TVxTg7Ljg4mmAT9F+tqqStNpxG/FBq+ZN4J+BomutR80zWswa0fiJBRLOkb6LtX wrkoSZ0WVpTXOMnoqvKvgjlA/I07gxSwGXDk8m25MzwZ9qldATMhd624TBWSvQorsix+ mGzCZcXJnjbI8t/vTRLf9uhaMpoLljwYLtN7yb8/aVkLif+/kj/sd6/n2oE3dCi2LssV GQ6jtnxOaP73AsGO9hhqWTvUo+2nPO14P6L4KvDATMy6zi5/PUB78pqFnWs+3faJkZvw xmOw== 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=rt40tX0jh4gaE4w/8bPobA5HpqR67Xk1Vb0RH26MFk0=; b=V6VKWG5qy8h7UWcOyPE64QN719erIvPyu6YJVMLA0l2cfQ8u90g+biuPw6Q1wlcfEu 870fZxFF5QLlQumt4JxnHSAdnrDoBJPEcDtfdh/aif/sDdvtGOxFVt226YmBeGp1tv4j bQqoaH7TEfUxEGF3VkNNiLzzzyeNd3Xb6CK5JOHxDKrjVNjEPo5Oa+zhB8lZGoxUUor2 6O750bhS2cja5Ggn7/u4xW5y6rr7wMxHv/ZtqsqPLjdaBXsYe0AUBsQPMSEKOaU/gLCQ 34HGG7I734MMIbQwhU4Q7fgH5+OrMFxubnk5mUchNaQEIvWuxhvkGrAfMTH3Td5f6r2a Y5qw== X-Gm-Message-State: AFqh2krmM3TK9f8NCmGsNlJPMzvBDygjwPDScR9maLOSuBMdroHxCQNw ZYVRprVHb6jLffebpXV79MnzFWkuT8ADf+7q X-Received: by 2002:a17:90a:41:b0:229:f580:e68a with SMTP id 1-20020a17090a004100b00229f580e68amr19539771pjb.17.1674543225001; Mon, 23 Jan 2023 22:53:45 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id q102-20020a17090a1b6f00b002293b1aa2b6sm1254873pjq.30.2023.01.23.22.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:53:44 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v5 2/4] eficonfig: refactor change boot order implementation Date: Tue, 24 Jan 2023 15:56:14 +0900 Message-Id: <20230124065616.25559-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230124065616.25559-1-masahisa.kojima@linaro.org> References: <20230124065616.25559-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 Tue Jan 24 06:56:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 646025 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp40463pvb; Mon, 23 Jan 2023 22:54:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXteoaVKK9+wm7elQn/Usr7EHiKa094K4WbBPd7zGqvnVqrwTzy1O52omKvmfG6niEj0joc9 X-Received: by 2002:a05:6830:18c7:b0:686:4a76:31e with SMTP id v7-20020a05683018c700b006864a76031emr13079415ote.38.1674543299317; Mon, 23 Jan 2023 22:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674543299; cv=none; d=google.com; s=arc-20160816; b=O19PXGwOl3gH7HghB+KPsEaZ0rwsqysH6d/5vZqArPPUfBkb1EiUZAUtWowE/ARefL dsnC1mb+IICyuqyvCwuzfrKhMMFI3vUD1H9wPAHG+uKEJCzH+UdmSOMJIH2XgcnzL78O 8x68wt2GHgHqzpD25iQxBy60QjpuIUhZ85Ds6gxx8CDT7BaBK1RrnFmJs6SbDFfFdt9i IfodygCJn6sqpcyi896SkgURe0BQnj5v311YLG3+QbCAM/X9yAndlNnupIugoc7ZO/v5 iIxk6xQyorRIcgHrY+y0gNsBy6aoJkdQM4o/ov+S+CHZYXFPBjcxx3u+F+cvDygVldYP kqnQ== 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=6DpE3nyrVWFrEbdglRUkZC3O4IVO3YYrNnumV9OtSIc=; b=jp6+4Rl8vYKZBxF2JLX+m7bLpJWThM+P3NmsFmb1fBFtN0oXLPpLMaWOm57DAPxKIu gHLgcFRLUfmMH5a0pLpk/DywGcEo0kE4dLwRgVqKXuxuSwcbx02HGfiE70ZBc07SVF/N pgxF6p3daWIPIfJOU2g5bKnCX8w5+UEd6jvXJuMKTLhnHlJFl0QKbZSHap08CvmD9Z6a KD/BshXFKS+0auXsUIweA3vVfxwP4WdjN08UtKG7h12uBMpkIrxn4+OGHPnfODCY4/Fx pGIwCUMRMg7A5mfKgF+sdQ+hYJ6CKmqMKfEujBpzssCqApW8zUrFtvSbzQTO3BVx5riK GBlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="W9eSj/tO"; 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 k8-20020a056830150800b00670813a7928si1430053otp.56.2023.01.23.22.54.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:54:59 -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="W9eSj/tO"; 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 E2702855EB; Tue, 24 Jan 2023 07:54: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=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="W9eSj/tO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B0F6E8539D; Tue, 24 Jan 2023 07:54:25 +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-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 264F5855EB for ; Tue, 24 Jan 2023 07:53:49 +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-x102e.google.com with SMTP id m11so2070155pji.0 for ; Mon, 23 Jan 2023 22:53:49 -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=6DpE3nyrVWFrEbdglRUkZC3O4IVO3YYrNnumV9OtSIc=; b=W9eSj/tO2/+E1qPqVhPT5xvwed5LLUAQ776HmROMX0Ydzg1zKZaDgrq90VcLnTPtnv woe2dqPKyMJjP524+xAm2FNv7tufvgfuQKVWMHbowAcuxx8EATXEVyBgsKNF3ntqTFrn utE8H9cmXN5nuIJxVBuvypRsFBHoP2a5MSyVAEhTHL+bcFMTmdaTrWCw88vikdDqBE6C 3/Uo+FfaP3y0BL5ryef+C3WbCQcYgkztCa6hppJXjqKdRNdmM+ZJCRmG3mw2gDqbgg4N Ja6de7bw7eIGdaE82HmrbSu+jMcQ81++1smM1MtZ9DorEATEtCvfliX81dr0kv1HhM+x X0Fg== 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=6DpE3nyrVWFrEbdglRUkZC3O4IVO3YYrNnumV9OtSIc=; b=Kg53t2GDzG5DMoCt9YYEP1t4WgdCYdYZKjsEuUCrUz7XWvbOZQAeNhjWKaqTHVvnfn dq/uMeullUQeZLAAhN98HqTcfutk+oLkLHrA6rt4T94JPr5ztJbZt8eQTHQ7WnYTYoe0 4gT+FEDBz2gD69XTM4tTbFyZ5/20hHZ/b2a86JxE4B35+FVQsMcIgRjps1llqYz7lWIT 6cTkGC+T/TitEqQlml+dDN94kl542JDh5rBwfV5aEZePkTlIVTZy670Lf73cyUjmywXl BSkfgDQbWUIGn58lpTuD5bmabnADxhHLxy9UQi3+/GWuckJwne/Ub4JPDVIz+/OUzNwz knPw== X-Gm-Message-State: AFqh2kpYJn9VLu4SxR1MAB2qiN9SEZhXfXbCbCKq7IrCAcidsykTxyGz m2Y85lXo3BpHIA/EkB3qLQtpFNzcuaYDR7UP X-Received: by 2002:a17:90a:2ecc:b0:226:7b3e:dea5 with SMTP id h12-20020a17090a2ecc00b002267b3edea5mr52391901pjs.36.1674543227096; Mon, 23 Jan 2023 22:53:47 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id q102-20020a17090a1b6f00b002293b1aa2b6sm1254873pjq.30.2023.01.23.22.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:53:46 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v5 3/4] eficonfig: add vertical scroll support Date: Tue, 24 Jan 2023 15:56:15 +0900 Message-Id: <20230124065616.25559-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230124065616.25559-1-masahisa.kojima@linaro.org> References: <20230124065616.25559-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". This commit also fixes the issue that "Save" and "Quit" entries can be moved by BKEY_PLUS in change boot order menu. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- Changes in v5: - create common function to update efi_menu active, start and end - fix the issue that "Save" and "Quit" can be moved by BKEY_PLUS press 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 | 92 ++++++++++++++++++++++++++++++++++++-------- include/efi_config.h | 4 ++ include/efi_loader.h | 1 + 3 files changed, 80 insertions(+), 17 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 01bd1b05bc..47c04cf536 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 @@ -122,6 +127,30 @@ struct eficonfig_save_boot_order_data { bool selected; }; +/** + * struct eficonfig_menu_adjust - update start and end entry index + * + * @efi_menu: pointer to efimenu structure + * @add: flag to add or substract the index + */ +static void eficonfig_menu_adjust(struct efimenu *efi_menu, bool add) +{ + if (add) + ++efi_menu->active; + else + --efi_menu->active; + + if (add && efi_menu->end < efi_menu->active) { + efi_menu->start++; + efi_menu->end++; + } else if (!add && efi_menu->start > efi_menu->active) { + efi_menu->start--; + efi_menu->end--; + } +} +#define eficonfig_menu_up(_a) eficonfig_menu_adjust(_a, false) +#define eficonfig_menu_down(_a) eficonfig_menu_adjust(_a, true) + /** * eficonfig_print_msg() - print message * @@ -157,18 +186,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 +218,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); } /** @@ -217,12 +244,14 @@ char *eficonfig_choice_entry(void *data) switch (key) { case BKEY_UP: if (efi_menu->active > 0) - --efi_menu->active; + eficonfig_menu_up(efi_menu); + /* no menu key selected, regenerate menu */ return NULL; case BKEY_DOWN: if (efi_menu->active < efi_menu->count - 1) - ++efi_menu->active; + eficonfig_menu_down(efi_menu); + /* no menu key selected, regenerate menu */ return NULL; case BKEY_SELECT: @@ -402,6 +431,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 +1899,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); @@ -1906,7 +1941,8 @@ char *eficonfig_choice_change_boot_order(void *data) switch (key) { case BKEY_PLUS: - if (efi_menu->active > 0) { + if (efi_menu->active > 0 && + efi_menu->active < efi_menu->count - 2) { list_for_each_safe(pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list); if (entry->num == efi_menu->active) @@ -1917,11 +1953,14 @@ char *eficonfig_choice_change_boot_order(void *data) tmp->num++; list_del(&tmp->list); list_add(&tmp->list, &entry->list); + + eficonfig_menu_up(efi_menu); } - fallthrough; + return NULL; case BKEY_UP: if (efi_menu->active > 0) - --efi_menu->active; + eficonfig_menu_up(efi_menu); + return NULL; case BKEY_MINUS: if (efi_menu->active < efi_menu->count - 3) { @@ -1936,12 +1975,13 @@ char *eficonfig_choice_change_boot_order(void *data) list_del(&entry->list); list_add(&entry->list, &tmp->list); - ++efi_menu->active; + eficonfig_menu_down(efi_menu); } return NULL; case BKEY_DOWN: if (efi_menu->active < efi_menu->count - 1) - ++efi_menu->active; + eficonfig_menu_down(efi_menu); + return NULL; case BKEY_SELECT: /* "Save" */ @@ -2590,6 +2630,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 +2641,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 Tue Jan 24 06:56:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 646024 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp40409pvb; Mon, 23 Jan 2023 22:54:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXsjPonxtPloBoCiQIWlENnEFBlMZOgo8iWo1dM3rofE/ctBPExfeyh4oKPastynxbK+SZfn X-Received: by 2002:a05:6830:6185:b0:684:b20e:af65 with SMTP id cb5-20020a056830618500b00684b20eaf65mr23005630otb.28.1674543287442; Mon, 23 Jan 2023 22:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674543287; cv=none; d=google.com; s=arc-20160816; b=0AbH4iPZXyqPIVJ1/+OJHfbRXUVUNuhh3W1YnEq1VeP9DAhfg+MOVlJ+mbSaSvyNBS L0aGh+b1YRwTUUywQa0h3vGhPLdwPXxjqrlU+CeruZO5Sgq3t0vtVe46M0exKWKOuMni /uNJUVak+utXPXnteGjBRjJ4DCHxvYHc04HbrRq6gPzz6JpAqvM+AmcI1LsPAkT3dGP/ mR5oxS7r47wKF4Lb7FaeePgBrkaaK2YkUzi5ZxcwvHcjIELd1whZiaegoDAzLe4qjCDD NpxYd3l5RM1Tn6S//faUnBYgHlg8Z8G0Yh/16qUL3w16+g74Vxbtmrtvsxd5no3P+0iz 16lA== 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=GqvhQO5ssFKsig0JoTxdAyi6Bj76rKrE9Aq1V9exu8E=; b=Y+msOXcSDGzotrn3QABaSQ56USns2rzkT5gxMby86V1ULinRcmNj/9+jt4IhzoJ7ce 5QNO9EwjmYemFgVTvQlR4TaYMqDCiWao25z6x9vUqukULF1yeGHUpgu6pR7dS9+dz0jG u9JehHi7EiUosdeoWPlDtyOIJZivr8FWCgq5BKu7IVRvsegJquxdVxcEWgUa6nWhsXwH gBYjrsAF0kiwDQZwU6ilNNLtpTP7xWv3QMQJabdeVQ8971Yh4O9uAs4HnESbtccyQit9 N6cbDvJOfHXGjSLJ78ZZDfXqCRxsCI5cYFxyoQjq4naSsGUoMYi4I5Z7Km9goneocM+t I58w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tVzUGmyH; 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 r21-20020a056830419500b00686decc66basi1538379otu.256.2023.01.23.22.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:54:47 -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=tVzUGmyH; 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 2447E8563B; Tue, 24 Jan 2023 07:54:30 +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="tVzUGmyH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15735855B7; Tue, 24 Jan 2023 07:54:25 +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 1437485616 for ; Tue, 24 Jan 2023 07:53: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=masahisa.kojima@linaro.org Received: by mail-pj1-x102a.google.com with SMTP id o13so13918259pjg.2 for ; Mon, 23 Jan 2023 22:53:50 -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=GqvhQO5ssFKsig0JoTxdAyi6Bj76rKrE9Aq1V9exu8E=; b=tVzUGmyHxIFhlJjg9IfAmdcaWooX3+cX0x24iBrYkd2Uf2Rb7ihanMpP5qzpzSgopW 05M/ndB7vdD9ULWLzr7pUCX8f8vXHmY/lulaTDEYCsh6LUVrdzcXrBkT+loUU8JBrPhC m7BW1joWkWtM/F/l4lVmc5ofAec/vkuZ7KfY7BWp02Zii9rpJVax5rAtenHCe+ZgH+Wv nW5t4+UrfFzBPzsHVjUsyPz7M7m3qLeuuILAbVGzINkBxXDQyHUaf1JRahccbHCN6VC/ hy9Yaj3e/8RCM+gzXV9Ww/8ZYrg/ruOL3G43ITzi68FRzoO94W9I+aoIB9aUJCUgTLYe i+rw== 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=GqvhQO5ssFKsig0JoTxdAyi6Bj76rKrE9Aq1V9exu8E=; b=o+mHHqt8Aw+XvxAiu4OtLwLuVGPFIf7M6eaMnHWG6k+BDCqJDDgvI4qjJ21LhCneYJ RhjqXTa+gMOH2hrjPMG4YcdN7nNkbeV6+/Oi/oFzQglfFKJI4j5yq5h6M1KZb0Moolc/ ywbrZWPATdAraDe4njKP5fjhMavpO0Hcc0iw5dNmEnHtuevXQSN8uGGCYoAufkxxbv77 PyhRj53KacmR0kVpEoxt3pggYH9VuJ9Cmu4wdY/wsYwpUcuhDUw6diy8u5nKDzKuJif+ RPkauQdK67IQXA2LAk6mkWRNo9mL/9CrNmTrAORzXVUAgFidPkGsMbRGAtKbqdYY0qoK F79w== X-Gm-Message-State: AFqh2kpqGymEaqNzDbH3XrjSE9oCriCJrPRGaYbqBK5rS1ActAtk07VM IC7elDsJzkfVvpmXnsYYYjpHXcHdc5r5Kdb+ X-Received: by 2002:a17:90b:270e:b0:229:ee6d:4178 with SMTP id px14-20020a17090b270e00b00229ee6d4178mr20076162pjb.38.1674543229221; Mon, 23 Jan 2023 22:53:49 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id q102-20020a17090a1b6f00b002293b1aa2b6sm1254873pjq.30.2023.01.23.22.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 22:53:48 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v5 4/4] eficonfig: increase the number of menu entries Date: Tue, 24 Jan 2023 15:56:16 +0900 Message-Id: <20230124065616.25559-5-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230124065616.25559-1-masahisa.kojima@linaro.org> References: <20230124065616.25559-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))