DMA Function

IBM PS/2 Models 50, 60, 80 MCA Hardware Features and Design Considerations 
   Pages 84-87

DMA Function  

The Personal System/2 Direct Memory Access (DMA) controller allows high and low speed 110 devices to transfer data directly to and from memory. This allows a higher CPU throughput by freeing the processor of the I/O chores. The DMA chip supports 8 channels. The DMA chip has a programming interface compatible to the Intel 8237 Programmable DMA controller with added enhancements provided
by an extended interface. There is however a fundamental difference in operation between the Personal System/2 DMA chip and the 8237 chip. The Personal System/2 DMA controller supports the new Micro Channel Architecture and uses a serial method to transfer data, while the 8237 DMA used in previous IBM personal computers uses a parallel DMA interface.

The processor can address the DMA and read or modify the controller's internal registers to define the various DMA modes, transfer addresses, transfer counts, channel masks and page registers.

The functions of the DMA controller can be grouped into two categories:
1. Program Condition
2. DMA Transfer.

During Program Condition, the DMA registers may be programmed or read using I/O instructions. Program Condition commences when the processor references the DMA with an address in the DMA I/O Address Space.

The second functional category of the controller is the actual DMA Transfer. A DMA transfer is initiated when a DMA slave wins the Arbitration bus and the DMA controller has been programmed to service the winning request in process. DMA Transfer may be in the form of a single transfer, multiple transfer (BURST), or read verification. During transfers, one byte or one word can be passed every (370 + (600)N) nanoseconds where N is the number of transfers. By asserting IOCHRDY slower I/O or memory devices can extend the I/O transfer cycle. During read verification, one byte is read from memory and no transfer to I/O occurs.

DMA Controller Transfer Modes  

1. Data transfers between memory and I/O devices.

Transfers are carried out serially, this means data is read from a device and latched in the DMA chip before it is written back to a second device. The memory address (target address) need only be specified for the DMA data transfer. The I/O address will be forced to hex 0000 during the I/O transfer. An optional 16-bit I/O address can be provided during the I/O portion of the transfer

2. Read verification operations.

The DMA chip does a memory read operation without doing an I/O operation. The address, count will be modified and Terminal Count will be provided.

3. Memory Refresh cycles.

The DMA controller runs a refresh cycle when requested and provide the nine bit address and control status for the operation.

General DMA Enhancements 

In addition to being software compatible to the IBM Personal Computer AT, the DMA chip will support the following additional functions not found on the Personal Computer AT:

• Readable Mode registers.
• One additional DMA channel (channel 4).
• Programmable bus width (8 or 16 bits).
• Virtual DMA channels 0 and 4.
• Page register crossover.
• Extended program control operations.
• Compatible with Micro Channel Architecture

DMA Extended Mode  

The Personal System/2 DMA controller features an extended mode which allows the DMA controller to be programmed via a simpler and more coherent programming interface. This mode provides additional read/write ports without the need to increase the I/O space requirements. Programming the DMA controller using the extended mode is done by using a Function Register and I/O addresses 018H and 01AH. The extended mode also allows access to registers which were inaccessible in previous IBM Personal Computers.

DMA Extended Register

PROGRAM COMMAND I/O ADDRESS
Function Register ........... (FR) .... lBH
Execute Function Register ... (EFR) ... lAH

Extended Mode Register 

The DMA supports an Extended Mode Register for each channel which can be programmed and read back by the processor. This register is resident in the DMA RAM and activated whenever a DMA channel requests DMA data transfer.

Extended Mode Register  



Programming the DMA Controller Using Extended Mode  

In order tor the processor to read or write any of the DMA's internal registers, the processor will have to execute one or both of the following steps.

1. Write the Function register by executing an OUT to address 18 hex with the proper data to indicate the function and the channel number. The internal byte pointer register will always reset to 0 when the OUT to port 18H is detected. Some
functions are implemented directly and do not require additional steps.

The functions selected via the function register are shown below.

DMA Extended Program Functions  

FUNCTIONS                                BITS FUNCTION DIRECT   RD WR
                                               HEX     CMD
I/O Address Register.................... 00-15  0 .............. X X Reserved ...............................        1
Reserved ...............................        E
Reserved ...............................        F

