Upload
dinesh-kumar-t
View
216
Download
0
Embed Size (px)
Citation preview
7/28/2019 fun-dma
1/7
Introduction
The DMA is used to free the CPU from direct control of data transfer between thememory and the Input/Output (I/O) Peripherals by making use of Channels. During this
time the processor will continue working on something else.
Direct Memory Access (DMA) Channels
Direct memory access (DMA) channels are system pathways used by many devices totransfer information directly to and from memory. DMA channels are not nearly as"famous" as IRQs as system resources go. This is mostly for a good reason: there arefewer of them and they are used by many fewer devices, and hence they usuallycause
fewer problems with system setup. However, conflicts on DMA channels can cause verystrange system problems and can be very difficult to diagnose. DMAs are used mostcommonly today by floppy disk drives, tape drives and sound cards.
Limitations of Standard DMA
While the use of DMA provided a significant improvement over processor-controlleddata transfers, it too eventually reached a point where its performance became a
limiting factor. DMA on the ISA bus has been stuck at the same performance level forover 10 years. For old 10 MB XT hard disks, DMA was a top performer. For a modern 8GB hard disk, transferring multiple megabytes per second, DMA is insufficient.
On newer machines, disks are controlled using either programmed I/O (PIO) or first-party DMA (bus mastering) on the PCI bus, and not using the standard ISA DMA that isused for devices like sound cards. Hard disk transfer modes are discussed in detailhere. This type of DMA does not rely on the slow ISA DMA controllers, and allows thesehigh-performance devices the bandwidth they need. In fact, many of the devices thatused to use DMA on the ISA bus use bus mastering over the PCI bus for fasterperformance. This includes newer high-end SCSI cards, and even network and video
cards.
Direct Memory Access (DMA) Channels
7/28/2019 fun-dma
2/7
Direct memory access (DMA) channels are system pathways used by many devices totransfer information directly to and from memory. DMA channels are not nearly as"famous" as IRQs as system resources go. This is mostly for a good reason: there arefewer of them and they are used by many fewer devices, and hence they usuallycausefewer problems with system setup. However, conflicts on DMA channels can cause very
strange system problems and can be very difficult to diagnose. DMAs are used mostcommonly today by floppy disk drives, tape drives and sound cards.
DMA Channel Function and Operation
This section takes a look at DMA channels and how they work. This includes anexplanation of the different types of DMA channels, the DMA controller, and a summaryof the different DMA channels used in the PC.
Why DMA Channels Were Invented forData Transfer
As you know, the processor is the "brain" of the machine, and in many ways it can alsobe likened to the conductor of an orchestra. In early machines the processor really didalmost everything. In addition to running programs it was also responsible for
transferring data to and from peripherals. Unfortunately, having the processor performthese transfers is very inefficient, because it then is unable to do anything else.
The invention of DMA enabled the devices to cut out the "middle man", allowing theprocessor to do other work and the peripherals to transfer data themselves, leading toincreased performance. Special channels were created, along with circuitry to controlthem, that allowed the transfer of information without the processor controlling everyaspect of the transfer. This circuitry is normally part of the system chipset on themotherboard.
Note that DMA channels are only on the ISA bus (and EISA and VLB, since they are
derivatives of it). PCI devices do not use standard DMA channels at all.
DMA Controllers
7/28/2019 fun-dma
3/7
The DMA controller, built into the system chipset on modern PCs, manages standardDMA transfers. The original PC and XT had one of these controllers and supported 4DMA channels, 0 to 3.
Starting with the IBM AT, a second DMA controller was added. Much in the way that the
second interrupt controller was cascaded with the first, the first DMA controller iscascaded to the second. The difference is that with IRQs, the second controller iscascaded to the first, but with DMAs the first is cascaded to the second. As a result,there are 8 DMAs, from 0 to 7, but DMA 4 is not usable. There is no rerouting as withIRQ2 and IRQ9 here, because all of the original DMAs (0 to 3) are still usable directly.
Third-Party and First-Party DMA (Bus
Mastering)Standard DMA is sometimes called "third party" DMA. This refers to the fact that thesystem DMA controller is actually doing the transfer (the first two parties are the senderand receiver of the transfer). There is also a type of DMA called "first party" DMA. In thissituation, the peripheral doing the transfer actually takes control of the system bus toperform the transfer. This is also called bus mastering.
Bus mastering provides much better performance than regular DMA because moderndevices have much smarter and faster DMA circuitry built into them than exists in theold standard ISA DMA controller. Newer DMA modes are now available, such as Ultra
DMA (mode 3 or DMA-33) that provide for very high transfer rates.
DMA Channels and the System Bus
All of the DMA channels except channel 4 are accessible to devices on the ISA systembus. Channel 4 is used to cascade the two DMA controllers together. PCI devices donot use standard system DMA channels.
As was the case with IRQs, the second DMA controller was added when the ISA buswas expanded to 16 bits with the creation of the AT. The lines to access these extraDMA channels were placed on the second part of the AT slot that is used by 16-bitcards. This means that only 16-bit cards can access DMA channels 5, 6 or 7.Unfortunately, many devices even today are still only 8-bit cards. You can tell by lookingat them and seeing that they only use the first part of the two-part ISA bus connector onthe motherboard.
7/28/2019 fun-dma
4/7
Summary of DMA Channels and Their
Typical UsesThe table below provides summary information about the 8 DMA channel numbers in atypical PC. You may find this table useful when considering how to configure yoursystem, or for resolving DMA conflicts. To see DMA channel usage organized by deviceinstead of DMA number.
DMABus
Line?
TypicalDefault
UseOther Common Uses
0 No MemoryRefresh
None
font
face="Arial,
Arial,
Helvetica">
1
8/16-bit
Soundcard (low
DMA)
SCSI host adapters, ECP parallelports, tape accelerator cards, network
cards, voice modems
28/16-
bit
Floppydisk
controllerTape accelerator cards
38/16-
bitNone
ECP parallel ports, SCSI hostadapters, tape accelerator cards,
sound card (low DMA), network cards,voice modems, hard disk controller on
old PC/XT
4 no
None;cascadefor DMAs
0-3
None
516-bitonly
Soundcard (high
DMA)SCSI host adapters, network cards
616-bitonly
NoneSound cards (high DMA), network
cards
7/28/2019 fun-dma
5/7
716-bitonly
NoneSound cards (high DMA), network
cards
Direct Memory Access (DMA) Functions
The DMA functions are:
ddi_dma_alloc_handle()
Allocate a DMA handle
ddi_dma_free_handle()
Free a DMA handle
ddi_dma_mem_alloc()
Allocate memory for a DMA transfer
ddi_dma_mem_free()
Free previously allocated DMA memory
ddi_dma_addr_bind_handle()
Bind an address to a DMA handle
ddi_dma_buf_bind_handle()
Bind a system buffer to a DMA handle
ddi_dma_unbind_handle()
Unbind the address in a DMA handle
ddi_dma_nextcookie()
Retrieve the subsequent DMA cookie
ddi_dma_getwin()
Activate a new DMA window
ddi_dma_numwin()
Retrieve number of DMA windows
7/28/2019 fun-dma
6/7
ddi_dma_sync()
Synchronize CPU and I/O views of memory
ddi_check_dma_handle()
Check a DMA handle
ddi_dma_set_sbus64()
Allow 64-bit transfers on SBus
ddi_slaveonly()
Report whether a device is installed in a slave access-only location
ddi_iomin()
Find the minimum alignment and transfer size for DMA
ddi_dma_burstsizes()
Find out the allowed burst sizes for a DMA mapping
ddi_dma_devalign()
Find DMA mapping alignment and minimum transfer size
ddi_dmae_alloc()
Acquire a DMA channel
ddi_dmae_release()
Release a DMA channel
ddi_dmae_getattr()
Get the DMA engine attributes
ddi_dmae_prog()
Program a DMA channel
ddi_dmae_stop()
Terminate a DMA engine operation
ddi_dmae_disable()
Disable a DMA channel
ddi_dmae_enable()
Enable a DMA channel
7/28/2019 fun-dma
7/7
ddi_dmae_getcnt()
Get the remaining DMA engine count
ddi_dmae_1stparty()
Configure the DMA channel cascade mode
ddi_dma_coff()
Convert a DMA cookie to an offset within a DMA handle
Table B-5 Deprecated Direct Memory Access (DMA) Functions
Deprecated Function Replacement
ddi_dma_addr_setu
p()ddi_dma_alloc_handle(), ddi_dma_addr_bind_handle()
ddi_dma_buf_setup()
ddi_dma_alloc_handle(), ddi_dma_buf_bind_handle()
ddi_dma_curwin() ddi_dma_getwin()
ddi_dma_free() ddi_dma_free_handle()
ddi_dma_htoc() ddi_dma_addr_bind_handle(), ddi_dma_buf_bind_handle()
ddi_dma_movwin() ddi_dma_getwin()
ddi_dma_nextseg()ddi_dma_nextcookie()
ddi_dma_segtocook
ie()
ddi_dma_nextcookie()
ddi_dma_setup() ddi_dma_alloc_handle(), ddi_dma_addr_bind_handle(), ddi_dma_bu
f_bind_handle()
ddi_dmae_getlim()ddi_dmae_getattr()
ddi_iopb_alloc() ddi_dma_mem_alloc()
ddi_iopb_free() ddi_dma_mem_free()
ddi_mem_alloc() ddi_dma_mem_alloc()
ddi_mem_free() ddi_dma_mem_free()
hat_getkpfnum() ddi_dma_addr_bind_handle(), ddi_dma_buf_bind_handle(), ddi_dma
_nextcookie()