Page 1 of 1

keyboard/mouse problem

Posted: Fri Apr 04, 2003 7:36 am
by FlashBurn
I?ve rewritten my code for the 2nd irq (irq 1) so that it could also receive data from the mouse. But I have to look if the data is from the keyboard or the mouse. I make this so:

Code: Select all

call kbd_wait_cmd
mov al,0c0h
out 64h,al
call kbd_wait_data
in al,64h
test al,1
jne .keyb
.mouse
 ;code
.keyb
 ;code
Bochs gives me the folowing error "kbd: OUTB set and command 0xc0 encountered". What made I wrong?

One more question. When the mouse is sending data, sends it the whole package and I have to inport all 3bytes or calls it the irq for every byte?

Re:keyboard/mouse problem

Posted: Fri Apr 04, 2003 7:46 am
by Pype.Clicker
err. afaik, the mouse doesn't raise IRQ1 when data are available. I'm not sure what interrupt is used for PS2 mouse (for serial mice, it is the COM1 or COM2 interrupt), so i would say you can expect the byte in 8042 to be for the keyboard when the keyboard interrupt is fired and to be for the mouse if the mouse interupt is fired ...

Re:keyboard/mouse problem

Posted: Fri Apr 04, 2003 7:56 am
by FlashBurn
But the ps2 mouse uses the kbd controller and so I think it uses the irq1, too! Because why should it use an extra irq? Also if the ps2 mouse doesn?t use the kbd irq, why gives me bochs this error?

Re:keyboard/mouse problem

Posted: Fri Apr 04, 2003 8:20 am
by distantvoices
On some older mainboards, afaik, irq 12 is used for ps/2 mice. i don't know if ps2 mice are handled by int 12 on newer mainboards.

Re:keyboard/mouse problem

Posted: Fri Apr 04, 2003 8:45 am
by FlashBurn
Ok, I want to test if the mouse sends it data and fires irq1. But how can I test if the data is from the kbd or from the mouse? I can?t send the command "read input port" because before I have to read the data and then the bytes for data are cleared. So how can I determine from which device the data is?

Re:keyboard/mouse problem

Posted: Fri Apr 04, 2003 9:49 am
by Pype.Clicker
on real hardware (pIII motherboard and Logitech PS2 mouse), i can remember i had IRQ12 fired when i moved the mouse by accident. And indeed the mouse data were stored at the 8042 (which is the microcontroller which handles keyboard, but NOT LIMITED to keyboard).

The result is that if you don't read bytes from the 8042 at the mouse interrupt, they will stay at the 8042 and lock further keyboard data.

Re:keyboard/mouse problem

Posted: Fri Apr 04, 2003 9:58 am
by Slasher
To find out if the data is from the keyboard or from the mouse, you need to test the status register of the 8042. I have forgotten which, check docs on keyboards the AUX bit in one register indicates the source. Also, to use irq 12h for the mouse, the keyboard controller has to be instructed to use it for ps2 mice, how this is done i have forgotten :-[ but can be found in docs.