Escolar Documentos
Profissional Documentos
Cultura Documentos
Direct memory access (DMA) facilitates data transfer operations between main memory and I/O subsystems with limited CPU intervention. The majority of I/O devices provide two methods for transferring data between a device and memory. The first method, called programmed I/O (PIO), is fairly easy to implement, but requires the processor to constantly read or write a single memory word (8-bits, 16-bits or 32-bits, depending on the device interface) until the data transfer is complete. Although PIO is not necessarily slower than DMA, it does consume more processor cycles and can be detrimental in a multi-processing environment. The second method, called DMA, allows a system to issue an I/O command to a device, initiate a DMA transaction and then place the process in a waiting queue. The system can now continue by selecting another process for execution, thereby utilizing the CPU cycles typically lost when using PIO. The DMA controller will inform the system when its current operation has been completed by issuing an interrupt signal. Although the data is still transferred 1 memory unit at a time from the device, the transfer to main memory now circumvents the CPU because the DMA controller can directly access the memory unit.
Channel
I/O port
Access
Description Channel
I/O port
Access
Description
Offset Channel 1 Offset 02H Read/Write Register (8-bit) Register Block Size Block Size 01H Read/Write 03H Read/Write Register Register 87H Write only Page 83H Write only Page
04H Read/Write Channel 2 05H Read/Write (8-bit) 81H Write only C0H Read/Write Channel 4 C2H Read/Write (16-bit) 8FH Write only C8H Read/Write Channel 6 CAH Read/Write (16-bit) 89H Write only
Miscellaneous Registers
Register Register Offset Offset 06H Read/Write Register Register Block Size Channel 3 Block Size 07H Read/Write Register (8-bit) Register Page Page 82H Write only Register Register Offset Offset C4H Read/Write Register Register Block Size Channel 5 Block Size C6H Read/Write Register (16-bit) Register Page Page 8BH Write only Register Register Offset Offset CCH Read/Write Register Register Block Size Channel 7 Block Size CEH Read/Write Register (16-bit) Register Page Page 8AH Write only Register Register
Primary Controller I/O port Access Description Command and Status Register Request Register Single Mask Register Mode Register Clear Flip-Flop Register Master Reset Register Master Enable Register Master Mask Register I/O port
Secondary Controller Access Description Command and Status Register Request Register Single Mask Register Mode Register Clear Flip-Flop Register Master Reset Register Master Enable Register Master Mask Register
08H Read/Write 09H Write only 0AH Write only 0BH Write only 0CH Write only 0DH Write only 0EH Write only 0FH Write only
D0H Read/Write D2H Write only D4H Write only D6H Write only D8H Write only DAH Write only DCH Write only DEH Write only
Mode Register
7 6 MODE
5 4 3 2 INC AI TYPE
1 0 CHANNEL
Bits 6 and 7 are used to select the transfer mode: 00b = Demand mode, 01b = Single mode, 10b = Block mode, 11b = Cascade mode Setting INC selects address decrement, clearing INC selects address increment Setting AI enables auto-initialization
Bits 2 and 3 are used to select the transfer type: 00b = Verify, 01b = Write to memory, 10b = Read from memory, 11b = Undefined Bits 0 and 1 are used to select the channel: 00b = channel 0, 01b = channel 1 10b = channel 2 and 11b = channel 3
7 6 5 4 3 Unused
2 SRST
1 0 CHANNEL
SRST (Set/Reset Mask) = 1 disables the selected channel. SRST = 0 will enable the selected channel Bits 0 and 1 are used to select the channel: 00b = channel 0, 01b = channel 1, 10b = channel 2 and 11b = channel 3
The Block Size/Countdown Register is 16-bits wide for both 8-bit and 16-bit DMA operations. However, the I/O port is only 8-bits wide and will require two successive read or write operations to the I/O port. The low order bits must be sent first, followed by the high order bits of the block length when writing to this I/O port. The length of the block being transferred, decremented by 1, can be set by writing to this I/O port. Reading from this I/O port returns the remaining block size, decremented by 1. The value of the Countdown Register will be set to -1 when a transfer has been completed. For 16-bit transactions, the value written to the countdown register is the number of 16-bit word transfers.
Offset Register
The Offset Register is 16-bits wide for both 8-bit and 16-bit DMA operations and contains the starting offset of the buffer used in the DMA transaction. The low order bits must be sent first, followed by the high order bits of the offset when writing to this register. For 16-bit transactions, the value written to the offset register must be aligned on a 16-bit boundary.
Page Registers
The Page Register specifies the base address of the page in memory where the DMA buffer resides. A page can be either 64K (8-bit transactions) or 128K (16-bit transaction) in size. The Page Register is very similar to the Segment Registers used by the PC to compute a physical address. For 8-bit transactions, only the lower 4 bits of the page register is used, thereby restricting the DMA buffer to reside below the first 1Mb of memory (address of buffer SHR 16).
1. Save the current interrupt status and disable interrupts by executing the CLI
2. 3. 4. 5. 6. 7. 8. 9.
instruction Disable the channel that will be used for the transaction Reset the flip-flop by writing a value of 0X to the register Set the Mode Register Set the Page Register Set the Offset Register Set the Block Size Register Enable the channel that will be used for the transaction Restore the interrupt status
8. The data is transferred from the diskette controller's data register to memory without passing through the DMA controller. After every transfer, the DMA controller will decrement the countdown register associated with channel 2. During the transfer, the CPU effectively shares the bus with the diskette controller by interleaving bus hold cycles and normal cycles under the supervision of the DMA controller (sometime referred to as cycle stealing). 9. If the transfer completes, the DMA controller will assert the terminal count line signal (TC). Note that the DMA controller may temporarily stop the transfer by dropping DREQ2 if the transfer rate is too fast to handle. The TC signal indicates to the diskette controller that the operation has been completed and the HRQ and DACK2 lines are deactivated before dropping DREQ2. 10. At this point the CPU will resume normal bus control, but the diskette controller will signal the operating system through the PIC that the operation is complete by asserting IRQ6. Control will typically be transferred to the interrupt handler of the diskette driver to verify the controller results before copying the data from the DMA buffer to the buffer supplied by the user processes.