The keyboard is not responding to commands...
Posted: Thu Apr 06, 2017 10:43 pm
I send the keyboard chips commands through port 64H and port 60H, although they seem to be taking no effect.
I am trying to set the typematic rate of the keyboard because I've been used to the windows super-fast typematic speed, so the default one is extremely slow to me.
I just don't understand what I'm doing wrong, as I've looked at a lot of sources (including this website) and I'm doing exactly what is required (I think...).
Here's my code (I'm sorry to be one of those people to throw their code at you, but I simply don't have a clue really):
NOTE: I have two test computers: my dell and my toshiba. The dell computer (bios v A05) keeps the keyboard the same WITHOUT changing the typematic rate (and OS runs as usual), but my toshiba (bios v 1.60, "InsydeH20 Setup Utility") appears to have disabled the keyboard entirely, so I can't type at all. I am in protected mode using my own IDT and GDT, so BIOS functions should not affect the keyboard. Other than that, I would have no idea why that is the case, since all keyboard 8042s should be the same.
Thanks for your input.
I am trying to set the typematic rate of the keyboard because I've been used to the windows super-fast typematic speed, so the default one is extremely slow to me.
I just don't understand what I'm doing wrong, as I've looked at a lot of sources (including this website) and I'm doing exactly what is required (I think...).
Here's my code (I'm sorry to be one of those people to throw their code at you, but I simply don't have a clue really):
Code: Select all
keyboard_send_cmd: ;command in ah
cli
.wait_for_buffer_clear:
in al, 64H
test al, 2 ;we make sure byte 2 of al is CLEARED (to make sure that the keyboard is not caught up in other commands.
jnz .wait_for_buffer_clear ;fyi, test is basically a 'cmp' instruction except it ANDS the two values instead of subtracting them. the zero flag is set if the result of the 'ANDing' of the two is zero.
.send_cmd:
mov ah, al
out 60H, al
sti
ret
keyboard_controller_send_cmd: ;command in ah
cli
.wait_for_buffer_clear:
in al, 64H
test al, 2 ;we make sure byte 2 of al is CLEARED (to make sure that the keyboard is not caught up in other commands.
jnz .wait_for_buffer_clear ;fyi, test is basically a 'cmp' instruction except it ANDS the two values instead of subtracting them. the zero flag is set if the result of the and is zero.
.send_cmd:
mov ah, al ;we transfer cmd byte to al because in and out instructions needs byte to be in al, not ah (just way its wired).
out 64H, al
sti
ret
keyboard_read_out: ;for future reference, if we need to read the output of a command sent to ps2 controller.
cli
.wait:
in al, 64H
test al, 1 ;is input filled (cmd done)?
jz .wait ;no == jump until complete
.get_val:
in al, 60H ;yes: al == output
sti
ret
keyboard_setup:
mov ah, 0ADH ;disable keyboard
call keyboard_controller_send_cmd
mov ah, 0F3H ;set typematic rate command
call keyboard_send_cmd
mov ah, 20H ;the operand of the previous command
call keyboard_send_cmd
mov ah, 0AEH ;re-enable keyboard
call keyboard_controller_send_cmd
ret
Thanks for your input.