Page 1 of 1

FDC programming with DMA

Posted: Mon Jan 31, 2005 5:02 pm
by ManOfSteel
Hello,

I've been programming my FDC driver for weeks and it seems it doesn't work as it's supposed to.

On Bochs, it will print a part of a sector to the screen (as it is supposed to), but will not work more than once and in the output file, it will show me the following lines:
...
00000218500i[FDD ] partial read() on floppy image returns 385/512
00000219012i[FDD ] read() on floppy image returns 0
00004763829e[DMA ] DMA: write to 0x08: value(14h) not 04h
00004763858e[DMA ] DMA: write to 0x08: value(10h) not 04h
...
On a real computer, it's called more than once but doesn't print the bytes in the sector, it seems that when it prints characters it replaces some existing letters on the screen so I presume it is printing zeros which means there's no sector data where it is supposed to be.

I would like to know what every line in Bochs output file means.
Also, I don't understand why Bochs tells me to use 0x4 (disable controller) instead of 0x14 and 0x10.

These are the steps I follow:
00011100b to 0x3f2: select drive 0, enable FDC with DMA, turn motor on
Check for busy bit on MSR
Check MSR for MRQ set and DIO cleared
00001111b to 0x3f5: seek
Check MSR for MRQ set and DIO cleared
0 to 0x3f5 (drive/head 0)
Check MSR for MRQ set and DIO cleared
0 to 0x3f5 (cylinder 0)
Check MSR for busy bit? off
00000110b to 0x0a: mask DMA channel 2
00010100b to 0x08: rotating priority, controller disabled
01010110b to 0x0b: write to memory using channel 2, autoinitialization enabled, single mode
0 to 0x0c: reset flip-flop
Address bits 0-7 to 0x04
Address bits 8-15 to 0x04
Address bits 16-19 (page) to 0x04
0 to 0x0c: reset flip-flop
Count bits 0-7 to 0x05
Count bits 8-15 to 0x05
00000010b to 0x0a: unmask DMA channel 2
00010000b to 0x08: enable DMA, rotating priority, memory to memory disabled
Check MSR for MRQ set and DIO cleared
01100110b to 0x3f5
Check MSR for MRQ set and DIO cleared
0 to 0x3f5 (drive/head 0)
Check MSR for MRQ set and DIO cleared
0 to 0x3f5 (cylinder 0)
Check MSR for MRQ set and DIO cleared
0 to 0x3f5 (head 0)
Check MSR for MRQ set and DIO cleared
4 to 0x3f5 (sector 4)
Check MSR for MRQ set and DIO cleared
2 to 0x3f5 (sector size = 512 bytes)
Check MSR for MRQ set and DIO cleared
18 to 0x3f5 (maximum sector per track)
Check MSR for MRQ set and DIO cleared
27 to 0x3f5 (GAP for 3.5' floppies)
Check MSR for MRQ set and DIO cleared
0xff to 0x3f5 (whole sector)
0 to 0x3f2: unselect drives, disable floppy drive controlers, reset drives

The floppy IRQ is what reads a few bytes from the memory where the DMA puts the sectors and prints them to the screen. The master PIC is acknowledged after that.

What am I missing here? Did I forget a step or did a step before another?

Thank you for any help.

Re:FDC programming with DMA

Posted: Tue Feb 01, 2005 9:26 am
by ManOfSteel
Anyone? I just need some tips, comments or anything from people who are making their FDC driver or managed to finish it.
Without this driver I would be completly stuck.

Re:FDC programming with DMA

Posted: Wed Feb 02, 2005 7:48 am
by thomasantony
Hi,
ManOfSteel, I am thomasantony from the osder forum. See my basic FDC driver at http://www.myfilebucket.com/u/tomasm/floppy.asm

Thomas Antony

Re:FDC programming with DMA

Posted: Fri Feb 04, 2005 4:10 am
by ManOfSteel
Hello,
Thanks for your driver, I will be studying it for the next days. But I didn't see any DMA related code, how do you deal with it? Specially, what does "DMA_Setup" do exactly?
Thanks again.

Re:FDC programming with DMA

Posted: Sat Feb 05, 2005 10:56 pm
by thomasantony
Hi,
Sorry I had forgotten about that! :D
Here it is :

http://www.myfilebucket.com/u/tomasm/dma.asm

It basically sets up the DMA for reading or writing

Thomas Antony