Page 1 of 1

floppy driver that does not use DMA

Posted: Mon Feb 23, 2009 2:12 pm
by yemista
Hello, I am writing a floppy driver and have written most of it, but cannot figure out how to use it without the DMA. Is this just a matter of enabling the DMA bit in the digital output register? I cant quite get it working, but I bet there are a lot of other errors since I have no way to test it yet.

Re: floppy driver that does not use DMA

Posted: Mon Feb 23, 2009 2:17 pm
by AJ
Hi,

I had a go at this myself a while ago and hit a couple of problems:

1. Many VMs/Emulators did not appear to fully support floppy PIO because it's not very common. Apparently real hardware can be buggy too.
2. I seem to remember hitting a problem with not recieving the data I was expecting - I got the result phase OK, but not the data.

Basically, most tutorials use DMA. If you want PIO, you pretty much have to do it from the datasheet.

Cheers,
Adam

Re: floppy driver that does not use DMA

Posted: Mon Feb 23, 2009 9:20 pm
by yemista
the reason i did not want to go this route is if you have to have a dma driver to test the floppy driver, and you need a floppy driver or some other disk driver to test the dma driver, youll never know why it doesnt work if it doesnt work

Re: floppy driver that does not use DMA

Posted: Tue Feb 24, 2009 2:41 am
by AJ
Fair point, but generally the reason that my floppy driver didn't work is because I used PIO :)

The DMA really isn't that hard - once it is set up to expect data, the floppy controller does the rest. The only reason why my OS has no place for a DMA floppy driver is that I much prefer stack physical frame allocation, and I see no reason why I should have a separate memory allocation routine specifically for low memory, purely because of legacy DMA. If you are using bitmap allocation or already have separate low memory allocation, I'd go with a DMA floppy driver every time.

Cheers,
Adam

Re: floppy driver that does not use DMA

Posted: Tue Feb 24, 2009 2:45 am
by xenos
Debugging a DMA driver and a floppy driver at the same time shouldn't be a big problem, once you have a clear interface between them. I assume:
  • The floppy driver is called on a read / write request, programs the floppy controller for reading / writing data using DMA and calls the DMA driver to set um DMA.
  • The DMA driver is called by the floppy driver and programs the DMA chip.
If you want to test and debug this, you can locate the error by checking the data flow. Just write everything to console or some log region in RAM (which you can dump using Bochs or whatever simulator you like). Then answer the following questions:
  • Does the floppy driver send the right commands to the floppy controller? If not, the floppy driver is buggy.
  • Does the floppy driver send the right request parameters to the DMA driver? If not, the floppy driver is buggy.
  • Does the DMA driver send the right commands to the DMA controller? If not, the DMA driver is buggy.

Re: floppy driver that does not use DMA

Posted: Tue Feb 24, 2009 3:01 am
by AJ
Hi,

Just as an addition to the above, if you use bochs you can log all debug events for the DMA and (this will produce a lot of output) the FDD. This should let you know what all your commands have done to the internal device registers. If it then fails to work on real hardware, check timings first!

Cheers,
Adam