Disk I/O (ATA IDE) problem

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
pranays
Posts: 3
Joined: Tue Jun 14, 2011 11:25 pm

Disk I/O (ATA IDE) problem

Post by pranays »

Hi guys,

I'm using bochs and have been trying my hands on writing a interrupt based disk I/O transfer mechanism. I'm really stuck and can't figure out what's happening and more importantly why its happening. So here's what i did and my problems and questions
Currently i'm not using any DMA. So What i've right now is that the IDE drive will interrupt my kernel after command and my ISR will then read data using PIO. I will move to DMA but i must first get this working.
  1. The first thing i was able to do IDENTIFY and my ISR got called and I was able to read data. OK, now at the end of ISR i read from port 0x1f7 because I read on the ATA PIO page on this website that you gotta read it to clear the INTR signal from the device. This reports that Status register has value of 0x50 which means that DRDY is set so i can issue other commands correct?
  • Second, I try to do READ SECTOR(0x20) and while checking the status register in this function i get the value as 0x00. So that means Drive isn't BUSY but drive isn't READY too. When can this happen?
  • Now I remove the IDENTIFY COMMAND routine and only use READ SECTOR function. This time it works. SO i'm guessing there's something about IDENTIFY which i don't know yet.
I've the documents from t13, i've read it again n again. I'm not sure what else to do... feel like stabbing that IDE drive seriously :evil:

Help me out guys plz... [-o< [-o<
RaffoPazzo
Posts: 23
Joined: Tue Apr 05, 2011 11:34 am

Re: Disk I/O (ATA IDE) problem

Post by RaffoPazzo »

pranays wrote:
  1. The first thing i was able to do IDENTIFY and my ISR got called and I was able to read data. OK, now at the end of ISR i read from port 0x1f7 because I read on the ATA PIO page on this website that you gotta read it to clear the INTR signal from the device. This reports that Status register has value of 0x50 which means that DRDY is set so i can issue other commands correct?
  • Second, I try to do READ SECTOR(0x20) and while checking the status register in this function i get the value as 0x00. So that means Drive isn't BUSY but drive isn't READY too. When can this happen?
  • Now I remove the IDENTIFY COMMAND routine and only use READ SECTOR function. This time it works. SO i'm guessing there's something about IDENTIFY which i don't know yet.
I'm not understanding something. You said you read 0x50 from the Status register after you have acknowledged the INTR and while trying a read sector you got 0x00 from the Status register. When exactly you read the Status register? I think just before writing all the read sector command parameters. In which case, those two reading from Status register should happen close to each other, which have to result in the same value been read.
Maybe posting your code would help me in comprehension.
pranays
Posts: 3
Joined: Tue Jun 14, 2011 11:25 pm

Re: Disk I/O (ATA IDE) problem

Post by pranays »

I'm in office right now, so don't have my code here. I'll be able to post it in evening though when i get back home.

As for the reading of status, I do it while filling in the ports value for READ SECTOR command. That's where i read 0x0.

The 0x50 I get is just before ACKing the interrupt i got when i executed the IDENTIFY command, so in my ISR i read from the register 0x1f7 so that i clear the INTR and i print the value which is 0x50 in my case.

The problem seems to be some where with the IDENTIFY, it is "doing something" i guess but idk what it does that i can't do READ SECTOR. If I leave IDENTIFY and send the same values to ports for READ SECTORS command it works.
Post Reply