Mouse + IRQ slave questions

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
User avatar
finarfin
Member
Member
Posts: 106
Joined: Fri Feb 23, 2007 1:41 am
Location: Italy & Ireland
Contact:

Mouse + IRQ slave questions

Post 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.
Elen síla lúmenn' omentielvo
- DreamOS64 - My latest attempt with osdev: https://github.com/dreamos82/Dreamos64
- Osdev Notes - My notes about osdeving! https://github.com/dreamos82/Osdev-Notes
- My old Os Project: https://github.com/dreamos82/DreamOs
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: Mouse + IRQ slave questions

Post 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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Mouse + IRQ slave questions

Post by Dex »

User avatar
finarfin
Member
Member
Posts: 106
Joined: Fri Feb 23, 2007 1:41 am
Location: Italy & Ireland
Contact:

Re: Mouse + IRQ slave questions

Post 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!
Elen síla lúmenn' omentielvo
- DreamOS64 - My latest attempt with osdev: https://github.com/dreamos82/Dreamos64
- Osdev Notes - My notes about osdeving! https://github.com/dreamos82/Osdev-Notes
- My old Os Project: https://github.com/dreamos82/DreamOs
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: Mouse + IRQ slave questions

Post by kop99 »

Why do you even check where the IRQ is raised?
There is IDT entry corresponding IRQ number, isn't it?
User avatar
finarfin
Member
Member
Posts: 106
Joined: Fri Feb 23, 2007 1:41 am
Location: Italy & Ireland
Contact:

Re: Mouse + IRQ slave questions

Post 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.
Elen síla lúmenn' omentielvo
- DreamOS64 - My latest attempt with osdev: https://github.com/dreamos82/Dreamos64
- Osdev Notes - My notes about osdeving! https://github.com/dreamos82/Osdev-Notes
- My old Os Project: https://github.com/dreamos82/DreamOs
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: Mouse + IRQ slave questions

Post 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 );
User avatar
finarfin
Member
Member
Posts: 106
Joined: Fri Feb 23, 2007 1:41 am
Location: Italy & Ireland
Contact:

Re: Mouse + IRQ slave questions

Post 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!!!
Elen síla lúmenn' omentielvo
- DreamOS64 - My latest attempt with osdev: https://github.com/dreamos82/Dreamos64
- Osdev Notes - My notes about osdeving! https://github.com/dreamos82/Osdev-Notes
- My old Os Project: https://github.com/dreamos82/DreamOs
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: Mouse + IRQ slave questions

Post 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
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: Mouse + IRQ slave questions

Post 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.
Post Reply