DMA PIO Interface

Section 1. DMA Controller Architecture  

The direct-memory-access (DMA) controller is a system component that has the single task of managing the transfer of data between two addressable locations within the system address space. Using the DMA controller to manage data transfers relieves the system master of having to perform these transfers.

The DMA controller consist of eight channels. Each channel can be programmed to perform specific operations using specific parameters. Each channel can be set to respond to a specific arbitration level.

The DMA operations supported by each channel include data-transfer operations and the memory-verify operation. Data-transfer operations move data between an I/O device and memory. Memory-verify operation performs a memory read cycle but does not perform a write cycle or transfer any data.

The DMA controller architecture provides two interfaces to control DMA operations: programmed-l/O (PIO) and subsystem control block (SCB). The PIO interface supports a 24-bit memory address and an 8- or 16-bit data width through a set of registers and I/O ports. The SCB interface supports a 32-bit memory address and an 8-, 16-, or 32-bit data width through a control-block interface.

The DMA controller for all systems based on the Micro Channel architecture must support the PIO interface. In addition, the Type 2 DMA controller provides the SCB interface.


Section 2. Programmed-I/O (PIO) Interface  

In the PIO interface, the system master uses a set of programmable registers to:

Specify the type of operation
Establish the addresses and direction
Specify the number of transfers for a given operation
Select the channel to be used

Each channel uses its own 24-bit memory address register and 16-bit transfer counter to define each DMA operation. Data width for each transfer can be set to 8 or 16 bits. Therefore, each channel can be set up to perform 64K transfers (up to 128KB) within a single, contiguous block of memory addresses from 0 to 16MB (224), independent of the setting of the other DMA channels.

Each channel is preset to respond to an arbitration level equal to its channel number. In addition, the arbitration levels for DMA channels 0 and 4 can be modified to respond to other values.

PIO Registers  

Register Name

Number of Registers

Size

R/W

I/O-Memory Address

8

16

R/W

Memory Address

8

24

R/W

Transfer Count

8

16

R/W

DMA Mode

8

8

R/W

DMA Mask

8

8

W

Arbitration Level

8

8

R/W

DMA Status

1

16

R

Function

1

8

W


NOTE: There are 8 DMA channels, hence 8 Registers

System Interfaces 

The I/O addresses assigned to the DMA controller are not accessible through the channel. These registers can be directly accessed only through I/O read and write operations from the system master. The following are the I/O addresses assigned to the DMA controller.

IO Address (hex)

Description

0000-000F

AT-compatible interface

0010-001F

PIO and SCB interfaces

0081-008F

AT-compatible interface

00C0-00DF

AT-compatible interface


NOTE: 0010-001F for PIO interface?

I/O addresses used by the PIO interface.

Address

Description

R/W

0018

Function register

WO

001A

Execute Function port

R/W


NOTE: "WO" probably would be "W" for "Write Only"

States  

The DMA controller operates on the registers and data based on its current state. The DMA controller has three states:
* Idle state
* Program state
* Transfer state

The controller, acting on behalf of different DMA channels, cannot be in more than one state at a time. In each state, the DMA controller monitors various conditions to determine the next operation to perform and what state to enter next.

Idle State  

The idle state is the default state for the DMA controller. The DMA controller enters this state after it is reset or after exiting from one of the other two states. While in the idle state, the DMA controller monitors the address bus and control signals to determine if an I/O cycle is occurring and monitors the arbitration bus and ARB/-GNT to determine if an arbitration cycle is occurring.

if an I/O cycle selects a DMA controller register, the DMA controller enters the program state and prepares to process the command.

During an arbitration cycle, the DMA controller monitors the arbitration bus. It enters the transfer state if the system channel is granted to an arbitration level that matches a value in an Arbitration Level register and the DMA channel ts enabled.

When the DMA controller enters the idle state after a system reset, its registers are initialized to a default state. (For information on the default state for these register, see “DMA Controller Resets” on page 7.)

Program State  

The DMA controller enters the program state whenever it detects an I/O cycle with an address within the address range assigned to the DMA controller.

The DMA controller is in the program state whenever commands are being issued that modify or return the contents of its registers. These commands are defined by the interfaces for PIO and SCB architectures.

The DMA controller exits from the program state after each I/O cycle is completed and returns to the appropriate state, either the idle state or the transfer state.

Transfer State  

The DMA controller is in the transfer state whenever it is driving the control signals and the address bus. It drives these signals while performing a DMA transfer operation (data transfer or memory-verify) or an SCB fetch operation (a control block or an indirect list).

