FDC without 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
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

FDC without DMA

Post by neon »

Hello everyone,

I am somewhat stuck here. Basically, I have the FDC operating in Non-DMA mode. When I issue a test read command to the FDC:

Code: Select all

flpydsk_send_command (
			FDC_CMD_READ_SECT | FDC_CMD_EXT_MULTITRACK | FDC_CMD_EXT_SKIP | FDC_CMD_EXT_DENSITY);
flpydsk_send_command ( 0);//head << 2 | _CurrentDrive );
flpydsk_send_command ( 0);//track);
flpydsk_send_command ( 0);//head);
flpydsk_send_command ( 1);//sector);
flpydsk_send_command ( FLPYDSK_SECTOR_DTL_512 );
flpydsk_send_command ( 18 );//FLPY_SECTORS_PER_TRACK );	//! --can be last sector to transfer...
flpydsk_send_command ( FLPYDSK_GAP3_LENGTH_3_5 );
flpydsk_send_command ( 512);
The command only seems to work when sectors per track is 512. Bochs just halts without any errors or warnings (besides Non-DMA not being fully supported of course.)

I get an IRQ afterwords for the completion of the command where the status (st0) says everything is fine. No other interrupt is generated.

The specifications state that I should get an IRQ for every byte transferred before the results phase but I do not, which is where my problem is at. Im not sure where else to look at the moment... :?

Does anyone have any suggestions at where I might be going wrong? I am happy with posting more code if needed.

Thanks for any help :)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
yemista
Member
Member
Posts: 299
Joined: Fri Dec 26, 2008 12:31 pm
Location: Boston
Contact:

Re: FDC without DMA

Post by yemista »

My floppy driver is not currently working, but back when I was working on it I also had trouble getting it to work in non-DMA mode, and from research and forums answers, the best I found was dont do it. It doesnt really work without DMA, and non-DMA mode is from way back, and bochs doesnt really support it or something along those lines
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: FDC without DMA

Post by earlz »

Most emulators don't support it, and also I've learned quite a few physical floppy drives don't support it.. I think Dex said he had it working at one point(Which is why he can boast his floppy driver is 20% faster than both Linux and Windows and very probably any other sane OS, as non-DMA sketchy, but on those that it does work, it's very fast... )
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: FDC without DMA

Post by bontanu »

earlz wrote:... and also I've learned quite a few physical floppy drives don't support it..
Unlikely. The FDC controller has a NDMA bit exactly for this hence "almost all" controllers support non-DMA operations.

However you might be right about emulators because emulators usually support only the operations of well known OS like Windows or Linux (sometimes).
I think Dex said he had it working at one point(Which is why he can boast his floppy driver is 20% faster than both Linux and Windows
Not possible. The non-DMA mode is slower than DMA mode because:
1) You receive 1 IRQ at each byte transferred and this slows things down.
2) You must handle each byte very fast inside the IRQ in software as opposed to DMA hardware.

Besides there is no purpose of doing this because the floppy DMA channel is hardwired to the floppy controller and if you do not use it then you waste it because it can not be used to anything else.

Solar OS once had a floppy driver in non DMA mode but I have removed it because it had no purpose anymore once I had the DMA version functional.

Hence the only purpose for non-DMA is testing until you get DMA working.
and very probably any other sane OS, as non-DMA sketchy, but on those that it does work, it's very fast... )
Dreams and illusions. Non DMA is in no way faster. In fact it is slower and slightly more complicated.

It is only usefully IF you have an embedded device that does not have a DMA controller because this way you save some money (0.001 cents) per device.

This was the case of some old ZxSpectrum 8 bit computer clones with added floppy drive controllers ... in the 1988-1990 years.

For floppy drives any differences in speed come from the mechanical parameters setup in the commands (in range of milliseconds).

Usually the well known OSes setup those parameters to conservative "safe but slow values" in order to ensure data safety (over a wide range of mechanical devices) first and speed last.
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: FDC without DMA

Post by Dex »

earlz wrote:Most emulators don't support it, and also I've learned quite a few physical floppy drives don't support it.. I think Dex said he had it working at one point(Which is why he can boast his floppy driver is 20% faster than both Linux and Windows and very probably any other sane OS, as non-DMA sketchy, but on those that it does work, it's very fast... )
Sorry, but its not me that as the non-DMA fdd driver, i use DMA, as for the the 20% faster, it was that i find that going back to realmode (as i have two drivers, a pmode and a bios) and using bios is about 20% faster to load a floppy image, than ether linux or windows.
Also i have not seen a working example of a non-dma fdd driver, most try it because thay beleave its simpler, but using DMA is so simple.
So save yourself the time and use DMA.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: FDC without DMA

Post by neon »

Hello everyone and thank you all for your replies :)

I do use DMA (indirectly) inside of my real systems disk driver. For this code in particular, however, I wanted to try doing something different. I am hearing, and the specifications say that the FDC can operate in a non-DMA environment, but I have never seen it done anywhere. Because of this, I wanted to find a way of getting it working. However, unless it is just both Bochs and VPC not supporting it (which sounds probable) I dont know where else to look in resolving the problem.

If no one knows though, that is fine...I will just stick with using DMA.

Thanks again for the feedback :)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: FDC without DMA

Post by bontanu »

neon wrote:... but I have never seen it done anywhere.
I did it at start. It can be done and it works ok but I can not remember IF it ever worked inside VirtualPC.... probably not ...

At that time I was testing on real hardware with a real floppy drive and then I got DMA up an running and never returned to test the non-DMA version in VPC.
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
Post Reply