Page 1 of 1

PS/2 Mouse Problem

Posted: Fri Jul 14, 2006 4:00 pm
by ComputerPsi
I have enabled the mouse in every possible way. I have remapped the PICs to 0x30 for master and 0x38 for slave. I'm in protected mode. The keyboard and mouse is unmasked - Everything else is masked. (0xfd for port 0x21 and 0xef for port 0xa1). I have a mouse and keyboard handler. I also have a "everything else" handler, just incase.
The keyboard works. When I move the mouse, no interrupt comes in and the keyboard stops working. I tried debugging it with Bochs. Before I move the mouse and I push a key, the following is debugged:
00012824000d[KBD ] gen_scancode(): BX_KEY_T pressed
00012824000d[KBD ] gen_scancode(): writing translated 14
00012824000d[KBD ] kbd_enQ(0x14)
00012824000d[KBD ] kbd_enQ: putting scancode 0x14 in internal buffer
00012824000d[KBD ] activating timer...
00012824000d[KBD ] service_keyboard: key in internal buffer waiting
00012824500d[IOAP ] set_irq_level(): INTIN1: level=1
00012824500d[IOAP ] IOAPIC: servicing
00012824500d[IOAP ] service_ioapic(): INTIN0 is masked
00012824500d[IOAP ] service_ioapic(): INTIN1 is masked
00012824500d[IOAP ] service_ioapic(): INTIN6 is masked
00012824500d[PIC ] IRQ line 1 now high
00012824500d[PIC ] signalling IRQ(1)
00012824500d[CPU0 ] interrupt(): vector = 49, INT = 0, EXT = 1
00012824500d[CPU0 ] int_trap_gate286(): INTERRUPT TO SAME PRIVILEGE

When I move the mouse, I get the following:
00030898000d[KBD ] [mouse] Dx=-1 Dy=0 Dz=0
00030898000d[KBD ] mouse_enQ(18)
00030898000d[KBD ] mouse_enQ(ff)
00030898000d[KBD ] mouse_enQ(00)
00030898000d[KBD ] service_keyboard: key(from mouse) in internal buffer waiting
00030898500d[IOAP ] set_irq_level(): INTIN12: level=1
00030898500d[IOAP ] IOAPIC: servicing
00030898500d[IOAP ] service_ioapic(): INTIN0 is masked
00030898500d[IOAP ] service_ioapic(): INTIN1 is masked
00030898500d[IOAP ] service_ioapic(): INTIN6 is masked
00030898500d[IOAP ] service_ioapic(): INTIN12 is masked
00030898500d[PIC ] IRQ line 12 now high
00030898500d[PIC ] slave: signalling IRQ(12)
00030898500d[PIC ] IRQ line 2 now high

As you can see, the CPU0 information is missing.

The second time a signal comes from the mouse, this is the only thing debugged:
00031096000d[KBD ] [mouse] Dx=-2 Dy=0 Dz=0

After the mouse is moved and I push a key, the following is debugged:
00036604000d[KBD ] gen_scancode(): BX_KEY_T pressed
00036604000d[KBD ] gen_scancode(): writing translated 14
00036604000d[KBD ] kbd_enQ(0x14)
00036604000d[KBD ] kbd_enQ: putting scancode 0x14 in internal buffer

What have I done wrong that is causing my mouse to not be able to cause an interrupt? Everything seems to be enabled and unmasked..

Posted: Fri Jul 14, 2006 4:33 pm
by Dex
Here somethings i have found, when dev my mouse, that is i enable mouse in realmode do the basic setup then disable it with:

Code: Select all

mov     bl,0a7h				; disable mouse
call    keyboard_cmd
Then do the remapp pic etc, then when in pmode do

Code: Select all

mov   bl,0xa8				; enable mouse
call  keyboard_cmd

Posted: Fri Jul 14, 2006 4:49 pm
by ComputerPsi
Already tried that. As I said, I enabled it in every way. :P Though I -did- find out what was wrong. I didn't know this, but it seems that in order for IRQ 12 to work, IRQ 2 must be unmasked. Anybody know why? Also, wouldn't this pose a problem since the a device connected to IRQ 2 make interrupts? - I mean if you want to block the interrupts from the device at IRQ 2 for some reason. (Yes, you can just ignore the interrupt, but I want to see if there is different way to solving that.)

Posted: Fri Jul 14, 2006 10:06 pm
by bontanu
The two 8259 like PIC controllers in a standard PC are chained through IRQ-2.

The output on the secondary PIC controller is the input for IRQ-2 line of the first controller.

As a consequence for any IRQ in range 8-15 to function properly you must also enable IRQ-2 ... makes sense