The DMA controller enters the transfer state from the idle state when all of the following conditions exist:
* An arbitrating device has been granted control of the system channel.
* The arbitration level matches the value in one of the Arbitration Level registers.
* The DMA channel with the matching arbitration level is enabled.

If more than one DMA channel meets these conditions, the lower-numbered DMA channel gets control and starts its DMA operation. After the lower-numbered channel has completed its operation, the next channel gets control and starts its operation. This continues until all operations for that arbitration level are completed.

NOTE: Although the DMA controller supports assigning the same level to more than one channel, IBM recommends that each DMA channel be assigned a unique arbitration level.

The DMA controller exits from the transfer state and returns to the idle state after an end-of-transfer is signaled or if a DMA error is detected. The end-of-transfer is signaled:
* After the DMA controller completes a single transfer for a nonbursting device
* After the DMA controller reaches the terminal count
* After a bursting device stops driving the ‘burst’ signal and the DMA controller has completed the current transfer

DMA Controller Resets  

The DMA controller controller can perform up to four levels of reset. The local bus is held not-ready until the reset operation has been completed.

Hardware reset (H) - is performed when the system is first powered-on. This level of reset initializes all the registers, functions, and state machines in the DMA controller to a known state.

Controller reset (S) - is performed by issuing the DMA Controller Reset command. This reset is similar to the hardware reset except that it initializes only the DMA controller registers and functions. It leaves system functions, such as arbitration and refresh, intact.

Channel reset (C) - is performed by issuing the DMA Channel Reset command. This command allows the programmer to reset a specific DMA channel without interfering with the other DMA channels. This reset affects only the registers, fields, and logic that pertain to the DMA channel being reset. For registers containing fields for more than one DMA channel, only the fields for the specified channel are reset. All DMA logic used during an active DMA transfer, including the state machine are also reset. The channel reset is only supported by the SCB interface.

Bus timeout reset (T) - is performed when a DMA channel has gained control of the system channel and a bus timeout occurs. This reset is similar to a channel reset except that DMA Status register is not reset.

The following shows the DMA registers and their content after a DMA hardware reset (H), controller reset (S), channel reset (C), or bus timeout reset (T).

DMA Register Reset  Initialization

Register

Reset Type

State After Reset

Function

 

Not initialized

Extended Function

 

Not initialized

Byte Pointer

H,S,C

Points to low byte

DMA Status

H,S,C

All status is cleared

Arbitration Level

H

Each channel is set to its channel number

DMA Mask

H,S,C,T

Channels disabled (hex FF)

DMA Mode

 

Not initialized

I/O-Memory Address

 

Not initialized

Memory Address

 

Not initialized

Transfer Count

 

Not initialized

Command Busy/Status

H,S,C

No errors and Attention register not busy

Attention

H,S,C

No active requests

Control Block Address

 

Not initialized

Indirect List Address

 

Not initialized

Indirect List Count

 

Not initialized

 FIFO Byte Count

H,S,C,T

 FIFO empty (hex 00)


 
PIO Interface Registers  

The PIO interface registers control and monitor the state of the DMA controller and each DMA channel in the DMA controller. The registers can be divided into three functional categories: system Interface, operational interface, and transfer control.
The following shows the registers and ports used, and the I/O addresses associated, with the PIO interface. The page number indicates where the register is described.

PIO Interface I/O Addresses and Registers  

I/O Address

Register

R/W

System Interface Registers

 

 

0018

Function

W

001A

Execute Function port

R/W

 

Byte pointer

na

Operation Control Registers

 

 

 

Arbitration Level

R/W

 

DMA Mask

W

 

DMA Status

R

Transfer Control Registers

 

 

 

DMA Mode

R/W

 

I/O-Memory Address

R/W

 

Memory Address

R/W

 

Transfer Count

R/W

 

Data Holding

na

NOTE: Programs and hardware writing to reserved areas should ensure that the areas are set to 0 (unless otherwise indicated); programs and hardware reading these areas should treat reserved values as don’t care.

System interface Registers  

These registers control the overall interface to the DMA controller and each of the DMA channels.

Function Register  
The Function register is an 8-bit, write-only register used to select a DMA channel and specify command to be performed. The Function register is loaded using the Write Function command


FUNC Function field (bits 7-4) selects cmd performed by specified DMA channel.
R is Reserved
SEL Select field (bits 2-0) specifies DMA channel to perform the PIO command.

Execute Function port  [involved]

Byte Pointer  

The byte pointer is a 2-bit, internal register that is used to point to the individual bytes in multiple-byte registers. The byte pointer is increased by 1 for each read or write operation to the Execute Function port (hex 001A).

