OSDev.org
https://forum.osdev.org/

[RESOLVED] ps/2 mouse initalization / keyboard interrupt
https://forum.osdev.org/viewtopic.php?f=1&t=24312
Page 1 of 2

Author:  megatron23 [ Sun Oct 23, 2011 3:58 pm ]
Post subject:  [RESOLVED] ps/2 mouse initalization / keyboard interrupt

If I initialize the mouse with SANiK's code and enable IRQ12 IRQ1 for keyboard input won't fire anymore. What could I have done wrong?

Author:  egos [ Sun Oct 23, 2011 4:10 pm ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

Show your ISR code for IRQ12.

Author:  megatron23 [ Sun Oct 23, 2011 4:19 pm ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

Code:
void mouse_handler() {
  uint8 mouse_stat = inportb(0x64);

  if ( !(mouse_stat & 0x01) || !(mouse_stat & 0x20) ) {
     return;
  }

  switch(mouse_cycle) {
    case 0:
      mouse_byte[0]=inportb(0x60);
      mouse_cycle++;
      break;
    case 1:
      mouse_byte[1]=inportb(0x60);
      mouse_cycle++;
      break;
    case 2:
      mouse_byte[2]=inportb(0x60);
      mouse_x=mouse_byte[1];
      mouse_y=mouse_byte[2];
      mouse_cycle=0;
      break;
  }
}

Author:  egos [ Sun Oct 23, 2011 6:51 pm ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

Well :) But where's EOI command?

Author:  megatron23 [ Mon Oct 24, 2011 3:27 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

egos wrote:
Well :) But where's EOI command?


That is in my ISR. I replied before you edited your reply from "Post your mouse handler".

The ISR calls the mouse_handler and EOI afterwards.
Other IRQs like 0 or 8 do fire, exept IRQ 1.

Author:  Bietje [ Mon Oct 24, 2011 3:37 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

What PIC mask did you set?

Author:  megatron23 [ Mon Oct 24, 2011 4:44 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

The pic mask set for IRQ12 is 0xEF on PIC2. Bit nr. 12 in word thus bit nr. 4 in byte for the dataport of pic 2.

Author:  Combuster [ Mon Oct 24, 2011 6:08 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

That's only the second half of the answer :wink:

Author:  megatron23 [ Mon Oct 24, 2011 6:50 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

It seems I missed the plot a little. Then what would be the first half? :?

Author:  egos [ Mon Oct 24, 2011 7:20 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

I think he means PIC1 mask.

Author:  megatron23 [ Mon Oct 24, 2011 8:38 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

I dont send a mask to PIC1 if I want to enable IRQ12.

The IRQ1 for keyboard is enabled elsewhere. It works without problems if I don't initialize the mouse.

Author:  egos [ Mon Oct 24, 2011 9:14 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

Does mouse work fine? Check program step by step to localise the fragment where keyboard is missed. Read controller command byte again to check that it is correct.

Author:  megatron23 [ Mon Oct 24, 2011 10:21 am ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

After enabling interrupts IRQ12 fires once where neither bit 0 nor bit 5 ist set in the byte from port 0x64. my handler then does not read data from port 0x60 and returns instead.

after that everything works as it should except IRQ1 does not fire anymore.

Author:  egos [ Mon Oct 24, 2011 12:28 pm ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

Controller command byte is the byte which you can read by command 20h. This byte contains "enable keyboard/mouse interrupt" bits and "disable keyboard/mouse" bits. Read and show this byte.

Author:  turdus [ Mon Oct 24, 2011 1:42 pm ]
Post subject:  Re: ps/2 mouse initalization / keyboard interrupt

megatron23 wrote:
After enabling interrupts IRQ12 fires once where neither bit 0 nor bit 5 ist set in the byte from port 0x64.

That could take a while to set. Read and check it in a loop (timeout). For example I try it 1000 times before saying it was a false IRQ.

Page 1 of 2 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/