Page 1 of 1

I can't receive secend IDE IRQ.

Posted: Fri Dec 11, 2015 12:44 am
by 626788149
Ok, I find out the problem, I just forget ide_wait_ready() before read the port.








When I start a hard disk read ,e.g ide_read(0, buf, 1);

I indeed can receive a IDE IRQ, But if I read hard disk again in interrupt handler, I can't receive a IDE IRQ anymore.

Code: Select all

int
ide_read(uint32_t secno, void *dst, size_t nsecs)
{
	int r;

	assert(nsecs <= 256);

	ide_wait_ready(0);
	outb(0x1F2, nsecs);
	outb(0x1F3, secno & 0xFF);
	outb(0x1F4, (secno >> 8) & 0xFF);
	outb(0x1F5, (secno >> 16) & 0xFF);
	outb(0x1F6, 0xE0 | ((diskno&1)<<4) | ((secno>>24)&0x0F));
	outb(0x1F7, 0x20);	// CMD 0x20 means read sector

	
	return 0;
}


static void 
do_hd_interrupt(struct frame *tf)
{
	printk("CPU:%d IRQ_IDE \n",get_cpuid()); 

	insl(0x1F0, buf, 512/4);
	

	get_stat();
	ide_read(200, buf, 1);
	get_stat();
	
	printk("%x\n",inb(0x3F6));
}

Re: I can't receive secend IDE IRQ.

Posted: Fri Dec 11, 2015 12:54 am
by iansjack
If you get one interrupt and no more it usually means that you aren't acknowledging the interrupt.

Re: I can't receive secend IDE IRQ.

Posted: Fri Dec 11, 2015 1:13 am
by sebihepp
It could also be due to the setup of the IDT. For Interrupt Gates, interrupts will be disabled on entry of isr and reenabled on leave.

Re: I can't receive secend IDE IRQ.

Posted: Fri Dec 11, 2015 1:21 am
by 626788149
iansjack wrote:If you get one interrupt and no more it usually means that you aren't acknowledging the interrupt.
I think this is not a problem of acknowledging the interrupt.

Code: Select all

case IRQ_IDE : 
		{	
			
			__asm __volatile("movb $0x20,%al\n\toutb %al,$0x20\n\tmovb $0xA0,%al\n\toutb %al,$0x20");
			lapic_eoi();

			do_hd_interrupt(tf);
			break;
		}

Re: I can't receive secend IDE IRQ.

Posted: Fri Dec 11, 2015 1:26 am
by 626788149
sebihepp wrote:It could also be due to the setup of the IDT. For Interrupt Gates, interrupts will be disabled on entry of isr and reenabled on leave.
Yes, I Know, When leave interrupt handler ,My kernel will run a user task. And I can't receive IDE IRQ anymore, But I can always receive Keyboard IRQ If
I push a key.

Re: I can't receive secend IDE IRQ.

Posted: Fri Dec 11, 2015 3:04 am
by iansjack
I can't see you reading the status register after transferring the data. It could be in your "get_stat()" function, but that's a black box to me.

Re: I can't receive secend IDE IRQ.

Posted: Fri Dec 11, 2015 5:21 am
by alexfru
626788149 wrote:And I can't receive IDE IRQ anymore, But I can always receive Keyboard IRQ If I push a key.
That suggests that you're doing everything right on the CPU side of interrupt handling, but not on the device side.