OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 9:13 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: The keyboard is not responding to commands...
PostPosted: Thu Apr 06, 2017 10:43 pm 
Offline

Joined: Wed Feb 08, 2017 7:51 pm
Posts: 22
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:
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.


Top
 Profile  
 
 Post subject: Re: The keyboard is not responding to commands...
PostPosted: Fri Apr 07, 2017 4:47 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: The keyboard is not responding to commands...
PostPosted: Fri Apr 07, 2017 7:41 am 
Offline

Joined: Wed Feb 08, 2017 7:51 pm
Posts: 22
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.


Top
 Profile  
 
 Post subject: Re: The keyboard is not responding to commands...
PostPosted: Fri Apr 07, 2017 4:35 pm 
Offline

Joined: Wed Feb 08, 2017 7:51 pm
Posts: 22
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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot], Majestic-12 [Bot] and 227 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group