OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 1:20 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Cant get PS2 Mouse interrupt to work
PostPosted: Tue May 09, 2023 12:57 pm 
Offline

Joined: Tue May 09, 2023 12:39 pm
Posts: 2
Hi,
I tried implementing an interrupt handler for the mouse in my x64 OS.
The code is the same as SANiK's one, but the interrupt handler is already "installed".
All the IDT stuff is working fine (both the keyboard and PIT work fine even in real hardware).
The only thing i do with the PIC is remapping it, as the wiki says
Maybe I am missing something with the init code:
Code:
void ps2mouse_setup() {

    // Unmask the pic
    uint8_t oldpic = inb(PIC2_DATA);
    outb(PIC2_DATA, oldpic & (~PIC_PS2MOUSE_IRQ)); // PIC_PS2MOUSE_IRQ = 0b00010000

    uint8_t status;

    //Enable the auxiliary mouse device
    ps2mouse_wait(1);
    outportb(0x64, 0xA8);

    //Enable the interrupts
    ps2mouse_wait(1);
    outportb(0x64, 0x20);
    ps2mouse_wait(0);
    status = (inportb(0x60) | 2);
    ps2mouse_wait(1);
    outportb(0x64, 0x60);
    ps2mouse_wait(1);
    outportb(0x60, status);

    //Tell the mouse to use default settings
    ps2mouse_write(0xF6);
    ps2mouse_read();  //Acknowledge

    //Enable the mouse
    ps2mouse_write(0xF4);
    ps2mouse_read();  //Acknowledge

    return;
}


The handler never [-X fires. I tried with different tutorials, but i get no interrupt: the only thing that changes is that the keyboard stops working.


Top
 Profile  
 
 Post subject: Re: Cant get PS2 Mouse interrupt to work
PostPosted: Tue May 09, 2023 6:21 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Without seeing more of your code it's hard to say for sure, but it sounds like you didn't unmask IRQ2 in the interrupt controller. You can't receive IRQ12 if IRQ2 is masked.

It's a good idea to separate your mouse driver from your PS/2 controller driver. Right now, your mouse driver is directly manipulating the PS/2 controller, which can interfere with the keyboard.


Top
 Profile  
 
 Post subject: Re: Cant get PS2 Mouse interrupt to work
PostPosted: Wed May 10, 2023 5:13 am 
Offline

Joined: Tue May 09, 2023 12:39 pm
Posts: 2
That was it! I needed to unmask IRQ2:
Code:
uint8_t oldpic1 = inb(PIC1_DATA);
outb(PIC1_DATA, oldpic1 & (~0b00000100)); // IRQ2

Right now the mouse and keyboard drivers are a mess, so I will take ur advice, thx!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: 8infy and 67 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group