DMA data transfer process

Source: Internet
Author: User

The DMA method has the following features:
1. Input and output requests from external devices are directly sent to the primary storage.
The primary memory can be accessed by both the CPU and peripheral devices. Therefore, there is usually a storage management component in the primary storage to queue applications for various access to the primary storage. Generally, the computer system puts the access requests for peripheral devices at the highest priority.
2. You do not need to save the site or restore the site, which greatly speeds up the operation of the DMA mode.
Because the program does not need to be executed to transmit data between the peripheral device and the primary memory, the data registers and instruction counters in the CPU are not used.
3. In the DMA controller, in addition to data buffer registers, device status registers, or control registers, you must also set the master memory address registers, device address registers, and data exchange count counters.
The entire data exchange process between the peripheral device and the primary storage must be completed under hardware control. In addition, because the peripheral devices are generally transmitted in bytes and the primary memory is accessed in word units, the DMA controller also has hardware that is assembled from bytes into words and removed from words into bytes.
4. Initialize the DMA controller before the DMA mode starts, including transmitting the first address, device address, and length of the exchanged data block to the DMA controller, start the device. After the DMA mode ends, you need to apply for an interruption to the CPU and post-process the data buffer in the primary memory in the interrupt service program. If you want to continue transmitting data, initialize the DMA controller again.
5. In the DMA mode, the CPU not only works in parallel with the peripheral device, but also does not require CPU intervention during the entire data transmission process. If the bandwidth of the primary memory is sufficient, the operation of the peripheral device does not affect the CPU to run its own program.
The workflow of the DMA method is as follows:
For input devices:
Read a byte or word from the input media to the data buffer register BD in the DMA controller. If the input device is character-oriented, assemble the characters into words.
If a word is not fully assembled, it is returned to it. If the verification fails, an application for interruption is sent. If the word is fully assembled, the data in BD is sent to the primary storage data register.
Send the address in the main memory address register BA (in the DMA controller) to the main memory address register, and add the address in BA to the next word address.
Subtract "1" from the data exchange count counter BC in the DMA controller ".
If the content in BC is "0", the entire DMA data transfer process ends. Otherwise, the system returns to the top and continues.
For output devices:
Send the address in the main memory address register BA (in the DMA controller) to the main memory address register, start the main memory, and add the address in the BA to the next word address.
Send the data in the primary memory data register to the data buffer register BD of the DMA controller. If the output device is character-oriented, remove the data in BD.
Write Data in BD to the output media one by one (for character-oriented devices) or the entire word.
Subtract "1" from the data exchange count counter BC in the DMA controller ".
If the content in BC is "0", the entire DMA data transfer process ends. Otherwise, the system returns to the top and continues.
Currently, the following three DMA methods are used:

1. Periodic theft
At the end of each command execution, the CPU tests whether there is a DMA service application. If yes, the CPU enters a DMA cycle. Use the CPU to complete the DMA workflow listed above during the DMA cycle. This includes transmitting data and primary storage addresses, subtracting "1" from the content in the exchange count counter, adding value to the primary storage address, and testing and judgment.
When the periodic stealing method is used, the primary storage can be connected directly to the peripheral device, but only to the CPU, that is, the connection method of 4.4 can still be used, because the data exchange between the peripheral device and the primary memory is the same as the input/output mode of program control and the interrupt input/output mode, they all go through the CPU.
The periodic data theft mode differs from the program control input/output mode and the interrupt input/output mode in that it does not need to use a program to complete data input or output, only a CPU cycle is used to complete the DMA process. Therefore, it works quickly.
The advantage of periodic theft is that the hardware structure is simple and easy to implement. The disadvantage is that the CPU time is actually occupied in the data input or output process.

2. Direct access
This is a real DMA method. The data transfer application of the DMA controller is not sent to the CPU, but directly to the primary memory. After receiving the response from the primary memory, the entire DMA workflow is completed in the DMA controller using hardware.
The advantages and disadvantages of direct access are the opposite of those of periodic access.
Currently, most computer systems use direct access.

3. Data block transmission mode
A large data buffer memory should be set in the device controller to store the next data block. For example, a 512-byte data buffer memory is usually set in a soft disk memory. Data exchange with device Media is carried out in data buffer storage. The data exchange between the device controller and the primary memory is measured in data blocks and is conducted in program Interrupt mode.
The data block transfer method is not a DMA method, but it obtains or sends data in the unit of data blocks during each interrupt input/output process. This is the same as the above two DMA methods, therefore, the input and output modes are also classified as DMA.
Peripheral devices using data block transmission methods include row-type printers, laser printers, card readers, and some plotters.

DMA data transfer process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.