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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

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

Post 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
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Look at my PS2 driver in my CVS.

It works in PMode and doesn't need to play with the keyboard.
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Post 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 /***/
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post by binutils »

blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Post by blackoil »

The above code has to be executed without KEYBOARD IRQ MASK, otherwise will fail.
Post Reply