Page 1 of 1
IRQ 12 - HELP PLEASE!
Posted: Fri Oct 18, 2002 3:41 pm
by Paul
Who has made their own PS/2 mouse driver *AND* keybaord driver in protected mode?
I made a keyboard driver that worked just fine
by itself. I hooked IRQ 1 to INT 21h and had no problems. Then, I enabled the mouse interrupt (IRQ 12) and hooked it to INT 2Ch and that is when the problems started. When I move the mouse, INT 2C is trigged just ONCE and never again!! Not only that but my keyboard
ISR stops running as well, once I touch the mouse.
I'm doing this at the end of EVERY ISR:
mov al,20h
mov dx,20h
out dx,al
That is supposed to allow another interrupt, correct?
Does anyone have any idea what is going on? If it is not simple to explain, could you please provide me with a simple mouse driver sample and keyboard driver
sample?
Thanks!
Paul
Re:IRQ 12 - HELP PLEASE!
Posted: Fri Oct 18, 2002 5:40 pm
by Friend
You need to send an EOI (End of Interrupt) to PIC1 and PIC2 for IRQ8-15.
mov al, 0x20 ; EOI Command
out 0x20, al ; Send it to Master!
out 0xa0, al ; Send it to Slave!
hope this helps.
Re:IRQ 12 - HELP PLEASE!
Posted: Fri Oct 18, 2002 5:43 pm
by PlayOS
Would you be willing to share the code that sets up the PS/2 mouse?
I tried just unmasking the mouse IRQ and nothing happened at all, so I guess there is some initialization that must have to be done first.
thanks.
Re:IRQ 12 - HELP PLEASE!
Posted: Fri Oct 18, 2002 7:18 pm
by Paul
Friend:
THANKS SO MUCH! That was the problem! You need to send the command to 0xa0 as well as 0x20!
PlayOS:
Here is how I enabled the mouse....
You need to first enable it so port 0x60 get ps/2
data, and you also have to set a bit in a register
to enable IRQ 12 interrupts. Look below...
setmouse:
mov bl,0a8h ; enable mouse cmd
call keyboard_cmd
call keyboard_read ; read status return
mov bl,0d4h ; next command is for mouse
call keyboard_cmd
mov al,0f4h ; enable mouse device
call keyboard_write
call keyboard_read ; read status return
;The chunk of code below enables IRQ 12
mov bl,0x20
call keyboard_cmd
call keyboard_read
or al,2
mov [tmp],al
mov bl,0x60
call keyboard_cmd
mov al,[tmp]
call keyboard_write
ret
keyboard_read:
push ecx
push edx
mov ecx,0ffffh
key_read_loop:
in al,64h
mov [mouse],byte 0
test al,32
jz short not32
mov [mouse],byte 1
not32: test al,1
jnz key_read_ready
loop key_read_loop
mov ah,1
jmp key_read_exit
key_read_ready:
push ecx
mov ecx,32
key_read_delay:
loop key_read_delay
pop ecx
in al,60h
xor ah,ah
key_read_exit:
pop edx
pop ecx
ret
keyboard_write:
push ecx
push edx
mov dl,al
mov ecx,0ffffh
kbd_wrt_loop1:
in al,64h
test al,20h
jz kbd_wrt_ok1
loop kbd_wrt_loop1
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok1:
in al,60h
mov ecx,0ffffh
kbd_wrt_loop:
in al,64h
test al,2
jz kbd_wrt_ok
loop kbd_wrt_loop
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok:
mov al,dl
out 60h,al
mov ecx,0ffffh
kbd_wrt_loop3:
in al,64h
test al,2
jz kbd_wrt_ok3
loop kbd_wrt_loop3
mov ah,1
jmp kbd_wrt_exit
kbd_wrt_ok3:
mov ah,8
kbd_wrt_loop4:
mov ecx,0ffffh
kbd_wrt_loop5:
in al,64h
test al,1
jnz kbd_wrt_ok4
loop kbd_wrt_loop5
dec ah
jnz kbd_wrt_loop4
kbd_wrt_ok4:
xor ah,ah
kbd_wrt_exit:
pop edx
pop ecx
ret
keyboard_cmd:
mov ecx,0ffffh
cmd_wait:
in al,64h
test al,2
jz cmd_send
loop cmd_wait
jmp cmd_error
cmd_send:
mov al,bl
out 64h,al
mov ecx,0ffffh
cmd_accept:
in al,64h
test al,2
jz cmd_ok
loop cmd_accept
cmd_error:
mov ah,1
jmp cmd_exit
cmd_ok:
xor ah,ah
cmd_exit:
ret
Regards,
Paul