Is this code working properly to listen to IRQ ?
Posted: Fri May 30, 2014 4:12 pm
Hello,
I tried to the a PS2/Mouse driver, but I have some troubles with my IRQ I think, it is a bit strange because my keyboard work perfectly.
I wanted to know if this code was good or if I have not understand the IRQ concept.
Here I register listener:
Here is my ASM code:
This code is not really mine, I used a tutorial on a french website and I think the IRQ is not properly working, isn't it ?
My isr_default_int looks like not call, even if I had properly set up my mouse.
Thanks in advance
I tried to the a PS2/Mouse driver, but I have some troubles with my IRQ I think, it is a bit strange because my keyboard work perfectly.
I wanted to know if this code was good or if I have not understand the IRQ concept.
Here I register listener:
Code: Select all
#include "io.h"
#include "idt.h"
#include "driver/mouse.h"
void _asm_default_int(void);
void _asm_irq_0(void);
void _asm_irq_1(void);
void _asm_irq_12(void);
/*
* 'init_idt_desc' initialise un descripteur de segment situe en idt.
* 'desc' est l'adresse lineaire du descripteur a initialiser.
* L'argument 'type' doit avoir pour valeur INTGATE, TRAPGATE
* ou TASKGATE.
*/
void init_idt_desc(u16 select, u32 offset, u16 type, struct idtdesc *desc)
{
desc->offset0_15 = (offset & 0xffff);
desc->select = select;
desc->type = type;
desc->offset16_31 = (offset & 0xffff0000) >> 16;
return;
}
/*
* Cette fonction initialise la IDT apres que le kernel soit charge
* en memoire.
*/
void init_idt(void)
{
int i;
/* Initialisation des descripteurs systeme par defaut */
for (i = 0; i < IDTSIZE; i++)
init_idt_desc(0x08, (u32) _asm_default_int, INTGATE, &kidt[i]);// default handler
init_idt_desc(0x08, (u32) _asm_irq_0, INTGATE, &kidt[32]); /* horloge */
init_idt_desc(0x08, (u32) _asm_irq_1, INTGATE, &kidt[33]); /* clavier */
/* Initialisation de la structure pour IDTR */
kidtr.limite = IDTSIZE * 8;
kidtr.base = IDTBASE;
/* Recopie de la IDT a son adresse */
memcpy((char *) kidtr.base, (char *) kidt, kidtr.limite);
/* Chargement du registre IDTR */
asm("lidtl (kidtr)");
}
Code: Select all
extern isr_default_int, isr_clock_int, isr_kbd_int
global _asm_default_int, _asm_irq_0, _asm_irq_1
_asm_default_int:
call isr_default_int
mov al,0x20
out 0x20,al
iret
_asm_irq_0:
call isr_clock_int
mov al,0x20
out 0x20,al
iret
_asm_irq_1:
call isr_kbd_int
mov al,0x20
out 0x20,al
iret
My isr_default_int looks like not call, even if I had properly set up my mouse.
Thanks in advance