term/limine: Allow overriding terminal config in entry
This commit is contained in:
parent
11b56c39f0
commit
997c787c16
|
@ -117,6 +117,7 @@ Editor control options.
|
||||||
|
|
||||||
* `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.
|
* `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.
|
||||||
* `KASLR` - For relocatable kernels, if set to `no`, disable kernel address space layout randomisation. KASLR is enabled by default.
|
* `KASLR` - For relocatable kernels, if set to `no`, disable kernel address space layout randomisation. KASLR is enabled by default.
|
||||||
|
* `TERM_CONFIG_OVERRIDE` - If set to `yes`, override the terminal configuration for this entry. Resets all the `TERM_*` assignments to default and allows setting them anew inside the entry. Note that without this, Limine will never look for terminal configuration settings inside entries.
|
||||||
|
|
||||||
* Chainload protocol on BIOS:
|
* Chainload protocol on BIOS:
|
||||||
* `DRIVE` - The 1-based drive to chainload, if omitted, assume boot drive.
|
* `DRIVE` - The 1-based drive to chainload, if omitted, assume boot drive.
|
||||||
|
|
|
@ -56,7 +56,7 @@ noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
|
||||||
|
|
||||||
status = gBS->SetWatchdogTimer(0, 0x10000, 0, NULL);
|
status = gBS->SetWatchdogTimer(0, 0x10000, 0, NULL);
|
||||||
if (status) {
|
if (status) {
|
||||||
term_vbe(0, 0);
|
term_vbe(NULL, 0, 0);
|
||||||
early_term = true;
|
early_term = true;
|
||||||
print("WARNING: Failed to disable watchdog timer!\n");
|
print("WARNING: Failed to disable watchdog timer!\n");
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
|
||||||
EFI_HANDLE current_handle = ImageHandle;
|
EFI_HANDLE current_handle = ImageHandle;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (current_handle == NULL) {
|
if (current_handle == NULL) {
|
||||||
term_vbe(0, 0);
|
term_vbe(NULL, 0, 0);
|
||||||
early_term = true;
|
early_term = true;
|
||||||
|
|
||||||
print("WARNING: Could not meaningfully match the boot device handle with a volume.\n");
|
print("WARNING: Could not meaningfully match the boot device handle with a volume.\n");
|
||||||
|
|
|
@ -598,8 +598,9 @@ void gterm_putchar(uint8_t c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool last_serial = false;
|
static bool last_serial = false;
|
||||||
|
static char *last_config = NULL;
|
||||||
|
|
||||||
bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
bool gterm_init(char *config, size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
if (current_video_mode >= 0
|
if (current_video_mode >= 0
|
||||||
#if bios == 1
|
#if bios == 1
|
||||||
&& current_video_mode != 0x03
|
&& current_video_mode != 0x03
|
||||||
|
@ -609,7 +610,8 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
&& height == 0
|
&& height == 0
|
||||||
&& fbinfo.framebuffer_bpp == 32
|
&& fbinfo.framebuffer_bpp == 32
|
||||||
&& !early_term
|
&& !early_term
|
||||||
&& serial == last_serial) {
|
&& serial == last_serial
|
||||||
|
&& config == last_config) {
|
||||||
*_rows = rows;
|
*_rows = rows;
|
||||||
*_cols = cols;
|
*_cols = cols;
|
||||||
gterm_clear(true);
|
gterm_clear(true);
|
||||||
|
@ -624,7 +626,8 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
&& fbinfo.framebuffer_height == height
|
&& fbinfo.framebuffer_height == height
|
||||||
&& fbinfo.framebuffer_bpp == 32
|
&& fbinfo.framebuffer_bpp == 32
|
||||||
&& !early_term
|
&& !early_term
|
||||||
&& serial == last_serial) {
|
&& serial == last_serial
|
||||||
|
&& config == last_config) {
|
||||||
*_rows = rows;
|
*_rows = rows;
|
||||||
*_cols = cols;
|
*_cols = cols;
|
||||||
gterm_clear(true);
|
gterm_clear(true);
|
||||||
|
@ -655,7 +658,7 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
ansi_colours[6] = 0x0000aaaa; // cyan
|
ansi_colours[6] = 0x0000aaaa; // cyan
|
||||||
ansi_colours[7] = 0x00aaaaaa; // grey
|
ansi_colours[7] = 0x00aaaaaa; // grey
|
||||||
|
|
||||||
char *colours = config_get_value(NULL, 0, "TERM_PALETTE");
|
char *colours = config_get_value(config, 0, "TERM_PALETTE");
|
||||||
if (colours != NULL) {
|
if (colours != NULL) {
|
||||||
const char *first = colours;
|
const char *first = colours;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -680,7 +683,7 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
ansi_bright_colours[6] = 0x0055ffff; // cyan
|
ansi_bright_colours[6] = 0x0055ffff; // cyan
|
||||||
ansi_bright_colours[7] = 0x00ffffff; // grey
|
ansi_bright_colours[7] = 0x00ffffff; // grey
|
||||||
|
|
||||||
char *bright_colours = config_get_value(NULL, 0, "TERM_PALETTE_BRIGHT");
|
char *bright_colours = config_get_value(config, 0, "TERM_PALETTE_BRIGHT");
|
||||||
if (bright_colours != NULL) {
|
if (bright_colours != NULL) {
|
||||||
const char *first = bright_colours;
|
const char *first = bright_colours;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -699,12 +702,12 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
default_bg = 0x00000000; // background (black)
|
default_bg = 0x00000000; // background (black)
|
||||||
default_fg = 0x00aaaaaa; // foreground (grey)
|
default_fg = 0x00aaaaaa; // foreground (grey)
|
||||||
|
|
||||||
char *theme_background = config_get_value(NULL, 0, "TERM_BACKGROUND");
|
char *theme_background = config_get_value(config, 0, "TERM_BACKGROUND");
|
||||||
if (theme_background != NULL) {
|
if (theme_background != NULL) {
|
||||||
default_bg = strtoui(theme_background, NULL, 16);
|
default_bg = strtoui(theme_background, NULL, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *theme_foreground = config_get_value(NULL, 0, "TERM_FOREGROUND");
|
char *theme_foreground = config_get_value(config, 0, "TERM_FOREGROUND");
|
||||||
if (theme_foreground != NULL) {
|
if (theme_foreground != NULL) {
|
||||||
default_fg = strtoui(theme_foreground, NULL, 16) & 0xffffff;
|
default_fg = strtoui(theme_foreground, NULL, 16) & 0xffffff;
|
||||||
}
|
}
|
||||||
|
@ -713,7 +716,7 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
text_bg = 0xffffffff;
|
text_bg = 0xffffffff;
|
||||||
|
|
||||||
background = NULL;
|
background = NULL;
|
||||||
char *background_path = config_get_value(NULL, 0, "TERM_WALLPAPER");
|
char *background_path = config_get_value(config, 0, "TERM_WALLPAPER");
|
||||||
if (background_path != NULL) {
|
if (background_path != NULL) {
|
||||||
struct file_handle *bg_file;
|
struct file_handle *bg_file;
|
||||||
if ((bg_file = uri_open(background_path)) != NULL) {
|
if ((bg_file = uri_open(background_path)) != NULL) {
|
||||||
|
@ -731,20 +734,20 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *theme_margin = config_get_value(NULL, 0, "TERM_MARGIN");
|
char *theme_margin = config_get_value(config, 0, "TERM_MARGIN");
|
||||||
if (theme_margin != NULL) {
|
if (theme_margin != NULL) {
|
||||||
margin = strtoui(theme_margin, NULL, 10);
|
margin = strtoui(theme_margin, NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *theme_margin_gradient = config_get_value(NULL, 0, "TERM_MARGIN_GRADIENT");
|
char *theme_margin_gradient = config_get_value(config, 0, "TERM_MARGIN_GRADIENT");
|
||||||
if (theme_margin_gradient != NULL) {
|
if (theme_margin_gradient != NULL) {
|
||||||
margin_gradient = strtoui(theme_margin_gradient, NULL, 10);
|
margin_gradient = strtoui(theme_margin_gradient, NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (background != NULL) {
|
if (background != NULL) {
|
||||||
char *background_layout = config_get_value(NULL, 0, "TERM_WALLPAPER_STYLE");
|
char *background_layout = config_get_value(config, 0, "TERM_WALLPAPER_STYLE");
|
||||||
if (background_layout != NULL && strcmp(background_layout, "centered") == 0) {
|
if (background_layout != NULL && strcmp(background_layout, "centered") == 0) {
|
||||||
char *background_colour = config_get_value(NULL, 0, "TERM_BACKDROP");
|
char *background_colour = config_get_value(config, 0, "TERM_BACKDROP");
|
||||||
if (background_colour == NULL)
|
if (background_colour == NULL)
|
||||||
background_colour = "0";
|
background_colour = "0";
|
||||||
uint32_t bg_col = strtoui(background_colour, NULL, 16);
|
uint32_t bg_col = strtoui(background_colour, NULL, 16);
|
||||||
|
@ -779,7 +782,7 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
|
|
||||||
size_t tmp_font_width, tmp_font_height;
|
size_t tmp_font_width, tmp_font_height;
|
||||||
|
|
||||||
char *menu_font_size = config_get_value(NULL, 0, "TERM_FONT_SIZE");
|
char *menu_font_size = config_get_value(config, 0, "TERM_FONT_SIZE");
|
||||||
if (menu_font_size != NULL) {
|
if (menu_font_size != NULL) {
|
||||||
parse_resolution(&tmp_font_width, &tmp_font_height, NULL, menu_font_size);
|
parse_resolution(&tmp_font_width, &tmp_font_height, NULL, menu_font_size);
|
||||||
|
|
||||||
|
@ -793,7 +796,7 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
font_bytes = tmp_font_bytes;
|
font_bytes = tmp_font_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *menu_font = config_get_value(NULL, 0, "TERM_FONT");
|
char *menu_font = config_get_value(config, 0, "TERM_FONT");
|
||||||
if (menu_font != NULL) {
|
if (menu_font != NULL) {
|
||||||
struct file_handle *f;
|
struct file_handle *f;
|
||||||
if ((f = uri_open(menu_font)) == NULL) {
|
if ((f = uri_open(menu_font)) == NULL) {
|
||||||
|
@ -810,7 +813,7 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
|
||||||
|
|
||||||
no_load_font:;
|
no_load_font:;
|
||||||
size_t font_spacing = 1;
|
size_t font_spacing = 1;
|
||||||
char *font_spacing_str = config_get_value(NULL, 0, "TERM_FONT_SPACING");
|
char *font_spacing_str = config_get_value(config, 0, "TERM_FONT_SPACING");
|
||||||
if (font_spacing_str != NULL) {
|
if (font_spacing_str != NULL) {
|
||||||
font_spacing = strtoui(font_spacing_str, NULL, 10);
|
font_spacing = strtoui(font_spacing_str, NULL, 10);
|
||||||
}
|
}
|
||||||
|
@ -852,7 +855,7 @@ no_load_font:;
|
||||||
vga_font_scale_x = 1;
|
vga_font_scale_x = 1;
|
||||||
vga_font_scale_y = 1;
|
vga_font_scale_y = 1;
|
||||||
|
|
||||||
char *menu_font_scale = config_get_value(NULL, 0, "TERM_FONT_SCALE");
|
char *menu_font_scale = config_get_value(config, 0, "TERM_FONT_SCALE");
|
||||||
if (menu_font_scale != NULL) {
|
if (menu_font_scale != NULL) {
|
||||||
parse_resolution(&vga_font_scale_x, &vga_font_scale_y, NULL, menu_font_scale);
|
parse_resolution(&vga_font_scale_x, &vga_font_scale_y, NULL, menu_font_scale);
|
||||||
if (vga_font_scale_x > 8 || vga_font_scale_y > 8) {
|
if (vga_font_scale_x > 8 || vga_font_scale_y > 8) {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
extern struct fb_info fbinfo;
|
extern struct fb_info fbinfo;
|
||||||
|
|
||||||
bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height);
|
bool gterm_init(char *config, size_t *_rows, size_t *_cols, size_t width, size_t height);
|
||||||
void gterm_deinit(void);
|
void gterm_deinit(void);
|
||||||
|
|
||||||
void gterm_putchar(uint8_t c);
|
void gterm_putchar(uint8_t c);
|
||||||
|
|
|
@ -35,7 +35,7 @@ noreturn void panic(bool allow_menu, const char *fmt, ...) {
|
||||||
#endif
|
#endif
|
||||||
term_backend == NOT_READY) {
|
term_backend == NOT_READY) {
|
||||||
early_term = true;
|
early_term = true;
|
||||||
term_vbe(0, 0);
|
term_vbe(NULL, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
nested:
|
nested:
|
||||||
|
|
|
@ -22,7 +22,7 @@ void term_deinit(void) {
|
||||||
term_notready();
|
term_notready();
|
||||||
}
|
}
|
||||||
|
|
||||||
void term_vbe(size_t width, size_t height) {
|
void term_vbe(char *config, size_t width, size_t height) {
|
||||||
if (term_backend != VBE) {
|
if (term_backend != VBE) {
|
||||||
term_deinit();
|
term_deinit();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ void term_vbe(size_t width, size_t height) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gterm_init(&term_rows, &term_cols, width, height)) {
|
if (!gterm_init(config, &term_rows, &term_cols, width, height)) {
|
||||||
#if bios == 1
|
#if bios == 1
|
||||||
// Failed to set VBE properly, default to text mode
|
// Failed to set VBE properly, default to text mode
|
||||||
term_textmode();
|
term_textmode();
|
||||||
|
|
|
@ -55,7 +55,7 @@ void term_fallback(void);
|
||||||
|
|
||||||
void term_reinit(void);
|
void term_reinit(void);
|
||||||
void term_deinit(void);
|
void term_deinit(void);
|
||||||
void term_vbe(size_t width, size_t height);
|
void term_vbe(char *config, size_t width, size_t height);
|
||||||
void term_textmode(void);
|
void term_textmode(void);
|
||||||
void term_notready(void);
|
void term_notready(void);
|
||||||
void term_putchar(uint8_t c);
|
void term_putchar(uint8_t c);
|
||||||
|
|
|
@ -644,7 +644,7 @@ static noreturn void _menu(bool timeout_enabled) {
|
||||||
randomise_mem_str = config_get_value(NULL, 0, "RANDOMIZE_MEMORY");
|
randomise_mem_str = config_get_value(NULL, 0, "RANDOMIZE_MEMORY");
|
||||||
bool randomise_mem = randomise_mem_str != NULL && strcmp(randomise_mem_str, "yes") == 0;
|
bool randomise_mem = randomise_mem_str != NULL && strcmp(randomise_mem_str, "yes") == 0;
|
||||||
if (randomise_mem) {
|
if (randomise_mem) {
|
||||||
term_vbe(0, 0);
|
term_vbe(NULL, 0, 0);
|
||||||
early_term = true;
|
early_term = true;
|
||||||
pmm_randomise_memory();
|
pmm_randomise_memory();
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ reterm:
|
||||||
if (menu_resolution != NULL)
|
if (menu_resolution != NULL)
|
||||||
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
|
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
|
||||||
|
|
||||||
term_vbe(req_width, req_height);
|
term_vbe(NULL, req_width, req_height);
|
||||||
} else {
|
} else {
|
||||||
#if bios == 1
|
#if bios == 1
|
||||||
term_textmode();
|
term_textmode();
|
||||||
|
@ -870,7 +870,7 @@ timeout_aborted:
|
||||||
goto refresh;
|
goto refresh;
|
||||||
}
|
}
|
||||||
if (term_backend == NOT_READY) {
|
if (term_backend == NOT_READY) {
|
||||||
term_vbe(0, 0);
|
term_vbe(NULL, 0, 0);
|
||||||
#if bios == 1
|
#if bios == 1
|
||||||
if (term_backend == NOT_READY) {
|
if (term_backend == NOT_READY) {
|
||||||
term_textmode();
|
term_textmode();
|
||||||
|
|
|
@ -580,7 +580,12 @@ FEAT_START
|
||||||
quiet = false;
|
quiet = false;
|
||||||
serial = false;
|
serial = false;
|
||||||
|
|
||||||
term_vbe(req_width, req_height);
|
char *term_conf_override_s = config_get_value(config, 0, "TERM_CONFIG_OVERRIDE");
|
||||||
|
if (term_conf_override_s != NULL && strcmp(term_conf_override_s, "yes") == 0) {
|
||||||
|
term_vbe(config, req_width, req_height);
|
||||||
|
} else {
|
||||||
|
term_vbe(NULL, req_width, req_height);
|
||||||
|
}
|
||||||
|
|
||||||
if (current_video_mode < 0) {
|
if (current_video_mode < 0) {
|
||||||
panic(true, "limine: Failed to initialise terminal");
|
panic(true, "limine: Failed to initialise terminal");
|
||||||
|
|
Loading…
Reference in New Issue