:: commit 2f7d3c378d68e3f23f7c9962d9e9d32de7b60dd0

mintsuki <mintsuki@protonmail.com> — 2020-09-29 19:48

parents: 562e3c7c88

Default back to text mode instead of VBE, add DEFAULT_ENTRY config option

diff --git a/CONFIG.md b/CONFIG.md
index a6881937..956e6668 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -21,9 +21,10 @@ Some *local assignments* are shared between entries using any *protocol*, while
 
 *Globally assignable* keys are:
 * `TIMEOUT` - Specifies the timeout in seconds before the first *entry* is automatically booted.
-* `TEXTMODE` - If set to `on`, do not use graphical VESA framebuffer for the boot menu.
-* `THEME_BLACK`, `THEME_RED`, `THEME_GREEN`, `THEME_BROWN`, `THEME_BLUE`, `THEME_MAGENTA`, `THEME_CYAN`, `THEME_GREY`, `THEME_WHITE` - Specifies the colors used by the terminal (RRGGBB).
-* `THEME_MARGIN` - Set the amount of margin around the terminal.
+* `DEFAULT_ENTRY` - 0-based entry index of the entry which will be automatically selected at startup. If unspecified, it is `0`.
+* `GRAPHICS` - If set to `yes`, do use graphical VESA framebuffer for the boot menu.
+* `THEME_BLACK`, `THEME_RED`, `THEME_GREEN`, `THEME_BROWN`, `THEME_BLUE`, `THEME_MAGENTA`, `THEME_CYAN`, `THEME_GREY`, `THEME_WHITE` - Specifies the colors used by the terminal (RRGGBB). Ignored if `GRAPHICS` is not `yes`.
+* `THEME_MARGIN` - Set the amount of margin around the terminal. Ignored if `GRAPHICS` is not `yes`.
 
 *Locally assignable (non protocol specific)* keys are:
 * `PROTOCOL` - The boot protocol that will be used to boot the kernel. Valid protocols are: `linux`, `stivale`, `stivale2`, `chainload`.
diff --git a/limine.bin b/limine.bin
index c832c493..19208988 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/menu.c b/stage2/menu.c
index ab542dbb..636ef501 100644
--- a/stage2/menu.c
+++ b/stage2/menu.c
@@ -21,8 +21,21 @@ char *menu(int boot_drive) {
 
     char buf[16];
 
-    // If there is no TEXTMODE config key or the value is not "on", enable graphics
-    if (config_get_value(buf, 0, 16, "TEXTMODE") == NULL || strcmp(buf, "on")) {
+    int selected_entry = 0;
+    if (config_get_value(buf, 0, 16, "DEFAULT_ENTRY")) {
+        selected_entry = (int)strtoui(buf);
+    }
+
+    int timeout = 5;
+    if (config_get_value(buf, 0, 16, "TIMEOUT")) {
+        timeout = (int)strtoui(buf);
+    }
+
+    if (!timeout)
+        goto autoboot;
+
+    // If there is GRAPHICS config key and the value is "yes", enable graphics
+    if (config_get_value(buf, 0, 16, "GRAPHICS") && !strcmp(buf, "yes")) {
         // default scheme
         int margin = 64;
         uint32_t colourscheme[] = {
@@ -104,15 +117,7 @@ char *menu(int boot_drive) {
     yesbg:;
     }
 
-    int timeout;
-    if (!config_get_value(buf, 0, 16, "TIMEOUT")) {
-        timeout = 5;
-    } else {
-        timeout = (int)strtoui(buf);
-    }
-
     disable_cursor();
-    int selected_entry = 0;
     bool skip_timeout = false;
 
 refresh:
diff --git a/test/limine.cfg b/test/limine.cfg
index c5e0e028..ab43e465 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -1,4 +1,6 @@
+DEFAULT_ENTRY=2
 TIMEOUT=3
+GRAPHICS=yes
 
 THEME_BLACK=80000000
 THEME_RED=aa0000
@@ -14,7 +16,7 @@ THEME_MARGIN=64
 BACKGROUND_PARTITION=0
 BACKGROUND_PATH=bg.bmp
 
-:MyOS
+:MyOS 0
 
 PROTOCOL=stivale2
 
@@ -29,3 +31,11 @@ PROTOCOL=stivale2
 KERNEL_PARTITION=0
 KERNEL_PATH=boot/test.elf
 KERNEL_CMDLINE=something
+
+:MyOS 2
+
+PROTOCOL=stivale2
+
+KERNEL_PARTITION=0
+KERNEL_PATH=boot/test.elf
+KERNEL_CMDLINE=something
tab: 248 wrap: offon