Page 1 of 1

Mouse + IRQ slave questions

Posted: Tue Jun 09, 2009 10:14 am
by finarfin
Hi!

These days i was trying to write a driver for ps/2 mouse, but it seems to doesn't work. It seems like the IRQ wasn't raised
Now some questions arrived in my brain:
1. When some IRQ from the slave pic are enable, i have to enable the cascade IRQ? (IRQ 2 in master PIC?)
2. I have to do particular things to enable slave pic irq? So for example if i have to enable irq 12 i have to clear the bit 5 in slave pic?

And after i serve the IRQ in pic slave, i have to send an EOI both to master and pic?

And another question: laptops touchpad is a PS2 or usb mouse?
And in bochs if i enable the mouse, it is ps2 or usb? or depend from real hw mouse?

Thanks,
And sorry for my english.

Re: Mouse + IRQ slave questions

Posted: Tue Jun 09, 2009 11:39 am
by kmtdk
well
first
you will have to use the secoundary PIC, and yes, mask off IRQ 12
and you will have to send the EOI to both (read the datasheet for the PIC :P )
USB and laptop is a little speciel
USB should act like PS2, but use the USB IRQ, however i have tried where it uses the IRQ 12 ???( dont relay on that)

the laptop is also ouht to act like PS2, and Fire the IRQ 12
BOCHS is default PS2
but it can appere as a serial and some other ..

KMT dk

Re: Mouse + IRQ slave questions

Posted: Tue Jun 09, 2009 12:34 pm
by Dex

Re: Mouse + IRQ slave questions

Posted: Tue Jun 09, 2009 3:46 pm
by finarfin
Now another question:
if a irq>7 is raised, what happens? i find IRQ2=1 or it is 0?
and if i want to check where the IRQ is raised, is correct that piece of code:

Code: Select all

int get_current_irq(){
    int cur_irq;
    outportb(GET_IRR_STATUS, MASTER_PORT);
    cur_irq = inportb(MASTER_PORT);
    if(cur_irq == 0) {
      outportb(GET_IRR_STATUS, SLAVE_PORT);
      cur_irq = inportb(SLAVE_PORT);
    }
    return find_first_bit(cur_irq);
}
 
Is correct to check if(icur_irq==0)? should it be cur_irq==4?
Thanks!

Re: Mouse + IRQ slave questions

Posted: Tue Jun 09, 2009 6:46 pm
by kop99
Why do you even check where the IRQ is raised?
There is IDT entry corresponding IRQ number, isn't it?

Re: Mouse + IRQ slave questions

Posted: Wed Jun 10, 2009 12:58 am
by finarfin
Yes i have an IDT entry,
but i use a global handler for all IRQ's, when an IRQ is raised the first function called is _irqinterrupt, that call get_current_irq and after it execute the correct handler.

Now the problem seems that mouse didn't raise any IRQ. It seems like nothing happen, irqinterrupt isn't called.

Re: Mouse + IRQ slave questions

Posted: Wed Jun 10, 2009 1:48 am
by kop99
Are you sure that you've enable mouse interupt in 8042?

On-Board 8042 Keyboard Microcontroller Command byte
Second bit is Mouse device interrupt enable.

So you have to do something like following code.

Code: Select all

    kSendKeyboardCmd( 0x20 );
    bCmdByte = kGetKeyboardData();

    bCmdByte |= 0x02;

    kSendKeyboardCmd( 0x60 );
    kSendKeyboardData( bCmdByte );

Re: Mouse + IRQ slave questions

Posted: Thu Jun 11, 2009 2:58 pm
by finarfin
The problem seems to be that the Mouse IRQ isn't raised.
I cleared the bit of IRQ 12, and the IRQ 2 for the cascade into pic registers

configured the IDT entries
teorycally with that operations mouse irq wil begin to work?
I need to do something else?

In bochs my touchpad is viewed like a ps2 mouse?

Thanks!!!

Re: Mouse + IRQ slave questions

Posted: Thu Jun 11, 2009 4:11 pm
by kmtdk
well
have you init the mouse currectly ??
but let me summerice a tinny list of what to do:
  • Do map IRQ's
    Do enable all IRQ
    Do enable aux line, using the KBC status byte
    Do ensure that "packed reporting" are enable ( the mouse)
    and be sure to send EOI for all interrupts,
    and when it is a IRQ from 0-7 it is only the master whitch need the EOI
    above means that the slave also needs the EOI
that should be it; (dont "kill" me if im wrong about the Irq numbers ..)



KMT dk

Re: Mouse + IRQ slave questions

Posted: Thu Jun 11, 2009 6:50 pm
by kop99
The problem seems to be that the Mouse IRQ isn't raised.
I cleared the bit of IRQ 12, and the IRQ 2 for the cascade into pic registers
In notebook, they clear mouse interupt enable bit in 8042, normally.
So make sure that bit is set.