floppy driver that does not use DMA

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
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

floppy driver that does not use DMA

Post 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.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: floppy driver that does not use DMA

Post 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
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: floppy driver that does not use DMA

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: floppy driver that does not use DMA

Post 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
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: floppy driver that does not use DMA

Post 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.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: floppy driver that does not use DMA

Post 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
Post Reply