Looks like osdev wiki example decrements count, and then only writes however much the last PRDT would read. Is that supposed to be that way?
Also, does AHCI use the byte count from the PRDT or (sector count) from this FIS to read sectors? What if I use byte count that's less/not aligned to sector size in PRDT?
Is there any specific reason why this example reads 8k per prdt?
Thanks
Wiki AHCI disk reading example broken?
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Wiki AHCI disk reading example broken?
That looks like a bug. The command FIS is sent directly over the wire unmodified, so it must tell the drive the total number of sectors to read.8infy wrote:Looks like osdev wiki example decrements count, and then only writes however much the last PRDT would read. Is that supposed to be that way?
The byte count in the PRDT tells the AHCI controller how many bytes it should expect to receive from the drive. The sector count in the CFIS tells the drive how many sectors to send.8infy wrote:Also, does AHCI use the byte count from the PRDT or (sector count) from this FIS to read sectors?
All of the entries in your PRDT need to add up to at least the total number of bytes you're going to read, but the individual entries only need to be aligned to 2-byte boundaries.8infy wrote:What if I use byte count that's less/not aligned to sector size in PRDT?
It's probably a misinterpretation of the spec. AHCI controllers are limited to 8kiB per DRQ data block, so you must avoid using PIO commands with larger DRQ data blocks. Most PIO commands transfer only one sector per DRQ data block, so you only need to look out for PACKET (without the DMA bit set) and the READ/WRITE MULTIPLE family of commands. The limit doesn't apply to DMA commands, and it definitely doesn't apply to the PRDT.8infy wrote:Is there any specific reason why this example reads 8k per prdt?
Re: Wiki AHCI disk reading example broken?
Awesome, thanks for the detailed answerOctocontrabass wrote:That looks like a bug. The command FIS is sent directly over the wire unmodified, so it must tell the drive the total number of sectors to read.8infy wrote:Looks like osdev wiki example decrements count, and then only writes however much the last PRDT would read. Is that supposed to be that way?
The byte count in the PRDT tells the AHCI controller how many bytes it should expect to receive from the drive. The sector count in the CFIS tells the drive how many sectors to send.8infy wrote:Also, does AHCI use the byte count from the PRDT or (sector count) from this FIS to read sectors?
All of the entries in your PRDT need to add up to at least the total number of bytes you're going to read, but the individual entries only need to be aligned to 2-byte boundaries.8infy wrote:What if I use byte count that's less/not aligned to sector size in PRDT?
It's probably a misinterpretation of the spec. AHCI controllers are limited to 8kiB per DRQ data block, so you must avoid using PIO commands with larger DRQ data blocks. Most PIO commands transfer only one sector per DRQ data block, so you only need to look out for PACKET (without the DMA bit set) and the READ/WRITE MULTIPLE family of commands. The limit doesn't apply to DMA commands, and it definitely doesn't apply to the PRDT.8infy wrote:Is there any specific reason why this example reads 8k per prdt?