I can't receive secend IDE IRQ.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
626788149
Member
Member
Posts: 25
Joined: Mon Oct 26, 2015 7:24 am
Location: Guilin,China

I can't receive secend IDE IRQ.

Post 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));
}
Last edited by 626788149 on Fri Dec 11, 2015 1:43 am, edited 1 time in total.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: I can't receive secend IDE IRQ.

Post by iansjack »

If you get one interrupt and no more it usually means that you aren't acknowledging the interrupt.
sebihepp
Member
Member
Posts: 190
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: I can't receive secend IDE IRQ.

Post 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.
626788149
Member
Member
Posts: 25
Joined: Mon Oct 26, 2015 7:24 am
Location: Guilin,China

Re: I can't receive secend IDE IRQ.

Post 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;
		}
626788149
Member
Member
Posts: 25
Joined: Mon Oct 26, 2015 7:24 am
Location: Guilin,China

Re: I can't receive secend IDE IRQ.

Post 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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: I can't receive secend IDE IRQ.

Post 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.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: I can't receive secend IDE IRQ.

Post 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.
Post Reply