linux: Add TEXTMODE config option
diff --git a/CONFIG.md b/CONFIG.md
index b47d7587..7ff44477 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -100,6 +100,7 @@ Some keys take *URIs* as values; these are described in the next section.
Note that one can define this last variable multiple times to specify multiple
modules.
* `RESOLUTION` - The resolution to be used. This setting takes the form of `<width>x<height>x<bpp>`. If the resolution is not available, Limine will pick another one automatically. Omitting `<bpp>` will default to 32.
+ * `TEXTMODE` - If set to `yes`, prefer text mode. (BIOS only)
* stivale and stivale2 protocols:
* `KERNEL_PATH` - The URI path of the kernel.
* `MODULE_PATH` - The URI path to a module.
diff --git a/stage23/protos/linux.c b/stage23/protos/linux.c
index 72bc0a75..d97a4f83 100644
--- a/stage23/protos/linux.c
+++ b/stage23/protos/linux.c
@@ -495,6 +495,16 @@ bool linux_load(char *config, char *cmdline) {
struct screen_info *screen_info = &boot_params->screen_info;
+#if bios == 1
+ {
+ char *textmode_str = config_get_value(config, 0, "TEXTMODE");
+ bool textmode = textmode_str != NULL && strcmp(textmode_str, "yes") == 0;
+ if (textmode) {
+ goto set_textmode;
+ }
+ }
+#endif
+
size_t req_width = 0, req_height = 0, req_bpp = 0;
char *resolution = config_get_value(config, 0, "RESOLUTION");
@@ -506,6 +516,7 @@ bool linux_load(char *config, char *cmdline) {
#if uefi == 1
panic("linux: Unable to set video mode");
#elif bios == 1
+set_textmode:;
size_t rows, cols;
init_vga_textmode(&rows, &cols, false);
