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.
Hi all,
I decided to write an ATAPI driver for my operating system. Currently I am having some issues with reading data. After sending the packet, there's no IRQ from the IDE controller. Any ideas why that happened, and how can I fix it?
This is the code that does the reading:
First, check that all of your constants are defined properly. They aren't listed here, so I just have to assume they are correct.
Second, depending on how your IRQ handler is set up, you may have a race condition after the first wait for IRQ. You may want to set your counter to zero, then wait for it to increment to one, read the buffer size, then wait for it to increment to 2, instead of resetting it to zero again.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
SpyderTL wrote:First, check that all of your constants are defined properly. They aren't listed here, so I just have to assume they are correct.
Second, depending on how your IRQ handler is set up, you may have a race condition after the first wait for IRQ. You may want to set your counter to zero, then wait for it to increment to one, read the buffer size, then wait for it to increment to 2, instead of resetting it to zero again.
First of all, my constants are all correct. Secondly, the whole thing gets stuck at the while loop right after sending the packet (and yes the counter is volatile). I even put a debug message in the IRQ handler and it didn't even show up, so I'm sure it's not a race condition problem.
Just a procrastinating uni student doing stupid things (or not doing them at all)...
Try removing the ide_irqrecv = 0 lines, and just print the value of this variable at each step, and inside of your while loop to make sure the IRQ counter is acting as expected. This will at least tell you where to look for the problem.
Also, you may get different IRQ numbers for different drives, and definitely for different controllers, so make sure your one IDE counter is hooked up to the correct IRQ, or set up multiple counters and check the correct counter in your code above.
If your code above works on BOCHS, then what other hardware/VMs have you tested that do not work?
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott