ISA DMA: Difference between revisions

243 bytes added ,  12 days ago
m
no edit summary
[unchecked revision][unchecked revision]
m (Interwiki)
mNo edit summary
 
(9 intermediate revisions by 9 users not shown)
Line 6:
* Transfers must be physically contiguous, and can only target the lowest 16 MB of physical memory;
* ISA DMA is slow - theoretically 4.77 MB/second, but more like 400 KB/second due to ISA bus protocols;
* ISA DMA frees up CPU resources, but loadsadds an extremely heavy load to the memory bus extremely heavily;
* Very few devices currently use ISA DMA -- only internal floppies, some embedded sound chips, some parallel ports, and some serial ports.
 
Notes:
* Sound Blaster and Sound Blaster PRO only support 8 bit DMA;
* [[Sound Blaster 16]]+ supports both;
* [[Floppy disk controllers]] only support 8 bit DMA and are hardwired to use DMA Channel 2.
 
== There Is More Than One Kind of DMA on a PC ==
Line 23:
 
== ISA DMA Background ==
'''ISA DMA''' (''Industry Standard Architecture Direct Memory Access''), like ISA itself, is an [https://en.wikipedia.org/wiki/Appendix_(anatomy) appendix] for modern PCs. It is used by the
internal floppy disk controller, ISA sound cards, ISA network cards, and parallel ports (if they support ECP mode). Whilst interrupt, keyboard
and timer interface circuits have obvious and relevant uses, the ISA DMA controller and its programming interface are still well and truly stuck in the
Line 496:
bus. Real code should separate the two "out 0x4" and "out 0x5" calls with an "out" to some other port.
 
<sourcesyntaxhighlight lang="asm">
<pre>
initialize_floppy_DMA:
; set DMA channel 2 to transfer data from 0x1000 - 0x33ff in memory
Line 503 ⟶ 502:
; set the counter to 0x23ff, the length of a track on a 1.44 MiB floppy - 1 (assuming 512 byte sectors)
; transfer length = counter + 1
out 0x0a, 0x050x06 ; mask DMA channel 2 and 0 (assuming 0 is already masked)
out 0x0c, 0xFF ; reset the master flip-flop
out 0x04, 0 ; address to 0 (low byte)
Line 511 ⟶ 510:
out 0x05, 0x23 ; count to 0x23ff (high byte),
out 0x81, 0 ; external page register to 0 for total address of 00 10 00
out 0x0a, 0x010x02 ; unmask DMA channel 2
ret
</syntaxhighlight>
</pre>
</source>
 
Once you have set up your start address and transfer length you do not need to touch it again, if you are using autoinit. Once reading or writing
is selected, you don't need to change that, either. To ''change'' selecting reading or writing you use the mode register.
 
<sourcesyntaxhighlight lang="asm">
<pre>
prepare_for_floppy_DMA_write:
out 0x0a, 0x050x06 ; mask DMA channel 2 and 0 (assuming 0 is already masked)
out 0x0b, 0x5A ; 01011010
; single transfer, address increment, autoinit, write, channel2)
out 0x0a, 0x010x02 ; unmask DMA channel 2
ret
 
prepare_for_floppy_DMA_read:
out 0x0a, 0x050x06 ; mask DMA channel 2 and 0 (assuming 0 is already masked)
out 0x0b, 0x56 ; 01010110
; single transfer, address increment, autoinit, read, channel2)
out 0x0a, 0x010x02 ; unmask DMA channel 2
ret
</syntaxhighlight>
</pre>
</source>
 
Some hardware, as well as VirtualPC do not support autoinit. You may want to set the Mode registers to 0x4A and 0x46 in the above routines, instead.
Note: Due to problems with autoinit on some real hardware and MS Virtual PC you might want to not use it -- and
set the Mode registers to 0x4A and 0x46 in the above routines, instead.
 
The above routines use single transfer mode for compatibility, but during the initialization of your floppy driver if you detect an "advanced" floppy
Line 547 ⟶ 542:
=== Articles ===
* [[Floppy Disk Controller]]
* [[Sound Blaster 16]]
 
=== External Links ===
* [http://www.intel-assembler.it/PORTALE/4/231466_8237A_DMA.pdf Intel 8237A datasheet]
*[http://bos.asmhackers.net/docs/dma/docs/ http://bos.asmhackers.net/docs/dma/docs/]
 
[[Category:Storage]]