mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-01 12:47:06 +03:00
Fix keyboard stuff
This commit is contained in:
parent
5dc8f48d6c
commit
cbcf3779b6
@ -125,7 +125,7 @@ limine_efi.elf: $(OBJ) font.o sys/smp_trampoline.o
|
||||
-T../gnu-efi/gnuefi/elf_x86_64_efi.lds \
|
||||
../gnu-efi/x86_64/gnuefi/crt0-efi-x86_64.o \
|
||||
../gnu-efi/x86_64/gnuefi/libgnuefi.a \
|
||||
../gnu-efi/lib/x86_64/efi_stub.o \
|
||||
../gnu-efi/x86_64/lib/x86_64/efi_stub.o \
|
||||
$(OBJ) font.o sys/smp_trampoline.o -o $@
|
||||
|
||||
-include $(HEADER_DEPS)
|
||||
|
@ -19,7 +19,8 @@ bool init_gop(struct fb_info *ret,
|
||||
uefi_call_wrapper(gBS->LocateProtocol, 3, &gop_guid, NULL, (void **)&gop);
|
||||
|
||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info;
|
||||
UINTN mode_info_size, native_mode, modes_count;
|
||||
UINTN mode_info_size;
|
||||
//UINTN native_mode, modes_count;
|
||||
|
||||
status = uefi_call_wrapper(gop->QueryMode, 4, gop,
|
||||
gop->Mode == NULL ? 0 : gop->Mode->Mode,
|
||||
|
@ -32,7 +32,7 @@ uint8_t bcd_to_int(uint8_t val);
|
||||
|
||||
__attribute__((noreturn)) void panic(const char *fmt, ...);
|
||||
|
||||
int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks);
|
||||
int pit_sleep_and_quit_on_keypress(int seconds);
|
||||
|
||||
uint64_t strtoui(const char *s, const char **end, int base);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
int getchar_internal(uint8_t scancode, uint8_t ascii) {
|
||||
switch (scancode) {
|
||||
#if defined (bios)
|
||||
case 0x44:
|
||||
return GETCHAR_F10;
|
||||
case 0x4b:
|
||||
@ -32,6 +33,30 @@ int getchar_internal(uint8_t scancode, uint8_t ascii) {
|
||||
return GETCHAR_PGUP;
|
||||
case 0x51:
|
||||
return GETCHAR_PGDOWN;
|
||||
#elif defined (uefi)
|
||||
case SCAN_F10:
|
||||
return GETCHAR_F10;
|
||||
case SCAN_LEFT:
|
||||
return GETCHAR_CURSOR_LEFT;
|
||||
case SCAN_RIGHT:
|
||||
return GETCHAR_CURSOR_RIGHT;
|
||||
case SCAN_UP:
|
||||
return GETCHAR_CURSOR_UP;
|
||||
case SCAN_DOWN:
|
||||
return GETCHAR_CURSOR_DOWN;
|
||||
case SCAN_DELETE:
|
||||
return GETCHAR_DELETE;
|
||||
case SCAN_END:
|
||||
return GETCHAR_END;
|
||||
case SCAN_HOME:
|
||||
return GETCHAR_HOME;
|
||||
case SCAN_PAGE_UP:
|
||||
return GETCHAR_PGUP;
|
||||
case SCAN_PAGE_DOWN:
|
||||
return GETCHAR_PGDOWN;
|
||||
case SCAN_ESC:
|
||||
return '\e';
|
||||
#endif
|
||||
}
|
||||
switch (ascii) {
|
||||
case '\r':
|
||||
@ -46,18 +71,52 @@ int getchar(void) {
|
||||
rm_int(0x16, &r, &r);
|
||||
return getchar_internal((r.eax >> 8) & 0xff, r.eax);
|
||||
}
|
||||
|
||||
int _pit_sleep_and_quit_on_keypress(uint32_t ticks);
|
||||
|
||||
int pit_sleep_and_quit_on_keypress(int seconds) {
|
||||
return _pit_sleep_and_quit_on_keypress(seconds * 18);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (uefi)
|
||||
int getchar(void) {
|
||||
EFI_INPUT_KEY key = {0};
|
||||
|
||||
UINTN which;
|
||||
|
||||
uefi_call_wrapper(
|
||||
gBS->WaitForEvent, 3, 1, (EFI_EVENT[]){ gST->ConIn->WaitForKey }, &which);
|
||||
|
||||
uefi_call_wrapper(gST->ConIn->ReadKeyStroke, 2, gST->ConIn, &key);
|
||||
|
||||
return getchar_internal(key.ScanCode, key.UnicodeChar);
|
||||
}
|
||||
|
||||
int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks) {
|
||||
(void)pit_ticks;
|
||||
return getchar();
|
||||
int pit_sleep_and_quit_on_keypress(int seconds) {
|
||||
EFI_INPUT_KEY key = {0};
|
||||
|
||||
UINTN which;
|
||||
|
||||
EFI_EVENT events[2];
|
||||
|
||||
events[0] = gST->ConIn->WaitForKey;
|
||||
|
||||
uefi_call_wrapper(
|
||||
gBS->CreateEvent, 5, EVT_TIMER, TPL_CALLBACK, NULL, NULL, &events[1]);
|
||||
|
||||
uefi_call_wrapper(
|
||||
gBS->SetTimer, 3, events[1], TimerRelative, 10000000 * seconds);
|
||||
|
||||
uefi_call_wrapper(gBS->WaitForEvent, 3, 2, events, &which);
|
||||
|
||||
if (which == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uefi_call_wrapper(gST->ConIn->ReadKeyStroke, 2, gST->ConIn, &key);
|
||||
|
||||
return getchar_internal(key.ScanCode, key.UnicodeChar);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -13,8 +13,8 @@ int_08_isr:
|
||||
|
||||
extern getchar_internal
|
||||
|
||||
global pit_sleep_and_quit_on_keypress
|
||||
pit_sleep_and_quit_on_keypress:
|
||||
global _pit_sleep_and_quit_on_keypress
|
||||
_pit_sleep_and_quit_on_keypress:
|
||||
; Hook int 0x08
|
||||
mov edx, dword [0x08*4]
|
||||
mov dword [int_08_callback], edx
|
||||
|
@ -448,7 +448,7 @@ refresh:
|
||||
for (int i = timeout; i; i--) {
|
||||
print("\rBooting automatically in %u, press any key to stop the countdown...", i);
|
||||
term_double_buffer_flush();
|
||||
if ((c = pit_sleep_and_quit_on_keypress(18))) {
|
||||
if ((c = pit_sleep_and_quit_on_keypress(1))) {
|
||||
skip_timeout = true;
|
||||
print("\e[2K\r\e[2A");
|
||||
goto timeout_aborted;
|
||||
|
@ -1,5 +1,5 @@
|
||||
DEFAULT_ENTRY=2
|
||||
TIMEOUT=no
|
||||
TIMEOUT=3
|
||||
GRAPHICS=yes
|
||||
MENU_RESOLUTION=1024x768
|
||||
MENU_FONT=boot:///boot/font.bin
|
||||
|
Loading…
Reference in New Issue
Block a user