StupidOS/kernel/dev/at/kbd.inc

84 lines
1.4 KiB
PHP
Raw Normal View History

2024-07-14 13:11:28 +00:00
;; File: kbd.inc
2024-07-16 08:37:36 +00:00
;;
;; Usefull links:
;; - <https://wiki.osdev.org/PS/2_Keyboard>
KBD_STATP = 0x64
KBD_ATAP = 0x60
KBS_DIB = 0x01
2024-07-14 13:11:28 +00:00
2024-07-17 07:41:36 +00:00
;; function: kbd_probe
;;
;; Out:
;; AL - 0 if not found
kbd_probe:
mov al, CMOS_INSTALLED_EQUIPMENT
out CMOS_COMMAND, al
in al, CMOS_DATA
and al, 0x4
ret
kbd_init:
call kbd_probe
or al, al
jz @f
mov esi, szMsgKbdFound
call klog
@@:
ret
2024-07-18 09:28:07 +00:00
kbd_open:
ret
kbd_close:
ret
2024-07-14 13:11:28 +00:00
kbd_getc:
2024-07-16 08:37:36 +00:00
in al, KBD_STATP
and al, KBS_DIB
jz @f
in al, KBD_ATAP
mov ah, al
and ah, 0x80
jnz @f
mov edx, aKbdNormalMap
movzx eax, al
add edx, eax
mov byte al, [edx]
call cga_putc
@@:
2024-07-14 13:11:28 +00:00
ret
kbd_irq:
pusha
mov al, PIC_EOI
out PIC1_COMMAND, al
2024-07-16 08:37:36 +00:00
call kbd_getc
2024-07-14 13:11:28 +00:00
popa
iret
2024-07-17 07:41:36 +00:00
szMsgKbdFound db "KBD: found", 0
2024-07-16 08:37:36 +00:00
aKbdNormalMap:
db 0, 0x1B, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
db '-', '=', 0x08, 0x09, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i'
db 'o', 'p', '[', ']', LF, 0, 'a', 's', 'd', 'f', 'g', 'h'
db 'j', 'k', 'l', ';', "'", '`', 0, '\', 'z', 'x', 'c', 'v'
db 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7'
db '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.'
2024-07-17 07:41:36 +00:00
db 0, 0, 0, 0, 0, 0, 0, 0
kbd_device:
db 'kbd', 0, 0, 0, 0, 0
dd kbd_init
2024-07-21 16:14:38 +00:00
kbd_cdevws:
dd 0
dd 0
dd 0