Interupt Problem
Posted: Thu Feb 28, 2008 2:59 pm
Hey everyone,
I'm having a problem with interrupts. I have enabled interrupts (sti), initialized, remapped and unmasked the PIC, yet my interrupt handlers will not fire. If I call asm("int $0"); my divide by zero handler fires, and if I call asm("int $33"); my general interrupt handler fires and it calls the keyboard routine. But simply pressing keys does not work.
Here is my PIC configuration:
Any ideas or tips would be very helpful.
The below is included in case it is helpful.
Any ideas would be great
I'm having a problem with interrupts. I have enabled interrupts (sti), initialized, remapped and unmasked the PIC, yet my interrupt handlers will not fire. If I call asm("int $0"); my divide by zero handler fires, and if I call asm("int $33"); my general interrupt handler fires and it calls the keyboard routine. But simply pressing keys does not work.
Here is my PIC configuration:
Code: Select all
//tell PICs they are cascaded
outportb(0x20, 0x11);
outportb(0xA0, 0x11);
//normally IRQs 0 to 7 are mapped to entries 8 to 15.
//This does not work in protected mode, because IDT entry 8 is a
//double fault. Without remapping, every time IRQ 0 fires (timer),
//you would get a double fault exception
// We send commands to the PICs [aka i8259s] in order
//to make IRQ 0 through 15 be remapped to IDT entries to 32 through 47
outportb(0x21, 0x20);
outportb(0xA1, 0x28);
//set IRQ2 as connection to PIC slave
outportb(0x21, 0x04);
outportb(0xA1, 0x02);
//unmask all interrupts
outportb(0x21, 0x01);
outportb(0xA1, 0x01);
outportb(0x21, 0x0);
outportb(0xA1, 0x0);
The below is included in case it is helpful.
Code: Select all
void irqHandler(regs *state)
{
system.console<<endl<<"IRQ "<<state->intNum<<" fired."<<endl;
void (*handler)(regs *state);
handler = (void (*)(regs*))handlerIdt->irqHandlers[state->intNum - 32];
if (handler)
handler(state);
//if an irq then we need to send an EOI to the slave PIC
if (state->intNum >= 40)
outportb(0xA0, 0x20);
//Always send EOI to master PIC
outportb(0x20, 0x20);
}
irqCommonStub:
pusha
push ds
push es
push fs
push gs
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push eax
mov eax, _Z10irqHandlerP4regs
call eax
pop eax
pop gs
pop fs
pop es
pop ds
popa
add esp, 8
iret
irq0:
cli
push byte 0
push byte 32
jmp irqCommonStub
irq1:
cli
push byte 0
push byte 33
jmp irqCommonStub