Only enter graphical terminal mode for menu

This commit is contained in:
mintsuki 2020-09-02 10:31:39 +02:00
parent 902109ef68
commit 5379787967
5 changed files with 24 additions and 21 deletions

View File

@ -32,7 +32,7 @@ echfs-test: test.img all
echfs-utils -m -p0 test.img import test/test.elf boot/test.elf
echfs-utils -m -p0 test.img import test/limine.cfg limine.cfg
./limine-install src/limine.bin test.img
qemu-system-x86_64 -hda test.img -debugcon stdio
qemu-system-x86_64 -hda test.img -debugcon stdio -enable-kvm
ext2-test: test.img all
$(MAKE) -C test

Binary file not shown.

View File

@ -24,6 +24,7 @@ void (*set_text_bg)(int bg);
static int rows, cols;
void term_vbe(void) {
term_deinit();
vbe_tty_init(&rows, &cols);
raw_putchar = vbe_putchar;
@ -39,6 +40,7 @@ void term_vbe(void) {
}
void term_textmode(void) {
term_deinit();
init_vga_textmode(&rows, &cols);
raw_putchar = text_putchar;

View File

@ -61,29 +61,22 @@ void main(int boot_drive) {
init_e820();
init_memmap();
char buf[32];
if (config_get_value(buf, 0, 32, "GRAPHICS")) {
if (!strcmp(buf, "on")) {
term_vbe();
}
}
char *cmdline = menu();
if (!config_get_value(buf, 0, 32, "KERNEL_PROTO")) {
if (!config_get_value(buf, 0, 32, "PROTOCOL")) {
char proto[32];
if (!config_get_value(proto, 0, 32, "KERNEL_PROTO")) {
if (!config_get_value(proto, 0, 32, "PROTOCOL")) {
panic("PROTOCOL not specified");
}
}
if (!strcmp(buf, "stivale")) {
if (!strcmp(proto, "stivale")) {
stivale_load(cmdline, boot_drive);
} else if (!strcmp(buf, "stivale2")) {
} else if (!strcmp(proto, "stivale2")) {
stivale2_load(cmdline, boot_drive);
} else if (!strcmp(buf, "linux")) {
} else if (!strcmp(proto, "linux")) {
linux_load(cmdline, boot_drive);
} else if (!strcmp(buf, "chainload")) {
} else if (!strcmp(proto, "chainload")) {
chainload();
} else {
panic("Invalid protocol specified");

View File

@ -17,15 +17,21 @@ static char config_entry_name[1024];
char *menu(void) {
cmdline = balloc(CMDLINE_MAX);
int timeout; {
char buf[32];
if (!config_get_value(buf, 0, 32, "TIMEOUT")) {
timeout = 5;
} else {
timeout = (int)strtoui(buf);
char buf[16];
if (config_get_value(buf, 0, 16, "GRAPHICS")) {
if (!strcmp(buf, "on")) {
term_vbe();
}
}
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;
@ -85,6 +91,7 @@ refresh:
}
}
clear(true);
term_textmode();
return cmdline;
case 'e':
config_set_entry(selected_entry);
@ -97,6 +104,7 @@ refresh:
print("\n\n> ");
gets(cmdline, cmdline, CMDLINE_MAX);
clear(true);
term_textmode();
return cmdline;
}
}