The contents of the byte pointer cannot be accessed. The byte pointer is cleared (set to point to the first byte of a register) automatically after a Write Function command (see page 25).



After the byte pointer is cleared, it points to bits 7-0 of a multiple-byte register. As each byte in the register is accessed, the byte pointer is increased to point to the next byte within the register. After the last byte (high byte) within the register is accessed, the byte pointer is undefined and must be cleared (set to point to the first byte).

Operation Control Registers  

These registers control the operation and maintain status for each DMA channel.

Arbitration Level Registers

There are eight Arbitration Level registers, one for each DMA channel. Each register is an 8-bit register that contains the arbitration level assigned to the specific DMA channel. The registers for DMA channels 0 and 4 are read/write. The registers for the other DMA channels are not accessible.

The registers are accessed using the Read or Write Arbitration Level command (see page 33).



ARBL Arbitration Level (bits 3— 0) specifies arb level for specific DMA channel.

DMA Mask Register 

The DMA Mask register is an 8-bit, write-only register that contains one field for each DMA channel. The individual fields determine whether DMA operations are enabled or disabled for that channel. If DMA operations are enabled for a DMA channel, the DMA controller enters the transfer state when the system channel is granted to the arbitration level for that DMA channel.

The individual fields are set to 1 using the Set DMA Mask command, and set to 0 using the Reset DMA Mask commands (see page 25). All fields are set to 1 after performing a Reset DMA Controller command (see page 26).



M7-M0 The Mask fields (bits 7-0) are used to enable and disable DMA operations on each of the DMA channels. When a Mask field is set to 1, the mask is set and the channel is disabled. When a Mask field is set to 0, the mask is reset and the channel is enabled. The Mask field is set to 1 by the DMA controller after the DMA channel has completed or terminated a DMA transfer operation.

DMA Status Register  

The DMA Status register is a 16-bit, read-only register that contains the status for the eight DMA channels. As each byte is read, its status is cleared (the byte is set to 00). Performing a Reset DMA Controller command clears the status in both bytes. The DMA Status register can be read using the Read DMA Status
command (see page 30).



TC7-0 The Terminal Count fields (bits 15-12 and 7-4) indicate whether the corresponding DMA channel has completed a DMA operation (transfer count has passed 0) since the status was previously cleared. If the field is 1, the channel has completed a DMA operation; if the field is 0, the channel has not completed a DMA operation.

RQ7-0 The DMA Request fields (bits 11-8 and 3-0) indicate whether the corresponding DMA channel has transferred data since the status was previously cleared. If the field is 1, the channel has been active; if the field is 0, the channel has not been active.

Transfer Control Registers  

These registers determine the operation of the DMA channel and are used to control the source and destination addresses of each transfer and the number bytes transferred.

DMA Mode Registers 

There are eight DMA Mode registers, one register for each DMA channel. Each register is an 8-bit, read/write register that controls the operation of that DMA channel.

The register is accessed using the Read or Write DMA Mode command (see page 30).



"R" is Reserved

S16 The Size 16 field (bit 6) specifies the minimum data width used during the I/O cycle and determines whether the transfer count is the number of bytes or words to be transferred. When the field is set to 1, the transfer count represents the number of words to transfer. When the field is set to 0, the transfer count represents the number of bytes to transfer.

When a 16-bit transfer is performed to an !/O device, the I/O address is aligned on a word boundary (address bit 0 is 0), regardless of the address in the I/O-Memory Address register.

DEC2 The Decrement 2 field (bit 4) specifies whether the DMA controller increases or decreases the address in the Memory Address register. When the field is set to 1, the Memory Address register is decreased by 1 for each byte transferred. When the field is set to 0, the Memory Address register is increased.

XFER The Transfer Control field (bits 3 and 2) specifies the type of  operation to be performed by the DMA channel.

DMA Operation Selection  

Transfer Control

Operation Performed

00

Memory verify

01

Memory-to-I/O transfer (memory is the source)

10

Memory verify

11

I/O-to-memory transfer (memory is the destination)


IOA The I/O Address field (bit 0) specifies whether to use the I/O address in the I/O-Memory Address register or to use I/O address hex 0000. When the field is 1, the DMA controller uses the address in the I/O-Memory Address register for the
DMA operation. When the field is 0, the DMA controller uses I/O address hex 0000 for the DMA transfer.

I/O-Memory Address Registers  

There are eight I/O-Memory Address registers, one for each DMA channel. Each register is a 16-bit, read/write register that contains the I/O address used during the DMA transfers for that DMA channel.

The l/O-Memory Address register is accessed using the Read or Write I/O Address command (see page 27).



Memory Address Registers 

