mouse irq problem
Posted: Tue Jul 08, 2008 7:15 am
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
the second code is moue irq
#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_*/
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
************************
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);
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();
}
#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'm so sorry for my english
Peace for all