Professional Documents
Culture Documents
Leicester University Department of Engineering Microprocessors
Leicester University Department of Engineering Microprocessors
doc
What is direct memory access Cycle stealing and hidden cycle DMA. What is the DMA controller programmed with The sequence of events for a DMA Disk access terminology Disk access time Bus arbitration Bus arbitration schemes (daisy chain, parallel, self-selection, collision) DMA on the IBM-PC: What it is and how it works A Sample DMA transfer (IBM-PC)
15
20
25
40
45
The sequence of events is: - Bus request to CPU (can I use the bus, please?) - Bus grant from CPU (yes, you can, at the end of this bus cycle) - Bus grant acknowledge to CPU ( thank you. Here I go!) - DMA controller reads device - DMA controller writes to memory - DMA controller increments counter - DMA controller checks for End-of-Count - At the End-of-Count the DMA controller may generate an interrupt request to tell the CPU: 'I have done a DMA operation. New data is available'.
10
15 DMA is commonly required to interface fast I/O devices such as video frame grabbers and hard disks: 1 s video frame grabber: 512 x 512 bytes in 50 means that the transfer rate must be 13.1 MBytes/s hard disk: 20 bit density = 50 kbits/inch 7200 rpm track radius (inner track) = 0.9" 50 kbits 7200 rotations 1min 2 0.9 inch min ute 60 s transfer time = inch = 33.93 Mbits/s
25
30
35
Answer: 40
Bus arbitration
Bus arbitration is the term used to describe the mechanism and the sequence of events that take place when another potential bus master requests the buses and is granted the use of the buses. In other words, deciding which potential bus master gets to use the bus next is called bus arbitration. For the MC68000 bus arbitration consists of the following: 1. Asserting a bus mastership request
45
2. Receiving a grant indicating that the bus is available at the end of the current cycle 3. Acknowledging that mastership has been assumed 5 The 68000 has three bus arbitration control pins: BR - The bus request signal is assigned by the potential bus master to the 68000 and signals intent to use the buses. This signal indicates 10
BG - The bus grant signal is assigned by the 68000 in response to a BR , and means that the bus will be released at the end of the current bus cycle. When BG is asserted BR can be de-asserted. BG can be routed through a daisy chain or through a specific priority-encoded circuit. BGACK - At the end of the current bus cycle the potential bus master takes control of the system buses and asserts a bus grant acknowledge signal to inform the old bus master that it is now controlling the buses. This signal should not be asserted until the following conditions are met:
15
20
1. A bus grant has been received 2. Address strobe is inactive, which indicates that the microprocessor is not using the bus 3. Data transfer acknowledge is inactive, which indicates that neither memory nor peripherals are using the bus 4. Bus grant acknowledge is inactive, which indicates that no other device is still claiming bus mastership.
25
30
35
http://www.whatis.com/dma.htm
DMA (Direct Memory Access) Direct Memory Access is a capability provided by some computer bus architectures that allows data to be sent directly from an attached device (such as a disk drive) to the memory on the computer's motherboard. The microprocessor is freed from involvement with the data transfer, thus speeding up overall computer operation.
45
Usually a specified portion of memory is designated as an area to be used for direct memory access. In the ISA bus standard, up to 16 megabytes of memory can be addressed for DMA. The EISA and MCA standards allow access to the full range of memory addresses (assuming they're addressable with 32 bits). PCI accomplishes DMA by using bus mastering (with the microprocessor "delegating" I/O control to the PCI controller).
An alternative to DMA is the Programmed Input/Output (PIO) interface in which all data transmitted between devices goes through the processor. A newer protocol for the ATA/IDE interface is Ultra DMA/33, which provides a burst data transfer rate up to 33 MB (megabytes) per second. Hard drives that come with Ultra DMA/33 also support PIO modes 1, 3, and 4, and multiword DMA mode 2 (at 16.6 megabytes per second).
Sources: Winn L. Rosch. The Winn L. Rosch Hardware Bible (Third Edition), Sams Publishing, 1994 Last update: October 13, 1999
10
http://www.freebsd.org/handbook/dma.html
25
30
35
40
DMA requests buses by asserting HRQ CPU releases bus and asserts HLDA DMA ``is in charge'' activates its -MEMR, -MEMW, -IOR, -IOW output signals 5
10
15
(-IOR, -MEMW in this case), and the memory address DMA asserts the DACK2 to peripheral Peripheral places the byte to be transferred on the bus Data lines DMA waits one clock, and then de-asserts -MEMW and -IOR signals so that the memory will latch and store the byte Peripheral drops the DRQ2 signal, so that the DMA knows it is no longer needed DMA de-asserts -DACK2 signal and peripheral releases data bus DMA controller tri-states the -MEMR, -MEMW, -IOR, -IOW and address signals DMA will de-assert the HRQ signal. CPU sees this, and de-asserts the HOLDA signal. CPU activates its -MEMR, -MEMW, -IOR, -IOW and address lines, and it resumes executing instructions and accessing main memory and the peripherals.
20
Here is an example of the steps that occur to cause and perform a DMA transfer. In this example, the floppy disk controller (FDC) has just read a byte from a diskette and wants the DMA to place it in memory at location 0x00123456. The process begins by the FDC asserting the DRQ2 signal (the DRQ line for DMA channel 2) to alert the DMA controller. The DMA controller will note that the DRQ2 signal is asserted. The DMA controller will then make sure that DMA channel 2 has been programmed and is unmasked (enabled). The DMA controller also makes sure that none of the other DMA channels are active or want to be active and have a higher priority. Once these checks are complete, the DMA asks the CPU to release the bus so that the DMA may use the bus. The DMA requests the bus by asserting the HRQ signal which goes to the CPU. The CPU detects the HRQ signal, and will complete executing the current instruction. Once the processor has reached a state where it can release the bus, it will. Now all of the signals normally generated by the CPU (-MEMR, -MEMW, -IOR, -IOW and a few others) are placed in a tri-stated condition (neither high or low) and then the CPU asserts the HLDA signal which tells the DMA controller that it is now in charge of the bus. Depending on the processor, the CPU may be able to execute a few additional instructions now that it no longer has the bus, but the CPU will eventually have to wait when it reaches an instruction that must read something from memory that is not in the internal processor cache or pipeline.
25
30
35
Now that the DMA ``is in charge'', the DMA activates its -MEMR, -MEMW, -IOR, -IOW output signals, and the address outputs from the DMA are set to 0x3456, which will be used to direct the byte that is about to transferred to a specific memory location. The DMA will then let the device that requested the DMA transfer know that the transfer is commencing. This is done by asserting the -DACK signal, or in the case of the floppy disk controller, -DACK2 is asserted.
40
The floppy disk controller is now responsible for placing the byte to be transferred on the bus Data lines. Unless the floppy controller needs more time to get the data byte on the bus (and if the peripheral does need more time it alerts the DMA via the READY signal), the DMA will wait one DMA clock, and then de-assert the -MEMW and -IOR signals so that the memory will latch and store the byte that was on the bus, and the FDC will know that the byte has been transferred. Since the DMA cycle only transfers a single byte at a time, the FDC now drops the DRQ2 signal, so the DMA knows that it is no longer needed. The DMA will de-assert the -DACK2 signal, so that the FDC knows it must stop placing data on the bus.
45
The DMA will now check to see if any of the other DMA channels have any work to do. If none of the channels have their DRQ lines asserted, the DMA controller has completed its work and will now tristate the -MEMR, -MEMW, -IOR, -IOW and address signals. 5 Finally, the DMA will de-assert the HRQ signal. The CPU sees this, and de-asserts the HOLDA signal. Now the CPU activates its -MEMR, -MEMW, -IOR, -IOW and address lines, and it resumes executing instructions and accessing main memory and the peripherals. For a typical floppy disk sector, the above process is repeated 512 times, once for each byte. Each time a byte is transferred, the address register in the DMA is incremented and the counter in the DMA that shows how many bytes are to be transferred is decremented. 10 When the counter reaches zero, the DMA asserts the EOP signal, which indicates that the counter has reached zero and no more data will be transferred until the DMA controller is reprogrammed by the CPU. This event is also called the Terminal Count (TC). There is only one EOP signal, and since only DMA channel can be active at any instant, the DMA channel that is currently active must be the DMA channel that just completed its task. If a peripheral wants to generate an interrupt when the transfer of a buffer is complete, it can test for its -DACKn signal and the EOP signal both being asserted at the same time. When that happens, it means the DMA will not transfer any more information for that peripheral without intervention by the CPU. The peripheral can then assert one of the interrupt signals to get the processors' attention. In the PC architecture, the DMA chip itself is not capable of generating an interrupt. The peripheral and its associated hardware is responsible for generating any interrupt that occurs. Subsequently, it is possible to have a peripheral that uses DMA but does not use interrupts. It is important to understand that although the CPU always releases the bus to the DMA when the DMA makes the request, this action is invisible to both applications and the operating systems, except for slight changes in the amount of time the processor takes to execute instructions when the DMA is active. Subsequently, the processor must poll the peripheral, poll the registers in the DMA chip, or receive an interrupt from the peripheral to know for certain when a DMA transfer has completed.
lect_dma.doc
15
20
25
FSS
30