There are eight Memory Address registers, one for each DMA channel. Each register is a 24-bit, read/write register that contains the memory address used during a DMA transfer. The memory address is increased or decreased as data is transferred.

The register is read using the Read Memory Address command (see page 28) and is loaded using the Write Memory Address command (see page 28).



Transfer Count Registers  

There are eight Transfer Count registers, one for each DMA channel. Each register is a 16-bit, read/write register that contains the number of transfer cycles to be performed. The register is decreased by the appropriate amount for each transfer cycle.

The Transfer Count register is read using the Read Transfer Count command (see page 29) and is loaded using the Write Transfer Count command (see page 29).



Data Holding Register  

The DMA controtler uses the Data Holding register to temporarily store the data being transferred. The minimum size of the Data Holding register is 2 bytes and the maximum is 255 bytes.

Data Structures 

The DMA controller defines two transfer-control structures used by the PIO interface, which define the physical limits of the transfer.

Address

The memory addressing is limited to 24 bits. Memory addresses that are increased beyond hex 0FFFFFF or decreased below 00 are undefined and cause  compatibility problems in systems with 32-bit addressing.

When decreasing the memory address, the starting memory address must be aligned on a word boundary for DMA transfers using 16-bit data widths.

The I/O address can be aligned on a byte or word boundary. However, the DMA controller forces the I/O address to align on a word boundary when the width is specified as 16-bits.

Transfer Count

The transfer count is a 16-bit, zero-base value; a transfer count of hex 00 results in one transfer cycle.

Operations 
 
The DMA operation to be performed is determined by the values loaded into the DMA Mode register, and determines how certain registers are used. The following describes how each of the registers is used for each type of operation.

All Operations 

The following registers have the same usage for all DMA operations.

Arbitration Level Register: This register is used to associate an arbitration level to a DMA channel. If the DMA channel is enabled, the DMA controller starts a DMA operation when the corresponding arbitration level is granted control of the system channel. If more than one DMA channel has the same arbitration level, the operations are performed for all channels, starting with the lowest DMA channel.

If the winning arbitration level matches the level specified for a DMA channel that is disabled, the DMA controller remains in the idle state. (A bus timeout will occur if another master does not take control of the system channel.)

DMA Mask Register: The appropriate Mask field must be set to 0 (enabled) for the DMA transfer operation to begin. The DMA controller sets the field to 1 (disabled) after it completes the DMA operation.

DMA Status Register: The DMA Status register indicates whether or not a DMA channel was active and whether or not a DMA operation has been completed.
 
The DMA controller sets a DMA Request field to 1 every time the DMA channel starts an operation. It sets the Terminal Count field to 1 after the terminal count changes from 0000 to hex FFFF to indicate that the DMA channel has completed an operation.

Memory-Verify Operation 

During the memory-verify operation, the DMA controller performs a memory-read cycle, but does not perform an I/O- or memory-write cycle. The operation begins when the arbitrating device is granted control of the system channel, if the DMA channel is enabled.

NOTE: All registers must be loaded with the appropriate values before starting the DMA operation.

DMA Mode Register: For memory-verify operations, the DMA Mode register is set to the following. The Size 16, Decrement 2, and I/O Address fields are set to the appropriate values, depending on the options desired.



I/O-Memory Address Register: This register is not used.

Memory Address Register: The Memory Address register points to the next memory location and is increased or decreased the appropriate amount, depending on the setting of the Decrement 2 field and the width of the transfer.

Transfer Count Register: The Transfer Count register contains the number of bytes or words that remain to be transferred (the Size 16 field determines whether the count value represents bytes or words). The count value is decreased the appropriate amount after the memory-read cycle. The DMA operation is completed (TC is driven active) when the transfer count goes from 0000 to hex FFFF.

Memory-to-I/O Transfer Operation

The memory-to-I/O transfer operation reads data from a location in memory and writes the data to an I/O device. The operation begins when the arbitrating device is granted control of the system channel, if the DMA channel is enabled.

NOTE: All registers must be loaded with the appropriate values before starting the DMA operation.

DMA Mode Register: For memory-to-I/O transfer operations, the DMA Mode register is set to the following. The Size 16, Decrement 2, and I/O Address fields are set to the appropriate values, depending on the options desired.



I/O-Memory Address Register: lf the I/O Address field is set to 1, the DMA controller drives the address specified in this register onto the address bus during the I/O-write cycle. If the I/O Address field is set to 0, this register is not used, and the DMA controller drives address hex 0000 onto the address bus.

If the Size 16 field is set to 1, the DMA controller forces the I/O address to a word boundary (address bit 0 is driven to 0) and writes at least one word to the I/O address before performing another memory-read cycle or ending the transfer.

