Page 1 of 1

Interrupt problem

Posted: Mon Aug 20, 2007 7:25 pm
by aninggo
i install the GDT and IDT success,i register the exceptions and time Interrupt, i use the

Code: Select all

 int a = 3, b = 0;
 a/=b;
test the exceptions, it's work fine; but time Interrupt is not work.

idt creat

Code: Select all

void IDT::createIdt(int n,uint offset,ushort selector,byte options)
{
	InterruptDescriptorTable *idt=(InterruptDescriptorTable*) IDT_BASE + n;
	ushort lOff,uOff;
	
	lOff = offset & 0x0000FFFF;		// Clear First 16 bits
	uOff = (offset & 0xFFFF0000) >> 16;	// Clear Lower 16 bits

	idt->lowerOffset = lOff;
	idt->selector = selector;
	idt->reserved = 0x00;
	idt->options = options;
	idt->upperOffset = uOff;
}
IRQ initialize

Code: Select all


	outb ( MASTER_PORT_A , 0x11 );
	outb ( SLAVE_PORT_A  , 0x11 );

	outb ( MASTER_PORT_B , 0x20);
	outb ( SLAVE_PORT_B  , 0x28);

	outb ( MASTER_PORT_B , 0x04);
	outb ( SLAVE_PORT_B  , 0x02);

	outb ( MASTER_PORT_B , 0x01);
	outb ( SLAVE_PORT_B  , 0x01);

	outb ( MASTER_PORT_B , 0xFF);
	outb ( SLAVE_PORT_B  , 0xFF);
	asm("sti");
enableIRQ

Code: Select all

void PIC::enableIRQ ( byte irq )
{
	if(irq > 15) return;

	if(irq < 8)
	{
		outb(MASTER_PORT_B,inb(MASTER_PORT_B)&irq);

	}
	else
	{
		irq = irq - 8;
		IRQSlaveStatus |= ( 0x01 << irq );
		outb(SLAVE_PORT_B,(byte) ~IRQSlaveStatus);
		IRQMasterStatus = IRQMasterStatus | 0x04;
		outb(MASTER_PORT_B,(byte) ~IRQMasterStatus);
	}
}

Code: Select all

(0) [0x00007575] 0008:00007575 (unk. ctxt): jmp .+0xfffffffe (0x00007575) ; ebfe
<bochs:3> info cpu
eax:0x00000202, ebx:0x00008c00, ecx:0x000b809e, edx:0x000b8001
ebp:0x00000000, esp:0x0000fb70, esi:0x00007154, edi:0x00005000
eip:0x00007575, eflags:0x00000206, inhibit_mask:0
cs:s=0x0008, dl=0x00000fff, dh=0x00c09a00, valid=1
ss:s=0x0010, dl=0x00000fff, dh=0x00c09300, valid=7
ds:s=0x0010, dl=0x00000fff, dh=0x00c09200, valid=7
es:s=0x0010, dl=0x00000fff, dh=0x00c09300, valid=1
fs:s=0x0010, dl=0x00000fff, dh=0x00c09300, valid=1
gs:s=0x0010, dl=0x00000fff, dh=0x00c09300, valid=1
ldtr:s=0x0000, dl=0x0000ffff, dh=0x00008200, valid=1
tr:s=0x0000, dl=0x0000ffff, dh=0x00008300, valid=1
gdtr:base=0x00006000, limit=0x800
idtr:base=0x00006800, limit=0x110
dr0:0x00000000, dr1:0x00000000, dr2:0x00000000
dr3:0x00000000, dr6:0xffff0ff0, dr7:0x00000400
cr0:0x80000011, cr1:0x00000000, cr2:0x00000000
cr3:0x00000000, cr4:0x00000000
done

Posted: Mon Aug 20, 2007 7:35 pm
by prajwal
When you say time interrupt its the timer interrupt, right??
Did u initialize/setup PIT (Programmable Interrupt Timer), which raises IRQ 1 (Timer Interrupt) periodically based on how it is setup / programmed...

Posted: Mon Aug 20, 2007 7:45 pm
by aninggo
yes,i say the timer interrupt,my english is not good So i try one's best to depict clarity:)

the pit initialize

Code: Select all

void PIT::initialize(
		PIC * pic,
		IDT * idt
		)
{
	static ushort count = PIT_FREQUENCY / 60;
	outb(PIT_MODE,0x36);
	outb(PIT_COUNTER0,(byte) count & 0xFF);	
	outb(PIT_COUNTER0,(byte) count >> 8);

	idt->createEntry (
		0x20,(uint)&Handler_TimerIRQ,
		CS_SELECTOR,TRAP_GATE|PRESENT|RING0|BITS32
			);
  
	pic->enableIRQ(TIMER);
}

Posted: Tue Aug 21, 2007 1:44 am
by cyr1x
mosman wrote:..., which raises IRQ 1 (Timer Interrupt) periodically based on how it is setup / programmed...
Afaik it's IRQ 0 , IRQ 1 is for the keyboard.