Memory Address Register (Write)......... 00-23  2 .............. X X
Memory Address Register (Read).......... 00-23  3 .............. X
Transfer Count (Write).................. 00-15  4 .............. X X
Transfer Count (Read)................... 00-15  5 .............. X

Status Register Read ................... 00-07  6 .............. X
Mode Register .......................... 00-07  7 .............. X X
Arbus Register ......................... 00-07  8 .............. X X
Mask Register Set Single Bit ........... .....  9 ..... X          X
Mask Register Reset Single Bit ......... .....  A ..... X          X
Reserved ............................... .....  B ..... X          X
Reserved ............................... .....  C ..... X          X
Master clear ........................... .....  D ..... X          X

Function register (Port 18H)


As shown in the figure above, the channel to be programmed is selected on data bits 0-3, and the function is programmed on data bits 4-7

2. Execute the function by doing an IN or OUT to address 1AH. The byte pointer will automatically increment by one and point to the next byte every time the 1AH port is used. Direct commands do not need this second step because the function
will be executed upon detection of the OUT to address 18H.
 
Nineteen different functions on 8 different channels are implemented by the DMA by only using two I/O ports. This register can support up to 15 DMA channels plus additional functions. Port 19H and 01BH are reserved by IBM for future use.

Programming Example Using the Extended Mode  

The purpose for the DMA extended operation is to make DMA programming easy and independent of the channel being programmed. The following is an example showing the programming of channel 2 using the 8237 and the extended mode.

Channel 2 Programming Example  

Program step            8237 Mode    Extended Mode
                       OUT to ADRS   OUT to ADRS
                         Data          Data

Set Channel Mask Bit     (0Ah) x6h   (18h) 92h
Clear Byte Pointer       (0Ch) xxh   (18h) 22h
Write Target Address     (04h) xxh   (lAh) xxh
Write Target Address     (04h) xxh   (lAh) xxh
Write Page Register      (81h) xxh   (lAh) xxh
Clear Byte Pointer       (0ch) xxh   {18h) 42h
Write Byte Count         (05h) xxh   (lAh) xxh
Write Byte Count         (05h) xxh   (lAh) xxh
Write Mode Register      (0Bh) xxh   (18h) 72h
                                     (lAh) xxh
Reset Channel 2 Mask Bit (0Ah) x2h   (18h) A2h

The following is an example showing the programming of channel 5 using the 8237 and the extended mode.

Programming Example using Extended Mode  

Program step                 8237 Mode     Extended Mode
                             OUT to ADRS   OUT to ADRS
                               Data          Data

Set Channel Mask Bit          (D4h) x5h   (18h) 95h
Memory Address Register Write (08h)       (18h) 25h
Write Memory Address          (C4h) xxh   (1Ah) xxh
Write Memory Address          (C4h) xxh   (1Ah) xxh
Write Page Register           (8Bh) xxh   (lAh) xxh
Transfer Count Register Write (08h) xxh   (18h) 45h
Write Word Count              (C6h) xxh   (lAh) xxh
Write Word Count              (C6h) xxh   (lAh) xxh
Write Mode Register           (D6h) xxh   (18h) 75h
                                          (lAh) xxh
Reset Channel 5 Mask Bit      (04h) xlh   (18h) A5h

It is clear from the above examples the extended method has consistency and can easily be adapted to any channel.

Virtual DMA Channel operation  

This feature creates additional DMA channels at the arbitration levels 08H-0EH using the two 4 bit register called Arbus Registers. These registers provide the
processor a way to dynamically re-assign the arbitration ID value to which the DMA controller will respond to the bus arbitration for DMA requests. This allows channels 0, 4 to service devices at any arbitration levels. The value of Fh is reserved for the processor and must never be used. In order to program the Arbus registers, the extended function 8 should be used. The upper 4 bits of the function
register should have 8 and the lower eight bits the channel number ( 0 or 4 ).

Although channels 0, 4 can respond to arbitration levels other than 0, 4, the programming of these two channels still has to be done as 0, 4. In other words
the arbitration level of the channel and the programming level of the channel are independent.

Arb bus Register Programming