The I/O address remains unchanged during DMA operations.

Memory Address Register: The Memory Address register points to the next memory location and is increased or decreased the appropriate amount, depending on the setting of the Decrement 2 field and the width of the transfer.

Transfer Count Register: The Transfer Count register contains the number of bytes or words that remain to be transferred (the Size 16 field determines whether the count value represents bytes or words). The count value is decreased the appropriate amount after the I/O-write cycle. The DMA operation is completed (TC is driven active) when the transfer count goes from 0000 to hex FFFF.

I/O-to-Memory Transfer Operation  

The I/O-to-memory transfer operation reads data from an I/O device and writes the data to a location in memory. The operation begins when the arbitrating device is granted control of the system channel, if the DMA channel is enabled.

NOTE: All registers must be loaded with the appropriate values before starting the DMA operation.

DMA Mode Register: For I/O-to-memory transfer operations, the DMA Mode register is set to the following. The Size 16, Decrement 2, and I/O Address fields are set to the appropriate values, depending on the options desired.



I/O-Memory Address Register: lf the I/O Address field is set to 1, the DMA controller drives the address specified in this register onto the address bus during the I/O-read cycle. If the I/O Address field is set to 0, this register is not used, and the DMA controller drives address hex 0000 onto the address bus.

lf the Size 16 field is set to 1, the DMA controller forces the I/O address to a word boundary (address bit 0 is driven to 0) and reads at least one word from the I/O address before performing the memory-write cycle.

The I/O address remains unchanged during DMA operations.

Memory Address Register: The Memory Address register points to the next memory location and is increased or decreased the appropriate amount, depending on the setting of the Decrement 2 field and the width of the transfer.

Transfer Count Register: The Transfer Count register contains the number of bytes or words that remain to be transferred (the Size 16 field determines whether the count value represents bytes or words). The count value is decreased the appropriate amount after the memory-write cycle. The DMA operation is completed (TC Is driven active) when the transfer count goes from 0000 to hex FFFF.

 
Commands  

These commands modify the state of the DMA controller, set parameters for other commands or DMA operations, or return information on the state of the DMA controller. There are two categories of commands through the Function register:
* Immediate commands
* Execute commands

All commands consist of an I/O write operation to the Function register (at address hex 0018). The immediate commands are those functions selected through the Function register that directly cause the DMA channel or DMA controller to perform some operation. The execute commands are those functions selected through the Function register that are performed when the Execute Function port (at hex 001A) is accessed.

The following shows the relationship between the functions selected and the command category.

PIO Commands  

Hex

Binary

Command

Category

00

0000

Read or write I/O address

Execute

01

0001

Reserved

 

02

0010

Write memory address

Execute

03

0011

Read memory address

Execute

04

0100

Write transfer count

Execute

05

0101

Read transfer count

Execute

06

0110

Read DMA status

Execute

07

0111

Read or write DMA mode

Execute

08

1000

Read or write arbitration level

Execute

09

1001

Set DMA mask

Immediate

0A

1010

Reset DMA mask

Immediate

0B, 0C

1011 / 1100

Reserved

 

0D

1101

Reset DMA controller

Immediate



Function Register Commands 

The PIO interface supports only one function-register command.

Write Function

This command loads the transferred data byte into the Function register. The Function field specifies the command to be performed and the Select field specifies the DMA channel.

This command sets the byte pointer to binary 00.

Write to Port 0018

   Transferred Data Byte



Immediate Commands 

For the immediate commands, writing to the Function register causes the operation to be performed. The Select field specifies the DMA channel. These commands are performed immediately and do not require additional I/O accesses to the Execute Function register. The immediate commands are:
* Set DMA Mask
* Reset DMA Mask
* Reset DMA Controller

Set DMA Mask  Hex 09 / 1001

This command sets the Mask field to 1 for the specified DMA channel. Setting the Mask field to 1 disables the DMA channel. The DMA channel is specified in the Select field.

Write to Port 0018



Reset DMA Mask  Hex 0A / 1010

This command sets the Mask field to 0 for the specified DMA channel. Setting this field to 0 enables the DMA channel. The DMA channel is specified in the Select field.

Write to Port 0018



Reset DMA Controller  Hex 0D / 1101

When it receives this command, the DMA controller:
* Terminates all transfer operations for all DMA channels
* Sets the byte pointer to binary 00
* Sets all mask fields to 1 to disable the DMA channels
* Sets all fields in the DMA Status register to 0

The Select field does not affect this command and should be set to 0.

Write to Port 0018