IRQ1 (keyboard) won't fire!
Posted: Sat Mar 05, 2011 1:36 am
Hitting the walls to no end with this, so finally coming to ask for help.
Here's my code i've used to remap PIC, rest assured my IDT is setup and up.
PIT does fires with this code when I write 0x00 to PIC_MASTER_DATA_PORT. I can see it appearing again and again for this interrupt hence i disabled timer to concentrate on keyboard.
Here's how i handler interrupts, through a common isr_routine.
Kindly help me! i wish to make it working by weekend otherwise it'll take another week for me to return to this
I'm using
Here's my code i've used to remap PIC, rest assured my IDT is setup and up.
Code: Select all
#define PIC_MASTER_COMMAND_PORT 0x20
#define PIC_MASTER_DATA_PORT PIC_MASTER_COMMAND_PORT+1
#define PIC_SLAVE_COMMAND_PORT 0xA0
#define PIC_SLAVE_DATA_PORT PIC_SLAVE_COMMAND_PORT+1
#define PIC_ICW1_COMMAND 0x11
#define PIC_ICW4_SLAVE 0x01
#define PIC_ICW4_MASTER 0x05
#define PIC_ICW2_MASTER 0x20
#define PIC_ICW2_SLAVE 0x28
#define PIC_ICW3_MASTER 0x04 //SLAVE's PIN NO.
#define PIC_ICW3_SLAVE 0x02 //Master's PIN NO, connected to slave.
outb(PIC_MASTER_COMMAND_PORT,PIC_ICW1_COMMAND);
outb(PIC_SLAVE_COMMAND_PORT,PIC_ICW1_COMMAND);
outb(PIC_MASTER_DATA_PORT,PIC_ICW2_MASTER);
outb(PIC_SLAVE_DATA_PORT,PIC_ICW2_SLAVE);
outb(PIC_MASTER_DATA_PORT,PIC_ICW3_MASTER);
outb(PIC_SLAVE_DATA_PORT,PIC_ICW3_SLAVE);
outb(PIC_MASTER_DATA_PORT,PIC_ICW4_MASTER);
outb(PIC_SLAVE_DATA_PORT,PIC_ICW4_SLAVE);
//enable all interrupts
outb(PIC_MASTER_DATA_PORT,0xFD);
outb(PIC_SLAVE_DATA_PORT,0x00);
Here's how i handler interrupts, through a common isr_routine.
Code: Select all
void isr_handler(PushRegisters *regs)
{
unsigned int intrnum=regs->procpushed.intr_num;
//printk("Will execute interrupt %d\n",intrnum);
if( handlers[intrnum].handler!=NULL)
{
handlers[intrnum].regs=*regs;
//Put a spinlock above this line when handling SMP.
handlers[intrnum].flags=ISR_BUSY;
//this handler shall be scheduled based on the flags.
//if(!handlers[intr_num].flags==ISR_BUSY)
handlers[intrnum].handler(&handlers[intrnum].regs); //call isr.
//we'll need to find a way to declare that an isr is free to be reloaded
//with another ISR handler or that it may be called.
//currently since interrupts get disabled so ISR gets executed always.
handlers[intrnum].flags=ISR_FREE;
}
else
{
handleExceptions(regs);
}
if(intrnum >31 && intrnum <40)
{
printk("sending master eoi and masking forever.\n");
if(intrnum==33) inb(0x60);//read from keyboard.
//outb(PIC_MASTER_DATA_PORT,1<<(intrnum-32));
outb(PIC_MASTER_COMMAND_PORT,0x20); //send EOI to master.
}
else if(intrnum >=40)
{
printk("sending both eoi\n");
outb(PIC_SLAVE_COMMAND_PORT,0x20); //Send EOI to slave.
outb(PIC_MASTER_COMMAND_PORT,0x20); //Send EOI to master.
}
}
I'm using
Bochs x86 Emulator 2.4.5
Build from CVS snapshot, on April 25, 2010