mouse irq problem

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
ahmedhalawa
Member
Member
Posts: 28
Joined: Wed Jul 02, 2008 9:28 am

mouse irq problem

Post by ahmedhalawa »

Peace for all (Greeting of Islam)
************************
After I had written mouse interrupt and testing it int qemu manger
Exception had happend the exception is "page fult" that happen after moving mouse if mouse still without move,exception couldn't happend ?
the frist code is mouse_install

Code: Select all

 mouse *m = new mouse();
 m->mouse_install();
 IntManager::setHandler(44,m);
 PIC::enableIRQ(2);
 PIC::enableIRQ(12);
the second code is moue irq

Code: Select all

//mouse.cpp
#include "./include/mouse.h"
#include "./include/pic.h"
#include "../include/system.h"
#include "../include/video.h"
BYTE mouse_cycle=0;
signed char mouse_byte[3];
signed char mouse_x=0;
signed char mouse_y=0;
int    x,y;
mouse::mouse()
{
}
void mouse::handle(regs* r, int vector, int errorCode)
{
    Video *v;
    switch(mouse_cycle)
    {
        case 0:
              mouse_byte[0]=Machine::inb(0x60);
              mouse_cycle++;
              break;
        case 1:
              mouse_byte[1]=Machine::inb(0x60);
              mouse_cycle++;
              break;
        case 2:
              mouse_byte[2]=Machine::inb(0x60);
              mouse_x      =mouse_byte[1];
              mouse_y      =mouse_byte[2];
              mouse_cycle =0;
              v->printfAt(mouse_x,mouse_y,"A");

    }
	PIC::acknowledgePIC2();
}

void mouse_wait(BYTE type) //unsigned char
{
  DWORD _time_out=100000;
  if(type==0)
  {
    while(_time_out--) //Data
    {
      if((Machine::inb(0x64) & 1)==1)
      {
        return;
      }
    }
    return;
  }
  else
  {
    while(_time_out--)
    {
      if((Machine::inb(0x64) & 2)==0)
      {
        return;
      }
    }
    return;
  }
}
void mouse_write(BYTE a_write)
{
  mouse_wait(1);
  Machine::outb(0x64, 0xD4);
  mouse_wait(1);
  Machine::outb(0x60, a_write);
}

BYTE mouse_read()
{
  mouse_wait(0);
  return Machine::inb(0x60);
}

void mouse::mouse_install()
{
  BYTE _status;
  mouse_wait(1);
  Machine::outb(0x64, 0xA8);
  mouse_wait(1);
  Machine::outb(0x64, 0x20);
  mouse_wait(0);
  _status=(Machine::inb(0x60) | 2);
  mouse_wait(1);
  Machine::outb(0x64, 0x60);
  mouse_wait(1);
  Machine::outb(0x60, _status);
  mouse_write(0xF6);
  mouse_read();
  mouse_write(0xF4);
  mouse_read();
}
#ifndef mouse_H_
#define mouse_H_

#include "../../include/system.h"
#include "../../include/interrupt.h"


class mouse: public Interrupt
{

public:
mouse();
void handle(regs* r, int vector, int errorCode);
void mouse_install();
};

#endif /*TIMER_H_*/

Code: Select all


what is the problem? :?: 
I remeber some thing thar exception does not happen when I move the mouse but it happen after writeing then moveing mouse
/*******/
i'm so sorry for my english
Peace for all
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: mouse irq problem

Post by jal »

ahmedhalawa wrote:what is the problem?
That pretty much depends on code you didn't show. A page fault usually happens when you are trying to execute code that is on a page that's not available. The only reason I can think of why this happens in your case is that there's something wrong with your IntManager class, or of course with your memory management routines - neither of which are available to us.

Peace for those deserving,


JAL
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: mouse irq problem

Post by bewing »

What JAL says is correct. You may also have additional problems because I don't see you doing an AcknowledgePIC12 ... or whatever you need to do to handle the IRQ12. And you are not waiting for an ACK from the keyboard (I think your mouse_read function would be sufficient) after sending the 0xA8 command.

Do you have virtual memory running? If so, do you know what memory address the code is trying to access, that generates the page fault?
User avatar
ahmedhalawa
Member
Member
Posts: 28
Joined: Wed Jul 02, 2008 9:28 am

Re: mouse irq problem

Post by ahmedhalawa »

I think I must attachment my src file

jal:

And there is no error on my memory manger
I have tasted it form 1 to 10
Peace for those deserving that is right but we need peace for every body not for one(peace for all is an Islam instructions and we must do that)

bewing:
AcknowledgePIC12: I have do that look at the code
which I've written it have,AcknowledgePIC2
AcknowledgePIC2 : it send EIO for pic and
pic2
===================================================
pleas from every body say small words which point to what would you want to say :idea:
Attachments
ahmed_halawa_src.rar
(38.17 KiB) Downloaded 57 times
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: mouse irq problem

Post by jal »

ahmedhalawa wrote:Peace for those deserving that is right but we need peace for every body not for one(peace for all is an Islam instructions and we must do that)
Well, let's not start a religious war here :) Suffice to say that I don't feel compelled to follow instructions of such a destructive religion. As for the source code, I'll take a look at it later this week, when I have some more time (possibly already tomorrow, but can't make a promise).


JAL
Post Reply