General Info

Interface: DMAController_i386
Files: dmacontroller_i386.h
Last change: 08/06/2005
Author: Luiz Henrique Shigunov
System Functions

0x00 - Alloc - Allocate a DMA channel
0x01 - Free - Free a DMA channel

0x03 - Setup - Setup a DMA channel


This page describes the DMAController_i386 interface which provides access to the DMA controller for the Intel IA32 architecture.

DMA is the component that controls data transfers from devices (HD, floppy, ..) to memory and from memory to devices. PC/AT and compatibles have two DMAs.

Each DMA has 4 channels (0-3). The PC/AT channels 0-3 from master DMA are called channels 4-7. So, we have 7 channels because channel 4 (master DMA channel 0) is used to cascade the two DMAs.

Channels in the PC/AT are used these way:

ChannelUsed by
0free/memory refresh
2floppy disk
4used to cascade master/slave

In some motherboards, channel 0 is free, but for compatibility it isn't used.

Channels 0-3 are 8 bits channel, that is, they transfer bytes. Channels 4-7 are 16 bits channels, that is, they transfer words. Because DMA counters are 16 bits, we can only transfer 64K units (bytes or words).

Each channel 0-3 has a 64 KB physical memory area below 16MB to hold data read or to be written. Channels 5-7 have 128KB memory areas.

System Functions

These functions are exclusive for system modules.

0x00 - Alloc


void *DMAController_i386_Alloc(SysModManager_Module *modID, unsigned int channel, unsigned int bufferSize);



This function allocates channel for module modID. Before using DMA a channel must be allocated to avoid conflicts.

bufferSize is the size of the buffer in pages.

The buffer size can be as great as 16 pages for channels 0-3 and 32 pages for channels 5-7.

Before writing to a device this buffer must be filled with data and, after reading from a device, data must be read from this buffer.

After allocating, channel must be setup.

Return value

Use the macros IS_PTR_ERROR and PTR_TO_ERROR to know whether an error occurred and to get the error.

0x01 - Free


int DMAController_i386_Free(SysModManager_Module *modID, unsigned int channel);



This function frees channel used by modID.

Return value

0x03 - Setup


int DMAController_i386_Setup(SysModManager_Module *modID, unsigned int channel, unsigned int bufferOffset, unsigned int size, int prop);



This function setups channel used by modID.

prop must be the sum of mode and type of transfer.

Mode must be:

Type of transfer must be:

Read/write will have size bytes and will start at offset bufferOffset in buffer.

For channels 5-7 bufferOffset must be even. If it's odd, previous even address is used. Besides that, size must be even too.

After setup, channel is free to be used.

Return value