summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/eficonfig.c399
-rw-r--r--cmd/eficonfig_sbkey.c18
-rw-r--r--cmd/mem.c26
3 files changed, 302 insertions, 141 deletions
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index d830e4af53..47c04cf536 100644
--- a/cmd/eficonfig.c
+++ b/cmd/eficonfig.c
@@ -22,9 +22,21 @@
#include <linux/delay.h>
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";
+
+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
@@ -105,6 +117,41 @@ struct eficonfig_boot_order_data {
};
/**
+ * 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;
+};
+
+/**
+ * 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
*
* display the message to the user, user proceeds the screen
@@ -134,23 +181,21 @@ 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 */
+ 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);
@@ -161,7 +206,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 +216,10 @@ 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"
- 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);
+ "%s"
+ ANSI_CLEAR_LINE_TO_END,
+ 1, 1, entry->efi_menu->menu_header, avail_row + 4, 1,
+ avail_row + 5, 1, entry->efi_menu->menu_desc);
}
/**
@@ -183,7 +228,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;
@@ -199,12 +244,14 @@ static 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:
@@ -361,9 +408,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;
@@ -376,16 +431,19 @@ efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char *menu_heade
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);
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 +702,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 +882,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 +1047,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 +1397,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 +1821,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);
@@ -1810,63 +1890,48 @@ 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);
+ struct eficonfig_entry *entry = data;
+ bool reverse = (entry->efi_menu->active == entry->num);
- /* 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);
+ if (entry->efi_menu->start > entry->num || entry->efi_menu->end < entry->num)
+ return;
- printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
+ 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);
+ 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;
@@ -1876,7 +1941,8 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
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)
@@ -1887,12 +1953,15 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
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;
- return EFI_NOT_READY;
+ eficonfig_menu_up(efi_menu);
+
+ return NULL;
case BKEY_MINUS:
if (efi_menu->active < efi_menu->count - 3) {
list_for_each_safe(pos, n, &efi_menu->list) {
@@ -1906,22 +1975,32 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)
list_del(&entry->list);
list_add(&entry->list, &tmp->list);
- ++efi_menu->active;
+ eficonfig_menu_down(efi_menu);
}
- return EFI_NOT_READY;
+ return NULL;
case BKEY_DOWN:
if (efi_menu->active < efi_menu->count - 1)
- ++efi_menu->active;
- return EFI_NOT_READY;
+ eficonfig_menu_down(efi_menu);
+
+ 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) {
@@ -1931,21 +2010,85 @@ 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
*
* @efi_menu: pointer to the efimenu structure
@@ -2020,6 +2163,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++) {
@@ -2070,7 +2214,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;
@@ -2093,7 +2247,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;
@@ -2114,47 +2267,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);
@@ -2500,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);
@@ -2510,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;
@@ -2567,7 +2715,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/cmd/mem.c b/cmd/mem.c
index 1e39348195..66c2d36a14 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -818,8 +818,8 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
*
* Returns: 0 if the test succeeds, 1 if the test fails.
*/
- pattern = (vu_long) 0xaaaaaaaa;
- anti_pattern = (vu_long) 0x55555555;
+ pattern = (vu_long)0xaaaaaaaaaaaaaaaa;
+ anti_pattern = (vu_long)0x5555555555555555;
debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
/*
@@ -970,7 +970,7 @@ static ulong test_bitflip_comparison(volatile unsigned long *bufa,
max = sizeof(unsigned long) * 8;
for (k = 0; k < max; k++) {
- q = 0x00000001L << k;
+ q = 1UL << k;
for (j = 0; j < 8; j++) {
schedule();
q = ~q;
@@ -1009,6 +1009,7 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
ulong errs = 0;
ulong incr, length;
ulong val, readback;
+ const int plen = 2 * sizeof(ulong);
/* Alternate the pattern */
incr = 1;
@@ -1020,17 +1021,17 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
* the "negative" patterns and increment the "positive"
* patterns to preserve this feature.
*/
- if (pattern & 0x80000000)
+ if (pattern > (ulong)LONG_MAX)
pattern = -pattern; /* complement & increment */
else
pattern = ~pattern;
}
length = (end_addr - start_addr) / sizeof(ulong);
end = buf + length;
- printf("\rPattern %08lX Writing..."
+ printf("\rPattern %0*lX Writing..."
"%12s"
"\b\b\b\b\b\b\b\b\b\b",
- pattern, "");
+ plen, pattern, "");
for (addr = buf, val = pattern; addr < end; addr++) {
schedule();
@@ -1046,10 +1047,9 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
if (readback != val) {
ulong offset = addr - buf;
- printf("\nMem error @ 0x%08X: "
- "found %08lX, expected %08lX\n",
- (uint)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
- readback, val);
+ printf("\nMem error @ 0x%0*lX: found %0*lX, expected %0*lX\n",
+ plen, start_addr + offset * sizeof(vu_long),
+ plen, readback, plen, val);
errs++;
if (ctrlc())
return -1;
@@ -1135,11 +1135,7 @@ static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc,
unmap_sysmem((void *)buf);
- if (errs == -1UL) {
- /* Memory test was aborted - write a newline to finish off */
- putc('\n');
- }
- printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
+ printf("\nTested %d iteration(s) with %lu errors.\n", iteration, count);
return errs != 0;
}