I was not using IRQs,just poll (wait for DRQ set).It's successful!!!
Now I try to wait for IRQ arrives. I failed.
Code: Select all
requestIRQ(14,&ideIRQPrimary);
requestIRQ(15,&ideIRQSecondary);
/*I had written a timer interrupt,so this code should have no problems.*/
ideOutb(IDE_PRIMARY ,IDE_REG_CONTROL,IDE_ENABLE_IRQ);
ideOutb(IDE_SECONDARY,IDE_REG_CONTROL,IDE_ENABLE_IRQ);
Code: Select all
const u8 primary = device->primary;
const u8 master = device->master;
u8 cmd[12] = {0xa8 /*READ (12).*/,0,0,0,0,0,0,0,0,0,0,0};
/*SCSI Command.*/
ideWaitReady(primary);
ideOutb(primary,IDE_REG_DEV_SEL,master << 4);
for(int i = 0;i < 4;++i) /*A little delay.*/
ideInb(primary,IDE_REG_CONTROL);
ideOutb(primary,IDE_REG_FEATURES,0x0); /*PIO Mode.*/
ideOutb(primary,IDE_REG_LBA1,(ATAPI_SECTOR_SIZE & 0xff));
ideOutb(primary,IDE_REG_LBA2,((ATAPI_SECTOR_SIZE >> 8)) & 0xff);
ideOutb(primary,IDE_REG_COMMAND,IDE_CMD_PACKET);
if(ideWaitInterrupt(device))
return -1; /*Return if error.*/
/*But if not,ideWaitInterrupt never returns. IRQ never arrivers,why?*/
Code: Select all
/*Do other things.*/
Code: Select all
static int ideIRQPrimary(IRQRegisters *reg,void *data)
{
printk("IDE IRQ arrives!\n");
Code: Select all
/*So this code below never runs.*/
u8 status = ideInb(IDE_PRIMARY,IDE_REG_STATUS);
if(!data)
return 0;
IDEInterruptWait *wait = (IDEInterruptWait *)data;
if(wait->primary != IDE_PRIMARY)
return 0;
wait->status = status;
wakeUpTask(wait->task);
return 0;
}
But I poll successfully and fail to wait for an IRQ.What's the reason???
Thanks.
