menu: Drop console entirely
diff --git a/common/console.c b/common/console.c
deleted file mode 100644
index d028a645..00000000
--- a/common/console.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <stddef.h>
-#include <stdint.h>
-#include <config.h>
-#include <console.h>
-#include <menu.h>
-#include <mm/pmm.h>
-#include <lib/print.h>
-#include <lib/readline.h>
-#include <lib/libc.h>
-#include <lib/misc.h>
-#include <lib/term.h>
-#include <lib/part.h>
-#include <lib/config.h>
-
-static void console_help(void) {
- print(
- "Available commands:\n"
- "exit -- Exit Limine console.\n"
- "clear -- Clear the console.\n"
- "%s"
- "lsvol -- List volumes.\n"
- "firmware -- Show firmware type.\n"
-#if defined (UEFI)
- "setup -- Reboot to firmware setup.\n"
- "slide -- Print load slide offset.\n"
-#endif
- "version -- Print version.\n"
- "copyright -- Print copyright.\n"
- "help -- Print this help message.\n",
- editor_enabled ? "editor -- Open an empty boot entry editor.\n" : ""
- );
-}
-
-#if defined (UEFI)
-extern symbol __slide;
-#endif
-
-void console(void) {
- print("Welcome to the Limine console.\nType 'help' for more information.\n\n");
-
- char *prompt = ext_mem_alloc(256);
-
- for (;;) {
- print(">>> ");
- readline("", prompt, 256);
-
- if (strcmp(prompt, "help") == 0) {
- console_help();
- } else if (strcmp(prompt, "exit") == 0) {
- break;
- } else if (strcmp(prompt, "clear") == 0) {
- print("\e[2J\e[H");
- } else if (strcmp(prompt, "lsvol") == 0) {
- list_volumes();
- } else if (editor_enabled && strcmp(prompt, "editor") == 0) {
- char *new_entry = config_entry_editor("New Entry", "");
- if (new_entry != NULL) {
- config_ready = true;
- boot(new_entry);
- }
- } else if (strcmp(prompt, "firmware") == 0) {
-#if defined (BIOS)
- print("BIOS\n");
-#elif defined (UEFI)
- print("UEFI\n");
-#else
- print("unknown\n");
-#endif
-#if defined (UEFI)
- } else if (strcmp(prompt, "setup") == 0) {
- if (reboot_to_fw_ui_supported()) {
- reboot_to_fw_ui();
- } else {
- print("Your firmware does not support rebooting to the firmware UI.\n");
- }
- } else if (strcmp(prompt, "slide") == 0) {
- print("%p\n", __slide);
-#endif
- } else if (strcmp(prompt, "version") == 0) {
- print(LIMINE_VERSION "\n");
- } else if (strcmp(prompt, "copyright") == 0) {
- print(LIMINE_COPYRIGHT "\n");
- print("Limine is distributed under the terms of the BSD-2-Clause license.\n");
- print("There is ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n");
- } else if (*prompt != 0) {
- print("Invalid command: `%s`.\n", prompt);
- }
- }
-
- reset_term();
- pmm_free(prompt, 256);
-}
diff --git a/common/console.h b/common/console.h
deleted file mode 100644
index 9c6618ca..00000000
--- a/common/console.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef CONSOLE_H__
-#define CONSOLE_H__
-
-void console(void);
-
-#endif
diff --git a/common/menu.c b/common/menu.c
index 62013a16..04f52c02 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -15,7 +15,6 @@
#include <mm/pmm.h>
#include <drivers/vbe.h>
#include <drivers/vga_textmode.h>
-#include <console.h>
#include <protos/linux.h>
#include <protos/chainload.h>
#include <protos/chainload_next.h>
@@ -856,21 +855,13 @@ refresh:
print("\n\n\n\n");
}
- while (menu_tree == NULL) {
+ if (menu_tree == NULL) {
if (quiet) {
quiet = false;
menu_init_term();
FOR_TERM(TERM->autoflush = false);
FOR_TERM(TERM->cursor_enabled = false);
}
- print("Config file %s.\n\n", config_ready ? "contains no valid entries" : "not found");
- print("For information on the format of Limine config entries, consult CONFIG.md in\n");
- print("the root of the Limine source repository.\n\n");
- print("Press a key to enter the Limine console...");
- FOR_TERM(TERM->double_buffer_flush(TERM));
- getchar();
- reset_term();
- console();
}
size_t max_tree_len, max_tree_height;
@@ -899,12 +890,14 @@ refresh:
if (!help_hidden) {
set_cursor_pos_helper(0, 3);
- if (selected_menu_entry->sub == NULL) {
- print(" \e[32mARROWS\e[0m Select \e[32mENTER\e[0m Boot %s",
- editor_enabled ? "\e[32mE\e[0m Edit" : "");
- } else {
- print(" \e[32mARROWS\e[0m Select \e[32mENTER\e[0m %s",
- selected_menu_entry->expanded ? "Collapse" : "Expand");
+ if (selected_menu_entry != NULL) {
+ if (selected_menu_entry->sub == NULL) {
+ print(" \e[32mARROWS\e[0m Select \e[32mENTER\e[0m Boot %s",
+ editor_enabled ? "\e[32mE\e[0m Edit" : "");
+ } else {
+ print(" \e[32mARROWS\e[0m Select \e[32mENTER\e[0m %s",
+ selected_menu_entry->expanded ? "Collapse" : "Expand");
+ }
}
#if defined(UEFI)
if (reboot_to_firmware_supported) {
@@ -920,7 +913,7 @@ refresh:
set_cursor_pos_helper(x, y);
}
- if (selected_menu_entry->sub != NULL)
+ if (selected_menu_entry == NULL || selected_menu_entry->sub != NULL)
skip_timeout = true;
int c;
@@ -949,7 +942,7 @@ refresh:
}
set_cursor_pos_helper(0, terms[0]->rows - 1);
- if (selected_menu_entry->comment != NULL) {
+ if (selected_menu_entry != NULL && selected_menu_entry->comment != NULL) {
FOR_TERM(TERM->scroll_enabled = false);
print("\e[36m%s\e[0m", selected_menu_entry->comment);
FOR_TERM(TERM->scroll_enabled = true);
@@ -992,6 +985,9 @@ timeout_aborted:
case '\n':
case ' ':
autoboot:
+ if (selected_menu_entry == NULL) {
+ break;
+ }
if (selected_menu_entry->sub != NULL) {
selected_menu_entry->expanded = !selected_menu_entry->expanded;
goto refresh;
@@ -1022,8 +1018,9 @@ timeout_aborted:
case 'e':
case 'E': {
if (editor_enabled) {
- if (selected_menu_entry->sub != NULL)
- goto refresh;
+ if (selected_menu_entry == NULL || selected_menu_entry->sub != NULL) {
+ break;
+ }
editor_no_term_reset = true;
char *new_body = config_entry_editor(selected_menu_entry->name, selected_menu_entry->body);
if (new_body == NULL)
@@ -1054,12 +1051,6 @@ timeout_aborted:
}
break;
}
- case 'c':
- case 'C': {
- reset_term();
- console();
- goto refresh;
- }
}
}
}
