[RESOLVED] ps/2 mouse initalization / keyboard interrupt

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.

Moderators: JAAman, klange, Octocontrabass, sortie, kmcguire, chase, thepowersgang, Owen, Combuster, AJ, 01000101, carbonBased, Candy, pcmattman

megatron23
Posts: 19
Joined: Sat Oct 22, 2011 3:03 pm

[RESOLVED] ps/2 mouse initalization / keyboard interrupt

Post by megatron23 »

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?
Last edited by megatron23 on Wed Oct 26, 2011 6:24 am, edited 2 times in total.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by egos »

Show your ISR code for IRQ12.
If you have seen bad English in my words, tell me what's wrong, please.
megatron23
Posts: 19
Joined: Sat Oct 22, 2011 3:03 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by megatron23 »

Code: Select all

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;
  }
}
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by egos »

Well :) But where's EOI command?
If you have seen bad English in my words, tell me what's wrong, please.
megatron23
Posts: 19
Joined: Sat Oct 22, 2011 3:03 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by megatron23 »

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.
Bietje
Member
Member
Posts: 100
Joined: Wed Apr 20, 2011 6:57 am

Re: ps/2 mouse initalization / keyboard interrupt

Post by Bietje »

What PIC mask did you set?
megatron23
Posts: 19
Joined: Sat Oct 22, 2011 3:03 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by megatron23 »

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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Freenode IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: ps/2 mouse initalization / keyboard interrupt

Post by Combuster »

That's only the second half of the answer :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
megatron23
Posts: 19
Joined: Sat Oct 22, 2011 3:03 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by megatron23 »

It seems I missed the plot a little. Then what would be the first half? :?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by egos »

I think he means PIC1 mask.
If you have seen bad English in my words, tell me what's wrong, please.
megatron23
Posts: 19
Joined: Sat Oct 22, 2011 3:03 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by megatron23 »

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.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by egos »

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.
If you have seen bad English in my words, tell me what's wrong, please.
megatron23
Posts: 19
Joined: Sat Oct 22, 2011 3:03 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by megatron23 »

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.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by egos »

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.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: ps/2 mouse initalization / keyboard interrupt

Post by turdus »

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