Suppose you have sent the command 0x20 to the Keyboard's on-board microcontroller and there should be a byte available at port 0x60. How should I know that the byte is available without using IRQs? I have checked BIT #1 of staus byte at port 0x64 but it never seems to get set like in the below procedure:

  __KeyboardDisable:
    PUSH    EAX
    MOV    AL , 0x20
    OUT    0x64 , AL
    ;.Wait1:
    ;  IN      AL , 0x64
    ;  TEST    AL , 0x02
    ;  JE      .Wait1
    IN      AL , 0x60
    OR      AL , 0x10
    MOV    AH , AL
    MOV    AL , 0x60
    OUT    0x64 , AL
    .Wait2:
      IN      AL , 0x64
      TEST    AL , 0x01
      JNZ    .Wait2
    MOV    AL , AH
    OUT    0x60 , AL
    POP    EAX
    RET               


The code gets stuck in the .Wait1 label. Can anybody help, please?
Posted on 2007-03-06 01:47:46 by XCHG
1) You always wait for the keyboard buffer to be empty before writing out to the i8042 controller.
2) Make sure interrupts are disabled.
3) I use "0xAD" disable the i8042, I'm not sure about your use of "0x20" at all.

You are trying to enable the A20 Gate... aren't you :P

If you need any more help, let us know ;)
Posted on 2007-03-06 05:39:42 by SpooK
The command 0x20 when sent to port 0x64 is supposed to transfer the Keyboard's controller Command Byte and make it available at port 0x60. You are right; I could send the command 0xAD to port which will save me a lot of coding but I thought there should be a way to know when bytes are available at port 0x60  :sad:
Posted on 2007-03-06 08:20:43 by XCHG

The command 0x20 when sent to port 0x64 is supposed to transfer the Keyboard's controller Command Byte and make it available at port 0x60. You are right; I could send the command 0xAD to port which will save me a lot of coding but I thought there should be a way to know when bytes are available at port 0x60  :sad:


Your code tests the response byte in Port 0x64 Bit 1 to see if it is 1 (not empty). 0 (empty) is what you want to test for, so change that JE to JNZ/JNE.

Your second wait in that same code tests the response byte in Port 0x64 Bit 0 to see if it is 0 (not empty). 1 (empty) is what you want to test for, so change that JNZ to JZ/JE.

I know it is rather frustrating, but if it makes you feel better, my basic keyboard driver (and A20 gate initialization) is almost 5 years old. Just continue to muddle the basic stuff, get it done... and then you don't have to look back :)
Posted on 2007-03-06 17:26:10 by SpooK