The keyboard is not responding to commands...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
interruption
Posts: 22
Joined: Wed Feb 08, 2017 7:51 pm

The keyboard is not responding to commands...

Post by interruption »

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):

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
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.
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: The keyboard is not responding to commands...

Post by Octocontrabass »

The keyboard port has to be enabled in order to communicate with the keyboard.
interruption wrote:all keyboard 8042s should be the same
They're not, and they haven't been at any time in the past 30 years.
interruption
Posts: 22
Joined: Wed Feb 08, 2017 7:51 pm

Re: The keyboard is not responding to commands...

Post by interruption »

interruption wrote:all keyboard 8042s should be the same
Octocontrabass wrote:They're not, and they haven't been at any time in the past 30 years.
Sorry, I made a mistake. What I MEANT to say is that basic commands registered by any 8042 chip should stay the same (like the IA-32 architecture does not change every time intel releases a new processor).

And yeah, now that I'm thinking about it, I shouldn't have disabled the keyboard in the first place.

Thanks for your input.
interruption
Posts: 22
Joined: Wed Feb 08, 2017 7:51 pm

Re: The keyboard is not responding to commands...

Post by interruption »

Well I tried what you said (taking out AD and AE instructions so that the keyboard remains enabled), but it's still not working.

Funny thing: when I out AD to 64H, my toshiba keyboard shuts itself off (like its supposed to) and my dell keyboard remains the same. It's as if the dell keyboard is completely ignoring my commands. Any ideas as to why this is happening?

NEVERMIND, I MADE A COMPLETE STUPID:

mov ah, al -> mov al, ah

It is simply amazing how something like that keeps you up for hours...

EDIT:

AND IT WORKED!!!!

so yay.

sorry for wasting your time...
Post Reply