[SOLVED] ATA DMA driver problem
Posted: Fri Oct 27, 2017 5:27 am
Hello everyone !
I have a working ATA PIO driver, but it is really slow, and since i have a scheduler i started to make an ATA DMA driver.
I followed the specs in "idems100.pdf" file and http://wiki.osdev.org/ATA/ATAPI_using_DMA on the wiki, but i'm stuck.
I end up waiting for an interrupt that never comes.
I'm using QEMU to test my kernel ; i did not test it on real hardware (because i can't right now) but i don't think that the problem comes from qemu.
The code is a bit messy, and some things that i should do during initialisation are done in the read function, but i really want to perform one working read and after that i'll clean up the whole thing.
If you want to read it, it's all on github : https://github.com/Valou3433/vk/blob/ma ... /ata_dma.c
I do :
- prepare a PRDT, with a pointer to a physical adress that is not aligned (is that a problem ? i'll fix that later but i don't know ; anyway i tried with aligned address it doesnt change anything)
- read BAR4 to get the ports
- reset start/stop bit
- send physical PRDT address
- set read bit in bus master command register
- clear err/interrupt bit
- select the drive (and send top 4 bits of LBA28 address)
- clean drive error port
- send sector count (which is actually one on the read that i have tried)
- send the rest of the LBA28 address
- poll for the drive BSY bit (is that really usefull ?)
- send DMA transfer command
- set the start/stop bit
- wait for an IRQ, that never comes (i know i should add a timeout in that case, but anyway the dma read doesnt work)
Am i doing something wrong ? i tried to find code samples or documentation, but they are really obscure about the whole thing...
Thanks for reading and trying to help me !
I have a working ATA PIO driver, but it is really slow, and since i have a scheduler i started to make an ATA DMA driver.
I followed the specs in "idems100.pdf" file and http://wiki.osdev.org/ATA/ATAPI_using_DMA on the wiki, but i'm stuck.
I end up waiting for an interrupt that never comes.
I'm using QEMU to test my kernel ; i did not test it on real hardware (because i can't right now) but i don't think that the problem comes from qemu.
The code is a bit messy, and some things that i should do during initialisation are done in the read function, but i really want to perform one working read and after that i'll clean up the whole thing.
If you want to read it, it's all on github : https://github.com/Valou3433/vk/blob/ma ... /ata_dma.c
I do :
- prepare a PRDT, with a pointer to a physical adress that is not aligned (is that a problem ? i'll fix that later but i don't know ; anyway i tried with aligned address it doesnt change anything)
- read BAR4 to get the ports
- reset start/stop bit
- send physical PRDT address
- set read bit in bus master command register
- clear err/interrupt bit
- select the drive (and send top 4 bits of LBA28 address)
- clean drive error port
- send sector count (which is actually one on the read that i have tried)
- send the rest of the LBA28 address
- poll for the drive BSY bit (is that really usefull ?)
- send DMA transfer command
- set the start/stop bit
- wait for an IRQ, that never comes (i know i should add a timeout in that case, but anyway the dma read doesnt work)
Am i doing something wrong ? i tried to find code samples or documentation, but they are really obscure about the whole thing...
Thanks for reading and trying to help me !