menu: Do not ignore key pressed during countdown
diff --git a/Makefile b/Makefile
index b023610e..fffdcb63 100644
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,7 @@ echfs-test: test.img
echfs-utils -m -p0 test.img import test/limine.cfg limine.cfg
echfs-utils -m -p0 test.img import test/bg.bmp bg.bmp
./limine-install limine.bin test.img
- qemu-system-x86_64 -net none -smp 4 -hda test.img -debugcon stdio
+ qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon stdio
ext2-test: test.img
$(MAKE) -C test
@@ -60,7 +60,7 @@ ext2-test: test.img
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
./limine-install limine.bin test.img
- qemu-system-x86_64 -hda test.img -smp 4 -debugcon stdio
+ qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon
fat32-test: test.img
$(MAKE) -C test
@@ -78,4 +78,4 @@ fat32-test: test.img
sudo losetup -d `cat loopback_dev`
rm -rf test_image loopback_dev
./limine-install limine.bin test.img
- qemu-system-x86_64 -hda test.img -smp 4 -debugcon stdio
+ qemu-system-x86_64 -net none -smp 4 -enable-kvm -cpu host -hda test.img -debugcon
diff --git a/limine.bin b/limine.bin
index 4b4ce944..c832c493 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/lib/blib.c b/stage2/lib/blib.c
index 94296e7b..d98014ef 100644
--- a/stage2/lib/blib.c
+++ b/stage2/lib/blib.c
@@ -74,10 +74,8 @@ uint64_t strtoui16(const char *s) {
return n;
}
-int getchar(void) {
- struct rm_regs r = {0};
- rm_int(0x16, &r, &r);
- switch ((r.eax >> 8) & 0xff) {
+int getchar_internal(uint32_t eax) {
+ switch ((eax >> 8) & 0xff) {
case 0x4b:
return GETCHAR_CURSOR_LEFT;
case 0x4d:
@@ -87,7 +85,13 @@ int getchar(void) {
case 0x50:
return GETCHAR_CURSOR_DOWN;
}
- return (char)(r.eax & 0xff);
+ return (char)(eax & 0xff);
+}
+
+int getchar(void) {
+ struct rm_regs r = {0};
+ rm_int(0x16, &r, &r);
+ return getchar_internal(r.eax);
}
static void gets_reprint_string(int x, int y, const char *s, size_t limit) {
diff --git a/stage2/lib/sleep.asm b/stage2/lib/sleep.asm
index c0463e32..cbb455ef 100644
--- a/stage2/lib/sleep.asm
+++ b/stage2/lib/sleep.asm
@@ -9,6 +9,8 @@ int_08_isr:
iret
bits 32
+extern getchar_internal
+
global pit_sleep_and_quit_on_keypress
pit_sleep_and_quit_on_keypress:
; Hook int 0x08
@@ -69,7 +71,6 @@ pit_sleep_and_quit_on_keypress:
; on keypress
xor ax, ax
int 0x16
- mov eax, 1
jmp .done
.timeout:
@@ -102,4 +103,8 @@ pit_sleep_and_quit_on_keypress:
mov edx, dword [0x80*4]
mov dword [0x08*4], edx
+ push eax
+ call getchar_internal
+ pop edx
+
ret
diff --git a/stage2/lib/term.c b/stage2/lib/term.c
index c4f8d378..51a0c555 100644
--- a/stage2/lib/term.c
+++ b/stage2/lib/term.c
@@ -202,6 +202,19 @@ static void escape_parse(char c) {
break;
}
break;
+ case 'K':
+ switch (esc_value0) {
+ case 2: {
+ int x = get_cursor_pos_x();
+ int y = get_cursor_pos_y();
+ set_cursor_pos(0, y);
+ for (int i = 0; i < cols; i++)
+ raw_putchar(' ');
+ set_cursor_pos(x, y);
+ break;
+ }
+ }
+ break;
default:
escape = 0;
raw_putchar('?');
diff --git a/stage2/menu.c b/stage2/menu.c
index f92d94f0..ab542dbb 100644
--- a/stage2/menu.c
+++ b/stage2/menu.c
@@ -134,23 +134,26 @@ refresh:
if (max_entries == 0)
panic("Config contains no entries.");
- print("\n");
+ print("\nArrows to choose, enter to select, 'e' to edit command line.");
+
+ int c;
if (skip_timeout == false) {
+ print("\n\n");
for (int i = timeout; i; i--) {
print("\rBooting automatically in %u, press any key to stop the countdown...", i);
- if (pit_sleep_and_quit_on_keypress(18)) {
+ if ((c = pit_sleep_and_quit_on_keypress(18))) {
skip_timeout = true;
- goto refresh;
+ print("\e[2K\r\e[2A");
+ goto timeout_aborted;
}
}
goto autoboot;
}
- print("Arrows to choose, enter to select, 'e' to edit command line.");
-
for (;;) {
- int c = getchar();
+ c = getchar();
+timeout_aborted:
switch (c) {
case GETCHAR_CURSOR_UP:
if (--selected_entry == -1)
diff --git a/test/limine.cfg b/test/limine.cfg
index 98d3b83d..c5e0e028 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -21,3 +21,11 @@ PROTOCOL=stivale2
KERNEL_PARTITION=0
KERNEL_PATH=boot/test.elf
KERNEL_CMDLINE=something
+
+:MyOS 1
+
+PROTOCOL=stivale2
+
+KERNEL_PARTITION=0
+KERNEL_PATH=boot/test.elf
+KERNEL_CMDLINE=something
