Page 1 of 1

Is there any classic PS/2 mouse init code works in PMode?

Posted: Mon Jun 04, 2007 10:17 pm
by blackoil
Is there any classic PS/2 mouse init code works in PMode, without disabling Keyboard interrupt? The init code I wrote works fine in BOCHS.
The keyboard dies when enabling the mouse IRQ12 bit, but the mouse works fine alone.

IBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_IBF
jnz IBF8042
ret

OBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_OBF
jz OBF8042
ret

call IBF8042
mov al,0x20
out PS2_Port_Command,al
call IBF8042
in al,PS2_Port_Data
or al,00000011b
push eax
call IBF8042
mov al,0x60
out PS2_Port_Command,al
call IBF8042
pop eax
out PS2_Port_Data,al

Posted: Mon Jun 04, 2007 11:34 pm
by pcmattman
Look at my PS2 driver in my CVS.

It works in PMode and doesn't need to play with the keyboard.

Posted: Tue Jun 05, 2007 12:45 am
by blackoil
With Mr. PCMattMan, my lucky star's help.

We got a working PMode code sequence for PS/2 mouse initialization.

IBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_IBF
jnz IBF8042
ret

OBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_OBF
jz OBF8042
ret

PS2MousePMInit: call IBF8042
mov al,0xA8
out PS2_Port_Command,al

call IBF8042
mov al,0x20
out PS2_Port_Command,al
/***/ call IBF8042
/***/ call OBF8042
in al,PS2_Port_Data
or al,00000011b
push eax
call IBF8042
mov al,0x60
out PS2_Port_Command,al
call IBF8042
pop eax
out PS2_Port_Data,al

call IBF8042
mov al,0xD4
out PS2_Port_Command,al
call IBF8042
mov al,0xF4
out PS2_Port_Data,al
call OBF8042
in al,PS2_Port_Data

Pay attention to the Mark /***/

Posted: Tue Jun 05, 2007 2:11 am
by binutils

Posted: Tue Jun 05, 2007 3:36 am
by blackoil
The above code has to be executed without KEYBOARD IRQ MASK, otherwise will fail.