PS/2 Mouse Interrupts not triggering

60 Views Asked by At

I have a problem and i just cant seem to fix it. I created my IDT, remapped my PIC and got keyboard input to work. Now I wanted to add mouse input, but it just doesnt work.

#define PS2_DATAPORT 0x60
#define PS2_CMDPORT  0x64

void mouse_driver()
{
    outportb(PS2_CMDPORT, 0xA8);
    outportb(PS2_CMDPORT, 0x20);
    
    uint8_t status = inportb(PS2_DATAPORT) | 2;
    
    outportb(PS2_CMDPORT, 0x60);
    outportb(PS2_DATAPORT, status);

    outportb(PS2_CMDPORT, 0xD4);
    outportb(PS2_DATAPORT, 0xFA);
    
    inportb(PS2_DATAPORT);
}

void _start()
{
    idt_init();
    idt_set_entry(0x2C, (uint32_t)isr44, 0x08, 0x8E);
    isr_set_handler(0x2C, handler_mouse);
    mouse_driver();
    idt_create();
 
    while(1) {}
}

uint8_t inportb(uint16_t port)
{
    uint8_t out;
    __asm__("inb %1, %0" : "=a" (out) : "dN" (port));
    return out;
}

void outportb(uint16_t port, uint8_t data) 
{
    __asm__("outb %1, %0" : : "dN" (port), "a" (data));
}

void pic_remap(int offset_master, int offset_slave)
{
    // Remap the PIC (=Programmable Interrupt Controller)
    outportb(PIC_MASTER, 0x11);
    outportb(PIC_SLAVE, 0x11);
    outportb(PIC_MASTER_DATA, offset_master);
    outportb(PIC_SLAVE_DATA, offset_slave);
    outportb(PIC_MASTER_DATA, 4);
    outportb(PIC_SLAVE_DATA, 2);

    outportb(PIC_MASTER_DATA, 0x01);
    outportb(PIC_SLAVE_DATA, 0x01);

    // mask
    outportb(PIC_MASTER_DATA, 0xFD);
    outportb(PIC_SLAVE_DATA, 0xFF);
}

Thought this would do the trick but still, the interrupt ist triggered. IDT is working calling the interrupt with int $0x2c leads to desired result. Any help would be much appreciated. Let me know if i should provide more code details! Thanks a lot.

Edit 1: I think it might have something to do with the mask… do i need to change the bit at position 4 at the slaves mask to a 0?

0

There are 0 best solutions below