boot: Use BIOS calls to read keyboard, which should work for USB

This commit is contained in:
K. Lange 2022-03-22 15:00:23 +09:00
parent de09abf2dd
commit 887bbc45a0
2 changed files with 22 additions and 4 deletions

View File

@ -252,6 +252,10 @@ do_bios_call.1:
cmp %bx, %ax cmp %bx, %ax
je do_bios_call.set_mode je do_bios_call.set_mode
mov $0x04, %ax
cmp %bx, %ax
je do_bios_call.test_key
/* Else: Bad call, jump to loop. */ /* Else: Bad call, jump to loop. */
jmp do_bios_call.done jmp do_bios_call.done
@ -277,6 +281,14 @@ do_bios_call.set_mode:
int $0x10 int $0x10
jmp do_bios_call.done jmp do_bios_call.done
do_bios_call.test_key:
movl 36(%esp), %ebx
xor %ax, %ax
mov %bl, %ah
int $0x16
movl %eax, 20(%esp)
jmp do_bios_call.done
do_bios_call.done: do_bios_call.done:
/* Disable interrupts again */ /* Disable interrupts again */
cli cli

View File

@ -166,16 +166,22 @@ int read_key(int * c) {
return 1; return 1;
} }
extern int do_bios_call(unsigned int function, unsigned int arg1);
int kbd_status(void) {
int result = do_bios_call(4,0x11);
return (result & 0xFF) == 0;
}
int read_scancode(int timeout) { int read_scancode(int timeout) {
if (timeout) { if (timeout) {
int start_s = read_cmos_seconds(); int start_s = read_cmos_seconds();
while (!(inportb(0x64) & 1)) { while (kbd_status()) {
int now_s = read_cmos_seconds(); int now_s = read_cmos_seconds();
if (now_s != start_s) return -1; if (now_s != start_s) return -1;
} }
} else {
while (!(inportb(0x64) & 1));
} }
return inportb(0x60); int result = do_bios_call(4,0);
return result >> 8;
} }
#endif #endif