DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SCO OpenServer

dma_alloc(D3oddi)


dma_alloc -- allocate a DMA channel

Synopsis

   #include <sys/dma.h>
   

int dma_alloc(unsigned chan, unsigned mod);

Description

The dma_alloc( ) function allows dynamic allocation of a DMA channel.

Arguments


chan
specifies the channel to be allocated. Possible values are:

8-bit channels:
DMA_CH0, DMA_CH1, DMA_CH2, DMA_CH3

16-bit channels:
DMA_CH5, DMA_CH6, DMA_CH7

Channel 4 is not available. Other channels may be permanently allocated by system drivers. Check the /usr/adm/messages file to determine which channels are in use. Use the printcfg(D3oddi) function in your driver initialization routine to display the DMA channel that you select.


mod
can have one of two values:

DMA_BLOCK
wait until the channel is available.

DMA_NBLOCK
return immediately with a return status of 0 (zero) if the channel was not free at this time.

Return values

dma_alloc returns 1 if it was successful; otherwise it returns 0 (zero) if a channel was not available.

If mod specifies blocking, the dma_alloc routine does not return until the requested channel is available. It sleeps until the channel is released and always returns a non-zero value. If mod specifies non-blocking, the dma_alloc function immediately returns a non-zero value if the channel is available, and zero if it is not.

Usage

Make certain that your DMA channel has been allocated before beginning your operations.

Context and synchronization

context If mod is set to DMA_NBLOCK, non-blockable, initialization, or interrupt context.

If mod is set to DMA_BLOCK, user or blockable context.

Hardware applicability

All AT-compatible hardware.

Version applicability

oddi: 1, 2, 2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp

SVR5 DDI compatibility

This function is not supported for DDI drivers, which use the resource manager database to allocate DMA channels. See ``Resource manager database'' in HDK Technical Reference.

References

dma_param(D3oddi), dma_start(D3oddi), dma_relse(D3oddi), dma_enable(D3oddi), dma_resid(D3oddi), printcfg(D3oddi)

``DMA'' in HDK Technical Reference

Examples

An example of using dma_alloc to allocate a DMA channel is shown below:
   #include <sys/errno.h>
   #include <sys/dma.h>
   

. . . extern struct dmareq dma_request;

/* Allocate channel 1. If not */ /* currently available, wait. */

if ( dma_alloc( DMA_CH1, DMA_BLOCK ) == 0 ) { seterror( EIO ); return; }

/* If channel is successfully allocated, */ /* then begin DMA streaming */

dma_start( &dma_request );


19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005